我的主要需求是使用INSERT OVERWRITE uery从HIVE加载HDFS文件。在这个查询中,我试图加入3个hive表。以下是查询:
select * FROM
AGG_CUSTOMER_EXPSR_DRV_HIVE DRV
LEFT OUTER JOIN
AGG_CUSTOMER_EXPSR_SRC_HIVE SRC
ON
(SRC.CUSTOMER_ID = DRV.CUSTOMER_ID)
AND (SRC.AGGREGATION_LEVEL_CD = DRV.AGGREGATION_LEVEL_CD)
AND (SRC.PRODUCT_GROUP_CD = DRV.PRODUCT_GROUP_CD) AND (SRC.SRC_SYS_CD = DRV.SRC_SYS_CD)
LEFT OUTER JOIN
ALTERNATE_IP_HIVE AIP1
ON
(DRV.DERIVED_CUSTOMER_ID = AIP1.IP_ID) AND (AIP1.IP_TYPE_CD IN (1, 4))
LEFT OUTER JOIN
ALTERNATE_IP_HIVE AIP3
ON
(SRC.FINANCIAL_RPTNG_UNIT_ID = AIP3.IP_ID) AND (AIP3.IP_TYPE_CD = 3)
WHERE EXCLUDE_IND ='N';
但我收到的错误如下:
-sh: syntax error near unexpected token
(`
有人可以帮我找出问题吗?
注意:我删除了SELECT子句中的字段。
答案 0 :(得分:0)
如果您在hive中创建了一个表,其中包含上述sql中的结果字段数,那么您可以简单地执行
INSERT OVERWRITE TABLE <database_name.your_created_table_name> SELECT * FROM
AGG_CUSTOMER_EXPSR_DRV_HIVE DRV
LEFT OUTER JOIN
AGG_CUSTOMER_EXPSR_SRC_HIVE SRC
ON
(SRC.CUSTOMER_ID = DRV.CUSTOMER_ID)
AND (SRC.AGGREGATION_LEVEL_CD = DRV.AGGREGATION_LEVEL_CD)
AND (SRC.PRODUCT_GROUP_CD = DRV.PRODUCT_GROUP_CD) AND (SRC.SRC_SYS_CD = DRV.SRC_SYS_CD)
LEFT OUTER JOIN
ALTERNATE_IP_HIVE AIP1
ON
(DRV.DERIVED_CUSTOMER_ID = AIP1.IP_ID) AND (AIP1.IP_TYPE_CD IN (1, 4))
LEFT OUTER JOIN
ALTERNATE_IP_HIVE AIP3
ON
(SRC.FINANCIAL_RPTNG_UNIT_ID = AIP3.IP_ID) AND (AIP3.IP_TYPE_CD = 3)
WHERE EXCLUDE_IND ='N';
来自SELECT的它是您的查询。您可以查看this URL以获取有关hiveql的更多帮助