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
Fix scalar subquery detection for INTERSECT/UNION queries in Calcite 1.37
This commit fixes the cartesian join error that occurs with INTERSECT/UNION queries
containing scalar subqueries like 'SELECT 1' in Calcite 1.37.0.
Changes to JoinUtils.java:
1. Enhanced isScalarSubquery() method to detect scalar subqueries represented as Values nodes:
- Added support for org.apache.calcite.rel.logical.LogicalValues
- Added support for org.apache.drill.exec.planner.common.DrillValuesRelBase
- Both check if tuples.size() <= 1 to identify scalar subqueries
2. Modified checkCartesianJoin() method to allow cartesian joins with scalar subqueries:
- Added hasScalarSubqueryInput() checks for both INNER and non-INNER joins
- Returns false (not a problematic cartesian join) when a scalar subquery is detected
- Allows nested loop joins for scalar subqueries instead of throwing errors
Reverted problematic changes:
- DrillRexBuilder.java: Removed ensureType() override that added casts for nullability
- DrillRelFactories.java: Removed nullability normalization in FilterFactory
- DefaultSqlHandler.java: Removed extra logging
Test results:
- TestSetOp tests (testIntersectCancellation, testUnionFilterPushDownOverOr): PASSING
- TestJoinNullable tests: PASSING
- No regression in other tests
0 commit comments