前导函数上截止日期的配置单元字符串

eufgjt7s  于 2021-06-24  发布在  Hive
关注(0)|答案(2)|浏览(361)

伙计们,我必须把它从pl/sql(oracle)转换成hive格式:

NVL(TO_CHAR(TO_DATE(SUBSTR(LEAD(DATE_TIME) OVER (PARTITION BY CU_NO ORDER BY CR_NO ,TO_NUMBER(DATE_TIME)),1,6),'YYMMDD'),'YYYYMMDD'),'99991231') END_DATE

我已经试过了:

NVL(cast(from_unixtime(UNIX_TIMESTAMP(SUBSTR(LEAD(DATE_TIME) OVER (PARTITION BY CU_NO ORDER BY CR_NO ,TO_NUMBER(DATE_TIME)),1,6), 'yyMMdd' ),'yyyyMMdd') as string)'99991231') END_DATE

它总是在“yyyymmdd”附近的“)”处返回缺少的eof。出什么事了?

rsaldnfx

rsaldnfx1#

NVL(cast(from_unixtime(UNIX_TIMESTAMP(SUBSTR(LEAD(DATE_TIME) OVER (PARTITION BY CU_NO ORDER BY CR_NO ,TO_NUMBER(DATE_TIME)),1,6), 'yyMMdd' ),'yyyyMMdd') as string) 缺少逗号 , '99991231') 使用缩进格式:

NVL(
    cast(
        from_unixtime(
            UNIX_TIMESTAMP(
                SUBSTR(
                    LEAD(DATE_TIME) OVER (PARTITION BY CU_NO
                                          ORDER BY CR_NO, 
                                                   TO_NUMBER(DATE_TIME)
                                         ),
                    1,6
                ),
                'yyMMdd'
            ),
            'yyyyMMdd'
        ) as string
    ),
'99991231'
)
mjqavswn

mjqavswn2#

您不需要按以下顺序额外添加到\u number():

NVL(cast(from_unixtime(UNIX_TIMESTAMP(
                        SUBSTR(
                         LEAD(DATE_TIME) OVER (PARTITION BY CU_NO ORDER BY CR_NO, DATE_TIME)
                        ,1,6), 'yyMMdd')
            ,'yyyyMMdd') 
   as string), '99991231')

相关问题