如何用hive ql生成序列号

时间:2013-03-30 17:51:13

标签: sql hadoop hive

如何编写hive sql以从表A中获取表B(没有任何UDF)?

表A

PLATFORM    USER_ID CLICK_TIME  CLICK_URL

WEB 12332321 2013-03-21 13:48:31.324 / home /

WEB 12332321 2013-03-21 13:48:32.954 / selectcat / er /

WEB 12332321 2013-03-21 13:48:46.365 /er/viewad/12.html

WEB 12332321 2013-03-21 13:48:53.651 /er/viewad/13.html

WEB 12332321 2013-03-21 13:49:13.435 /er/viewad/24.html

WEB 12332321 2013-03-21 13:49:35.876 / selectcat / che /

WEB 12332321 2013-03-21 13:49:56.398 /che/viewad/93.html

WEB 12332321 2013-03-21 13:50:03.143 /che/viewad/10.html

WEB 12332321 2013-03-21 13:50:34.265 / home /

WAP 32483923 2013-03-21 23:58:41.123 / m / home /

WAP 32483923 2013-03-21 23:59:16.123 / m / selectcat / fang /

WAP 32483923 2013-03-21 23:59:45.123 /m/fang/33.html ......

表B

PLATFORM USER_ID SEQ FROM_URL TO_URL

WEB 12332321 1 NULL / home /

WEB 12332321 2 / home / / selectcat / er /

WEB 12332321 3 / selectcat / er / /er/viewad/12.html

WEB 12332321 4 /er/viewad/12.html /er/viewad/13.html

WEB 12332321 5 /er/viewad/13.html /er/viewad/24.html

WEB 12332321 6 /er/viewad/24.html / selectcat / che /

WEB 12332321 7 / selectcat / che / /che/viewad/93.html

WEB 12332321 8 /che/viewad/93.html /che/viewad/10.html

WEB 12332321 9 /che/viewad/10.html / home /

WAP 32483923 1 NULL / m / home /

WAP 32483923 2 / m / home / / m / selectcat / fang /

WAP 32483923 3 / m / selectcat / fang / /m/fang/33.html

WAP 32483923 4 /m/fang/33.html /m/fang/54.html

1 个答案:

答案 0 :(得分:0)

没有UDF的Rank()现在是不可能的。您可以使用PIG或使用伪UDF。这是类似的帖子(source)。 GL!