PLSQL to PIG Conversion

喜夏-厌秋 提交于 2020-01-06 19:41:29

问题


Select x,y,..,
     CASE(
     when A.A_code = 'G' THEN
                            COUNT(DISTINCT CASE
                                    WHEN T.trxn = 'P' THEN
                                     D.A || D.B || D.C 
                                     ELSE
                                     NULL
                                  END)
                          else
                            0
                          end p_count,..From..

is my plsql query structure. I need to convert it.

I have converted the inner case query success fully and it is executed,

the inner query of the plsql case condition will become in PIG as

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

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

JOINED = JOIN T by id,D by id;

p_count = FOREACH JOINED  GENERATE 
                  (case T::trxn
                       WHEN 'P'
                       THEN
                       CONCAT(D::A,D::B,D::C)
                       ELSE
                   NULL
                       END)

Before that i need to check the outer condition(A.A_code = 'G'). It looks like while condition . But the table field which we need to check is different.They are from different tables Please guide me how to check the A.A_code = 'G' first. Then only the inner query will be executed.

Please give me a solution as soon as possible. Thanks in advance!

来源:https://stackoverflow.com/questions/30860944/plsql-to-pig-conversion

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!