Define tuple datas in the pig script
Asked Answered
M

2

14

I am currently debugging a pig script. I'd like to define a tuple in the Pig file directly (instead of the basic "Load" function).

Is there a way to do it?

I am looking for something like that:

A= ('name#bob'','age#29';'name#paul','age#12')

The dump Will return :

('bob',29)
('paul',12)
Manual answered 14/9, 2012 at 11:14 Comment(5)
If you have loaded some data you can create tuples by using TOTUPLE : pig.apache.org/docs/r0.10.0/func.html#totupleMainsail
I just want to define a tuple without using any LOAD functions.Manual
You can define parameters in a pig script with %declare but I don't think you are allowed just to create some data on the fly (without loading it from hdfs/local disk)Mainsail
You can't. Check this pig-dev mailing list: mail-archives.apache.org/mod_mbox/pig-dev/201408.mbox/…Goneness
I answered it in another thread: https://mcmap.net/q/902202/-how-to-create-a-small-constant-relation-table-in-pigWaterway
O
4

It is in fact impossibble to do this in pig as it currently stands. If you just want to debug create a file in hadoop and load that. Write the data you want into the file (whatever you would have created manually had it been possibble) and upload it. Then load it using pig.

Oshea answered 7/11, 2013 at 21:29 Comment(0)
M
1

The following (dirty) trick do the job: - create a file With one empty row ans store it to your HDFS. - load it : Line = load /user/toto/onelinefile USING .. - create own datas : foreach line generate 'bob' as name, 22 as age;

Manual answered 19/4, 2014 at 0:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.