2012-07-11 108 views
0

我正在用這個查詢做什麼錯,每當我嘗試執行它時,我總是得到錯誤。語義分析錯誤

SELECT 
    t1.buyer_id, 
    t1.item_id, 
    t1.created_time, 
    t2.product_id, 
    t2.timestamps 
FROM 
    TestingTable1 t1 
    JOIN 
    (
    SELECT 
     user_id, 
     prod_and_ts.product_id as product_id, 
     prod_and_ts.timestamps as timestamps 
    FROM 
     TestingTable2 
     LATERAL VIEW explode(purchased_item) exploded_table as prod_and_ts 
    ) t2 
    ON(t1.buyer_id = t2.user_id) 
WHERE 
    (t1.item_id <> t2.product_id) 
    OR (unix_timestamp(t1.created_time) <> t2.timestamps); 

這是錯誤我GET-

FAILED: Error in semantic analysis: line 13:6 Invalid Table Alias or 
Column Reference prod_and_ts 

回答

0

我不知道,但橫向視圖語法

LATERAL VIEW udtf(expression) tableAlias AS columnAlias (',' columnAlias)* 

在你的情況prod_and_ts這是一個columnAlias,不tableAlias你不能使用prod_and_ts.product_id。請嘗試使用prod_and_ts。

+0

根據你我需要做什麼改變?對不起,我無法理解。 – ferhan 2012-07-11 05:45:47

+0

這樣的語法,但它應該更正您的多列結果。 SELECT user_id,product_id FROM TestingTable2 LATERAL VIEW爆炸(purchased_item)exploded_table作爲product_id – AlexT 2012-07-11 06:46:41