-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Enhancement] Support insert match column by name #51181
Conversation
7a3efe3
to
ad739d2
Compare
Signed-off-by: wyb <[email protected]>
ad739d2
to
06ee642
Compare
Quality Gate passedIssues Measures |
[Java-Extensions Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
[FE Incremental Coverage Report]✅ pass : 75 / 85 (88.24%) file detail
|
[BE Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
@@ -320,7 +320,7 @@ public enum ErrorCode { | |||
"No partitions have data available for loading. If you are sure there may be no data to be loaded, " + | |||
"you can use `ADMIN SET FRONTEND CONFIG ('empty_load_as_error' = 'false')` " + | |||
"to ensure such load jobs can succeed"), | |||
ERR_INSERTED_COLUMN_MISMATCH(5604, new byte[] {'2', '2', '0', '0', '0'}, | |||
ERR_INSERT_COLUMN_COUNT_MISMATCH(5604, new byte[] {'2', '2', '0', '0', '0'}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is 42601 more suitable?
@@ -329,6 +329,7 @@ public enum ErrorCode { | |||
ERR_ROUTINE_LOAD_OFFSET_INVALID(5607, new byte[] {'0', '2', '0', '0', '0'}, | |||
"Consume offset: %d is greater than the latest offset: %d in kafka partition: %d. " + | |||
"You can modify 'kafka_offsets' property through ALTER ROUTINE LOAD and RESUME the job"), | |||
ERR_INSERT_COLUMN_NAME_MISMATCH(5608, new byte[] {'2', '2', '0', '0', '0'}, "%s column: %s has no matching %s column"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
42601?
} else { | ||
Preconditions.checkState(insertStmt.isColumnMatchByName()); | ||
if (query instanceof ValuesRelation) { | ||
throw new SemanticException("Insert match column by name does not support values()"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use ErrorReport.reportSemanticException(42601, ...)
mentionedColumns = | ||
((OlapTable) table).getBaseSchemaWithoutGeneratedColumn().stream() | ||
.map(Column::getName).collect(Collectors.toSet()); | ||
mentionedColumns.addAll(((OlapTable) table).getBaseSchemaWithoutGeneratedColumn().stream().map(Column::getName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you tell me the reason to use addAll()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mentionedColumns
is CASE_INSENSITIVE_ORDER
set.
Collectors.toSet()
returns hash set.
Signed-off-by: wyb <[email protected]>
Signed-off-by: wyb <[email protected]> Signed-off-by: zhiminr.ren <[email protected]>
Why I'm doing:
currently, insert only supports matching column by position,
the order that values are inserted into the columns of the table is determined by the order that the columns were declared in values or select column list.
What I'm doing:
support matching by name.
this allows the order of the columns in the table differs from the order of the select columns in select statement.
Fixes #issue
What type of PR is this:
Does this PR entail a change in behavior?
If yes, please specify the type of change:
Checklist:
Bugfix cherry-pick branch check: