输入不匹配“)”应为end

ki0zmccv  于 2021-07-15  发布在  Pig
关注(0)|答案(1)|浏览(434)

我需要创建dms\u eprpfl实体,如下pig脚本所示:

DMS_EPRPFL = FOREACH ORDER_EPSE_ENEE_ENR  GENERATE

GROUP_EPSE_ENEE_ENR::IDT_GCP           AS    IDT_GCP,
GROUP_EPSE_ENEE_ENR::CD_FRM_JUR        AS    CD_FRM_JUR,
GROUP_EPSE_ENEE_ENR::DA_CRE_EPS        AS    DA_CRE_EPS,
GROUP_EPSE_ENEE_ENR::NO_SIREN           AS   NO_SIREN,
GROUP_EPSE_ENEE_ENR::CD_POST            AS   CD_POST,
GROUP_EPSE_ENEE_ENR::CD_OSCE_PAYS_FIS    AS  CD_OSCE_PAYS_FIS,
GROUP_EPSE_ENEE_ENR::CD_NAF              AS  CD_NAF,
GROUP_EPSE_ENEE_ENR::CD_NACE             AS  CD_NACE,
(CASE (GROUP_EPSE_ENEE_ENR::CD_AXE_MCH)
WHEN ('PLIB' OR 'ATPE' OR 'COMM') THEN 'P'
WHEN ('PME') THEN 'E'
WHEN ('AGRI') THEN 'A'
WHEN ('OBNL') THEN 'O'
WHEN ('COLL') THEN 'C'
WHEN ('EFIN') THEN 'B'
WHEN ('NONA' OR 'SCI') THEN 'X')               AS CD_MARCHE,
GROUP_EPSE_ENEE_ENR::CD_AXE_SNIV_MCH           AS CD_AXE_SNIV_MCH,
MIN(GROUP_EPSE_ENEE_ENR::A_PRM_CTR)            AS A_PRM_CTR,
MIN(GROUP_EPSE_ENEE_ENR::A_PRM_CAV)            AS A_PRM_CAV,
MIN(GROUP_EPSE_ENEE_ENR::A_PRPRE)              AS A_PRPRE,
GROUP_EPSE_ENEE_ENR::CD_NOT                    AS CD_NOT;

问题在于 CD_MARCHE 。事实上,我需要根据特定的条件和使用case运算符生成它。
执行脚本时出现以下错误:
不匹配的输入“)”应为end
在这条线上

WHEN ('NONA' OR 'SCI') THEN 'X')               AS CD_MARCHE,

我在那里找不到问题。
谢谢你的帮助

siv3szwd

siv3szwd1#

从http://pig.apache.org/docs/latest/basic.html#arithmetic
这两种情况

CASE expression [ WHEN value THEN value ]+ [ ELSE value ]? END

CASE [ WHEN condition THEN value ]+ [ ELSE value ]? END

在您的示例中,您使用的是前一个混合条件(a或b),其中它只接受值。需要两个改变。
在case语句的末尾添加“end”,并使用后面的case语句。
重写

(CASE (field)
    WHEN ( 'PLIB' OR 'ATPE' OR 'COMM' ) THEN 'P' 
    WHEN ('PME') THEN 'E'
    ...
    WHEN ('NONA' OR 'SCI') THEN 'X') AS CD_MARCHE,

(CASE 
    WHEN (field in ('PLIB','ATPE','COMM') ) THEN 'P' 
    WHEN (field == 'PME') THEN 'E'
    ...
    WHEN (field in ('NONA','SCI')) THEN 'X' END) AS CD_MARCHE,

相关问题