Pig UNION基础教程文档
收录于 2023-04-20 00:10:05 · بالعربية · English · Español · हिंदीName · 日本語 · Русский язык · 中文繁體
Apache Pig UNION 运算符
Apache Pig UNION 运算符用于计算两个或多个关系的并集。它不维护元组的顺序。它也不会消除重复的元组。
UNION 运算符示例
在这个示例中,我们计算两个关系的数据。
执行 UNION 运算符的步骤
在您的本地机器上创建一个文本文件并向其中写入一些值。$ nano punion1.txt
$ nano punion2.txt
$ cat punion1.txt $ cat punion2.txt
$ hdfs dfs-put punion1.txt /pigexample $ hdfs dfs-put punion2.txt /pigexample
$ pig
grunt> A = load '/pigexample/punion1.txt' using PigStorage(',') as (a1:int,a2:int);
grunt> DUMP A;
grunt> B = LOAD '/pigexample/punion2.txt' USING PigStorage(',') AS (b1:int,b2:int,b3:int);
grunt> DUMP B;
grunt> Result = UNION A,B;
grunt> DUMP Result;
在这里,我们得到了想要的输出。