Skip to content

Commit c60e322

Browse files
committed
dev
1 parent 7f9fed9 commit c60e322

File tree

2 files changed

+21
-24
lines changed

2 files changed

+21
-24
lines changed

rust/cubestore/cubestore-sql-tests/src/tests.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8001,6 +8001,10 @@ async fn limit_pushdown_without_group(service: Box<dyn SqlClient>) {
80018001
.exec_query("CREATE TABLE foo.pushdown_where_group2 (a int, b int, c int) index ind1 (a, b, c) index ind2 (c, b)")
80028002
.await
80038003
.unwrap();
8004+
service
8005+
.exec_query("CREATE TABLE foo.pushdown_where_group2_with_alias (a_alias int, b_alias int, c_alias int) index ind1 (a_alias, b_alias, c_alias) index ind2 (c_alias, b_alias)")
8006+
.await
8007+
.unwrap();
80048008
service
80058009
.exec_query(
80068010
"INSERT INTO foo.pushdown_where_group1
@@ -8279,6 +8283,22 @@ async fn limit_pushdown_without_group(service: Box<dyn SqlClient>) {
82798283
]),
82808284
]
82818285
);
8286+
8287+
// ====================================
8288+
let res = assert_limit_pushdown(
8289+
&service,
8290+
"SELECT a, b, c FROM (
8291+
SELECT a, b, c FROM foo.pushdown_where_group1
8292+
union all
8293+
SELECT a_alias a, b_alias b, c_alias c FROM foo.pushdown_where_group2_with_alias
8294+
) as `tb`
8295+
ORDER BY 3 DESC LIMIT 3",
8296+
Some("ind2"),
8297+
true,
8298+
true,
8299+
)
8300+
.await
8301+
.unwrap();
82828302
}
82838303
async fn limit_pushdown_without_group_resort(service: Box<dyn SqlClient>) {
82848304
service.exec_query("CREATE SCHEMA foo").await.unwrap();

rust/cubestore/cubestore/src/queryplanner/planning.rs

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -639,28 +639,6 @@ fn get_alias_to_column(expr: &Vec<Expr>) -> HashMap<String, logical_plan::Column
639639
alias_to_column
640640
}
641641

642-
///Try to get original column namse from if underlined projection or aggregates contains columns aliases
643-
fn get_original_name(may_be_alias: &String, input: &LogicalPlan) -> String {
644-
fn get_name(exprs: &Vec<Expr>, may_be_alias: &String) -> String {
645-
let expr = exprs.iter().find(|&expr| match expr {
646-
Expr::Alias(_, name) => name == may_be_alias,
647-
_ => false,
648-
});
649-
if let Some(expr) = expr {
650-
if let Some(original_name) = extract_column_name(expr) {
651-
return original_name;
652-
}
653-
}
654-
may_be_alias.clone()
655-
}
656-
match input {
657-
LogicalPlan::Projection { expr, .. } => get_name(expr, may_be_alias),
658-
LogicalPlan::Filter { input, .. } => get_original_name(may_be_alias, input),
659-
LogicalPlan::Aggregate { group_expr, .. } => get_name(group_expr, may_be_alias),
660-
_ => may_be_alias.clone(),
661-
}
662-
}
663-
664642
fn sort_to_column_names(sort_exprs: &Vec<Expr>, input: &LogicalPlan) -> (Vec<String>, bool) {
665643
let mut res = Vec::new();
666644
let mut has_desc = false;
@@ -675,7 +653,6 @@ fn sort_to_column_names(sort_exprs: &Vec<Expr>, input: &LogicalPlan) -> (Vec<Str
675653
}
676654
match expr.as_ref() {
677655
Expr::Column(c) => {
678-
// res.push(get_original_name(&c.name, input));
679656
res.push(c.name.clone());
680657
}
681658
_ => {
@@ -820,7 +797,7 @@ impl PlanRewriter for ChooseIndex<'_> {
820797
}
821798
}
822799
LogicalPlan::Filter { predicate, .. } => {
823-
let mut single_filtered = Vec::new();
800+
let mut single_filtered: Vec<&datafusion::prelude::Column> = Vec::new();
824801
if single_value_filter_columns(predicate, &mut single_filtered) {
825802
Some(
826803
context.update_single_value_filtered_cols(

0 commit comments

Comments
 (0)