-
Notifications
You must be signed in to change notification settings - Fork 85
feat(core): add context to RelVisitor, ExpressionVisitor and FuncArgVisitor #427
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
Conversation
0a7d4cb
to
b91d2e7
Compare
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.
Had a chance to take a look, and have some high-level notes.
I'm generally a fan of this, but I do worry that it could introduce a lot of noise for visitations that don't require context.
Your usage in a2f0c8e
(#426) doesn't strictly require a context parameter like you're introducing, as you could achieve a similar result by just pushing the context before calls to accept, and popping it after. However, that is more error prone and having it as parameter makes it easier to understand the dataflow and makes it harder for users to not propagate the context because they're forced to.
I'm going to ping the Slack to get additional eyes for this, because it does end up being an fairly intrusive API change and I'd like to hear what others think.
I also had this concern while working on this. I first had a new set of visitors that I was shipping alongside the existing once. I then decided to just replace the existing once. There are definitely trade-offs for both options. |
make sense. that's why I tagged it as a breaking change since users of substrait-java might be implementing the current visitor and it might be nice to get informed in the release notes that such an intrusive API change has happened. |
b91d2e7
to
0b61b18
Compare
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.
We've had this open for a bit and haven't had any other feedback, so I'm prepared to merge it this week.
My original plan had been to wait for #426 to be ready as well to merge both of them at the same time and minimize API churn, however I think that might open us up to merge conflicts.
Something I think we could do to minimize API churn would be to bring the SubstraitRelNodeConverter.Context
class into this PR, just like
public static class Context {
public static Context newContext() {
return new Context();
}
}
and update the SubstraitRelNodeConverter
to use it:
public class SubstraitRelNodeConverter
extends AbstractRelVisitor<RelNode, SubstraitRelNodeConverter.Context, RuntimeException>
This way, we only break the API once with this merge, and then #426 will add the functionality to the Context.
What do you think @nielspardon? If you make a new commit switching that over, I can review it easily and merge it on Friday.
core/src/test/java/io/substrait/type/proto/GenericRoundtripTest.java
Outdated
Show resolved
Hide resolved
0b61b18
to
a4d1c33
Compare
Updated the PR accordingly. |
8c524de
to
8476462
Compare
I pushed a few more of the API changes from including the |
…isitor BREAKING CHANGE: adds a new context argument to RelVisitor, ExpressionVisitor and FuncArgVisitor Signed-off-by: Niels Pardon <[email protected]>
8476462
to
9fe3b8a
Compare
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.
There's still a couple of usages of null
where we could use the EmptyVisitationContext instead, but that can be handled as a follow-up change.
For the future, if you could avoid squashing and force pushing PR feedback, it would help with reviewing. Specifically, if you make make changes based on PR feedback their own commit, I can just look at the commit during review. We squash merge into main, so they won't show up in the final history anyway.
@@ -176,13 +178,13 @@ private NamedStructGatherer() { | |||
|
|||
public static Map<List<String>, NamedStruct> gatherTables(Rel rel) { | |||
var visitor = new NamedStructGatherer(); | |||
rel.accept(visitor); | |||
rel.accept(visitor, null); |
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.
We should update all the usage of null to use the EmptyVisitationContext.INSTANCE you introduced, but we can do that as a follow-up.
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 created #434 for this
sure |
BREAKING CHANGE: adds a new context argument to RelVisitor, ExpressionVisitor and FuncArgVisitor
Preparation for #426
Adds the new context argument as a
io.substrait.util.EmptyVisitationContext
with valuenull
everywhere.