I have 50 fields, Is there any option in pig to print first 40 field in Apache Pig? I require something like range $0-$39

99封情书 提交于 2019-12-11 07:08:56

问题


I have 50 fields, Is there any option in pig to print first 40 fields? I require something like range $0-$39. I don’t want to specify each and every field like $0, $1,$2 etc

Giving every column when the number of columns is less is acceptable but when there are a huge number of columns what is the case?


回答1:


You can use the .. notation.

First 40 fields

B = FOREACH A GENERATE $0..$39;

All fields

B = FOREACH A GENERATE $0..;

Multiple ranges,for example first 10,15-20,25-50

B = FOREACH A GENERATE $0..$9,$14..$19,$24..;

Random fields 22,33-44,46

B = FOREACH A GENERATE $21,$32..$43,$45;


来源:https://stackoverflow.com/questions/47051846/i-have-50-fields-is-there-any-option-in-pig-to-print-first-40-field-in-apache-p

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!