Skip to content

feat: add plan builders #73

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 5 commits into from
May 1, 2025
Merged

Conversation

tokoko
Copy link
Contributor

@tokoko tokoko commented Apr 16, 2025

  • add plan builders for read, project, filter, etc
  • add simple builders for types

@tokoko tokoko changed the title feat: add plan builders for read, project, filter feat: add plan builders Apr 22, 2025

return resolve

def fetch(plan: stp.Plan,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this takes a plan (not a relation) and wraps it in a Fetch relation and returns a new plan? Is that worth adding a comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this is to allow passing along information about extensions and CTEs. Added a module-level comment.

return resolve

def cross(
left: Union[stp.Plan, UnboundPlan],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this take either a Plan or an UnboundPlan where other relations don't? Is it worth adding a type definition for this Union so that all uses are kept in sync?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all of them should take in Union[stp.Plan, UnboundPlan], I thought I made the changes everywhere, I'll fix it. type definition sounds like a good idea.

def map(key: stt.Type, value: stt.Type, nullable=True):
return stt.Type(map=stt.Type.Map(key=key, value=value, nullability=stt.Type.NULLABILITY_NULLABLE if nullable else stt.Type.NULLABILITY_REQUIRED))

def named_struct(names: Iterable[str], struct: stt.Type):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't return an stt.Type so it probably doesn't belong in this file. If you want to keep it here it needs a comment so that users don't mistakenly think that it is the same as others in this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I could get away with it since NamedStruct is also defined in type_pb2. Do you think a return type annotation should be enough to show it's different?

@EpsilonPrime EpsilonPrime merged commit b12b2ab into substrait-io:main May 1, 2025
17 checks passed
@tokoko tokoko deleted the plan-builders branch May 1, 2025 03:14
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