Skip to content

Commit

Permalink
fix cluster key
Browse files Browse the repository at this point in the history
  • Loading branch information
bobhan1 committed Aug 5, 2024
1 parent 835e645 commit 52f5df3
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,9 @@ public LogicalPlan completeQueryPlan(ConnectContext ctx, LogicalPlan logicalQuer
List<String> cols = Lists.newArrayList();
boolean isMow = targetTable.getEnableUniqueKeyMergeOnWrite();
String tableName = tableAlias != null ? tableAlias : targetTable.getName();
boolean hasClusterKey = targetTable.getBaseSchema().stream().anyMatch(Column::isClusterKey);
// currently cluster key doesn't support partial update, so we can't convert
// a delete stmt to partial update load if the table has cluster key
for (Column column : targetTable.getFullSchema()) {
NamedExpression expr = null;
if (column.getName().equalsIgnoreCase(Column.DELETE_SIGN)) {
Expand All @@ -411,6 +414,8 @@ public LogicalPlan completeQueryPlan(ConnectContext ctx, LogicalPlan logicalQuer
expr = new UnboundSlot(tableName, column.getName());
} else if (!isMow && (!column.isVisible() || (!column.isAllowNull() && !column.hasDefaultValue()))) {
expr = new UnboundSlot(tableName, column.getName());
} else if (hasClusterKey) {
expr = new UnboundSlot(tableName, column.getName());
} else {
continue;
}
Expand All @@ -420,7 +425,7 @@ public LogicalPlan completeQueryPlan(ConnectContext ctx, LogicalPlan logicalQuer

logicalQuery = new LogicalProject<>(selectLists, logicalQuery);

boolean isPartialUpdate = isMow && cols.size() < targetTable.getColumns().size();
boolean isPartialUpdate = isMow && !hasClusterKey && cols.size() < targetTable.getColumns().size();
logicalQuery = handleCte(logicalQuery);
// make UnboundTableSink
return UnboundTableSinkCreator.createUnboundTableSink(nameParts, cols, ImmutableList.of(),
Expand Down

0 comments on commit 52f5df3

Please sign in to comment.