Hive查询:阶段中不明确的列引用acct_nbr

时间:2018-05-01 05:36:01

标签: sql hadoop hive hiveql

我收到“不明确的列引用”

查询:

SELECT stage.acct_nbr 
FROM   (SELECT * 
        FROM   mem stage 
               JOIN (SELECT acct_nbr, 
                            corp_ent_cd, 
                            sub_seq_nbr, 
                            mem_nbr, 
                            Max(cdc_src_last_updt_ts) AS cdc_src_last_updt_ts 
                     FROM   mem 
                     WHERE  file_nm = 'DLTV.FULL.MES3191.D180423' 
                     GROUP  BY acct_nbr, 
                               corp_ent_cd, 
                               sub_seq_nbr, 
                               mem_nbr) c 
                 ON c.corp_ent_cd = stage.corp_ent_cd 
                    AND c.acct_nbr = stage.acct_nbr 
                    AND c.sub_seq_nbr = stage.sub_seq_nbr 
                    AND c.mem_nbr = stage.mem_nbr 
                    AND stage.cdc_src_last_updt_ts = c.cdc_src_last_updt_ts 
        WHERE  stage.file_nm = 'DLTV.FULL.MES3191.D180423') stage; 

错误消息:

  

错误:编译语句时出错:FAILED:SemanticException [错误10007]:阶段中的模糊列引用acct_nbr(state = 42000,code = 10007)

然而,如果我选择*而不是选择stage.acct_nbr,它会正确执行。

有人可以解决我的问题吗?

1 个答案:

答案 0 :(得分:2)

问题出在foreach ($datas as $data) { $item = db::findFirst([ 'conditions' => 'dbID = :dbID:', 'bind' => [ 'dbID' => $data['dbID'] ] ]); // Record does not exist in our DB - skip or even create it? if ($item === false) { continue; } // Proceed with updating data $item->account = $data['Account']; $item->amount = (float) $data['Amount']; $item->transactionNo = $data['TransactionNo']; $item->save(); }

子查询SELECT *c.acct_nbr有两列,因此外stage.acct_nbr无法SELECT区分您想要获得的colunm。

因此,您可以在stage.acct_nbr子查询中选择c.acct_nbrstage.acct_nbr

你可以试试这个。

select