SQL查询错误10002 - Hive查询

时间:2017-07-13 01:31:18

标签: sql hiveql

我正在尝试执行以下查询,但它始终会出错。

DROP TABLE IF EXISTS DAILY_STORE_ACTIVITY_HADOOP;
CREATE EXTERNAL TABLE DAILY_STORE_ACTIVITY_HADOOP (storeActivityId String, storeId string, associateProgramId string, earningsDate bigint, totalHappyBonus double, totalNonHappyShippedEarning double, totalShippedEarnings double, totalReturnedEarnings double, totalNewCustomerBonus double, totalNonHappyRefundEarning double, totalKindleEbooksCount BIGINT,  totalFreeKindleEbooksCount BIGINT, totalCount BIGINT) ROW FORMAT delimited fields terminated by '\n';
ALTER TABLE DAILY_STORE_ACTIVITY_HADOOP set SERDE 'org.openx.data.jsonserde.JsonSerDe';
ALTER TABLE DAILY_STORE_ACTIVITY_HADOOP set location 'hdfs://${processingOutputLocation}';

INSERT OVERWRITE TABLE DAILY_STORE_ACTIVITY_HADOOP select CONCAT((t.storeId),'||','${programIdString}')storeActivityId, 
t.storeId storeId, 
'${programIdString}' associateProgramId, 
t.earningsDate earningsDate, 
t.totalHappyBonus totalHappyBonus, 
t.totalNonHappyShippedEarning totalNonHappyShippedEarning,
t.totalShippedEarnings totalShippedEarnings, 
t.totalReturnedEarnings totalReturnedEarnings, 
t.totalNewCustomerBonus totalNewCustomerBonus, 
t.totalNonHappyRefundEarning totalNonHappyRefundEarning, 
t.totalKindleEbooksCount totalKindleEbooksCount, 
t.totalFreeKindleEbooksCount totalFreeKindleEbooksCount, 
t.totalShippedQuantity totalShippedQuantity from (

SELECT 
store_id storeId, 
unix_timestamp(request_date ,'dd-MMM-yyyy') * 1000 earningsDate, 
0 as totalKindleEbooksCount,
0 as totalShippedQuantity,
0 as totalFreeKindleEbooksCount, 
sum(total_Happy_bonus) as totalHappyBonus,
sum(total_non_Happy_shipped_earning) as totalNonHappyShippedEarning,
sum(total_shipped_earnings) as totalShippedEarnings, 
sum(total_returned_earnings) as totalReturnedEarnings,
sum(total_new_customer_bonus) as totalNewCustomerBonus,
sum(total_non_Happy_refund_earning) as totalNonHappyRefundEarning

from STORE_ACTIVITY_AGGREGATES where associate_program_id=${programId} and
unix_timestamp(request_date, 'dd-MMM-yyyy') >= unix_timestamp('${startDate}', 'dd-MMM-yyyy') and
unix_timestamp(request_date, 'dd-MMM-yyyy') < unix_timestamp('${endDate}', 'dd-MMM-yyyy') group by store_id,
unix_timestamp(request_date,'dd-MMM-yyyy') having sum(total_Happy_bonus) <> 0 or sum(total_non_Happy_shipped_earning) <> 0
or sum(total_shipped_earnings) <> 0 or sum(total_returned_earnings) <> 0 or sum(total_new_customer_bonus) <> 0 or
sum(total_non_Happy_refund_earning) <> 0
) t GROUP BY t.STOREID, t.earningsDate;

我所面对的ERRORFAILED: SemanticException

  

[错误10002]:第7行:2无效的列引用&#39; totalHappyBonus&#39;。

我需要专家帮助来纠正此错误。

0 个答案:

没有答案