Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache pig 声明逗号分隔的字符串常量_Apache Pig_Constants_Declare - Fatal编程技术网

Apache pig 声明逗号分隔的字符串常量

Apache pig 声明逗号分隔的字符串常量,apache-pig,constants,declare,Apache Pig,Constants,Declare,目标:声明逗号分隔的字符串常量 test.csv ========= a b c d e f 清管器脚本: %declare ACTIVE_VALUES 'a', 'b','c' ; -- Declaring constant like this using "" (double quotes) or even using escape characters (\) is resulting in a WARN mes

目标:声明逗号分隔的字符串常量

    test.csv
    =========
    a
    b
    c
    d
    e
    f
清管器脚本:

  %declare ACTIVE_VALUES 'a', 'b','c' ; 

  -- Declaring constant like this using "" (double quotes) or even using escape characters (\) is resulting in a WARN message as below 
  -- WARN  org.apache.pig.tools.parameters.PreprocessorContext - Warning : Multiple values found for ACTIVE_VALUES

  A = LOAD 'test.csv' using PigStorage(',') AS (value:chararray);
  B = FILTER A BY value in ($ACTIVE_VALUES);
  dump B;
 a
 b
 c
预期输出:

  %declare ACTIVE_VALUES 'a', 'b','c' ; 

  -- Declaring constant like this using "" (double quotes) or even using escape characters (\) is resulting in a WARN message as below 
  -- WARN  org.apache.pig.tools.parameters.PreprocessorContext - Warning : Multiple values found for ACTIVE_VALUES

  A = LOAD 'test.csv' using PigStorage(',') AS (value:chararray);
  B = FILTER A BY value in ($ACTIVE_VALUES);
  dump B;
 a
 b
 c
在Pig中声明逗号分隔字符串常量的任何输入

--使用“”(双引号)或甚至使用转义字符(\)像这样声明常量会产生如下警告消息


--WARN org.apache.pig.tools.parameters.PreprocessorContext-警告:为活动_值找到多个值

您可以使用单个逗号分隔的字符串('a,b,c'),并对活动_值使用STRSPLIT()函数来获取一袋字符,这些字符可以展平以创建多个记录。此数据可以与测试文件中的数据进行内部连接,以获得所需的结果。

好主意,您能否分享一个示例,说明如何拆分%define中定义的值并将其保存到别名/引用中。