feat: pushdown select distinct in some cases (#5847)

* feat: pushdown select distinct

* test: add sqlness test

* test: fix analyzer test
This commit is contained in:
Yingwen
2025-04-09 10:39:04 +08:00
committed by GitHub
parent 311727939d
commit 95d0c650ec
5 changed files with 47 additions and 22 deletions

View File

@@ -489,13 +489,7 @@ mod test {
let config = ConfigOptions::default();
let result = DistPlannerAnalyzer {}.analyze(plan, &config).unwrap();
let expected = [
"Sort: t.number ASC NULLS LAST",
" Distinct:",
" Projection: t.number",
" MergeScan [is_placeholder=false]",
]
.join("\n");
let expected = ["Projection: t.number", " MergeScan [is_placeholder=false]"].join("\n");
assert_eq!(expected, result.to_string());
}

View File

@@ -96,7 +96,13 @@ impl Categorizer {
LogicalPlan::Extension(extension) => {
Self::check_extension_plan(extension.node.as_ref() as _)
}
LogicalPlan::Distinct(_) => Commutativity::Unimplemented,
LogicalPlan::Distinct(_) => {
if partition_cols.is_empty() {
Commutativity::Commutative
} else {
Commutativity::Unimplemented
}
}
LogicalPlan::Unnest(_) => Commutativity::Commutative,
LogicalPlan::Statement(_) => Commutativity::Unsupported,
LogicalPlan::Values(_) => Commutativity::Unsupported,