-
Notifications
You must be signed in to change notification settings - Fork 684
GenericDialect: support colon operator for JsonAccess #2124
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
base: main
Are you sure you want to change the base?
Conversation
Samyak2
commented
Dec 4, 2025
- Port JsonAccess colon operator from Snowflake to Generic dialect
- This will be used in variant data type support in Datafusion
- see discussion in epic: Initial implementation of this crate datafusion-contrib/datafusion-variant#2
2a3a6c0 to
5b6007b
Compare
alamb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
I will fix the CI in a bit - sorry did not notice that! |
- Port JsonAccess colon operator from Snowflake to Generic dialect - This will be used in variant data type support in Datafusion - see discussion in datafusion-contrib/datafusion-variant#2
5b6007b to
4ae25fd
Compare
|
CI should pass now. There were some changes in main that I had not rebased on. |
| assert!(matches!(select2.projection[0], SelectItem::Wildcard(_))); | ||
| } | ||
|
|
||
| // https://docs.snowflake.com/en/user-guide/querying-semistructured |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // https://docs.snowflake.com/en/user-guide/querying-semistructured |
| let dialects = TestedDialects::new(vec![ | ||
| Box::new(GenericDialect {}), | ||
| Box::new(SnowflakeDialect {}), | ||
| ]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be all dialects instead? we don't seem to have special handling for generic and snowflake
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We actually do have special handling for SnowflakeDialect and GenericDialect:
datafusion-sqlparser-rs/src/parser/mod.rs
Line 3814 in ce74e7f
| || (dialect_of!(self is SnowflakeDialect | GenericDialect) && Token::Colon == *tok) |
(this is in main currently, not a change in this PR)
From what I know, only Snowflake and Databricks support this syntax. So I can expand the test to include Databricks as well. But I don't think it would make sense to run this test on dialects that don't support this syntax. What do you think?
| } else { | ||
| Some(self.parse_expr()?) | ||
| // parse expr until we hit a colon (or any token with lower precedence) | ||
| Some(self.parse_subexpr(self.dialect.prec_value(Precedence::Colon))?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for the changes to the subscript behavior, we don't seem to have any new tests to accompany them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes actually came from a failing test, but I will add some more tests to explicitly look for this behavior.