【发布时间】:2017-05-07 16:24:12
【问题描述】:
我有一个像这样有两行的蜂巢表:
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)
【问题讨论】:
-
case或cast? -
强制转换,将 int 转换为时间戳
-
顺便说一句,你为什么要这样做?
标签: sql hadoop apache-spark hive