我正在尝试在配置单元中执行更新操作,这意味着为配置单元0.13插入覆盖。以下是我的查询
INSERT OVERWRITE TABLE TABLE_A
SELECT
A.ADDRESS1=B.ADDR_LINE_1,
A.ADDRESS2,
A.ADDRESS3=CONCAT(B.CITY, ', ', B.STATE, ' ', B.POSTAL_CDE) ,
A.STORETYPE
FROM
P.STUDENT A
JOIN
`default.CUSTOMER` B ON A.REGION = B.SHIP_TO_LOCATION_NUM
AND A.STORENUMBER = B.SHIP
UNION ALL
SELECT
A.ADDRESS1,
A.ADDRESS2,
A.ADDRESS3,
A.STORETYPE=cast(B1.id AS string)
FROM
`P.STUDENT` A
JOIN
R.RTL B1 ON A.REGION = B1.SHIP_TO_LOCATION_NUM
AND A.STORENUMBER = B1.SHIP ;
After the execution i receive an error saying:
FAILED: SemanticException 36:0 Schema of both sides of union should match: Column _c0 is of type boolean on first table and type string on second table. Error encountered near token 'P.STUDENT'.
我发现连接中的所有数据类型都是字符串。对于B1.id
,我正在投射为字符串cast(B1.id AS string)
。任何人都可以告诉我这个查询的问题。我正在使用hive 0.13。
由于
答案 0 :(得分:0)
下面的查询工作,似乎上面的查询中的A.ADDRESS1=B.ADDR_LINE_1,
语句返回boolen。
INSERT OVERWRITE TABLE TABLE_A
SELECT
B.ADDR_LINE_1,
A.ADDRESS2,
CONCAT(B.CITY, ', ', B.STATE, ' ', B.POSTAL_CDE) ,
A.STORETYPE
FROM
P.STUDENT A
JOIN
`default.CUSTOMER` B ON A.REGION = B.SHIP_TO_LOCATION_NUM
AND A.STORENUMBER = B.SHIP
UNION ALL
SELECT
A.ADDRESS1,
A.ADDRESS2,
A.ADDRESS3,
cast(B1.id AS string)
FROM
`P.STUDENT` A
JOIN
R.RTL B1 ON A.REGION = B1.SHIP_TO_LOCATION_NUM
AND A.STORENUMBER = B1.SHIP ;