On 7/29/11 9:47 AM, rob parker wrote:

grunt>  describe AjD;
AjD: {ACCT::year: int,ACCT::month: int,ACCT::day: int,ACCT::account:
chararray,ACCT::metric1: double,ACCT::metric2: double,DIM::year:
int,DIM::month: int,DIM::days: int}

grunt>  FINAL = FOREACH AjD
GENERATE ACCT.year, ACCT.month, ACCT.account, (ACCT.metric2 / DIM.days);
grunt>  dump FINAL;
...
ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1066: Unable to open iterator
for alias FINAL. Backend error : Scalar has more than one row in the output.
1st : (2011,7,26,key1,23.25,2470.0), 2nd
:(2011,7,26,key2,10.416666666666668,232274.08333333334)

The column in AjD schema is ACCT::year, not ACCT.year (note the "::" vs ".").

So you need to change it to -
grunt>  FINAL = FOREACH AjD
GENERATE ACCT::year, ACCT::month, ACCT::account, (ACCT::metric2 / DIM::days);

You are accidentally using the relation-as-scalar feature here.
http://pig.apache.org/docs/r0.8.1/piglatin_ref2.html#Casting+Relations+to+Scalars
There is a jira open to deprecate the syntax for this feature so that users don't accidentally end up using it - https://issues.apache.org/jira/browse/PIG-1967

-Thejas

Reply via email to