-
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(migrations): add --define flag to apply command #7401
Conversation
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.
LGTM, with one suggestion.
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.
Thanks @jzaralim ! Only reviewed the last commit -- LGTM besides the comments inline.
for (String pair : definedVars) { | ||
final String[] parts = pair.split("="); | ||
if (parts.length != 2) { | ||
throw new IllegalArgumentException("Variables must be defined using '=' (i.e. var=val)."); |
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.
Not your code but let's take this opportunity to improve the error message (the migrations tool displays this error directly so we should make it more informative). Let's include the bad argument in the error message.
...ols/src/test/java/io/confluent/ksql/tools/migrations/commands/ApplyMigrationCommandTest.java
Show resolved
Hide resolved
ksqldb-common/src/main/java/io/confluent/ksql/parser/VariableParser.java
Show resolved
Hide resolved
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.
LGTM with one minor suggestion inline. Thanks @jzaralim !
createMigrationFile(2, NAME, migrationsDir, "INSERT INTO FOO VALUES ('${name}2');"); | ||
command = PARSER.parse("-a", "-d", "name=tame", "-d", "dame=blame"); | ||
createMigrationFile(1, NAME, migrationsDir, "INSERT INTO FOO VALUES ('${name}'); INSERT INTO FOO VALUES ('${dame}');"); | ||
createMigrationFile(2, NAME, migrationsDir, "DEFINE name='flame'; INSERT INTO FOO VALUES ('${name}');"); |
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.
Let's have a separate unit test for this piece that verifies the order of precedence between DEFINE statements within migrations files and the command options. (The unit test name does not clarify that this is being tested here, so it's unclear to the reader that this piece of the test is important. Unit tests are meant to be small and quick to run so it doesn't hurt to have more of them, as long as each tests a very targeted piece of functionality.)
Description
Allow users to define variables using the
--define
flag when callingapply
. For example,This commit builds on top of #7366, so you can just review the
feat(migrations): add --define flag to apply command
commit.Testing done
Unit test, updated integration test
Reviewer checklist