[
https://issues.apache.org/jira/browse/NIFI-4647?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16443670#comment-16443670
]
ASF subversion and git services commented on NIFI-4647:
-------------------------------------------------------
Commit 090e748726b319a96ec941f51299d1436f5f5136 in nifi's branch
refs/heads/master from [~ca9mbu]
[ https://git-wip-us.apache.org/repos/asf?p=nifi.git;h=090e748 ]
NIFI-4647: Fix support for strings in unions for ConvertAvroToORC
Signed-off-by: Pierre Villard <[email protected]>
This closes #2644.
> 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)