[
https://issues.apache.org/jira/browse/NIFI-9956?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Lehel Boér resolved NIFI-9956.
------------------------------
Resolution: Resolved
> 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)