You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/10/13 09:27:57 UTC

[GitHub] [flink] leonardBang commented on a change in pull request #13594: [FLINK-19423][jdbc] Fix ArrayIndexOutOfBoundsException when executing DELETE statement in JDBC upsert sink

leonardBang commented on a change in pull request #13594:
URL: https://github.com/apache/flink/pull/13594#discussion_r503803038



##########
File path: flink-connectors/flink-connector-jdbc/src/main/java/org/apache/flink/connector/jdbc/table/JdbcDynamicOutputFormatBuilder.java
##########
@@ -182,7 +168,12 @@ public JdbcDynamicOutputFormatBuilder setFieldDataTypes(DataType[] fieldDataType
 		checkArgument(dmlOptions.getKeyFields().isPresent());
 		String[] pkNames = Arrays.stream(pkFields).mapToObj(k -> dmlOptions.getFieldNames()[k]).toArray(String[]::new);
 		String deleteSql = dmlOptions.getDialect().getDeleteStatement(dmlOptions.getTableName(), pkNames);
-		return createKeyedRowExecutor(dmlOptions.getDialect(), pkFields, pkTypes, deleteSql, fieldTypes);
+		JdbcRowConverter rowConverter = dmlOptions.getDialect().getRowConverter(RowType.of(pkTypes));
+		Function<RowData, RowData> keyExtractor = createRowKeyExtractor(fieldTypes, pkFields);
+		return JdbcBatchStatementExecutor.keyed(
+			deleteSql,
+			keyExtractor,
+			(st, key) -> rowConverter.toExternal(key, st));

Review comment:
       nice catch




----------------------------------------------------------------
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:
users@infra.apache.org