下面代码报空指针

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. pytorch模型结构可视化,可显示每层的尺寸

    最近在学习一些检测方面的网络,使用的是pytorch.模型结构可视化是学习网络的有用的部分,pytorch没有原生支持这个功能,需要找一些其他方式,下面总结几种方法(推荐用4). 1. torch . ...

  2. 使用Spring中@Async注解实现异步调用

    异步调用? 在解释异步调用之前,我们先来看同步调用的定义:同步就是整个处理过程顺序执行,当各个过程都执行完毕,并返回结果. 异步调用则是只是发送了调用的指令,调用者无需等待被调用的方法完全执行完毕,继 ...

  3. Lambda获取类属性的名字

    using System; using System.ComponentModel; using System.Linq.Expressions; using System.Reflection; p ...

  4. Macbook 安装Windows的完美教程

    [原文](http://www.melodydance.top/mac-win.html) 1. 背景 Windows相对于Mac市场占有率更高,对很多人来说Windows使用起来更方便,以至于很多人 ...

  5. 用 Flutter 搭建标签+导航框架

    前言 在 Flutter 这个分类的第一篇文章总结了下最新的 Mac 搭建 Flutter 开发环境和对声明式UI这个理解的东西,前面也有提过,准备像在 SwiftUI 分类中那样花一些功夫来写一个 ...

  6. 【JS学习】for-in与for-of

    前言:本博客系列为学习后盾人js教程过程中的记录与产出,如果对你有帮助,欢迎关注,点赞,分享.不足之处也欢迎指正,作者会积极思考与改正. 总述: 名称 遍历 适用 for-in 索引 主要建议白能力对 ...

  7. 【Oracle】查看oracle用户相关权限

    系统权限 SELECT * FROM DBA_SYS_PRIVS WHERE GRANTEE = 'CHAXUN' UNION ALL SELECT * FROM DBA_SYS_PRIVS WHER ...

  8. Java编译期注解处理器详细使用方法

    目录 Java编译期注解处理器 启用注解处理器 遍历语法树 语法树中的源节点 语法树节点的操作 给类增加注解 给类增加import语句 构建一个内部类 使用方法 chainDots方法 总结 Java ...

  9. 关于JDK15的简单理解

    一.为什么要了解JDK15? 2020年9月15日,Oracle官方发布了JDK15版本,及时关注官方的更新动态,可以让我们在日常开发中更合理的选择更加优秀的工具方法,避免使用一些过时的或一些即将被删 ...

  10. SDNU_ACM_ICPC_2021_Winter_Practice_1st [个人赛] 2021.1.19 星期二

    SDNU_ACM_ICPC_2021_Winter_Practice_1st [个人赛] K - Color the ball 题意: 有n个气球,每次都给定两个整数a,b,给a到b内所有的气球涂一个 ...