Mangat Rai Modi
Mangat Rai Modi

Reputation: 5706

Apache Pig escape column name

I am reading Parquet logs in PIG. Log schema contains a field FULL nested under field USER. Since FULL is a keyword in Pig I can't load the file. Pig is giving compile time errors. There is no way to escape such field name. It would really adverse to change column name in schema. This is what I am using to load

user_parquet = LOAD 'test' USING org.apache.parquet.pig.ParquetLoader();
user_normalized = FOREACH user_parquet GENERATE ..... USER.FULL as user_full ...

I tried escaping with \, ``, '' but none of them worked!

Upvotes: 1

Views: 664

Answers (1)

Mangat Rai Modi
Mangat Rai Modi

Reputation: 5706

Basically I solved the issue by referring field with field number instead of field name:-

user_parquet = LOAD 'test' USING org.apache.parquet.pig.ParquetLoader();
user_normalized = FOREACH user_parquet GENERATE ..... USER.$0 as user_full ...

Pig, as any other language as no way to escape keyword if used as variable name.

Upvotes: 1

Related Questions