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中定义的值并将其保存到别名/引用中。