[
https://issues.apache.org/jira/browse/PIG-4327?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Daniel Dai updated PIG-4327:
----------------------------
Fix Version/s: 0.15.0
> Schema of map with value that has an alias can't be parsed again
> ----------------------------------------------------------------
>
> Key: PIG-4327
> URL: https://issues.apache.org/jira/browse/PIG-4327
> Project: Pig
> Issue Type: Bug
> Components: parser
> Affects Versions: 0.12.0, 0.13.0
> Reporter: Michael Prim
> Assignee: Michael Prim
> Fix For: 0.15.0
>
> Attachments:
> 0001-Extend-map-type-to-allow-for-alias-of-its-values.patch
>
>
> Tried to create a map of a primitive type, the resulting schema can't be
> parsed again by the parser if there is a alias set for the value.
> I could not set an alias, but the alias gets set by pig itself, e.g. when
> converting avro schemas to pig schemas and there was a map of records in avro.
> See also my other bug report https://issues.apache.org/jira/browse/PIG-4326 ,
> even without that fix, pig produces schemas of maps with values that have an
> alias.
> You can easily reproduce the crash, using those two unit tests. The second
> one should actually succeed but throws a ParserException instead
> {code}
> @Test
> public void testWorksWithoutAlias() throws FrontendException {
> List<FieldSchema> innerFields = new ArrayList<>();
> innerFields.add(new FieldSchema(null, DataType.LONG));
> List<FieldSchema> fields = new ArrayList<>();
> fields.add(new FieldSchema("mapAlias", new Schema(innerFields),
> DataType.MAP));
> Schema inputSchema = new Schema(fields);
> Schema fromString =
> Utils.getSchemaFromBagSchemaString(inputSchema.toString());
> assertEquals(inputSchema.toString(), fromString.toString());
> }
> @Test
> public void testBreaksWithAlias() throws FrontendException {
> List<FieldSchema> innerFields = new ArrayList<>();
> innerFields.add(new FieldSchema("valueAlias", DataType.LONG));
> List<FieldSchema> fields = new ArrayList<>();
> fields.add(new FieldSchema("mapAlias", new Schema(innerFields),
> DataType.MAP));
> Schema inputSchema = new Schema(fields);
> Schema fromString =
> Utils.getSchemaFromBagSchemaString(inputSchema.toString());
> assertEquals(inputSchema.toString(), fromString.toString());
> }
> {code}
> I suppose that the issue is in the grammar itself and easy to fix for someone
> knowing antlr. I don't think the issue is related to the actual type of the
> value, as I could also provide tests that fail if we don't use a primitive
> but complex type with an alias.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)