Commit dba0816
committed
feat: parse JsonAccess as a custom binary operator
- Needed in datafusion-contrib/datafusion-variant#26
- `sqlparser-rs` currently exposes the colon operator (`:`) as a
special `JsonAccess` expression. So it fails in datafusion's parsing
before an `ExprPlanner` is even invoked.
- Fix it by converting `JsonAccess` to a normal binary expr, on which
the `ExprPlanner` is invoked and custom parsing can be done.
I have arrived at this solution iteratively to solve
datafusion-contrib/datafusion-variant#26.
Some alternatives I considered (but NOT IMPLEMENTED):
- Add a new `Operator::Colon` variant instead of
`BinaryOperator::Custom`. This will make more sense to do if
datafusion plans on supporting the colon operator on other data types
(like json strings).
- Add a new `Expr::JsonAccess` instead of re-using `BinaryExpr`.
Alongside this, we could also introduce datafusion's version of
a `JsonPath` struct. `Expr::JsonAccess` could also contain the
optional cast that usually comes after it (like in
`col_a:field_b::int`). The cast might be needed for performance
optimizations. This is a much bigger change, so I have not done it.
If either of these make sense to do at this time, please let me know and
I will do theose changes.1 parent 73fbd48 commit dba0816
1 file changed
+21
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
| 25 | + | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
651 | 651 | | |
652 | 652 | | |
653 | 653 | | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
654 | 657 | | |
655 | 658 | | |
656 | 659 | | |
657 | 660 | | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
658 | 677 | | |
659 | 678 | | |
660 | 679 | | |
| |||
0 commit comments