Skip to content

Commit 1355520

Browse files
committed
Support cross join without any join clause
1 parent cb3979e commit 1355520

File tree

3 files changed

+76
-2
lines changed

3 files changed

+76
-2
lines changed

backends-clickhouse/src/test/scala/org/apache/gluten/execution/GlutenClickHouseJoinSuite.scala

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,76 @@ class GlutenClickHouseJoinSuite extends GlutenClickHouseWholeStageTransformerSui
170170
}
171171
}
172172

173+
test("GLUTEN-10961 cross join with empty join clause") {
174+
val crossSql1 =
175+
"""
176+
|select a, b from (select id as a from range(1) )
177+
|cross join (
178+
| select id as b from range(2)
179+
|);
180+
|""".stripMargin
181+
compareResultsAgainstVanillaSpark(crossSql1, true, { _ => })
182+
183+
val crossSql2 =
184+
"""
185+
|select a, b from (select id as a from range(1) where id > 1 )
186+
|cross join (
187+
| select id as b from range(2)
188+
|);
189+
|""".stripMargin
190+
compareResultsAgainstVanillaSpark(crossSql2, true, { _ => })
191+
192+
val fullSql1 =
193+
"""
194+
|select a, b from (select id as a from range(1) where id > 1)
195+
|full join (
196+
| select id as b from range(2)
197+
|)
198+
|""".stripMargin
199+
compareResultsAgainstVanillaSpark(fullSql1, true, { _ => })
200+
201+
val fullSql2 =
202+
"""
203+
|select a, b from (select id as a from range(1) )
204+
|full join (
205+
| select id as b from range(2)
206+
|)
207+
|""".stripMargin
208+
compareResultsAgainstVanillaSpark(fullSql2, true, { _ => })
209+
210+
val innerSql1 =
211+
"""
212+
|select a, b from (select id as a from range(1) where id > 1)
213+
|inner join (
214+
| select id as b from range(2)
215+
|)
216+
|""".stripMargin
217+
compareResultsAgainstVanillaSpark(innerSql1, true, { _ => })
218+
val innerSql2 =
219+
"""
220+
|select a, b from (select id as a from range(1) )
221+
|inner join (
222+
| select id as b from range(2)
223+
|)
224+
|""".stripMargin
225+
compareResultsAgainstVanillaSpark(innerSql2, true, { _ => })
226+
227+
val leftSql1 =
228+
"""
229+
|select a, b from (select id as a from range(1) where id > 1)
230+
|left join (
231+
| select id as b from range(2)
232+
|)
233+
|""".stripMargin
234+
compareResultsAgainstVanillaSpark(leftSql1, true, { _ => })
235+
val leftSql2 =
236+
"""
237+
|select a, b from (select id as a from range(1) )
238+
|left join (
239+
| select id as b from range(2)
240+
|)
241+
|""".stripMargin
242+
compareResultsAgainstVanillaSpark(leftSql2, true, { _ => })
243+
}
244+
173245
}

cpp-ch/clickhouse.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
CH_ORG=Kyligence
22
CH_BRANCH=rebase_ch/20250729
3-
CH_COMMIT=77ef0818976
3+
CH_COMMIT=fc5d7b7b234

cpp-ch/local-engine/Common/CHUtil.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,9 +1097,11 @@ std::pair<DB::JoinKind, DB::JoinStrictness> JoinUtil::getCrossJoinKindAndStrictn
10971097
switch (join_type)
10981098
{
10991099
case substrait::CrossRel_JoinType_JOIN_TYPE_INNER:
1100+
return {DB::JoinKind::Cross, DB::JoinStrictness::All};
11001101
case substrait::CrossRel_JoinType_JOIN_TYPE_LEFT:
1102+
return {DB::JoinKind::Left, DB::JoinStrictness::All};
11011103
case substrait::CrossRel_JoinType_JOIN_TYPE_OUTER:
1102-
return {DB::JoinKind::Cross, DB::JoinStrictness::All};
1104+
return {DB::JoinKind::Full, DB::JoinStrictness::All};
11031105
default:
11041106
throw Exception(ErrorCodes::UNKNOWN_TYPE, "unsupported join type {}.", magic_enum::enum_name(join_type));
11051107
}

0 commit comments

Comments
 (0)