下面代码报空指针

with `__all_dim__` as (
select
*
from (
select
from_unixtime(unix_timestamp(`__bts__`) -1,'yyyy-MM-dd HH:mm:ss') as `__bts__`
from (
select
concat_ws(' ', `d`.`date`, `t`.`time_of_day`) as `__bts__`
from `ecmp`.`dim_date` as `d`
left join `ecmp`.`dim_time_of_day` as `t` on 1 = 1
where
`d`.`date` >= '2020-01-12'
and `d`.`date` <= '2020-01-13'
) as `__bts___tp1`
where
`__bts__` > '2020-01-12 00:00:00'
and `__bts__` <= '2020-01-13 00:00:00'
and second(`__bts__`) = 0
and minute(`__bts__`) = 0
and hour(`__bts__`) = 0
and pmod(day(`__bts__`), 1) = 0
) as `__time_model__`
cross join (
select
`dd_59282`.`tenant_pk` as `tenant_pk`,
`dd_59282`.`tenant_id` as `tenant_id`,
`dd_59282`.`tenant_name` as `tenant_name`
from `ecmp`.`dim_tenant` as `dd_59282`
) as `tenant_pk`
cross join (
select
'Fatal' as incident_level from system.dual
union all
select
'Error' as incident_level from system.dual
union all
select
'Warning' as incident_level from system.dual
union all
select
'Info' as incident_level from system.dual
) as `incident_level`
)
,`t` as (
select
`tenant_pk`,
`incident_accept_violation_count`,
`incident_level`,
rank() over( partition by `incident_level` order by `incident_accept_violation_count` DESC) as `incident_accept_violation_count_rank`,
rank() over( partition by `incident_level` order by `incident_accept_violation_count` ASC) as `__inverse_rank__`
from (
select
`__all_dim__`.*,-- 经排查发现表名加单引号再.*就是会报空指针,去掉表名的单引号后该问题解决
CAST(round(nvl(`incident_accept_violation_count`, 0), 0) as INT) as `incident_accept_violation_count`
from `__all_dim__`
left join (
select
`incident_level`,
`tenant_pk`,
count(*) as `incident_accept_violation_count`
from `ecmp`.dwd_incident_accept
where
incident_accept_violation_flag = '违规'
and `incident_accept_time` >= '2020-01-12 00:00:00'
AND `incident_accept_time` <= '2020-01-12 23:59:59'
group by
`incident_level`,
`tenant_pk`
) as `t1` on 1 = 1
and `__all_dim__`.`tenant_pk` = `t1`.`tenant_pk`
and `__all_dim__`.`incident_level` = `t1`.`incident_level`
) as `t0`
) select
`__all_dim__`.`__bts__` as `__bts__`,
CAST(SYSDATE as STRING) as `__cts__`,
CAST(dround(nvl(`incident_accept_violation_count`, 0), 0) as INT) as `incident_accept_violation_count`,
CAST(dround(`incident_accept_violation_count_rank`, 0) as INT) as `incident_accept_violation_count_rank`,
CAST(dround(`incident_accept_violation_count_win_rate`, 1) as DOUBLE) as `incident_accept_violation_count_win_rate`,
`__all_dim__`.`incident_level` as `incident_level`,
`__all_dim__`.`tenant_id` as `tenant_id`,
`__all_dim__`.`tenant_name` as `tenant_name`,
`__all_dim__`.`tenant_pk` as `tenant_pk`
from `__all_dim__`
left join (
select
'2020-01-12 23:59:59' as `__bts__`,
`incident_accept_violation_count`,
`incident_accept_violation_count_rank`,
`incident_accept_violation_count_win_rate`,
CAST(coalesce(`tp1`.`incident_level`) as STRING) as `incident_level`,
CAST(coalesce(`tp1`.`tenant_pk`) as STRING) as `tenant_pk`
from (
select
`t`.`tenant_pk`,
`t`.`incident_level`,
`t`.`incident_accept_violation_count`,
`t`.`incident_accept_violation_count_rank`,
if(`c`.ct = 1,null,(`__inverse_rank__` -1) /(`c`.ct -1) * 100) as `incident_accept_violation_count_win_rate`
from `t`
left join (
select
`incident_level`,
count(*) as `ct`
from `t`
group by
`incident_level`
) as `c` on 1 = 1
and `t`.`incident_level` = `c`.`incident_level`
) as `tp1`
) as `__dws__` on `__all_dim__`.`__bts__` = `__dws__`.`__bts__`
and `__all_dim__`.`tenant_pk` = `__dws__`.`tenant_pk`
and `__all_dim__`.`incident_level` = `__dws__`.`incident_level`;

然后修改后直接SELECT * FROM t;是没有问题的,但是用先有的select报错

[Code: 10009, SQL State: 42000] COMPILE FAILED: Semantic error: [Error 10009] Line 54:8 Invalid table alias. Error encountered near token 'all_dim'

with alldim as (
select
*
from (
select
from_unixtime(unix_timestamp(`__bts__`) -1,'yyyy-MM-dd HH:mm:ss') as `__bts__`
from (
select
concat_ws(' ', `d`.`date`, t.`time_of_day`) as `__bts__`
from `ecmp`.`dim_date` as `d`
left join `ecmp`.`dim_time_of_day` as t on 1 = 1
where
`d`.`date` >= '2020-01-12'
and `d`.`date` <= '2020-01-13'
) as `__bts___tp1`
where
`__bts__` > '2020-01-12 00:00:00'
and `__bts__` <= '2020-01-13 00:00:00'
and second(`__bts__`) = 0
and minute(`__bts__`) = 0
and hour(`__bts__`) = 0
and pmod(day(`__bts__`), 1) = 0
) as `__time_model__`
cross join (
select
`dd_59282`.`tenant_pk` as `tenant_pk`,
`dd_59282`.`tenant_id` as `tenant_id`,
`dd_59282`.`tenant_name` as `tenant_name`
from `ecmp`.`dim_tenant` as `dd_59282`
) as `tenant_pk`
cross join (
select
'Fatal' as incident_level from system.dual
union all
select
'Error' as incident_level from system.dual
union all
select
'Warning' as incident_level from system.dual
union all
select
'Info' as incident_level from system.dual
) as `incident_level`
)
, t as (
select
`tenant_pk`,
`incident_accept_violation_count`,
`incident_level`,
rank() over( partition by `incident_level` order by `incident_accept_violation_count` DESC) as `incident_accept_violation_count_rank`,
rank() over( partition by `incident_level` order by `incident_accept_violation_count` ASC) as `__inverse_rank__`
from (
select
--alldim.*,
alldim.`tenant_pk`,--去掉.*,改用需要几列查询几列的方式
alldim.`incident_level`,
CAST(round(nvl(`incident_accept_violation_count`, 0), 0) as INT) as `incident_accept_violation_count`
from alldim
left join (
select
`incident_level`,
`tenant_pk`,
count(*) as `incident_accept_violation_count`
from `ecmp`.dwd_incident_accept
where
incident_accept_violation_flag = '违规'
and `incident_accept_time` >= '2020-01-12 00:00:00'
AND `incident_accept_time` <= '2020-01-12 23:59:59'
group by
`incident_level`,
`tenant_pk`
) as `t1` on 1 = 1
and alldim.`tenant_pk` = `t1`.`tenant_pk`
and alldim.`incident_level` = `t1`.`incident_level`
) as `t0`) select
alldim.`__bts__` as `__bts__`,
CAST(SYSDATE as STRING) as `__cts__`,
CAST(round(nvl(`incident_accept_violation_count`, 0), 0) as INT) as `incident_accept_violation_count`,--dround改成round,手写错误
CAST(round(`incident_accept_violation_count_rank`, 0) as INT) as `incident_accept_violation_count_rank`,
CAST(round(`incident_accept_violation_count_win_rate`, 1) as DOUBLE) as `incident_accept_violation_count_win_rate`,
alldim.`incident_level` as `incident_level`,
alldim.`tenant_id` as `tenant_id`,
alldim.`tenant_name` as `tenant_name`,
alldim.`tenant_pk` as `tenant_pk`
from alldim
left join (
select
'2020-01-12 23:59:59' as `__bts__`,
`incident_accept_violation_count`,
`incident_accept_violation_count_rank`,
`incident_accept_violation_count_win_rate`,
CAST(coalesce(`tp1`.`incident_level`) as STRING) as `incident_level`,
CAST(coalesce(`tp1`.`tenant_pk`) as STRING) as `tenant_pk`
from (
select
t.`tenant_pk`,
t.`incident_level`,
t.`incident_accept_violation_count`,
t.`incident_accept_violation_count_rank`,
if(`c`.ct = 1,null,(`__inverse_rank__` -1) /(`c`.ct -1) * 100) as `incident_accept_violation_count_win_rate`
from t
left join (
select
`incident_level`,
count(*) as `ct`
from t
group by
`incident_level`
) as `c` on 1 = 1
and t.`incident_level` = `c`.`incident_level`
) as `tp1`
)
as `__dws__` on alldim.`__bts__` = `__dws__`.`__bts__`
and alldim.`tenant_pk` = `__dws__`.`tenant_pk`
and alldim.`incident_level` = `__dws__`.`incident_level`;

Inceptor [Code: 40000, SQL State: 42000] COMPILE FAILED: Internal error NullPointerException: [Error 40000] java.lang.NullPointerException的更多相关文章

  1. Mybatis批量删除之Error code 1064, SQL state 42000;

    (一)小小的一次记载. (二):最近的项目都是使用MyBatis,批量新增自己都会写了,但是一次批量删除可把我给折腾了下,写法网上都有,但是照着做就是不行,最后问公司的人,问网友才得到答案,那就是jd ...

  2. MySQL 报错:Translating SQLException with SQL state '42000', error code '1064', message

    MySQL报错详细日志 2019-09-12 16:42:29 [http-nio-80-exec-25] DEBUG [org.springframework.jdbc.support.SQLErr ...

  3. sql与SQL CODE和SQL State相关报错

    操作数据库过程中,遇到许多问题,很多都与SQL CODE和SQL State相关,现在把一个完整的SQLCODE和SQLState错误信息和相关解释作以下说明,一来可以自己参考,对DB2错误自行找出原 ...

  4. hive分区导致FAILED: Hive Internal Error: java.lang.NullPointerException(null)

    写了一条hive sql ,其中条件中存在 dt>=20150101 and dt<=20150228 这样的条件,原来执行没问题,今天就抛出 FAILED: Hive Internal ...

  5. failed with: java.lang.NullPointerException

    failed with: java.lang.NullPointerException 需要在nutch的配置文件 'conf/nutch-site.xml'. 里设置如下,不然就报上面的错误了. 当 ...

  6. 解决spring mvc 上传报错,Field [] isn't an enum value,Failed to convert value of type 'java.lang.String[]' to required type '

    没有选择附件,但是点击上传按钮的时候会报错. 之前不选择文件,直接上传空文件是可以的,后来不知道改了什么就不行了. 错误信息: -- :: [http--] TRACE org.springframe ...

  7. 异常:failed for object com.sdu.crm.pojo.Customer@136a986 [java.lang.NullPointerException]

    异常: failed for object com.sdu.crm.pojo.Customer@136a986 [java.lang.NullPointerException] 大家好,如果大家看到了 ...

  8. Servlet.service() for servlet [jsp] in context with path [/Healthy_manager] threw exception [Unable to compile class for JSP] with root cause java.lang.IllegalArgumentException: Page directive: inval

    严重: Servlet.service() for servlet [jsp] in context with path [/Healthy_manager] threw exception [Una ...

  9. Failed to convert value of type 'java.lang.String' to required type 'java.time.LocalDate';

    springboot jdbc查询使用LocalDate报:Failed to convert value of type 'java.lang.String' to required type 'j ...

随机推荐

  1. 杭电OJ2010---水仙花数(c++)(方法:输出几个数之间用空格隔开,最后一个数没有空格)

    水仙花数 Problem Description 春天是鲜花的季节,水仙花就是其中最迷人的代表,数学上有个水仙花数,他是这样定义的: "水仙花数"是指一个三位数,它的各位数字的立方 ...

  2. vim_command

    vi 打开vi空白面板 vi filename 以编辑模式打开文件.如果参数为已有文件,在vi中打开:如果参数为新文件名,在vi退出时提示用户保存编辑内容 vi -R filename 以只读模式打开 ...

  3. JavaScript—深入理解函数

    当程序在调用某个函数时,做了以下的工作:准备执行环境,初始函数作用域链和arguments参数对象. 函数的声明语句 function命令声明的代码区块,就是一个函数.function命令后面是函数名 ...

  4. PHP将数据集转换成树状结构

    /** * 把返回的数据集转换成Tree * @param array $list 要转换的数据集 * @param string $pid parent标记字段 * @param string $l ...

  5. Flutter 基础组件:输入框和表单

    前言 Material组件库中提供了输入框组件TextField和表单组件Form. 输入框TextField 接口描述 const TextField({ Key key, // 编辑框的控制器,通 ...

  6. Linux学习笔记 | 将默认镜像源修改为国内镜像源

    前言: 在使用Linux操作系统的时候,难免会下载各种安装包,而Linux使用的下载源服务器属于国外,下载速度相对国内会慢很多,像日常使用的阿里云和腾讯云等国内服务器厂商,镜像源都默认为自己相关的镜像 ...

  7. px转rem的填坑之路

    这是要为一个vue项目做自适应,设计稿是1920*1080的,要适应各种手机.ipad.3840*2160的超大屏,所以就选择了rem,包用的是 postcss-pxtorem 在适配的时候遇到了很多 ...

  8. pyinstaller打包shotgun有关的程序

    By 鬼猫猫 http://www.cnblogs.com/muyr/ 背景 使用pyinstaller打包跟shotgun有关的程序后,在自己电脑上运行都OK,但是编译好的exe在其他人的电脑上运行 ...

  9. uni-app开发经验分享二十: 微信小程序 授权登录 获取详细信息 获取手机号

    授权页面 因为微信小程序提供的 权限弹窗 只能通用户确认授权 所以可以 写一个授权页面,让用户点击 来获取用户相关信息 然后再配合后台就可以完成登录 <button class="bt ...

  10. 十九、更改LCD显示屏

    一.裸机修改 之前测试用的屏幕是480*272的分辨率,现在要换成800*480的屏,因此要对软件代码进行修改. 对于裸机驱动而言,主要有两个点需要注意,一个是屏幕分辨率变了,因此初始化的时候与屏幕分 ...