[ https://issues.apache.org/jira/browse/NIFI-4647?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Pierre Villard updated NIFI-4647: --------------------------------- Component/s: (was: Core Framework) Extensions > ConvertAvroToORC fails if the avro schema uses a union of a null, string, and > long > ---------------------------------------------------------------------------------- > > Key: NIFI-4647 > URL: https://issues.apache.org/jira/browse/NIFI-4647 > Project: Apache NiFi > Issue Type: Bug > Components: Extensions > Reporter: Benjamin Garrett > Assignee: Matt Burgess > Priority: Major > Fix For: 1.7.0 > > > If an avro schema has a field defined like this: > {"name":"myStringOrLong","type":["null","string","long"],"default":null} > then when we run ConvertAvroToORC we get the following error: > Object Type for class org.apache.avro.util.Utf8 not in Union declaration > This is because Avro uses its internal Utf8 class (instead of 'String') as a > performance optimization as discussed elsewhere on the internet, such as > here: > http://apache-avro.679487.n3.nabble.com/why-Utf8-vs-String-td3247788.html > but the NiFiOrcUtils class is not expecting the Utf8 class to be used for > 'string' types. > A simple workaround is to modify NiFiOrcUtils lines 72-73 to be something > like this: > Class clazzToCompareTo = o.getClass(); > if (o instanceof org.apache.avro.util.Utf8 ) { > clazzToCompareTo = String.class; > } > TypeInfo objectTypeInfo = > TypeInfoUtils.getTypeInfoFromObjectInspector( > ObjectInspectorFactory.getReflectionObjectInspector( > clazzToCompareTo, > ObjectInspectorFactory.ObjectInspectorOptions.JAVA)); > This solution works for me. -- This message was sent by Atlassian JIRA (v7.6.3#76005)