【问题标题】:hive date format error when used with the table与表一起使用时配置单元日期格式错误
【发布时间】:2016-04-12 15:45:55
【问题描述】:

我在表 1 中有类似 date_column = 20140228 的字段。当我对下面的数字进行硬编码时,它可以工作,但是当我指定列名时,它会失败。有错误 H110 无法提交声明。编译语句时出错:FAILED: ParseException line 2:1 cannot identify input near 'select' 'date_format' '(' in select Clause [ERROR_STATUS]

Working:
    select date_format(from_unixtime(unix_timestamp(cast('2014022817' as string),'yyyyMMddHH')),'yyyy-MM-dd HH');

Failing:
    select 
        select date_format(from_unixtime(unix_timestamp(cast(date_column as string),'yyyyMMddHH')),'yyyy-MM-dd HH')
    from 
        table1

【问题讨论】:

    标签: sql hive


    【解决方案1】:

    为什么要重复select?试试这个:

    select date_format(from_unixtime(unix_timestamp(cast(date_column as string
                                                        ),'yyyyMMddHH'
                                                   )
                                    ),'yyyy-MM-dd HH'
                      )
    from table1
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多