File tree Expand file tree Collapse file tree 1 file changed +64
-0
lines changed
rust/cubesql/cubesql/src/compile/test Expand file tree Collapse file tree 1 file changed +64
-0
lines changed Original file line number Diff line number Diff line change 11use cubeclient:: models:: V1LoadRequestQuery ;
22use datafusion:: physical_plan:: displayable;
3+ use pretty_assertions:: assert_eq;
34use std:: sync:: Arc ;
45
56use crate :: {
@@ -1037,3 +1038,66 @@ async fn select_agg_where_false() {
10371038 }
10381039 ) ;
10391040}
1041+
1042+ /// Test that aggregation over CubeScan(limit=n, ungrouped=true) is NOT pushed to CubeScan
1043+ #[ tokio:: test]
1044+ async fn wrapper_agg_over_limit ( ) {
1045+ if !Rewriter :: sql_push_down_enabled ( ) {
1046+ return ;
1047+ }
1048+ init_testing_logger ( ) ;
1049+
1050+ let query_plan = convert_select_to_query_plan (
1051+ // language=PostgreSQL
1052+ r#"
1053+ SELECT
1054+ customer_gender
1055+ FROM (
1056+ SELECT
1057+ customer_gender
1058+ FROM
1059+ KibanaSampleDataEcommerce
1060+ LIMIT 5
1061+ ) scan
1062+ GROUP BY
1063+ 1
1064+ "#
1065+ . to_string ( ) ,
1066+ DatabaseProtocol :: PostgreSQL ,
1067+ )
1068+ . await ;
1069+
1070+ let physical_plan = query_plan. as_physical_plan ( ) . await . unwrap ( ) ;
1071+ println ! (
1072+ "Physical plan: {}" ,
1073+ displayable( physical_plan. as_ref( ) ) . indent( )
1074+ ) ;
1075+
1076+ let logical_plan = query_plan. as_logical_plan ( ) ;
1077+ assert_eq ! (
1078+ logical_plan. find_cube_scan( ) . request,
1079+ V1LoadRequestQuery {
1080+ measures: Some ( vec![ ] ) ,
1081+ dimensions: Some ( vec![ ] ) ,
1082+ segments: Some ( vec![ ] ) ,
1083+ order: Some ( vec![ ] ) ,
1084+ limit: Some ( 5 ) ,
1085+ ungrouped: Some ( true ) ,
1086+ ..Default :: default ( )
1087+ }
1088+ ) ;
1089+
1090+ assert ! ( logical_plan
1091+ . find_cube_scan_wrapper( )
1092+ . wrapped_sql
1093+ . unwrap( )
1094+ . sql
1095+ . contains( "\" limit\" :5" ) ) ;
1096+ assert ! ( !query_plan
1097+ . as_logical_plan( )
1098+ . find_cube_scan_wrapper( )
1099+ . wrapped_sql
1100+ . unwrap( )
1101+ . sql
1102+ . contains( "ungrouped" ) ) ;
1103+ }
You can’t perform that action at this time.
0 commit comments