下面代码报空指针

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. Ubuntu无法ssh远程连接问题 (转)

    [系统]Ubuntu 12.04 server [问题描述]新安装的Ubuntu系统无法直接通过ssh远程连接. [解决办法] 新安装的Ubuntu系统并未安装ssh-server服务,需要自行安装, ...

  2. Java 8 之前的时间处理

    最近在自己瞎折腾,有一个需求是计算当前日期到指定日期有多少天,用于实现纪念日或倒计时的功能.查阅资料后发现Java 8之前的时间日期处理很是麻烦而且被频频吐槽,以至于后来在 Java 8 中推出了一个 ...

  3. SqlLoad的简单使用

    sqlload的简单使用: 能实现: 快速导入大量数据 1.先安装oracle 客户端机器.有点大,600M+, 2.安装时选择管理员安装(1.1g) 3.第三步的时候我的出错了.说是环境变量校验不通 ...

  4. LeetCode220 存在重复元素 III

    给定一个整数数组,判断数组中是否有两个不同的索引 i 和 j,使得 nums [i] 和 nums [j] 的差的绝对值最大为 t,并且 i 和 j 之间的差的绝对值最大为 ķ. 示例 1: 输入: ...

  5. 【.NET 与树莓派】使用 GPIO 库

    上回老周在说准备工作的时候,提到过树莓派用金属盒散热的事情.有朋友会说,加了金属盒子接线不方便,就算用了"T"形板,毕竟是把导线延长了的.其实扩展板就是把原有的引脚引出(类似于延长 ...

  6. .NET 5 程序高级调试-WinDbg

    上周和大家分享了.NET 5开源工作流框架elsa,程序跑起来后,想看一下后台线程的执行情况.抓了个进程Dump后,使用WinDbg调试,加载SOS调试器扩展,结果无法正常使用了: 0:000> ...

  7. docker 数据卷的挂载和使用

    容器之间的数据共享技术, Docker容器产生的数据同步到本地 卷技术 --> 目录挂载, 将容器内的目录挂载到服务器上 使用命令来挂载 -v # 可以挂载多个目录 docker run -it ...

  8. 关于 percona monitoring plugins插件报slave is stoped on ip地址

    思路:肯定是某个item触发了触发器 去看触发器,找到 slave is stoped,如下图 看到键是mysql.running-slave ,然后去定义key的文件中查看该键对应的脚本,修改脚本. ...

  9. 【葵花宝典】lvs+keepalived部署kubernetes(k8s)高可用集群

    一.部署环境 1.1 主机列表 主机名 Centos版本 ip docker version flannel version Keepalived version 主机配置 备注 lvs-keepal ...

  10. 阅读lodash源码之旅数组方法篇-compact和concat

    鲁迅说过:只有阅读过优秀库源码的人,才能配的上是真正的勇士. compact 创建一个新数组,包含原数组中所有的非假值元素.例如false, null,0, "", undefin ...