Skip to content

Commit

Permalink
[FIXUP proper message] more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mcheshkov committed Nov 13, 2024
1 parent 284215b commit f926c8c
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions rust/cubesql/cubesql/src/compile/test/test_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1240,3 +1240,59 @@ async fn select_agg_where_false() {
}
);
}

/// Aggregation(dimension) with falsy filter should NOT get pushed to CubeScan with limit=0
#[tokio::test]
async fn wrapper_dimension_agg_where_false() {
if !Rewriter::sql_push_down_enabled() {
return;
}
init_testing_logger();

let query_plan = convert_select_to_query_plan(
// language=PostgreSQL
r#"
SELECT
MAX(customer_gender)
FROM
KibanaSampleDataEcommerce
WHERE 1 = 0
"#
.to_string(),
DatabaseProtocol::PostgreSQL,
)
.await;

let physical_plan = query_plan.as_physical_plan().await.unwrap();
println!(
"Physical plan: {}",
displayable(physical_plan.as_ref()).indent()
);

let logical_plan = query_plan.as_logical_plan();
assert_eq!(
logical_plan.find_cube_scan().request,
V1LoadRequestQuery {
measures: Some(vec![]),
dimensions: Some(vec![]),
segments: Some(vec![]),
order: Some(vec![]),
limit: Some(0),
ungrouped: Some(true),
..Default::default()
}
);

assert!(logical_plan
.find_cube_scan_wrapper()
.wrapped_sql
.unwrap()
.sql
.contains("\"limit\":0"));
assert!(logical_plan
.find_cube_scan_wrapper()
.wrapped_sql
.unwrap()
.sql
.contains("\"ungrouped\":true"));
}

0 comments on commit f926c8c

Please sign in to comment.