我有一个包含两行的配置单元表:
0: jdbc:hive2://localhost:10000/default> select * from t2;
+-----+--------+
| id | value |
+-----+--------+
| 10 | 100 |
| 11 | 101 |
+-----+--------+
2 rows selected (1.116 seconds)
但是当我发出查询时:
select cast(1 as timestamp) from t2;
它给出了不一致的结果,谁能告诉我原因?
0: jdbc:hive2://localhost:10000/default> select cast(1 as timestamp) from t2;
+--------------------------+
| _c0 |
+--------------------------+
| 1970-01-01 07:00:00.001 |
| 1970-01-01 07:00:00.001 |
+--------------------------+
2 rows selected (0.913 seconds)
0: jdbc:hive2://localhost:10000/default> select cast(1 as timestamp) from t2;
+--------------------------+
| _c0 |
+--------------------------+
| 1970-01-01 08:00:00.001 |
| 1970-01-01 07:00:00.001 |
+--------------------------+
2 rows selected (1.637 seconds)
最佳答案
我无法重现您的问题,您使用的是哪个 Hive 版本? Hive 有时间戳和 bigint 的错误(请参阅 https://issues.apache.org/jira/browse/HIVE-3454 ),但它不能解释您的问题。例如 Hive 0.14 给出了不同的结果
SELECT (cast 1 as timestamp), cast(cast(1 as double) as timestamp) from my_table limit 5;
关于sql - 为什么转换为时间戳会给出两个不同的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41276440/