-
Notifications
You must be signed in to change notification settings - Fork 92
feat: support Nested Structs #579
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
base: main
Are you sure you want to change the base?
feat: support Nested Structs #579
Conversation
fac05f2 to
0957216
Compare
690c298 to
2f14645
Compare
|
@gord02 you will need to make sure that the subject line and text of all commits in your pull request conform to the structure dictated by conventional commits. You can look at the output of the Lint commits for semantic-release build check to see problems flagged, and also the CONTRIBUTING guide for tips. When you have lots of commits that need fixing, it can sometimes be easier to squash them into fewer commits to reduce the number of changes you need to make. |
ef39861 to
17119c8
Compare
|
Does this PR replace #417 which seems to have tried to do a similar change? |
|
Hi @nielspardon! This PR completes and builds off of that PR yes. So it can be deleted. |
…ut literals for substrait proto
17119c8 to
d799bdf
Compare
benbellick
left a comment
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 have left a few comments on here so far. I think some of them might cause some reshuffling around so I'll save some of the more in-depth suggestions for the future. One other thing, it would be great if you could introduce some test which specifically demonstrates the logic you introduced where deserialized protos can handle either the presence of fields or values, but not both. I can imagine a test in which you constuct two protos, one via values and one via fields, and just demonstrate that once you render them both as POJOs, they are equal. That's just one idea though.
Anyways, thanks for all of your work! Let me know if anything I wrote isn't clear :)
core/src/main/java/io/substrait/expression/ExpressionCreator.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/substrait/expression/ExpressionCreator.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/substrait/expression/ExpressionCreator.java
Outdated
Show resolved
Hide resolved
6d13b3f to
ea02912
Compare
benbellick
left a comment
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 for your patience, both in waiting for my review and for dealing with my comments! I appreciate the work. I didn't get a chance to review all of the PR, but wanted to flush the comments I had so far before running off to a meeting. 🙇
core/src/main/java/io/substrait/expression/ExpressionCreator.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/substrait/expression/ExpressionCreator.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/substrait/expression/proto/ExpressionProtoConverter.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/substrait/relation/ExpressionCopyOnWriteVisitor.java
Outdated
Show resolved
Hide resolved
core/src/test/java/io/substrait/relation/VirtualTableScanTest.java
Outdated
Show resolved
Hide resolved
core/src/test/java/io/substrait/relation/VirtualTableScanTest.java
Outdated
Show resolved
Hide resolved
core/src/test/java/io/substrait/relation/VirtualTableScanTest.java
Outdated
Show resolved
Hide resolved
isthmus/src/main/java/io/substrait/isthmus/SubstraitRelNodeConverter.java
Show resolved
Hide resolved
b4eab3f to
607877b
Compare
607877b to
3406d3c
Compare
benbellick
left a comment
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.
Okay got the chance to do another pass. I think I'm just going to review the core section for now until I think its in a good place, and then I'll continue onwards with the review in isthmus / spark if that works for you! Thanks again for your work 🚀
core/src/main/java/io/substrait/expression/proto/ProtoExpressionConverter.java
Show resolved
Hide resolved
core/src/main/java/io/substrait/expression/proto/ProtoExpressionConverter.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/substrait/expression/proto/ExpressionProtoConverter.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/substrait/relation/ExpressionCopyOnWriteVisitor.java
Outdated
Show resolved
Hide resolved
core/src/test/java/io/substrait/relation/VirtualTableScanTest.java
Outdated
Show resolved
Hide resolved
core/src/test/java/io/substrait/relation/VirtualTableScanTest.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/substrait/expression/proto/ProtoExpressionConverter.java
Outdated
Show resolved
Hide resolved
benbellick
left a comment
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.
very minor changes to suggest within core, but after those, everything there looks good! I will come back and review the isthmus stuff in a bit. As mentioned before, I am not as familiar there so it could be a good idea to rope in @vbarua or someone.
Nice work!
core/src/main/java/io/substrait/expression/ExpressionCreator.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/substrait/relation/ProtoRelConverter.java
Outdated
Show resolved
Hide resolved
core/src/test/java/io/substrait/relation/VirtualTableScanTest.java
Outdated
Show resolved
Hide resolved
core/src/test/java/io/substrait/type/proto/ReadRelRoundtripTest.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/substrait/expression/ExpressionCreator.java
Outdated
Show resolved
Hide resolved
core/src/test/java/io/substrait/type/proto/ReadRelRoundtripTest.java
Outdated
Show resolved
Hide resolved
core/src/test/java/io/substrait/type/proto/ReadRelRoundtripTest.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/substrait/expression/ExpressionCreator.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/substrait/expression/ExpressionCreator.java
Outdated
Show resolved
Hide resolved
vbarua
left a comment
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.
Left some comments. The biggest thing I noticed is the logic for converting to Substrait to Calcite doesn't quite work. Your LogicalValuesTest doesn't check for right invariant to detect it.
core/src/main/java/io/substrait/expression/ExpressionCreator.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/substrait/relation/ProtoRelConverter.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/substrait/expression/ExpressionCreator.java
Outdated
Show resolved
Hide resolved
isthmus/src/test/java/io/substrait/isthmus/LogicalValuesTest.java
Outdated
Show resolved
Hide resolved
isthmus/src/test/java/io/substrait/isthmus/LogicalValuesTest.java
Outdated
Show resolved
Hide resolved
isthmus/src/test/java/io/substrait/isthmus/LogicalValuesTest.java
Outdated
Show resolved
Hide resolved
| Assert.equals(1, logicalValues.tuples.size()); // one row | ||
| Assert.equals(2, logicalValues.tuples.get(0).size()); // 2 literal expressions | ||
| LogicalProject logicalProject = (LogicalProject) relNode; | ||
| Assert.equals(1, logicalProject.getProjects().size()); // one non-literal expression |
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.
If you inspect the rowType of the LogicalProject you've created, you'll notice that it only outputs a single column. We should have two columns, because the VirtualTable we're converting has two columns. The issues is that Calcite, unlike Substrait, only outputs the values of project expressions.
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.
The way I wrote the code was just to use the logicalProject to store expressions that could not fit in the logicalValues table, which are all non-literal expressions. Should this be changed such that all the expressions are reflected in the logicalProject?
|
|
||
| return LogicalValues.create( | ||
| relBuilder.getCluster(), rowTypeWithNames, ImmutableList.copyOf(tuples)); | ||
| return relBuilder.push(logicalValues).project(projectExpressions).build(); |
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 doesn't actually output the correct number of columns when you use it. I left a comment in LogicalValueTest about it.
be3f127 to
a03532c
Compare
This PR is to change the substrait-java virtualTableScan to use nested structs in place of the now deprecated struct literals.
The issue
Key changes:
Testing:
Testing:
./gradlew test --tests io.substrait.isthmus.LogicalValuesTest --debug-jvm