下面代码报空指针

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. 洛谷P1055 字符串的处理-----ISBN

    题目描述 每一本正式出版的图书都有一个ISBN号码与之对应,ISBN码包括99位数字.11位识别码和33位分隔符,其规定格式如x-xxx-xxxxx-x,其中符号-就是分隔符(键盘上的减号),最后一位 ...

  2. k8s之RBAC授权模式

    导读 上一篇说了k8s的授权管理,这一篇就来详细看一下RBAC授权模式的使用 RBAC授权模式 基于角色的访问控制,启用此模式,需要在API Server的启动参数上添加如下配置,(k8s默然采用此授 ...

  3. python3.6安装教程

    Python代码要运行,必须要有Python解释器.Python3.x的版本是没有什么区别的,这里以3.6版本来演示安装的过程.这里只介绍Windows环境下的安装. 下载安装程序 Python官方的 ...

  4. dig的安装和使用

    -bash: dig: command not found 解决办法: yum -y install bind-utils dig www.baid bu.com   查看a记录 dig www.ba ...

  5. 【Oracle】substr()函数详解

    Oracle的substr函数简单用法 substr(字符串,截取开始位置,截取长度) //返回截取的字 substr('Hello World',0,1) //返回结果为 'H'  *从字符串第一个 ...

  6. Flutter 自定义列表以及本地图片引用

    前言 上篇关于Flutter的文章总结了下标签+导航的项目模式的搭建,具体的有需要的可以去看看Flutter分类的文章,这篇文章我们简单的总结一下关于Flutter本地文件引用以及简单的自定义List ...

  7. 干电池升压IC

    1, 干电池升压IC                         升压输出3V,3,3V,5V等3V-5V可调   2, 单节锂电池升压IC                     升压输出4.2 ...

  8. ASP.NET MVC5+EF6+EasyUI 后台管理系统(89)-国际化,本地化,多语言应用

    开篇 早年写过一篇多语言的应用 :   本地化(多语言)   讲述了如何创建多语言的资源文件,并利用资源文件来获得页面和请求的语言属性 本次补充这篇文章,的原因是在实际项目中,有多种需要多语言的情况 ...

  9. JavaScript学习总结(基础知识)

    js代码引入 方式1: <script> alert('欢迎来到德玛西亚!') </script> 方式2:外部文件引入 src属性值为js文件路径 <script sr ...

  10. uni-app开发经验分享十八:对接第三方h5

    1.uni-app中对接第三方为了防止跳出app使用了webview <template> <view> <web-view :src="url" @ ...