大家好,
我有我的表结构,如下所示。
Create table hv (x int,y int,z int ,w int )
PIGLATIN用于加载表格
A = LOAD 'XYZ.CSV.GZ' using pigstorage AS (x,y,w)
这次文件中缺少Z col,因此我希望在PIGLATIN中将z的值保留为null,并且我不想更改 hive 表结构。如何在pig中为该列生成null的值?
最佳答案
引用Nulls and constants,您可以执行以下操作:
--load your hive table
A = LOAD 'hive_db.table_name' USING org.apache.hive.hcatalog.pig.HCatLoader();
--this will generate a NULL column with datatype bytearray
B = FOREACH A GENERATE X,Y,NULL,W;
--then you can further process your data
STORE B INTO '/your/hdfs' USING PigStorage(',');
关于hadoop - 在 pig 级别将空值作为别名处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41846008/