[Fix](merge-on-write) throw exception when the user don't specify the insert columns in insert statement for partial update (#25437)
This commit is contained in:
@ -507,6 +507,11 @@ public class NativeInsertStmt extends InsertStmt {
|
||||
Set<String> mentionedColumns = Sets.newTreeSet(String.CASE_INSENSITIVE_ORDER);
|
||||
List<String> realTargetColumnNames;
|
||||
if (targetColumnNames == null) {
|
||||
if (!isFromDeleteOrUpdateStmt
|
||||
&& analyzer.getContext().getSessionVariable().isEnableUniqueKeyPartialUpdate()) {
|
||||
throw new AnalysisException("You must explicitly specify the columns to be updated when "
|
||||
+ "updating partial columns using the INSERT statement.");
|
||||
}
|
||||
// the mentioned columns are columns which are visible to user, so here we use
|
||||
// getBaseSchema(), not getFullSchema()
|
||||
for (Column col : targetTable.getBaseSchema(false)) {
|
||||
|
||||
@ -81,6 +81,12 @@ public class BindSink implements AnalysisRuleFactory {
|
||||
boolean isNeedSequenceCol = child.getOutput().stream()
|
||||
.anyMatch(slot -> slot.getName().equals(Column.SEQUENCE_COL));
|
||||
|
||||
if (sink.getColNames().isEmpty() && sink.isFromNativeInsertStmt()
|
||||
&& sink.isPartialUpdate()) {
|
||||
throw new AnalysisException("You must explicitly specify the columns to be updated when "
|
||||
+ "updating partial columns using the INSERT statement.");
|
||||
}
|
||||
|
||||
LogicalOlapTableSink<?> boundSink = new LogicalOlapTableSink<>(
|
||||
database,
|
||||
table,
|
||||
|
||||
Reference in New Issue
Block a user