-
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
fix: allow dynamic construction of an ARRAY of STRUCTS with duplicate values #5436 #5506
Conversation
It looks like @nae701 hasn't signed our Contributor License Agreement, yet.
You can read and sign our full Contributor License Agreement here. Once you've signed reply with Appreciation of efforts, clabot |
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.
This is great work @nae701! Opening your first ksqlDB PR in only 2 days is quite impressive. I have some comments inline that we'll need to address, and then we can be ready to merge
ksqldb-execution/src/main/java/io/confluent/ksql/execution/codegen/CodeGenSpec.java
Outdated
Show resolved
Hide resolved
final String structSchemaName = CodeGenUtil.schemaName(structSchemaCount++); | ||
structToSchemaName.put(struct, structSchemaName); | ||
if (!structToSchemaName.containsKey(struct)) { |
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.
I think we should flip the semantics of the if statement here and instead return early if the structToSchemaName
already contains the entry - that way we wont be incrementing structSchemaCount
or adding the unnecessary argument to the argumentBuilder
.
ksqldb-functional-tests/src/test/resources/query-validation-tests/create-struct.json
Show resolved
Hide resolved
ksqldb-execution/src/main/java/io/confluent/ksql/execution/codegen/CodeGenSpec.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! Feel free to merge when the Jenkins build is green. Congrats on your first ksql commit 🎉
Description
What behavior do you want to change, why, how does your patch achieve the changes?
Error was occuring when user wants to create an array of structs with duplicate values. This patch fixes this by using a mutable hash map and then making an immutable hash map copy from that, since the immutable hash map builder did not check for duplicates but will fail once we try to build it.
Testing done
Describe the testing strategy. Unit and integration tests are expected for any behavior changes.
A new unit test was created in the create-struct.json that checks for this specific test case of duplicate values.
Reviewer checklist