[ 
https://issues.apache.org/jira/browse/NIFI-9956?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17528206#comment-17528206
 ] 

Lehel Boér edited comment on NIFI-9956 at 4/26/22 2:27 PM:
-----------------------------------------------------------

[https://github.com/apache/nifi/pull/5998]

Quick fix is available


was (Author: lehel44):
https://github.com/apache/nifi/pull/5998

> 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
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> 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)

Reply via email to