[
https://issues.apache.org/jira/browse/NIFI-16478?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18129278#comment-18129278
]
ASF subversion and git services commented on NIFI-16478:
--------------------------------------------------------
Commit 1704417199295801b2c7aa6c016e3dfa9bbe76a2 in nifi's branch
refs/heads/main from Mark Payne
[ https://gitbox.apache.org/repos/asf?p=nifi.git;h=17044171992 ]
NIFI-16478 Preserved nested arrays when choosing a CHOICE sub-type (#11824)
When several CHOICE sub-types are compatible with a value and none is a clear
match, DataTypeUtils.chooseDataType now prefers a sub-type that does not
convert nested arrays, collections, or maps into Strings, rather than always
selecting the first compatible sub-type.
Co-authored-by: Cursor <[email protected]>
> Nested arrays are written as Java object strings when a CHOICE includes an
> array of strings
> -------------------------------------------------------------------------------------------
>
> Key: NIFI-16478
> URL: https://issues.apache.org/jira/browse/NIFI-16478
> Project: Apache NiFi
> Issue Type: Bug
> Components: Extensions
> Reporter: Mark Payne
> Assignee: Mark Payne
> Priority: Major
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> When a field's schema is a CHOICE between an array of strings and a nested
> array of records, nested array values can be written as Java object strings
> instead of keeping their structure. For example, this value:
> {noformat}
> [[[]], [[{"key": "a", "value": "b"}]]]
> {noformat}
> is written as:
> {noformat}
> ["[[Ljava.lang.Object;@4613311f]", "[[Ljava.lang.Object;@6540cf1d]"]
> {noformat}
> This happens, for example, when ConsumeKafka uses "Continue with Merged
> Schema" and one message has an empty array for a field (inferred as an array
> of strings) while another message has nested arrays of records for the same
> field.
> {{DataTypeUtils.chooseDataType}} considers both choices compatible because
> any {{Object}} array is accepted as a String. Re-inferring the value's type
> does not match either choice, so it falls back to the first compatible
> choice. When that choice is the array of strings, each inner array is
> converted with {{Arrays.toString}}.
> When no choice is a clear match, {{chooseDataType}} should prefer a choice
> that does not convert nested arrays, collections, or maps into Strings.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)