Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.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 Pig-更新列时保留架构_Apache Pig - Fatal编程技术网

Apache pig Pig-更新列时保留架构

Apache pig Pig-更新列时保留架构,apache-pig,Apache Pig,我想使用函数更新关系中的列。我已经知道了如何使用更新的数据添加新列并删除旧列,但新列不包含我希望保留的字段名 例如,假设students.txt是: John 18 4.0 Mary 19 3.8 Bill 20 3.9 Joe 18 3.8 猪: x = load 'students.txt' as (name:chararray, age:int, gpa:float); dump x (John,18,4.0) (Mar

我想使用函数更新关系中的列。我已经知道了如何使用更新的数据添加新列并删除旧列,但新列不包含我希望保留的字段名

例如,假设
students.txt
是:

John    18      4.0
Mary    19      3.8
Bill    20      3.9
Joe     18      3.8
猪:

x = load 'students.txt' as (name:chararray, age:int, gpa:float);

dump x
(John,18,4.0)
(Mary,19,3.8)
(Bill,20,3.9)
(Joe,18,3.8)

describe x
x: {name: chararray,age: int,gpa: float}


y = foreach x generate name, (age==18?999:age), gpa;

dump y;
(John,999,4.0)
(Mary,19,3.8)
(Bill,20,3.9)
(Joe,999,3.8)

describe y;
y: {name: chararray,int,gpa: float}
如何为第二个字段保留名称
age
,以便
y
具有与
x
相同的模式

此外,是否有一种简单的方法可以保存数据集中的每一列,但此列的旧版本除外?(即忽略一个字段的星形表达式或项目范围表达式)


还是有更好的方法来解决这个问题?

我找到了一个快速的方法。该键在函数后使用
作为[字段名]

y = foreach x generate name, (age==18?999:age) as age, gpa;

dump y
(John,999,4.0)
(Mary,19,3.8)
(Bill,20,3.9)
(Joe,999,3.8)

describe y
y: {name: chararray,age: int,gpa: float}