Skip to content

Commit

Permalink
fix: test fix2
Browse files Browse the repository at this point in the history
  • Loading branch information
akhilender-bongirwar committed Oct 20, 2024
1 parent a924933 commit d6783ff
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions crates/proof-of-sql/src/sql/parse/query_expr_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1109,14 +1109,14 @@ fn we_can_group_by_without_using_aggregate_functions() {
#[test]
fn group_by_expressions_are_parsed_before_an_order_by_referencing_an_aggregate_alias_result() {
let query_text =
"select max(salary) as max_sal, department as d, count(department) from sxt.employees group by department, tax order by max_sal";
"select max(salary) as max_sal, role_id as d, count(role_id) from sxt.employees group by role_id, tax order by max_sal";

let t = "sxt.employees".parse().unwrap();
let accessor = schema_accessor_from_table_ref_with_schema(
t,
indexmap! {
"salary".parse().unwrap() => ColumnType::BigInt,
"department".parse().unwrap() => ColumnType::BigInt,
"role_id".parse().unwrap() => ColumnType::BigInt,
"tax".parse().unwrap() => ColumnType::BigInt,
},
);
Expand All @@ -1129,19 +1129,19 @@ fn group_by_expressions_are_parsed_before_an_order_by_referencing_an_aggregate_a
filter(
vec![
col_expr_plan(t, "salary", &accessor),
col_expr_plan(t, "department", &accessor),
col_expr_plan(t, "role_id", &accessor),
col_expr_plan(t, "tax", &accessor),
],
tab(t),
const_bool(true),
),
vec![
group_by_postprocessing(
&["department", "tax"],
&["role_id", "tax"],
&[
aliased_expr(max(col("salary")), "max_sal"),
aliased_expr(col("department"), "d"),
aliased_expr(count(col("department")), "__count__"),
aliased_expr(col("role_id"), "d"),
aliased_expr(count(col("role_id")), "__count__"),
],
),
orders(&["max_sal"], &[Asc]),
Expand Down Expand Up @@ -1402,30 +1402,30 @@ fn we_can_use_multiple_group_by_clauses_with_multiple_agg_and_non_agg_exprs() {
t,
indexmap! {
"salary".parse().unwrap() => ColumnType::BigInt,
"bonus".parse().unwrap() => ColumnType::BigInt,
"bonus_amount".parse().unwrap() => ColumnType::BigInt,
"tax".parse().unwrap() => ColumnType::BigInt,
"name".parse().unwrap() => ColumnType::VarChar,
},
);
let query_text = "select salary as d1, max(tax), salary as d2, sum(bonus) as sum_bonus, count(name) as count_s from sxt.employees group by salary, bonus, salary";
let query_text = "select salary as d1, max(tax), salary as d2, sum(bonus_amount) as sum_bonus_amount, count(name) as count_s from sxt.employees group by salary, bonus_amount, salary";

let intermediate_ast = SelectStatementParser::new().parse(query_text).unwrap();
let ast =
QueryExpr::<NaiveCommitment>::try_new(intermediate_ast, t.schema_id(), &accessor).unwrap();

let expected_ast = QueryExpr::new(
filter(
cols_expr_plan(t, &["salary", "bonus", "tax", "name"], &accessor),
cols_expr_plan(t, &["salary", "bonus_amount", "tax", "name"], &accessor),
tab(t),
const_bool(true),
),
vec![group_by_postprocessing(
&["salary", "bonus", "salary"],
&["salary", "bonus_amount", "salary"],
&[
aliased_expr(col("salary"), "d1"),
aliased_expr(max(col("tax")), "__max__"),
aliased_expr(col("salary"), "d2"),
aliased_expr(sum(col("bonus")), "sum_bonus"),
aliased_expr(sum(col("bonus_amount")), "sum_bonus_amount"),
aliased_expr(count(col("name")), "count_s"),
],
)],
Expand Down Expand Up @@ -1918,19 +1918,19 @@ fn count_aggregation_always_have_integer_type() {
indexmap! {
"name".parse().unwrap() => ColumnType::VarChar,
"salary".parse().unwrap() => ColumnType::BigInt,
"bonus".parse().unwrap() => ColumnType::Int128,
"employee_id".parse().unwrap() => ColumnType::Int128,
},
);
let query_text =
"select 7 + count(name) as cs, count(salary) * -5 as ci, count(bonus) from sxt.employees";
"select 7 + count(name) as cs, count(salary) * -5 as ci, count(employee_id) from sxt.employees";

let intermediate_ast = SelectStatementParser::new().parse(query_text).unwrap();
let ast =
QueryExpr::<NaiveCommitment>::try_new(intermediate_ast, t.schema_id(), &accessor).unwrap();

let expected_ast = QueryExpr::new(
filter(
cols_expr_plan(t, &["bonus", "salary", "name"], &accessor),
cols_expr_plan(t, &["employee_id", "salary", "name"], &accessor),
tab(t),
const_bool(true),
),
Expand All @@ -1940,7 +1940,7 @@ fn count_aggregation_always_have_integer_type() {
&[
aliased_expr(padd(lit(7), count(col("name"))), "cs"),
aliased_expr(pmul(count(col("salary")), lit(-5)), "ci"),
aliased_expr(count(col("bonus")), "__count__"),
aliased_expr(count(col("employee_id")), "__count__"),
],
),
select_expr(&[
Expand Down

0 comments on commit d6783ff

Please sign in to comment.