-
Notifications
You must be signed in to change notification settings - Fork 1k
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
feat: block inserting into sources with headers #8417
Conversation
@@ -144,6 +146,10 @@ public void execute( | |||
|
|||
final DataSource dataSource = getDataSource(config, metaStore, insertValues); | |||
|
|||
if (!verifyInsertValuesAllowed(insertValues.getColumns(), dataSource)) { | |||
throw new KsqlException("Cannot insert into a HEADER 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.
It'd be good to display the column header name. Perhaps throwing the exception from inside the method would be helpful so you can customize the message. What about renaming the method too validateInsert()
or throwIfInsertOnHeadersColumns()
?
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.
Updated the messages
@@ -280,5 +280,9 @@ private void throwIfInsertOnReadOnlyTopic( | |||
throw new KsqlException("Cannot insert into read-only topic: " | |||
+ dataSource.getKafkaTopicName()); | |||
} | |||
|
|||
if (!dataSource.getSchema().headers().isEmpty()) { | |||
throw new KsqlException("Cannot insert into a source with header columns"); |
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.
Instead of source
, use the name of the source. The dataSource.getDataSourceType()
returns the type.
Description
Makes the following statements fail:
INSERT INTO ... SELECT ...
if the target source has header columnsINSERT VALUES ...
if one of the target columns is a header columnTesting done
Manually tested and added unit tests. Integration tests will be in another PR.
Reviewer checklist