fix(substrait): Allow scalar subquery in projection#18068
fix(substrait): Allow scalar subquery in projection#18068bvolpato wants to merge 1 commit intoapache:mainfrom
Conversation
88a4027 to
5cbfa7b
Compare
| // For joins without conditions, use cross_join if inner, otherwise use a filter with Boolean(true) | ||
| if join_type == JoinType::Inner { | ||
| left.cross_join(right.build()?)?.build() | ||
| } else { |
There was a problem hiding this comment.
One thing to take into account is that Postgres does not allow this. In Postgres, it's invalid to provide an inner join without a join condition (although other DBs like MySQL allow it).
My impression is that the change in #15334 was actually trying to adhere to this standard, which is a fair decision, so that means that probably the Substrait path should also adhere to that standard, unless there's a strong reason to diverge.
Don't have a strong opinion about whether if we should automatically convert inner joins without conditions to cross joins or not, but I'd advocate for consistency in both the normal SQL path and the Substrait path
|
Thank you for your contribution. Unfortunately, this pull request is stale because it has been open 60 days with no activity. Please remove the stale label or comment or this will be closed in 7 days. |
Which issue does this PR close?
Rationale for this change
Recent validations added at #15334 started to cause problems for some LEFT JOIN queries that don't have conditions, for example:
This query gets optimized as a left join without conditions.
This basically follows the same approach from #15334 :
datafusion/datafusion/optimizer/src/scalar_subquery_to_join.rs
Line 345 in a65a2cb
What changes are included in this PR?
For joins without conditions, use cross_join if inner, otherwise use a filter with
Boolean(true)Are these changes tested?
Added a roundtrip test case.
Are there any user-facing changes?
n/a