PLSQL到PIGLATIN

时间:2015-06-17 10:59:59

标签: apache-pig

select (WHEN tt.trxn = 'P' AND ip.crdate = dtd.podate 

        THEN
             dtd.A || dtdB || dtd.C 
        ELSE
             NULL
             END) XXXX,..

是我的plsql脚本。

我正在使用案例条件。

T = LOAD '//transaction_types' USING PigStorage(',') as (id:int,trxn:chararray);

D = LOAD '/home/sterlingpc1/Desktop/det_trades' USING PigStorage(',') as (id:int,id1:int,A:chararray,B:chararray,C:chararray,pdate:chararray);

I = LOAD '//transaction_types' USING PigStorage(',') as (id1:int,cdate:chararray);

JOINED = JOIN T by id,D by id;
JOINED1 = JOIN JOINED by id1,I by id1;
b = FOREACH JOINED1 GENERATE 
                  (case 
                       WHEN T::trxn == 'P' AND
                     I::cdate == dtd::pdate
                       THEN
                       CONCAT(D::A,D::B,D::C)
                       ELSE
                   NULL
                       END)

它抛出异常。

如何在PIG Latin的CASE STATEMENT中提供或检查多个条件(FOR tt.trxn = 'P' AND ip.crdate = dtd.podate)。

1 个答案:

答案 0 :(得分:0)

tab.T

01,对 02,P 03,P

tab.D

01,AA,BB,CC,ASDF 02,AAA,BBB,CCC,航空自卫队 03,AA,BB,CC,ASDF

tab.I

01,AA,ASDF 02,AAA,航空自卫队 03,AA,ASDF

T = LOAD'/ home / sterlingpc1 / Documents / TEST / T'使用PigStorage(',')as(id:int,trxn:chararray);

D = LOAD'/ home / sterlingpc1 / Documents / TEST / D'使用PigStorage(',')as(id:int,A:chararray,B:chararray,C:chararray,pdate:chararray);

I = LOAD'/ home / sterlingpc1 / Documents / TEST / I'使用PigStorage(',')as(id:int,A:chararray,cdate:chararray);

JOINED =由ID加入T,由ID加入;

JOINED1 = A加入加入,A加入;

b = FOREACH JOINED1 GENERATE                   (案件                        当T :: trxn =='p'时                        然后                        CONCAT(d :: A,d :: B,d :: C)                        其他                        空值                        END);

dump b

(AABBCC) (AABBCC) (AABBCC) (AABBCC) (AAABBBCCC)

b1 = FOREACH JOINED1 GENERATE                   (情况何时                        我:: cdate == D :: pdate                        然后                        CONCAT(d :: A,d :: B,d :: C)                        其他                        空值                        END);

dump b1

(AABBCC) (AABBCC) (AABBCC) (AABBCC) (AAABBBCCC)

b2 = FOREACH JOINED1 GENERATE                   (案件                      当T :: trxn =='p'OR时                      我:: cdate == D :: pdate                        然后                        CONCAT(d :: A,d :: B,d :: C)                        其他                        空值                        END);

dump b2

(AABBCC) (AABBCC) (AABBCC) (AABBCC) (AAABBBCCC)

b2 = FOREACH JOINED1 GENERATE                   (案件                      当T :: trxn =='p'AND时                      我:: cdate == D :: pdate                        然后                        CONCAT(d :: A,d :: B,d :: C)                        其他                        空值                        END);

dump b2

(AABBCC) (AABBCC) (AABBCC) (AABBCC) (AAABBBCCC)

我有一个解决方案。我只是改变了条件。对于小'p',我把'P'。那是错误的。现在我得到了预期的输出朋友。非常感谢!