【发布时间】:2016-06-29 22:43:13
【问题描述】:
我在 hive 中有两个表并尝试执行连接:
A表:
id ord_time
84 10:00:00
84 12:00:00
84 15:00:00
84 4:00:00
数据类型:
Id : int
ord_time : String
表 B:
id time_desc beg_tm end_tm
84 Late Night 00:00:00 04:59:59
84 Break Fast 05:00:00 10:29:59
84 Dinner 16:00:00 20:59:59
84 Lunch 11:00:00 13:59:59
84 Snack 14:00:00 15:59:59
数据类型:
Id : int
time_desc : String
beg_tm : String
end_tm : String
查询:
Select a.ord_time,b.id,b.time_desc,b.beg_tm,b.end_tm
from Table A a,Table B b
where a.id = b.id
and a.ord_time between b.beg_tm and b.end_tm
当我运行上述查询时,结果为 Null。
我希望输出是:
id ord_time time_desc
84 10:00:00 BreakFast
84 12:00:00 Lunch
84 15:00:00 Snack
84 04:00:00 Late Night
【问题讨论】:
-
您的时间数据中是否有前导或尾随空白字符?我还注意到一个表没有前导零,但另一个有(这不起作用)