File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed
rust/cubesql/cubesql/src/compile/test Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -1162,3 +1162,59 @@ async fn select_agg_where_false() {
11621162 }
11631163 ) ;
11641164}
1165+
1166+ /// Aggregation(dimension) with falsy filter should NOT get pushed to CubeScan with limit=0
1167+ #[ tokio:: test]
1168+ async fn wrapper_dimension_agg_where_false ( ) {
1169+ if !Rewriter :: sql_push_down_enabled ( ) {
1170+ return ;
1171+ }
1172+ init_testing_logger ( ) ;
1173+
1174+ let query_plan = convert_select_to_query_plan (
1175+ // language=PostgreSQL
1176+ r#"
1177+ SELECT
1178+ MAX(customer_gender)
1179+ FROM
1180+ KibanaSampleDataEcommerce
1181+ WHERE 1 = 0
1182+ "#
1183+ . to_string ( ) ,
1184+ DatabaseProtocol :: PostgreSQL ,
1185+ )
1186+ . await ;
1187+
1188+ let physical_plan = query_plan. as_physical_plan ( ) . await . unwrap ( ) ;
1189+ println ! (
1190+ "Physical plan: {}" ,
1191+ displayable( physical_plan. as_ref( ) ) . indent( )
1192+ ) ;
1193+
1194+ let logical_plan = query_plan. as_logical_plan ( ) ;
1195+ assert_eq ! (
1196+ logical_plan. find_cube_scan( ) . request,
1197+ V1LoadRequestQuery {
1198+ measures: Some ( vec![ ] ) ,
1199+ dimensions: Some ( vec![ ] ) ,
1200+ segments: Some ( vec![ ] ) ,
1201+ order: Some ( vec![ ] ) ,
1202+ limit: Some ( 0 ) ,
1203+ ungrouped: Some ( true ) ,
1204+ ..Default :: default ( )
1205+ }
1206+ ) ;
1207+
1208+ assert ! ( logical_plan
1209+ . find_cube_scan_wrapper( )
1210+ . wrapped_sql
1211+ . unwrap( )
1212+ . sql
1213+ . contains( "\" limit\" :0" ) ) ;
1214+ assert ! ( logical_plan
1215+ . find_cube_scan_wrapper( )
1216+ . wrapped_sql
1217+ . unwrap( )
1218+ . sql
1219+ . contains( "\" ungrouped\" :true" ) ) ;
1220+ }
You can’t perform that action at this time.
0 commit comments