gpt4 book ai didi

hadoop - 在Pig中处理数据结构

转载 作者:行者123 更新时间:2023-12-02 21:36:24 26 4
gpt4 key购买 nike

之前我问过Hive或Pig中的manipulating a data structure。我能够在SQL中得到答案,然后从那里找出Hive的答案。我仍在寻找Pig的解决方案。

我想更改myTable:
enter image description here

进入myTable2:
enter image description here

我试过了:

myTable2 = FOREACH myTable GENERATE item, year, 
'jan' AS month, jan AS value,
'feb' AS month, feb AS value,
'mar' AS month, mar AS value;

在Hive中工作大致相同,但Pig给我的好处是:
ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1108:
<line 2, column 35> Duplicate schema alias: month

最佳答案

我想通了,尽管我希望看到一个更简洁的版本:

JAN = FOREACH myTable GENERATE item, year, 'jan' AS month, jan AS value;
FEB = FOREACH myTable GENERATE item, year, 'feb' AS month, feb AS value;
MAR = FOREACH myTable GENERATE item, year, 'mar' AS month, mar AS value;
myTable2 = union JAN, FEB, MAR;

关于hadoop - 在Pig中处理数据结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31929320/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com