Skip to content
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

feat(parse): add text::simple_extensions::ArgumentsItem parser #185

Merged
merged 14 commits into from
May 28, 2024

Conversation

shanretoo
Copy link
Contributor

Adds a parser for text::simple_extensions::ArgumentsItem that parses the argument.

@CLAassistant
Copy link

CLAassistant commented May 16, 2024

CLA assistant check
All committers have signed the CLA.

@shanretoo shanretoo marked this pull request as draft May 16, 2024 14:40
@shanretoo shanretoo marked this pull request as ready for review May 16, 2024 14:47
Copy link
Member

@mbrobbel mbrobbel left a comment

Choose a reason for hiding this comment

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

Thanks for this contribution! This looks great.

It would be really great if we can run tests against the extensions in the substrait submodule.

src/parse/text/simple_extensions/argument.rs Outdated Show resolved Hide resolved
src/parse/text/simple_extensions/argument.rs Outdated Show resolved Hide resolved
src/parse/text/simple_extensions/argument.rs Outdated Show resolved Hide resolved
src/parse/text/simple_extensions/argument.rs Outdated Show resolved Hide resolved
src/parse/text/simple_extensions/argument.rs Outdated Show resolved Hide resolved
src/parse/text/simple_extensions/argument.rs Outdated Show resolved Hide resolved
src/parse/text/simple_extensions/argument.rs Outdated Show resolved Hide resolved
src/parse/text/simple_extensions/argument.rs Outdated Show resolved Hide resolved
@mbrobbel mbrobbel mentioned this pull request May 16, 2024
32 tasks
@shanretoo
Copy link
Contributor Author

How about adding tests against the extensions in the substrait submodule in the future prs, i.e. after including extensions in this repo like the work you have done in the closed pr: https://github.com/mbrobbel/substrait-rs/blob/aebd6cc53152cda3602decfbd096329e6f4e5850/build.rs#L188-L197
@mbrobbel

@mbrobbel
Copy link
Member

How about adding tests against the extensions in the substrait submodule in the future prs, i.e. after including extensions in this repo like the work you have done in the closed pr: https://github.com/mbrobbel/substrait-rs/blob/aebd6cc53152cda3602decfbd096329e6f4e5850/build.rs#L188-L197 @mbrobbel

Sounds good: #186

mbrobbel added a commit to substrait-io/substrait that referenced this pull request May 23, 2024
This came up in a [discussion on a substrait-rs
PR](substrait-io/substrait-rs#185 (comment)):
it doesn't make sense for the options field of enum args to be empty.
This PR modifies the schema to state that the `options` array of enum
args should be non-empty.
@shanretoo
Copy link
Contributor Author

@mbrobbel

I have implemented Parse for those enums and fixed corresponding tests.

But when I try to add checks to ensure the parsing work for core extensions, I encountered a problem:

  1. The parse method of Parse trait is using the value receiver of self.
fn parse(self, ctx: &mut C) -> Result<Self::Parsed, Self::Error>;
  1. But the ArgumentsItems extracted from EXTENSIONS are references and ArgumentsItem does not implement Copy trait. It is not possible to call parse for them.
error[E0507]: cannot move out of `*item` which is behind a shared reference
   --> src/parse/text/simple_extensions/argument.rs:632:21
    |
632 |                     item.parse(&mut Context::default())?;
    |                     ^^^^ move occurs because `*item` has type `text::simple_extensions::ArgumentsItem`, which does not implement the `Copy` trait

I'm wondering that if we can modify parse method to use the reference receiver.
What's your opinion here?

@mbrobbel
Copy link
Member

mbrobbel commented May 23, 2024

But the ArgumentsItems extracted from EXTENSIONS are references and ArgumentsItem does not implement Copy trait. It is not possible to call parse for them.

You can clone the SimpleExtensions before parsing them.

I'm wondering that if we can modify parse method to use the reference receiver. What's your opinion here?

We could do this, but it moves cloning (where needed) into the parser impls - unless we also change all parsed items to reference data in the original items. I think the common case would be for users to have owned instances they want to parse, and when they don't, like in your example when you only have a reference, users can explicitly clone. What do you think?

@shanretoo
Copy link
Contributor Author

Thank you for your detailed explanation. It makes sense to me. This pr is ready for review.

Copy link
Member

@mbrobbel mbrobbel left a comment

Choose a reason for hiding this comment

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

Thanks!
I have some final questions/suggestions - but we can also move some of these to follow-up PRs if you want.

src/parse/text/simple_extensions/mod.rs Outdated Show resolved Hide resolved
src/parse/text/simple_extensions/argument.rs Outdated Show resolved Hide resolved
src/parse/text/simple_extensions/argument.rs Show resolved Hide resolved
src/parse/text/simple_extensions/argument.rs Show resolved Hide resolved
src/parse/text/simple_extensions/argument.rs Outdated Show resolved Hide resolved
src/parse/text/simple_extensions/argument.rs Outdated Show resolved Hide resolved
src/parse/text/simple_extensions/argument.rs Show resolved Hide resolved
src/parse/text/simple_extensions/argument.rs Show resolved Hide resolved
src/parse/text/simple_extensions/argument.rs Show resolved Hide resolved
Copy link
Member

@mbrobbel mbrobbel left a comment

Choose a reason for hiding this comment

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

Noticed one typo, but other than that this looks good, thanks again!

src/parse/text/simple_extensions/argument.rs Outdated Show resolved Hide resolved
src/parse/text/simple_extensions/argument.rs Outdated Show resolved Hide resolved
src/parse/text/simple_extensions/argument.rs Outdated Show resolved Hide resolved
Co-authored-by: Matthijs Brobbel <[email protected]>
@shanretoo
Copy link
Contributor Author

Really appreciate your review!

@mbrobbel mbrobbel merged commit 3409b79 into substrait-io:main May 28, 2024
12 checks passed
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.

3 participants