mattyb149 commented on a change in pull request #5024:
URL: https://github.com/apache/nifi/pull/5024#discussion_r619497224



##########
File path: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PutDatabaseRecord.java
##########
@@ -691,14 +691,14 @@ private void executeDML(final ProcessContext context, 
final ProcessSession sessi
 
                     final Object[] values = currentRecord.getValues();
                     final List<DataType> dataTypes = 
currentRecord.getSchema().getDataTypes();
-                    List<ColumnDescription> columns = 
tableSchema.getColumnsAsList();
 
                     for (int i = 0; i < fieldIndexes.size(); i++) {
                         final int currentFieldIndex = fieldIndexes.get(i);
                         Object currentValue = values[currentFieldIndex];
                         final DataType dataType = 
dataTypes.get(currentFieldIndex);
                         final int fieldSqlType = 
DataTypeUtils.getSQLTypeValue(dataType);
-                        final ColumnDescription column = 
columns.get(currentFieldIndex);
+                        String columnName = 
normalizeColumnName(currentRecord.getSchema().getField(currentFieldIndex).getFieldName(),
 settings.translateFieldNames);

Review comment:
       I'll put a null check in for `column` before I call `column.dataType` as 
defensive code, but the for-loop iterates over included field indexes, meaning 
exactly those fields that are in the record and that have a corresponding 
column in the table, so I wouldn't expect `column` to ever be null because 
we've already checked it. See lines 912-935 for example, they prevent the field 
index from being added to the list iterated over in the above for-loop unless 
it matches a column in the target table.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to