Hive 时间戳查询

Def*_*con 3 sql hadoop timestamp hive casting

我创建了一个具有以下格式的时间戳列(数据类型为时间戳)的配置单元表:

2017-01-23 21:23:17.261456

但是,当我这样做时。它不能正常工作。它将选择时间戳后的日期。该列应该是字符串还是我使用的查询错误?

select * from example where time_created < '2017-01-01 22:30:57.375117'
Run Code Online (Sandbox Code Playgroud)

Ale*_*Ale 6

我遇到了同样的问题:字符串和时间戳之间的比较不是自动完成的。这对我有用:

select * from example 
         where unix_timestamp(time_created, 'yyyy-MM-dd HH:mm:ss.SSS') < 
               unix_timestamp('2017-01-01 22:30:57.375117','yyyy-MM-dd HH:mm:ss.SSS')
Run Code Online (Sandbox Code Playgroud)