Skip to content

Store spans for Value expressions #1738

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 18 commits into from
Feb 25, 2025
Merged

Store spans for Value expressions #1738

merged 18 commits into from
Feb 25, 2025

Conversation

lovasoa
Copy link
Contributor

@lovasoa lovasoa commented Feb 21, 2025

@iffyio @alamb : I allowed edit by maintainers on this PR; help would be very welcome.

I implemented all the required changes in the library itself, but there are still massive (mostly repetitive and probably automatable) changes to make in the tests.

I would love if I could get some help on this, this should greatly decrease missing spans in parsed trees.

@lovasoa
Copy link
Contributor Author

lovasoa commented Feb 21, 2025

feel free to edit the code directly without asking me first :)

@alamb
Copy link
Contributor

alamb commented Feb 23, 2025

FYI @eliaperantoni -- any chance you are willing to help our with this one?

Copy link

@eliaperantoni eliaperantoni left a comment

Choose a reason for hiding this comment

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

Looks awesome! This is a much needed feature, thank you for the contribution :) The library changes look good to me, I will help with the tests as soon as I can

@lovasoa
Copy link
Contributor Author

lovasoa commented Feb 24, 2025

I did the bigquery tests. The others are remaining

image

If someone wants to volunteer help...

@alamb
Copy link
Contributor

alamb commented Feb 24, 2025

If someone wants to volunteer help...

I will post a note in DataFUsion slack and see if I can find anyone to help

In terms of logitistics, I suggest people:

  1. Check out your branch
  2. Fix one or two of the tests
  3. Make a PR targeting your branch.

I will do an example of this for one or two in a moment

@alamb
Copy link
Contributor

alamb commented Feb 24, 2025

@lovasoa here is a proposed contribution:

If you like that, I think we can apply the same thing to the other tests fairly easily

@lovasoa
Copy link
Contributor Author

lovasoa commented Feb 24, 2025

Ok, ast-grep is a bit of a pita to use with rust, but I managed to get it to do most of the work with the following rule:

id: x
language: rust
rule:
  any:
    - kind: token_tree
      pattern: $ARG
      follows:
        kind: identifier
        pattern: Value
        follows:
          kind: identifier
          pattern: Expr
          stopBy: end
fix: ($ARG.with_empty_span())

the tests pass now !

@alamb
Copy link
Contributor

alamb commented Feb 24, 2025

Looking quite nice!

Any chance you can pull the doc strings from lovasoa@4d101b0 as well?

@lovasoa lovasoa marked this pull request as ready for review February 24, 2025 16:13
@lovasoa
Copy link
Contributor Author

lovasoa commented Feb 24, 2025

Any chance you can pull the doc strings from lovasoa@4d101b0 as well?

I did. I think this is ready for merging

@alamb
Copy link
Contributor

alamb commented Feb 24, 2025

It appears there are a few failed tests:

Screenshot 2025-02-24 at 11 34 25 AM

@lovasoa
Copy link
Contributor Author

lovasoa commented Feb 24, 2025

It appears there are a few failed tests

😬 I had forgotten to run cargo test --all-features. It's fixed now.

@lovasoa lovasoa changed the title [WIP] Store spans for Value expressions Store spans for Value expressions Feb 24, 2025
@lovasoa
Copy link
Contributor Author

lovasoa commented Feb 24, 2025

It would be nice if we could get this merged before other pending PRs, because it touches almost all the tests, and is guaranteed to generate big conflicts as we change them.

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@iffyio what do you think?

value: Box::new(Expr::Value(Value::SingleQuotedString(String::from(
"123:45.67",
)))),
value: Box::new(Expr::Value(
Copy link
Contributor

Choose a reason for hiding this comment

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

minor stuff we could use the Expr::value here too

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! But I don't have the strength to fight ast-grep again 🙂‍↔️

Copy link
Contributor

Choose a reason for hiding this comment

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

I saw it in my editor and couldn't exist:

Copy link
Contributor

@iffyio iffyio left a comment

Choose a reason for hiding this comment

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

Thanks @lovasoa!

Noticed some added comments in the bigquery tests I didn't follow and looked like they might need cleanup instead? Otherwise LGTM to merge in the meantime!

Comment on lines +32 to +44
"SELECT ", // line 1, column 1
"'single', ", // line 1, column 7
r#""double", "#, // line 1, column 14
"'''triple-single''', ", // line 1, column 22
r#""""triple-double""", "#, // line 1, column 33
r#"'single\'escaped', "#, // line 1, column 43
r#"'''triple-single\'escaped''', "#, // line 1, column 55
r#"'''triple-single'unescaped''', "#, // line 1, column 68
r#""double\"escaped", "#, // line 1, column 83
r#""""triple-double\"escaped""", "#, // line 1, column 92
r#""""triple-double"unescaped""", "#, // line 1, column 105
r#""""triple-double'unescaped""", "#, // line 1, column 118
r#"'''triple-single"unescaped'''"#, // line 1, column 131
Copy link
Contributor

Choose a reason for hiding this comment

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

do the added comments here need cleanup or do they serve a purpose?

@iffyio iffyio merged commit c335c88 into apache:main Feb 25, 2025
9 checks passed
@alamb
Copy link
Contributor

alamb commented Feb 25, 2025

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants