-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Context
Discussion started here - #2 (comment) (see next few comments too).
The colon operator is a shorthand for variant_get. For example, variant_get(column, '$.field', 'int') can be written as column:field::int. The part after the colon is a JSON path.
Implementation
- The first major blocker was the fact that the parser did not understand
:as an operator.- It is supported in the
snowflakedialect ofdatafusion-sqlparser-rs, but datafusion uses thegenericdialect. - Some initial exploration was done here: epic: Initial implementation of this crate #2 (comment)
- I have a PR for this in the parser here: GenericDialect: support colon operator for JsonAccess apache/datafusion-sqlparser-rs#2124
- It is supported in the
- Use
ExprPlannerto allow:as a custom operator from this crate. See: epic: Initial implementation of this crate #2 (comment) - The actual implementation of the operator - which would simply call the same function as
variant_get.
References
- Databricks documentation on
:- https://docs.databricks.com/aws/en/sql/language-manual/functions/colonsign (note: their colon works on JSON strings too, but we would be focusing on variant in this case) - A blog post I had authored on variant: https://www.e6data.com/blog/faster-json-sql-variant-data-type
Metadata
Metadata
Assignees
Labels
No labels