[
https://issues.apache.org/jira/browse/NIFI-9956?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17527399#comment-17527399
]
Lehel Boér commented on NIFI-9956:
----------------------------------
[https://github.com/apache/nifi/pull/5937] changes in JsonTreeReader requires
to define the subschema that fits for the nested JsonNodes in case of Nested
Node Strategy. We are currently providing a schema that fits for the whole Json
(Root Node Strategy). One idea is to make it selectable within the Nested Node
Strategy whether the specified schema is specified for nested node or root node.
> QuerySalesforceObject schema parsing does not work
> --------------------------------------------------
>
> Key: NIFI-9956
> URL: https://issues.apache.org/jira/browse/NIFI-9956
> Project: Apache NiFi
> Issue Type: Bug
> Reporter: Lehel Boér
> Assignee: Lehel Boér
> Priority: Major
>
> In QuerySalesforceObject, the converted NiFi RecordSchema is wrapped in a
> "records" schema field.
>
> {code:java}
> RecordSchema querySObjectResultSchema = new
> SimpleRecordSchema(Collections.singletonList(
> new RecordField("records", RecordFieldType.ARRAY.getArrayDataType(
> RecordFieldType.RECORD.getRecordDataType(
> recordSchema
> )
> ))
> )); {code}
> In JsonTreeReader the fieldNames are extracted from the Json node, not from
> the schema.
> {code:java}
> final Iterator<String> fieldNames = jsonNode.fieldNames();{code}
> When trying to get the recordField by the fieldName, the result is always
> null, because the schema is wrapped in an outer "record" array type and it
> does not have the field name. The value type will be inferred in
> _getRawNodeValue._
> {code:java}
> while (fieldNames.hasNext()) {
> final String fieldName = fieldNames.next();
> final JsonNode childNode = jsonNode.get(fieldName);
> final RecordField recordField = schema.getField(fieldName).orElse(null);
> final Object value;
> if (coerceTypes && recordField != null) {
> final DataType desiredType = recordField.getDataType();
> final String fullFieldName = fieldNamePrefix == null ? fieldName :
> fieldNamePrefix + fieldName;
> value = convertField(childNode, fullFieldName, desiredType,
> dropUnknown);
> } else {
> value = getRawNodeValue(childNode, recordField == null ? null :
> recordField.getDataType(), fieldName);
> }
> values.put(fieldName, value);
> } {code}
> I think the wrapper "record" array type can be removed from the
> SObjectResultSchema.
--
This message was sent by Atlassian Jira
(v8.20.7#820007)