Skip to content

Commit 80bce2e

Browse files
committed
test(cubesql): Add test for aggregation with WHERE false
1 parent 8f66334 commit 80bce2e

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

rust/cubesql/cubesql/src/compile/test/test_wrapper.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use cubeclient::models::V1LoadRequestQuery;
12
use datafusion::physical_plan::displayable;
23
use std::sync::Arc;
34

@@ -1001,3 +1002,38 @@ async fn test_wrapper_limit_zero() {
10011002

10021003
let _physical_plan = query_plan.as_physical_plan().await.unwrap();
10031004
}
1005+
1006+
/// Aggregation with falsy filter should NOT get pushed to CubeScan with limit=0
1007+
#[tokio::test]
1008+
async fn select_agg_where_false() {
1009+
if !Rewriter::sql_push_down_enabled() {
1010+
return;
1011+
}
1012+
init_testing_logger();
1013+
1014+
let query_plan = convert_select_to_query_plan(
1015+
"SELECT SUM(sumPrice) FROM KibanaSampleDataEcommerce WHERE 1 = 0".to_string(),
1016+
DatabaseProtocol::PostgreSQL,
1017+
)
1018+
.await;
1019+
1020+
let physical_plan = query_plan.as_physical_plan().await.unwrap();
1021+
println!(
1022+
"Physical plan: {}",
1023+
displayable(physical_plan.as_ref()).indent()
1024+
);
1025+
1026+
let logical_plan = query_plan.as_logical_plan();
1027+
assert_eq!(
1028+
logical_plan.find_cube_scan().request,
1029+
V1LoadRequestQuery {
1030+
measures: Some(vec![]),
1031+
segments: Some(vec![]),
1032+
dimensions: Some(vec![]),
1033+
order: Some(vec![]),
1034+
limit: None,
1035+
ungrouped: Some(true),
1036+
..Default::default()
1037+
}
1038+
);
1039+
}

0 commit comments

Comments
 (0)