Support Questions

Find answers, ask questions, and share your expertise

PIG: Unable to open iterator for alias AliasName.Scalar has more than one row in the output

avatar
Expert Contributor

Hi all,

I am new to pig and trying to learn on my own.

I have written a script to get the epoch time with a word that is reading from words.txt file.

Here is the script.

words = LOAD 'words.txt' AS word:chararray;
B = FOREACH A GENERATE CONCAT(CONCAT(A.word,'_'),(chararray)ToUnixTime(CurrentTime());
dump B;

But the issue is, if words.txt file have only one word it is giving proper output.

If it is having multiple words like

word1
word2
word3
word4

then it is giving the following error

ERROR 1066: Unable to open iterator for alias B

java.lang.Exception: org.apache.pig.backend.executionengine.ExecException: ERROR 0: Scalar has more than one row in the output. 1st : (word1 ), 2nd :(word2) (common cause: "JOIN" then "FOREACH ... GENERATE foo.bar" should be "foo::bar" ) at org.apache.hadoop.mapred.LocalJobRunner$Job.runTasks(LocalJobRunner.java:462) at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:522) Caused by: org.apache.pig.backend.executionengine.ExecException: ERROR 0: Scalar has more than one row in the output. 1st : (word1 ), 2nd :(word2) (common cause: "JOIN" then "FOREACH ... GENERATE foo.bar" should be "foo::bar" ) at org.apache.pig.impl.builtin.ReadScalars.exec(ReadScalars.java:122) at o

Please suggest me to solve this issue.

Thank you.

Mohan.V

1 ACCEPTED SOLUTION

avatar
Expert Contributor

I think i found the answer on my own.

B = FOREACH words GENERATE CONCAT(CONCAT(word,'_'),(chararray)ToUnixTime(CurrentTime()));

I just removed A. from the inner CONCAT. And it worked fine.

View solution in original post

1 REPLY 1

avatar
Expert Contributor

I think i found the answer on my own.

B = FOREACH words GENERATE CONCAT(CONCAT(word,'_'),(chararray)ToUnixTime(CurrentTime()));

I just removed A. from the inner CONCAT. And it worked fine.