Skip to content

Commit f316f9d

Browse files
committed
chore: codefmt
1 parent d00b88d commit f316f9d

File tree

17 files changed

+114
-75
lines changed

17 files changed

+114
-75
lines changed

src/query/service/src/physical_plans/physical_join.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
use databend_common_exception::ErrorCode;
1516
use databend_common_exception::Result;
1617
use databend_common_sql::binder::JoinPredicate;
1718
use databend_common_sql::optimizer::ir::RelExpr;
@@ -40,6 +41,13 @@ pub fn physical_join(join: &Join, s_expr: &SExpr) -> Result<PhysicalJoinType> {
4041
JoinType::Asof | JoinType::LeftAsof | JoinType::RightAsof
4142
);
4243

44+
if join.equi_conditions.is_empty()
45+
&& (join.join_type.is_any_join() || join.join_type == JoinType::Cross(true))
46+
{
47+
return Err(ErrorCode::SemanticError(
48+
"ANY JOIN only supports equality-based hash joins",
49+
));
50+
}
4351
if !join.equi_conditions.is_empty() && !check_asof {
4452
// Contain equi condition, use hash join
4553
return Ok(PhysicalJoinType::Hash);

src/query/service/src/pipelines/processors/transforms/hash_join/hash_join_state.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,4 +344,9 @@ impl HashJoinHashTable {
344344
HashJoinHashTable::KeysU256(table) => table.hash_table.len(),
345345
}
346346
}
347+
348+
#[allow(dead_code)]
349+
pub fn is_empty(&self) -> bool {
350+
self.len() == 0
351+
}
347352
}

src/query/service/tests/it/sql/planner/optimizer/data/results/basic/01_cross_join_aggregation_optimized.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Aggregate(Final)
55
├── group items: []
66
├── aggregate functions: [SUM(i1.i) AS (#2), MIN(i1.i) AS (#3), MAX(i2.i) AS (#4)]
77
└── Exchange(Merge)
8-
└── Join(Cross)
8+
└── Join(Cross(false))
99
├── build keys: []
1010
├── probe keys: []
1111
├── other filters: []

src/query/service/tests/it/sql/planner/optimizer/data/results/basic/01_cross_join_aggregation_raw.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ EvalScalar
55
├── aggregate functions: [SUM(i1.i) AS (#2), MIN(i1.i) AS (#3), MAX(i2.i) AS (#4)]
66
└── EvalScalar
77
├── scalars: [i1.i (#0) AS (#0), i1.i (#0) AS (#0), i2.i (#1) AS (#1)]
8-
└── Join(Cross)
8+
└── Join(Cross(false))
99
├── build keys: []
1010
├── probe keys: []
1111
├── other filters: []

src/query/service/tests/it/sql/planner/optimizer/data/results/obfuscated/01_multi_join_avg_case_expression_optimized.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ Exchange(Merge)
1313
├── Exchange(Hash): keys: [a.a0d (#0)]
1414
└── EvalScalar
1515
├── scalars: [a.a0d (#0) AS (#0), a.a0k (#7) AS (#7), a.a0m (#9) AS (#9), c.a5m (#144) AS (#144), if(eq(d.a1v (#154), '603020'), 1, 0) AS (#166), b.a2t (#70) AS (#171), c.a4m (#118) AS (#172), d.a5w (#156) AS (#173)]
16-
└── Join(Inner)
16+
└── Join(Inner(false))
1717
├── build keys: [c.a0m (#149)]
1818
├── probe keys: [a.a0m (#9)]
1919
├── other filters: []
20-
├── Join(Inner)
20+
├── Join(Inner(false))
2121
│ ├── build keys: [b.a0k (#48), b.a0n (#50)]
2222
│ ├── probe keys: [a.a0k (#7), a.a0n (#10)]
2323
│ ├── other filters: [lte(b.a2c (#52), a.a0d (#0)), gt(b.a2k (#61), a.a0d (#0))]
24-
│ ├── Join(Inner)
24+
│ ├── Join(Inner(false))
2525
│ │ ├── build keys: [d.a5t (#151)]
2626
│ │ ├── probe keys: [a.a0l (#8)]
2727
│ │ ├── other filters: []

src/query/service/tests/it/sql/planner/optimizer/data/results/obfuscated/01_multi_join_avg_case_expression_raw.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ EvalScalar
99
├── scalars: [a.a0d (#0) AS (#0), a.a0k (#7) AS (#7), a.a0m (#9) AS (#9), c.a5m (#144) AS (#144), if(eq(d.a1v (#154), '603020'), 1, 0) AS (#166)]
1010
└── Filter
1111
├── filters: [gte(a.a0d (#0), '20240526'), lte(a.a0d (#0), '20250525'), eq(b.a2t (#70), '624100'), eq(substring(c.a4m (#118), 20, 1), '1'), eq(substring(d.a5w (#156), 1, 1), '1')]
12-
└── Join(Left)
12+
└── Join(Left(false))
1313
├── build keys: [d.a5t (#151)]
1414
├── probe keys: [a.a0l (#8)]
1515
├── other filters: []
16-
├── Join(Left)
16+
├── Join(Left(false))
1717
│ ├── build keys: [c.a0m (#149)]
1818
│ ├── probe keys: [a.a0m (#9)]
1919
│ ├── other filters: []
20-
│ ├── Join(Left)
20+
│ ├── Join(Left(false))
2121
│ │ ├── build keys: [b.a0k (#48), b.a0n (#50)]
2222
│ │ ├── probe keys: [a.a0k (#7), a.a0n (#10)]
2323
│ │ ├── other filters: [lte(b.a2c (#52), a.a0d (#0)), gt(b.a2k (#61), a.a0d (#0))]

src/query/service/tests/it/sql/planner/optimizer/data/results/obfuscated/01_multi_join_sum_case_expression_optimized.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Exchange(Merge)
99
├── aggregate functions: [sum(CASE WHEN d.a1v = '603020' THEN 1 ELSE 0 END) AS (#173)]
1010
└── Exchange(Hash)
1111
├── Exchange(Hash): keys: [a.a0d (#0)]
12-
└── Join(Inner)
12+
└── Join(Inner(false))
1313
├── build keys: [c.a0m (#149)]
1414
├── probe keys: [a.a0m (#9)]
1515
├── other filters: []
@@ -23,11 +23,11 @@ Exchange(Merge)
2323
│ ├── Exchange(Hash): keys: [a.a0d (#0)]
2424
│ └── EvalScalar
2525
│ ├── scalars: [a.a0d (#0) AS (#0), a.a0k (#7) AS (#7), a.a0m (#9) AS (#9), if(eq(d.a1v (#154), '603020'), 1, 0) AS (#166), b.a2t (#70) AS (#169), d.a5w (#156) AS (#171)]
26-
│ └── Join(Inner)
26+
│ └── Join(Inner(false))
2727
│ ├── build keys: [b.a0k (#48), b.a0n (#50)]
2828
│ ├── probe keys: [a.a0k (#7), a.a0n (#10)]
2929
│ ├── other filters: [lte(b.a2c (#52), a.a0d (#0)), gt(b.a2k (#61), a.a0d (#0))]
30-
│ ├── Join(Inner)
30+
│ ├── Join(Inner(false))
3131
│ │ ├── build keys: [d.a5t (#151)]
3232
│ │ ├── probe keys: [a.a0l (#8)]
3333
│ │ ├── other filters: []

src/query/service/tests/it/sql/planner/optimizer/data/results/obfuscated/01_multi_join_sum_case_expression_raw.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ EvalScalar
99
├── scalars: [a.a0d (#0) AS (#0), a.a0k (#7) AS (#7), a.a0m (#9) AS (#9), c.a5m (#144) AS (#144), if(eq(d.a1v (#154), '603020'), 1, 0) AS (#166)]
1010
└── Filter
1111
├── filters: [gte(a.a0d (#0), '20240526'), lte(a.a0d (#0), '20250525'), eq(b.a2t (#70), '624100'), eq(substring(c.a4m (#118), 20, 1), '1'), eq(substring(d.a5w (#156), 1, 1), '1')]
12-
└── Join(Left)
12+
└── Join(Left(false))
1313
├── build keys: [d.a5t (#151)]
1414
├── probe keys: [a.a0l (#8)]
1515
├── other filters: []
16-
├── Join(Left)
16+
├── Join(Left(false))
1717
│ ├── build keys: [c.a0m (#149)]
1818
│ ├── probe keys: [a.a0m (#9)]
1919
│ ├── other filters: []
20-
│ ├── Join(Left)
20+
│ ├── Join(Left(false))
2121
│ │ ├── build keys: [b.a0k (#48), b.a0n (#50)]
2222
│ │ ├── probe keys: [a.a0k (#7), a.a0n (#10)]
2323
│ │ ├── other filters: [lte(b.a2c (#52), a.a0d (#0)), gt(b.a2k (#61), a.a0d (#0))]

src/query/service/tests/it/sql/planner/optimizer/data/results/tpcds/Q01_optimized.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Limit
1010
├── limit: [100]
1111
└── EvalScalar
1212
├── scalars: [customer.c_customer_id (#79) AS (#79), ctr1.ctr_total_return (#48) AS (#154), scalar_subquery_147 (#147) AS (#155), store.s_store_sk (#49) AS (#156), ctr1.ctr_store_sk (#7) AS (#157), store.s_state (#73) AS (#158), ctr1.ctr_customer_sk (#3) AS (#159), customer.c_customer_sk (#78) AS (#160)]
13-
└── Join(Inner)
13+
└── Join(Inner(false))
1414
├── build keys: [ctr1.ctr_customer_sk (#3)]
1515
├── probe keys: [customer.c_customer_sk (#78)]
1616
├── other filters: []
@@ -20,7 +20,7 @@ Limit
2020
│ ├── order by: []
2121
│ └── limit: NONE
2222
└── Exchange(Broadcast)
23-
└── Join(Inner)
23+
└── Join(Inner(false))
2424
├── build keys: [sr_store_sk (#103)]
2525
├── probe keys: [sr_store_sk (#7)]
2626
├── other filters: [gt(ctr1.ctr_total_return (#48), scalar_subquery_147 (#147))]
@@ -34,7 +34,7 @@ Limit
3434
│ ├── Exchange(Hash): keys: [store_returns.sr_customer_sk (#3)]
3535
│ └── EvalScalar
3636
│ ├── scalars: [store_returns.sr_customer_sk (#3) AS (#3), store_returns.sr_store_sk (#7) AS (#7), store_returns.sr_return_amt (#11) AS (#11), store_returns.sr_returned_date_sk (#0) AS (#148), date_dim.d_date_sk (#20) AS (#149), date_dim.d_year (#26) AS (#150)]
37-
│ └── Join(Inner)
37+
│ └── Join(Inner(false))
3838
│ ├── build keys: [date_dim.d_date_sk (#20)]
3939
│ ├── probe keys: [store_returns.sr_returned_date_sk (#0)]
4040
│ ├── other filters: []
@@ -50,7 +50,7 @@ Limit
5050
│ ├── order by: []
5151
│ └── limit: NONE
5252
└── Exchange(Broadcast)
53-
└── Join(Inner)
53+
└── Join(Inner(false))
5454
├── build keys: [sr_store_sk (#103)]
5555
├── probe keys: [store.s_store_sk (#49)]
5656
├── other filters: []
@@ -80,7 +80,7 @@ Limit
8080
├── Exchange(Hash): keys: [store_returns.sr_customer_sk (#99)]
8181
└── EvalScalar
8282
├── scalars: [store_returns.sr_customer_sk (#99) AS (#99), store_returns.sr_store_sk (#103) AS (#103), store_returns.sr_return_amt (#107) AS (#107), store_returns.sr_returned_date_sk (#96) AS (#151), date_dim.d_date_sk (#116) AS (#152), date_dim.d_year (#122) AS (#153)]
83-
└── Join(Inner)
83+
└── Join(Inner(false))
8484
├── build keys: [date_dim.d_date_sk (#116)]
8585
├── probe keys: [store_returns.sr_returned_date_sk (#96)]
8686
├── other filters: []

src/query/service/tests/it/sql/planner/optimizer/data/results/tpcds/Q01_raw.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Limit
2929
│ ├── scalars: [store_returns.sr_customer_sk (#99) AS (#99), store_returns.sr_store_sk (#103) AS (#103), store_returns.sr_return_amt (#107) AS (#107)]
3030
│ └── Filter
3131
│ ├── filters: [eq(store_returns.sr_returned_date_sk (#96), date_dim.d_date_sk (#116)), eq(date_dim.d_year (#122), 2001)]
32-
│ └── Join(Cross)
32+
│ └── Join(Cross(false))
3333
│ ├── build keys: []
3434
│ ├── probe keys: []
3535
│ ├── other filters: []
@@ -43,11 +43,11 @@ Limit
4343
│ ├── filters: []
4444
│ ├── order by: []
4545
│ └── limit: NONE
46-
└── Join(Cross)
46+
└── Join(Cross(false))
4747
├── build keys: []
4848
├── probe keys: []
4949
├── other filters: []
50-
├── Join(Cross)
50+
├── Join(Cross(false))
5151
│ ├── build keys: []
5252
│ ├── probe keys: []
5353
│ ├── other filters: []
@@ -60,7 +60,7 @@ Limit
6060
│ │ ├── scalars: [store_returns.sr_customer_sk (#3) AS (#3), store_returns.sr_store_sk (#7) AS (#7), store_returns.sr_return_amt (#11) AS (#11)]
6161
│ │ └── Filter
6262
│ │ ├── filters: [eq(store_returns.sr_returned_date_sk (#0), date_dim.d_date_sk (#20)), eq(date_dim.d_year (#26), 2001)]
63-
│ │ └── Join(Cross)
63+
│ │ └── Join(Cross(false))
6464
│ │ ├── build keys: []
6565
│ │ ├── probe keys: []
6666
│ │ ├── other filters: []

0 commit comments

Comments
 (0)