Inceptor [Code: 40000, SQL State: 42000] COMPILE FAILED: Internal error NullPointerException: [Error 40000] java.lang.NullPointerException

下面代码报空指针

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`;

原文地址:https://www.cnblogs.com/qfdy123/p/12200731.html

时间: 2024-08-29 05:09:22

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

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

(一)小小的一次记载. (二):最近的项目都是使用MyBatis,批量新增自己都会写了,但是一次批量删除可把我给折腾了下,写法网上都有,但是照着做就是不行,最后问公司的人,问网友才得到答案,那就是jdbc中需要在url中指定允许进行进行多条语句同时执行. 自己在写批量更新的时候也把相应的语句打印出来了的,复制出来执行是没问题,但是用junit测试的时候一直报错如下 Error code 1064, SQL state 42000: You have an error in your SQL sy

[Error Code: 942, SQL State: 42000] ORA-00942: 表或视图不存在

排除SQL错误的问题之后 在表的前面加上用户名即可 用户名:SHJD SQL:select t.Work_Date from PVOAS_OCR_FILE_RESULT t select t.Work_Date from SHJD.PVOAS_OCR_FILE_RESULT t 原文地址:https://www.cnblogs.com/fengnan/p/10445133.html

Translating SQLException with SQL state &#39;42000&#39;, error code &#39;1064&#39;错误

PostgreSQL, Sybase]2018-04-12 14:18:55 [org.springframework.jdbc.support.SQLErrorCodesFactory]-[DEBUG] Looking up default SQLErrorCodes for DataSource [{ CreateTime:"2018-04-12 14:18:43", ActiveCount:1, PoolingCount:0, CreateCount:1, DestroyCoun

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

写了一条hive sql ,其中条件中存在 dt>=20150101 and dt<=20150228 这样的条件,原来执行没问题,今天就抛出 FAILED: Hive Internal Error: java.lang.NullPointerException(null)java.lang.NullPointerException at org.apache.hadoop.hive.ql.optimizer.pcr.PcrExprProcFactory.opAnd(PcrExprProcFa

HTTP Status 500 - Request processing failed; nested exception is java.lang.NullPointerException

type Exception report message Request processing failed; nested exception is java.lang.NullPointerException description The server encountered an internal error that prevented it from fulfilling this request. exception org.springframework.web.util.Ne

解决parseSdkContent failed java.lang.NullPointerException错误

今天我的eclipse崩溃了,报“parseSdkContent failed java.lang.NullPointerException”的错误. 所有的安卓项目都不正常,创建项目就会报 java.lang.NullPointerException的错误.后来上网搜到了解决办法, 办法就是,把项目的存储路径下的.metadata(即:workspace\.metadata)文件删了就行了.但重新打开 eclipse,你的原工作路径下的工程也都不存在.那你就重新导入原工作路径下的所有工程. 解

parseSdkContent failed java.lang.NullPointerException解决办法

最近手贱更新了Android studio,而as又自动更新了sdk,导致该死的Eclipse找不到当初设置的api文档了,整个Eclipse都不好了,所有的Android项目报错,所有的项目都无法导入.生成. 每次打开adt都会报错parseSdkContent failed java.lang.NullPointerException 1.网上很多人说可以删除workspace下的.metadata文件来解决,但我的就没好使. 2.还有人说可以删除C:\Documents and Setti

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 [Unable to compile class for JSP] with root causejava.lang.IllegalArgumentException: Page directive: invalid value for import    at org.apache.jasper.comp

eclipse parseSdkContent failed java.lang.NullPointerException

开Eclipse出现错误“parseSdkContent failed”. 1. 备份C:\Users\Administrator\.android 中的adb_usb.ini文件 2.删除文件夹 C:\Users\Administrator\.android 3. 第二步后,可能会出现adb连接不了,此时cmd命令行执行android update adb,执行成功后,文件夹C:\Users\Administrator\.android重新出现,把该文件夹中的adb_usb.ini用第一步备份