[英]HiveSQL - Invalid column reference
I get the error我得到错误
[Code: 10002, SQL State: 42000] [代码:10002,SQL State:42000]
Error while compiling statement: FAILED: SemanticException [Error 10002]: Line 11:60 Invalid column reference 'FIELD3'编译语句时出错:FAILED: SemanticException [Error 10002]: Line 11:60 Invalid column reference 'FIELD3'
when running the following query:运行以下查询时:
CREATE TABLE NEW_TABLE
AS
SELECT
T1.*,
T2.*,
T3.*
FROM
OLD_TABLE1 T1
LEFT JOIN
OLD_TABLE2 T2 ON (T1.FIELD1 = T2.FIELD1)
LEFT JOIN
OLD_TABLE3 T3 ON (T1.FIELD3 = T3.FIELD3);
What is the potential issue of the above query?上述查询的潜在问题是什么? I double checked that the FIELD3
exists in OLD_TABLE1
and OLD_TABLE3
.我仔细检查了FIELD3
是否存在于OLD_TABLE1
和OLD_TABLE3
中。
One major issue you have is that duplicated column names in the table.您遇到的一个主要问题是表中的列名重复。 At the very least, the JOIN
conditions will introduce duplicates.至少, JOIN
条件会引入重复。 There might be other duplicates as well.可能还有其他重复项。
List the columns you want explicitly :明确列出您想要的列:
CREATE TABLE NEW_TABLE AS
SELECT . . . -- list column names explicitly
FROM OLD_TABLE1 T1 LEFT JOIN
OLD_TABLE2 T2
ON T1.FIELD1 = T2.FIELD1 LEFT JOIN
OLD_TABLE3 T3
ON T1.FIELD3 = T3.FIELD3;
This problem may occur with CREATE TABLE
. CREATE TABLE
可能会出现此问题。 That said, it is more common with aggregation queries.也就是说,聚合查询更常见。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.