beryllw commented on code in PR #2573:
URL: https://github.com/apache/fluss/pull/2573#discussion_r2766773911
##########
fluss-client/src/main/java/org/apache/fluss/client/lookup/TableLookup.java:
##########
@@ -49,23 +51,71 @@ private TableLookup(
MetadataUpdater metadataUpdater,
LookupClient lookupClient,
@Nullable List<String> lookupColumnNames) {
+ this(tableInfo, schemaGetter, metadataUpdater, lookupClient,
lookupColumnNames, false);
+ }
+
+ private TableLookup(
+ TableInfo tableInfo,
+ SchemaGetter schemaGetter,
+ MetadataUpdater metadataUpdater,
+ LookupClient lookupClient,
+ boolean insertIfNotExists) {
+ this(tableInfo, schemaGetter, metadataUpdater, lookupClient, null,
insertIfNotExists);
+ }
+
+ private TableLookup(
+ TableInfo tableInfo,
+ SchemaGetter schemaGetter,
+ MetadataUpdater metadataUpdater,
+ LookupClient lookupClient,
+ @Nullable List<String> lookupColumnNames,
+ boolean insertIfNotExists) {
this.tableInfo = tableInfo;
this.schemaGetter = schemaGetter;
this.metadataUpdater = metadataUpdater;
this.lookupClient = lookupClient;
this.lookupColumnNames = lookupColumnNames;
+ this.insertIfNotExists = insertIfNotExists;
+ }
+
+ @Override
+ public Lookup enableInsertIfNotExists() {
+ if (lookupColumnNames != null) {
+ throw new IllegalArgumentException(
+ "insertIfNotExists can not be used with prefix lookup");
+ }
+
+ if (tableInfo.getSchema().getColumns().stream()
+ .filter(column -> column.getDataType().isNullable())
+ .filter(column ->
!tableInfo.getPrimaryKeys().contains(column.getName()))
+ .anyMatch(
+ column ->
+ !tableInfo
+ .getSchema()
+ .getAutoIncrementColumnNames()
+ .contains(column.getName()))) {
+ throw new IllegalArgumentException(
+ "insertIfNotExists cannot be enabled for tables with
nullable columns besides primary key and auto increment columns.");
Review Comment:
InsertIfNotExists requires all non-primary-key columns (except
auto-increment) to be NULL.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]