You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "He Jiang (Jira)" <ji...@apache.org> on 2022/09/26 14:14:00 UTC
[jira] [Comment Edited] (NIFI-10198) PutDatabaseRecord only checks required colums for 'Fail on Unmatched Columns'
[ https://issues.apache.org/jira/browse/NIFI-10198?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17609518#comment-17609518 ]
He Jiang edited comment on NIFI-10198 at 9/26/22 2:13 PM:
----------------------------------------------------------
@sbylemans Another tricky case that I often used is adding a datetime column in mysql table with the default value of CURRENT_TIMESTAMP to track the creation time of a record.
Generally speaking, any column with default value of a table could be skipped safely for putting record in.
So I just recommend to revise the description to "If an incoming record does not have a field mapping for *all required columns* of the database table, this property specifies how to handle the situation."
Any more thoughts?
was (Author: hejiang):
@sbylemans Another tricky case that I often used is adding a datetime column in mysql table with the default value of CURRENT_TIMESTAMP to track the creation time of a record.
Generally speaking, any column with default value of a table could be skipped safely for putting record in.
So I just recommend to revise the description to "If an incoming record does not have a field mapping for *all required columns* of the database table, this property specifies how to handle the situation."
Any more thoughtw?
> PutDatabaseRecord only checks required colums for 'Fail on Unmatched Columns'
> -----------------------------------------------------------------------------
>
> Key: NIFI-10198
> URL: https://issues.apache.org/jira/browse/NIFI-10198
> Project: Apache NiFi
> Issue Type: Bug
> Components: Core Framework
> Affects Versions: 1.15.3
> Reporter: Sander Bylemans
> Priority: Critical
> Labels: patch
>
> The PutDatabaseRecord processor has a method called {{checkValuesForRequiredColumns}}:
> {code:java}
> private void checkValuesForRequiredColumns(RecordSchema recordSchema, TableSchema tableSchema, DMLSettings settings) {
> final Set<String> normalizedFieldNames = getNormalizedColumnNames(recordSchema, settings.translateFieldNames);
> for (final String requiredColName : tableSchema.getRequiredColumnNames()) {
> final String normalizedColName = normalizeColumnName(requiredColName, settings.translateFieldNames);
> if (!normalizedFieldNames.contains(normalizedColName)) {
> String missingColMessage = "Record does not have a value for the Required column '" + requiredColName + "'";
> if (settings.failUnmappedColumns) {
> getLogger().error(missingColMessage);
> throw new IllegalArgumentException(missingColMessage);
> } else if (settings.warningUnmappedColumns) {
> getLogger().warn(missingColMessage);
> }
> }
> }
> }
> {code}
> Which checks columns that are defined with a {{NOT NULL}} constraint. For the {{Unmatched Column Behavior}} with a value {{Fail on Unmatched Columns}}, this is not expected behavior as the description reads: "If an incoming record does not have a field mapping for *all* of the database table's columns, this property specifies how to handle the situation".
> Therefore the method should be adjusted so it checks all columns, not just the "required" ones.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)