gpt4 book ai didi

hadoop - 失败:解析错误:第7:19行输入 '('不匹配,期望FROM中的from子句

转载 作者:行者123 更新时间:2023-12-02 21:50:28 25 4
gpt4 key购买 nike

输入:table1

id1, p1, c1, t1-1
id2, p1, c1, t1-2
id3, p2, c2, t1-2
id4, p3, c3, t1-3
id5, p1, c1, t1-4
id6, p2, c2, t1-4
id7, p1, c3, t1-4
id8, p2, c2, t1-5
id9, p2, c3, t1-5
id10, p2, c4, t1-5
id11, p2, c3, t1-6
id12, p1, c1, t2-1
id13, p1, c2, t2-1
id14, p2, c2, t2-3
id15, p2, c3, t2-3
id16, p1, c1, t2-4

输出应为
id5, p1, c1, t1-4
id8, p2, c2, t1-5
id4, p3, c3, t1-3
id7, p1, c3, t1-4
id11, p2, c3, t1-6
id10, p2, c4, t1-5
id16, p1, c1, t2-4
id13, p1, c2, t2-1
id14, p2, c2, t2-3
id15, p2, c3, t2-3

配置单元查询:
SET mapred.reduce.tasks=1;
CREATE EXTERNAL TABLE table1(
id string,
t string,
p string,
c string)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\t'
LOCATION 's3://input/';

ALTER TABLE table1 RECOVER PARTITIONS;

CREATE EXTERNAL TABLE table2 (
id string,
t string,
p string,
c string)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\n'
STORED AS TEXTFILE
LOCATION 's3://output/';

错误:
hive> 
>
> INSERT OVERWRITE TABLE table2
> SELECT id, p, c, t
> FROM
> (
> SELECT id, p, c, t,
> ROW_NUMBER() OVER (PARTITION BY SUBSTR(t, 1, INSTR(t, '-') - 1), p, c ORDER BY t DESC) rnum
> FROM table1
> ) q
> WHERE rnum = 1
> ;
FAILED: Parse Error: line 7:19 mismatched input '(' expecting FROM in from clause

如何解决呢?

最佳答案

SELECT t1.id, t1.p, t1.c, t1.time_stamp,
FROM table1 t1 JOIN
( SELECT p, c, Max(UNIX_TIMESTAMP(time_stamp)) as max_epoch
FROM table1
GROUP BY p, c) temp
WHERE t1.p = temp.p AND t1.c = temp.c AND UNIX_TIMESTAMP(t2.time_stamp) = max_epoch ;

关于hadoop - 失败:解析错误:第7:19行输入 '('不匹配,期望FROM中的from子句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21424854/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com