[ 
https://issues.apache.org/jira/browse/PIG-1612?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12909418#action_12909418
 ] 

Thejas M Nair commented on PIG-1612:
------------------------------------

For example, in this exception stack trace -
{code}
Caused by: org.apache.pig.impl.logicalLayer.parser.ParseException: Error 
merging schemas for union operator : Error merging schema: ({i: int,j: long}) 
with merged schema: ({l1::i: int,l1::j: long,l2::i: int,l2::j: long}) of 
schemas : [{l1::i: int,l1::j: long,l2::i: int,
l2::j: long}]
        at 
org.apache.pig.impl.logicalLayer.parser.QueryParser.UnionClause(QueryParser.java:3409)
        at 
org.apache.pig.impl.logicalLayer.parser.QueryParser.BaseExpr(QueryParser.java:1457)
        at 
org.apache.pig.impl.logicalLayer.parser.QueryParser.Expr(QueryParser.java:1010)
        at 
org.apache.pig.impl.logicalLayer.parser.QueryParser.Parse(QueryParser.java:797)
        at 
org.apache.pig.impl.logicalLayer.LogicalPlanBuilder.parse(LogicalPlanBuilder.java:63)
        at org.apache.pig.PigServer$Graph.parseQuery(PigServer.java:1593)
        ... 13 more
Caused by: org.apache.pig.impl.logicalLayer.schema.SchemaMergeException: ERROR 
0: Error merging schema: ({i: int,j: long}) with merged schema: ({l1::i: 
int,l1::j: long,l2::i: int,l2::j: long}) of schemas : [{l1::i: int,l1::j: 
long,l2::i: int,l2::j: long}]
        at 
org.apache.pig.impl.logicalLayer.schema.Schema.mergeSchemasByAlias(Schema.java:1652)
        at 
org.apache.pig.impl.logicalLayer.parser.QueryParser.UnionClause(QueryParser.java:3405)
        ... 18 more
Caused by: org.apache.pig.impl.logicalLayer.schema.SchemaMergeException: ERROR 
0: Caught exception finding FieldSchema for aliasi
        at 
org.apache.pig.impl.logicalLayer.schema.Schema.getFieldSubNameMatchThrowSchemaMergeException(Schema.java:1787)
        at 
org.apache.pig.impl.logicalLayer.schema.Schema.mergeSchemaByAlias(Schema.java:1686)
        at 
org.apache.pig.impl.logicalLayer.schema.Schema.mergeSchemasByAlias(Schema.java:1646)
        ... 19 more
Caused by: org.apache.pig.impl.logicalLayer.FrontendException: ERROR 1025: 
Found more than one match: l1::i, l2::i
        at 
org.apache.pig.impl.logicalLayer.schema.Schema.getField(Schema.java:819)
        at 
org.apache.pig.impl.logicalLayer.schema.Schema.getFieldSubNameMatch(Schema.java:836)
        at 
org.apache.pig.impl.logicalLayer.schema.Schema.getFieldSubNameMatchThrowSchemaMergeException(Schema.java:1783)
        ... 21 more

{code}
The pig statement that results in this error is a union command -
u = union onschema f, l3;

The error message that is printed only says -  'Found more than one match: 
l1::i, l2::i' . It would be more useful for the user if we are able to say 
something on lines of  -
"Error merging schema: ({i: int,j: long}) with merged schema: ({l1::i: 
int,l1::j: long,l2::i: int,l2::j: long}) of schemas : [{l1::i: int,l1::j: 
long,l2::i: int,l2::j: long}]. Found more than one match: l1::i, l2::i" 
(assuming this was the message generated exception from Schema.java:1652)



> error reporting: PigException needs to have a way to indicate that its 
> message is appropriate for user
> ------------------------------------------------------------------------------------------------------
>
>                 Key: PIG-1612
>                 URL: https://issues.apache.org/jira/browse/PIG-1612
>             Project: Pig
>          Issue Type: Improvement
>            Reporter: Thejas M Nair
>             Fix For: 0.9.0
>
>
> The error message printed to the user by pig is the message from the 
> exception that is the 'root cause' from the chain of getCause() of exception 
> that has been thrown. But often the 'root cause' exception does not have 
> enough context that would make for a better error message. It should be 
> possible for a PigException to indicate to the code that determines the error 
> message that its getMessage() string should be used instead of that of the 
> 'cause' exception.
> The following code in LogUtils.java is used to determine the exception that 
> is the 'root cause' -
> {code}
>     public static PigException getPigException(Throwable top) {
>         Throwable current = top;
>         Throwable pigException = top;
>         while (current != null && current.getCause() != null){
>             current = current.getCause();
>             if((current instanceof PigException) && 
> (((PigException)current).getErrorCode() != 0)) {
>                 pigException = current;
>             }
>         }
>         return (pigException instanceof PigException? 
> (PigException)pigException : null);
>         
>     }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to