Skip to content
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

Merged
merged 3 commits into from
Dec 2, 2021
Merged

Conversation

jzaralim
Copy link
Contributor

Description

Makes the following statements fail:

  • INSERT INTO ... SELECT ... if the target source has header columns
  • INSERT VALUES ... if one of the target columns is a header column

Testing done

Manually tested and added unit tests. Integration tests will be in another PR.

Reviewer checklist

  • Ensure docs are updated if necessary. (eg. if a user visible feature is being added or changed).
  • Ensure relevant issues are linked (description should include text like "Fixes #")

@jzaralim jzaralim requested a review from spena November 27, 2021 03:30
@jzaralim jzaralim requested a review from a team as a code owner November 27, 2021 03:30
@@ -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");
Copy link
Member

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()?

Copy link
Contributor Author

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");
Copy link
Member

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.

@jzaralim jzaralim merged commit 0239a95 into master Dec 2, 2021
@jzaralim jzaralim deleted the head-insert branch December 2, 2021 01:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants