Skip to content

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

Merged
merged 1 commit into from
Jul 11, 2025

Conversation

nielspardon
Copy link
Member

@nielspardon nielspardon commented Jun 27, 2025

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 value null everywhere.

@nielspardon nielspardon changed the title feat(core): adds context to RelVisitor, ExpressionVisitor and FuncArgVisitor feat(core): add context to RelVisitor, ExpressionVisitor and FuncArgVisitor Jun 27, 2025
@nielspardon nielspardon force-pushed the par-visitor-context branch from 0a7d4cb to b91d2e7 Compare June 27, 2025 19:39
Copy link
Member

@vbarua vbarua left a 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.

@nielspardon
Copy link
Member Author

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.

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.

@nielspardon
Copy link
Member Author

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.

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.

@nielspardon nielspardon force-pushed the par-visitor-context branch from b91d2e7 to 0b61b18 Compare July 1, 2025 16:52
@nielspardon nielspardon requested a review from vbarua July 1, 2025 16:54
Copy link
Member

@vbarua vbarua left a 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.

@nielspardon nielspardon force-pushed the par-visitor-context branch from 0b61b18 to a4d1c33 Compare July 11, 2025 07:25
@nielspardon
Copy link
Member Author

What do you think @nielspardon? If you make a new commit switching that over, I can review it easily and merge it on Friday.

Updated the PR accordingly.

@nielspardon nielspardon force-pushed the par-visitor-context branch 2 times, most recently from 8c524de to 8476462 Compare July 11, 2025 09:08
@nielspardon
Copy link
Member Author

I pushed a few more of the API changes from including the SubstraitRelNodeConverter.Context in this PR, especially for the unit test class accept() calls which means #426 is now super clean.

…isitor

BREAKING CHANGE: adds a new context argument to RelVisitor, ExpressionVisitor and FuncArgVisitor

Signed-off-by: Niels Pardon <[email protected]>
@nielspardon nielspardon force-pushed the par-visitor-context branch from 8476462 to 9fe3b8a Compare July 11, 2025 11:53
Copy link
Member

@vbarua vbarua left a 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);
Copy link
Member

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.

Copy link
Member Author

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

@vbarua vbarua merged commit 0e9c492 into substrait-io:main Jul 11, 2025
12 checks passed
@nielspardon
Copy link
Member Author

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.

sure

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