[
https://issues.apache.org/jira/browse/PIG-518?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12857157#action_12857157
]
Viraj Bhat commented on PIG-518:
--------------------------------
The above script generates the following error in Pig 0.7
2010-04-14 17:10:49,807 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR
1048: Two inputs of BinCond must have compatible schemas. left hand side: b:
bag({colb2: bytearray,colb3: bytearray}) right hand side:
bag({(chararray,chararray)})
A type cast to the right type solves the problem.
{code}
a = load 'sports_views.txt' as (col1:chararray, col2:chararray,
col3:chararray);
b = load 'queries.txt' as (colb1:chararray,colb2:chararray,colb3:chararray);
mycogroup = cogroup a by col1 inner, b by colb1;
mynewalias = foreach mycogroup generate flatten(a), flatten((COUNT(b) > 0L ?
b.(colb2,colb3) : {('','')}));
dump mynewalias;
{code}
(alice,lakers,3,ipod,3)
(alice,warriors,7,ipod,3)
(peter,sun,7,sun,4)
(peter,nets,7,sun,4)
Closing bug as Pig yields the correct error message which the user can use to
recode his script
> LOBinCond exception in LogicalPlanValidationExecutor when providing default
> values for bag
> -------------------------------------------------------------------------------------------
>
> Key: PIG-518
> URL: https://issues.apache.org/jira/browse/PIG-518
> Project: Pig
> Issue Type: Bug
> Components: impl
> Affects Versions: 0.2.0
> Reporter: Viraj Bhat
> Attachments: queries.txt, sports_views.txt
>
>
> The following piece of Pig script, which provides default values for bags
> {('','')} when the COUNT returns 0 fails with the following error. (Note:
> Files used in this script are enclosed on this Jira.)
> ================================================================================================
> a = load 'sports_views.txt' as (col1, col2, col3);
> b = load 'queries.txt' as (colb1,colb2,colb3);
> mycogroup = cogroup a by col1 inner, b by colb1;
> mynewalias = foreach mycogroup generate flatten(a), flatten((COUNT(b) > 0L ?
> b.(colb2,colb3) : {('','')}));
> dump mynewalias;
> ================================================================================================
> java.io.IOException: Unable to open iterator for alias: mynewalias [Unable to
> store for alias: mynewalias [Can't overwrite cause]]
> at java.lang.Throwable.initCause(Throwable.java:320)
> at
> org.apache.pig.impl.logicalLayer.validators.TypeCheckingVisitor.visit(TypeCheckingVisitor.java:1494)
> at org.apache.pig.impl.logicalLayer.LOBinCond.visit(LOBinCond.java:85)
> at org.apache.pig.impl.logicalLayer.LOBinCond.visit(LOBinCond.java:28)
> at
> org.apache.pig.impl.plan.DependencyOrderWalker.walk(DependencyOrderWalker.java:68)
> at org.apache.pig.impl.plan.PlanVisitor.visit(PlanVisitor.java:51)
> at
> org.apache.pig.impl.logicalLayer.validators.TypeCheckingVisitor.checkInnerPlan(TypeCheckingVisitor.java:2345)
> at
> org.apache.pig.impl.logicalLayer.validators.TypeCheckingVisitor.visit(TypeCheckingVisitor.java:2252)
> at org.apache.pig.impl.logicalLayer.LOForEach.visit(LOForEach.java:121)
> at org.apache.pig.impl.logicalLayer.LOForEach.visit(LOForEach.java:40)
> at
> org.apache.pig.impl.plan.DependencyOrderWalker.walk(DependencyOrderWalker.java:68)
> at org.apache.pig.impl.plan.PlanVisitor.visit(PlanVisitor.java:51)
> at
> org.apache.pig.impl.plan.PlanValidator.validateSkipCollectException(PlanValidator.java:101)
> at
> org.apache.pig.impl.logicalLayer.validators.TypeCheckingValidator.validate(TypeCheckingValidator.java:40)
> at
> org.apache.pig.impl.logicalLayer.validators.TypeCheckingValidator.validate(TypeCheckingValidator.java:30)
> at
> org.apache.pig.impl.logicalLayer.validators.LogicalPlanValidationExecutor.validate(LogicalPlanValidationExecutor.java:
> 79)
> at org.apache.pig.PigServer.compileLp(PigServer.java:684)
> at org.apache.pig.PigServer.compileLp(PigServer.java:655)
> at org.apache.pig.PigServer.store(PigServer.java:433)
> at org.apache.pig.PigServer.store(PigServer.java:421)
> at org.apache.pig.PigServer.openIterator(PigServer.java:384)
> at
> org.apache.pig.tools.grunt.GruntParser.processDump(GruntParser.java:269)
> at
> org.apache.pig.tools.pigscript.parser.PigScriptParser.parse(PigScriptParser.java:178)
> at
> org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:84)
> at org.apache.pig.tools.grunt.Grunt.exec(Grunt.java:64)
> at org.apache.pig.Main.main(Main.java:306)
> Caused by: java.io.IOException: Unable to store for alias: mynewalias [Can't
> overwrite cause]
> ... 26 more
> Caused by: java.lang.IllegalStateException: Can't overwrite cause
> ... 26 more
> ================================================================================================
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira