File tree Expand file tree Collapse file tree 2 files changed +47
-2
lines changed
rust/cubesql/cubesql/src/compile Expand file tree Collapse file tree 2 files changed +47
-2
lines changed Original file line number Diff line number Diff line change @@ -17504,4 +17504,49 @@ LIMIT {{ limit }}{% endif %}"#.to_string(),
1750417504 displayable(physical_plan.as_ref()).indent()
1750517505 );
1750617506 }
17507+
17508+ #[tokio::test]
17509+ async fn test_where_subquery_sql_push_down_measure_fn() {
17510+ if !Rewriter::sql_push_down_enabled() {
17511+ return;
17512+ }
17513+ init_testing_logger();
17514+
17515+ let query_plan = convert_select_to_query_plan(
17516+ r#"
17517+ WITH top_customers AS (
17518+ SELECT
17519+ KibanaSampleDataEcommerce.id,
17520+ MEASURE(KibanaSampleDataEcommerce.sumPrice) AS sum_value
17521+ FROM KibanaSampleDataEcommerce
17522+ GROUP BY 1
17523+ ORDER BY 2 DESC
17524+ LIMIT 3
17525+ )
17526+ SELECT
17527+ KibanaSampleDataEcommerce.id,
17528+ MEASURE(KibanaSampleDataEcommerce.sumPrice) AS sum_value
17529+ FROM KibanaSampleDataEcommerce
17530+ WHERE KibanaSampleDataEcommerce.id IN (
17531+ SELECT id FROM top_customers
17532+ )
17533+ GROUP BY 1
17534+ ORDER BY 1
17535+ "#
17536+ .to_string(),
17537+ DatabaseProtocol::PostgreSQL,
17538+ )
17539+ .await;
17540+
17541+ let logical_plan = query_plan.as_logical_plan();
17542+ let sql = logical_plan.find_cube_scan_wrapped_sql().wrapped_sql.sql;
17543+ assert!(sql.contains("IN (SELECT"));
17544+ assert!(sql.contains(r#"\\\"limit\\\": 3\\n"#));
17545+
17546+ let physical_plan = query_plan.as_physical_plan().await.unwrap();
17547+ println!(
17548+ "Physical plan: {}",
17549+ displayable(physical_plan.as_ref()).indent()
17550+ );
17551+ }
1750717552}
Original file line number Diff line number Diff line change @@ -609,7 +609,7 @@ impl WrapperRules {
609609 ) ,
610610 ) ,
611611 wrapper_pullup_replacer(
612- wrapped_select_subqueries_empty_tail ( ) ,
612+ "?inner_subqueries" ,
613613 wrapper_replacer_context(
614614 "?alias_to_cube" ,
615615 "WrapperReplacerContextPushToCube:true" ,
@@ -735,7 +735,7 @@ impl WrapperRules {
735735 ) ,
736736 ) ,
737737 wrapper_pullup_replacer(
738- wrapped_select_subqueries_empty_tail ( ) ,
738+ "?inner_subqueries" ,
739739 wrapper_replacer_context(
740740 "?alias_to_cube" ,
741741 "WrapperReplacerContextPushToCube:true" ,
You can’t perform that action at this time.
0 commit comments