简体   繁体   English

比较 Hive QL 中的时间戳和字符串

[英]Compare timestamp and string in Hive QL

There is a dataset containing some values that are not desirable: for example, they are missing and shown in '1970/01/01 00:00:00' as the placeholder.有一个数据集包含一些不需要的值:例如,它们丢失并显示在“1970/01/01 00:00:00”中作为占位符。

To make sure the query is what I want, how should I filter on this column (timestamp data type)?为了确保查询是我想要的,我应该如何过滤此列(时间戳数据类型)? Or I should put: where does it go wrong if I wrote:或者我应该写:如果我写了哪里出错了:

select * from table where timestamp_col <> '1970-01-01 00:00:00'

cast string to timestamp and you will see.将字符串转换为时间戳,您将看到。 In some Hive versions timestamp requires also 0 milliseconds to be added:在某些 Hive 版本中,时间戳也需要添加 0 毫秒:

select timestamp('1970-01-01 00:00:00.0') 

check that it returns timestamp, not NULL and use in the filter检查它是否返回时间戳,而不是 NULL 并在过滤器中使用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM