Skip to content

Replace Method and CompositeAccess with CompoundFieldAccess #1716

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
Feb 19, 2025

Conversation

iffyio
Copy link
Contributor

@iffyio iffyio commented Feb 8, 2025

Continuation of #1551

This moves over two of the special case compound expressions delimited by period to use the new CompoundFieldAccess representation.

It moves the logic to parse the various kinds of compound expression into the same function parse_compound_expr, where previously they were somewhat spread between individual expression parsing and the compound field access parsing.

@iffyio
Copy link
Contributor Author

iffyio commented Feb 8, 2025

FYI @goldmedal

Copy link
Contributor

@goldmedal goldmedal left a comment

Choose a reason for hiding this comment

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

Thanks @iffyio 👍. It looks good to me. I think it's a nice improvement to remove the duplicate definition.

@iffyio iffyio requested a review from alamb February 17, 2025 06:36
let expr = dialects.verified_expr(
"CONVERT(XML, '<Book>abc</Book>').value('.', 'NVARCHAR(MAX)').value('.', 'NVARCHAR(MAX)')",
);
match expr {
Expr::Method(Method { expr, method_chain }) => {
assert!(matches!(*expr, Expr::Convert { .. }));
Expr::CompoundFieldAccess { root, access_chain } => {
Copy link
Contributor

Choose a reason for hiding this comment

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

it is nice to have a unified AST representation here

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.

Thanks @iffyio

I read through this PR -- and reviewed the test changes carefully. While I don't claim to understand all of the code, it looks quite a bit nicer and cleaner to me. 🚀

Thank you very much. Nice work

Also thank you @goldmedal for the review

@iffyio
Copy link
Contributor Author

iffyio commented Feb 19, 2025

Thanks for the reviews @alamb @goldmedal 🙏

@alamb
Copy link
Contributor

alamb commented Feb 19, 2025

Looks like this needs a merge up from main to resolve some conflicts

@iffyio
Copy link
Contributor Author

iffyio commented Feb 19, 2025

Yeah I'll resolve the conflicts!

@iffyio iffyio merged commit 3e90a18 into apache:main Feb 19, 2025
9 checks passed
@iffyio iffyio deleted the compound-expr branch February 19, 2025 17:49
ayman-sigma pushed a commit to sigmacomputing/sqlparser-rs that referenced this pull request Apr 10, 2025
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