You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Support complex join conditions for grouped joins (#9157)
Add support for complex join conditions for grouped joins
DataFusion plans non-trivial joins (ones that are not `l.column = r.column`) as `Filter(CrossJoin(...))`
To support ungrouped-grouped joins with queries like this SQL API needs to rewrite logical plan like that to `WrappedSelect` with join inside. To do that it need to distinguish between plan coming from regular `JOIN` and actual `CROSS JOIN` with `WHERE` on top. This is done with new `JoinCheckStage`: it starts on `Filter(CrossJoin(wrapper, wrapper))`, traverses all `AND`s in filter condition, checks that "leaves" in condition are comparing two join sides, and pulls up that fact. After that regular join rewrite can start on checked condition.
Supporting changes:
* Allow grouped join sides to have different in_projection flag
* Allow non-push_to_cube WrappedSelect in grouped subquery position in join
* Make zero members wrapper more expensive than filter member
* Replace alias to cube during wrapper pull up
* Wrap is_null expressions in parens, to avoid operator precedence issues
Expression like `(foo IS NOT NULL = bar IS NOT NULL)`` would try to compare `foo IS NOT NULL` with `bar`, not with `bar IS NOT NULL`
Copy file name to clipboardExpand all lines: packages/cubejs-schema-compiler/src/adapter/BaseQuery.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -3327,7 +3327,7 @@ export class BaseQuery {
3327
3327
column_aliased: '{{expr}} {{quoted_alias}}',
3328
3328
query_aliased: '{{ query }} AS {{ quoted_alias }}',
3329
3329
case: 'CASE{% if expr %} {{ expr }}{% endif %}{% for when, then in when_then %} WHEN {{ when }} THEN {{ then }}{% endfor %}{% if else_expr %} ELSE {{ else_expr }}{% endif %} END',
3330
-
is_null: '{{ expr }} IS {% if negate %}NOT {% endif %}NULL',
3330
+
is_null: '({{ expr }} IS {% if negate %}NOT {% endif %}NULL)',
0 commit comments