[
https://issues.apache.org/jira/browse/PIG-4219?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Lorand Bendig updated PIG-4219:
-------------------------------
Attachment: PIG-4219.patch
It seems to me that if the outermost tuple in a bag has only one field it will
be thrown away when the logical plan is created.
LogicalPlanGenerator.g:
{code}
bag_type returns[LogicalSchema logicalSchema]
: ^( BAG_TYPE IDENTIFIER? tuple_type? )
{
if ($tuple_type.logicalSchema!=null &&
$tuple_type.logicalSchema.size()==1 &&
$tuple_type.logicalSchema.getField(0).type==DataType.TUPLE) {
$logicalSchema = $tuple_type.logicalSchema;
}
else {
LogicalSchema s = new LogicalSchema();
s.addField(new LogicalFieldSchema($IDENTIFIER.text,
$tuple_type.logicalSchema, DataType.TUPLE));
$logicalSchema = s;
}
}
;
{code}
By only having the code from the else branch solves the problem and all unit
tests pass as well. I attached a patch, however, I'm not sure about the
consequences.
[~daijy] what do you think (if/else branch has been introduced with PIG-1876) ?
> When parsing a schema, pig drops tuple inside of Bag if it contains only one
> field
> ----------------------------------------------------------------------------------
>
> Key: PIG-4219
> URL: https://issues.apache.org/jira/browse/PIG-4219
> Project: Pig
> Issue Type: Bug
> Reporter: Julien Le Dem
> Attachments: PIG-4219.patch
>
>
> Example
> {code:java}
> //We generate a schema object and call toString()
> String schemaStr = "my_list: {array: (array_element: (num1: int,num2: int))}";
> // Reparsed using org.apache.pig.impl.util.Utils
> Schema schema = Utils.getSchemaFromString(schemaStr);
> // But no longer matches the original structure
> schema.toString();
> // => {my_list: {array_element: (num1: int,num2: int)}}
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)