diff --git a/query/src/exec/context.rs b/query/src/exec/context.rs index bf638a5cda..702e032bac 100644 --- a/query/src/exec/context.rs +++ b/query/src/exec/context.rs @@ -169,7 +169,7 @@ impl IOxExecutionContext { /// tables referenced in the SQL have been registered with this context pub fn prepare_sql(&mut self, sql: &str) -> Result> { debug!(text=%sql, "planning SQL query"); - let logical_plan = self.inner.sql(sql)?.to_logical_plan(); + let logical_plan = self.inner.create_logical_plan(sql)?; self.prepare_plan(&logical_plan) } diff --git a/query_tests/cases/in/duplicates.expected b/query_tests/cases/in/duplicates.expected index fed41303fc..122384e6fb 100644 --- a/query_tests/cases/in/duplicates.expected +++ b/query_tests/cases/in/duplicates.expected @@ -12,12 +12,6 @@ | logical_plan after simplify_expressions | Sort: #h2o.time ASC NULLS FIRST, #h2o.state ASC NULLS FIRST, #h2o.city ASC NULLS FIRST | | | Projection: #h2o.time, #h2o.state, #h2o.city, #h2o.min_temp, #h2o.max_temp, #h2o.area | | | TableScan: h2o projection=Some([0, 1, 2, 3, 4, 5]) | -| logical_plan after projection_push_down | Sort: #h2o.time ASC NULLS FIRST, #h2o.state ASC NULLS FIRST, #h2o.city ASC NULLS FIRST | -| | Projection: #h2o.time, #h2o.state, #h2o.city, #h2o.min_temp, #h2o.max_temp, #h2o.area | -| | TableScan: h2o projection=Some([0, 1, 2, 3, 4, 5]) | -| logical_plan after simplify_expressions | Sort: #h2o.time ASC NULLS FIRST, #h2o.state ASC NULLS FIRST, #h2o.city ASC NULLS FIRST | -| | Projection: #h2o.time, #h2o.state, #h2o.city, #h2o.min_temp, #h2o.max_temp, #h2o.area | -| | TableScan: h2o projection=Some([0, 1, 2, 3, 4, 5]) | | physical_plan | SortExec: [time@0 ASC,state@1 ASC,city@2 ASC] | | | ProjectionExec: expr=[time@5 as time, state@4 as state, city@1 as city, min_temp@3 as min_temp, max_temp@2 as max_temp, area@0 as area] | | | ExecutionPlan(PlaceHolder) | @@ -41,10 +35,6 @@ | | TableScan: h2o projection=Some([0, 1, 2, 3, 4, 5]) | | logical_plan after simplify_expressions | Projection: #h2o.time, #h2o.state, #h2o.city, #h2o.min_temp, #h2o.max_temp, #h2o.area | | | TableScan: h2o projection=Some([0, 1, 2, 3, 4, 5]) | -| logical_plan after projection_push_down | Projection: #h2o.time, #h2o.state, #h2o.city, #h2o.min_temp, #h2o.max_temp, #h2o.area | -| | TableScan: h2o projection=Some([0, 1, 2, 3, 4, 5]) | -| logical_plan after simplify_expressions | Projection: #h2o.time, #h2o.state, #h2o.city, #h2o.min_temp, #h2o.max_temp, #h2o.area | -| | TableScan: h2o projection=Some([0, 1, 2, 3, 4, 5]) | | physical_plan | ProjectionExec: expr=[time@5 as time, state@4 as state, city@1 as city, min_temp@3 as min_temp, max_temp@2 as max_temp, area@0 as area] | | | ExecutionPlan(PlaceHolder) | | | DeduplicateExec: [city@1 ASC NULLS LAST,state@4 ASC NULLS LAST,time@5 ASC NULLS LAST] | @@ -76,16 +66,6 @@ | | TableScan: h2o projection=Some([4]) | | | Projection: #h2o.city AS name | | | TableScan: h2o projection=Some([1]) | -| logical_plan after projection_push_down | Union | -| | Projection: #h2o.state AS name | -| | TableScan: h2o projection=Some([4]) | -| | Projection: #h2o.city AS name | -| | TableScan: h2o projection=Some([1]) | -| logical_plan after simplify_expressions | Union | -| | Projection: #h2o.state AS name | -| | TableScan: h2o projection=Some([4]) | -| | Projection: #h2o.city AS name | -| | TableScan: h2o projection=Some([1]) | | physical_plan | ExecutionPlan(PlaceHolder) | | | ProjectionExec: expr=[state@0 as name] | | | ExecutionPlan(PlaceHolder) | diff --git a/query_tests/cases/in/pushdown.expected b/query_tests/cases/in/pushdown.expected index b4c6a84dc6..7173930313 100644 --- a/query_tests/cases/in/pushdown.expected +++ b/query_tests/cases/in/pushdown.expected @@ -9,10 +9,6 @@ | | TableScan: restaurant projection=Some([0, 1, 2, 3]) | | logical_plan after simplify_expressions | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | | | TableScan: restaurant projection=Some([0, 1, 2, 3]) | -| logical_plan after projection_push_down | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | -| | TableScan: restaurant projection=Some([0, 1, 2, 3]) | -| logical_plan after simplify_expressions | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | -| | TableScan: restaurant projection=Some([0, 1, 2, 3]) | | physical_plan | ProjectionExec: expr=[count@0 as count, system@1 as system, time@2 as time, town@3 as town] | | | IOxReadFilterNode: table_name=restaurant, chunks=1 predicate=Predicate | +-----------------------------------------+---------------------------------------------------------------------------------------------+ @@ -29,12 +25,6 @@ | logical_plan after simplify_expressions | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | | | Filter: #restaurant.count Gt Int64(200) | | | TableScan: restaurant projection=Some([0, 1, 2, 3]) | -| logical_plan after projection_push_down | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | -| | Filter: #restaurant.count Gt Int64(200) | -| | TableScan: restaurant projection=Some([0, 1, 2, 3]) | -| logical_plan after simplify_expressions | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | -| | Filter: #restaurant.count Gt Int64(200) | -| | TableScan: restaurant projection=Some([0, 1, 2, 3]) | | physical_plan | ProjectionExec: expr=[count@0 as count, system@1 as system, time@2 as time, town@3 as town] | | | FilterExec: CAST(count@0 AS Int64) > 200 | | | IOxReadFilterNode: table_name=restaurant, chunks=1 predicate=Predicate | @@ -52,12 +42,6 @@ | logical_plan after simplify_expressions | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | | | Filter: #restaurant.count Gt Float64(200) | | | TableScan: restaurant projection=Some([0, 1, 2, 3]) | -| logical_plan after projection_push_down | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | -| | Filter: #restaurant.count Gt Float64(200) | -| | TableScan: restaurant projection=Some([0, 1, 2, 3]) | -| logical_plan after simplify_expressions | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | -| | Filter: #restaurant.count Gt Float64(200) | -| | TableScan: restaurant projection=Some([0, 1, 2, 3]) | | physical_plan | ProjectionExec: expr=[count@0 as count, system@1 as system, time@2 as time, town@3 as town] | | | FilterExec: CAST(count@0 AS Float64) > 200 | | | IOxReadFilterNode: table_name=restaurant, chunks=1 predicate=Predicate | @@ -75,12 +59,6 @@ | logical_plan after simplify_expressions | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | | | Filter: #restaurant.system Gt Float64(4) | | | TableScan: restaurant projection=Some([0, 1, 2, 3]) | -| logical_plan after projection_push_down | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | -| | Filter: #restaurant.system Gt Float64(4) | -| | TableScan: restaurant projection=Some([0, 1, 2, 3]) | -| logical_plan after simplify_expressions | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | -| | Filter: #restaurant.system Gt Float64(4) | -| | TableScan: restaurant projection=Some([0, 1, 2, 3]) | | physical_plan | ProjectionExec: expr=[count@0 as count, system@1 as system, time@2 as time, town@3 as town] | | | FilterExec: system@1 > 4 | | | IOxReadFilterNode: table_name=restaurant, chunks=1 predicate=Predicate | @@ -98,12 +76,6 @@ | logical_plan after simplify_expressions | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | | | Filter: #restaurant.count Gt Int64(200) And #restaurant.town NotEq Utf8("tewsbury") | | | TableScan: restaurant projection=Some([0, 1, 2, 3]) | -| logical_plan after projection_push_down | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | -| | Filter: #restaurant.count Gt Int64(200) And #restaurant.town NotEq Utf8("tewsbury") | -| | TableScan: restaurant projection=Some([0, 1, 2, 3]) | -| logical_plan after simplify_expressions | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | -| | Filter: #restaurant.count Gt Int64(200) And #restaurant.town NotEq Utf8("tewsbury") | -| | TableScan: restaurant projection=Some([0, 1, 2, 3]) | | physical_plan | ProjectionExec: expr=[count@0 as count, system@1 as system, time@2 as time, town@3 as town] | | | FilterExec: CAST(count@0 AS Int64) > 200 AND CAST(town@3 AS Utf8) != tewsbury | | | IOxReadFilterNode: table_name=restaurant, chunks=1 predicate=Predicate | @@ -121,12 +93,6 @@ | logical_plan after simplify_expressions | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | | | Filter: #restaurant.count Gt Int64(200) And #restaurant.town NotEq Utf8("tewsbury") And #restaurant.system Eq Int64(5) Or #restaurant.town Eq Utf8("lawrence") | | | TableScan: restaurant projection=Some([0, 1, 2, 3]) | -| logical_plan after projection_push_down | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | -| | Filter: #restaurant.count Gt Int64(200) And #restaurant.town NotEq Utf8("tewsbury") And #restaurant.system Eq Int64(5) Or #restaurant.town Eq Utf8("lawrence") | -| | TableScan: restaurant projection=Some([0, 1, 2, 3]) | -| logical_plan after simplify_expressions | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | -| | Filter: #restaurant.count Gt Int64(200) And #restaurant.town NotEq Utf8("tewsbury") And #restaurant.system Eq Int64(5) Or #restaurant.town Eq Utf8("lawrence") | -| | TableScan: restaurant projection=Some([0, 1, 2, 3]) | | physical_plan | ProjectionExec: expr=[count@0 as count, system@1 as system, time@2 as time, town@3 as town] | | | FilterExec: CAST(count@0 AS Int64) > 200 AND CAST(town@3 AS Utf8) != tewsbury AND system@1 = CAST(5 AS Float64) OR CAST(town@3 AS Utf8) = lawrence | | | IOxReadFilterNode: table_name=restaurant, chunks=1 predicate=Predicate | @@ -144,12 +110,6 @@ | logical_plan after simplify_expressions | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | | | Filter: #restaurant.count Gt Int64(200) And #restaurant.town NotEq Utf8("tewsbury") And #restaurant.system Eq Int64(5) Or #restaurant.town Eq Utf8("lawrence") And #restaurant.count Lt Int64(40000) | | | TableScan: restaurant projection=Some([0, 1, 2, 3]) | -| logical_plan after projection_push_down | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | -| | Filter: #restaurant.count Gt Int64(200) And #restaurant.town NotEq Utf8("tewsbury") And #restaurant.system Eq Int64(5) Or #restaurant.town Eq Utf8("lawrence") And #restaurant.count Lt Int64(40000) | -| | TableScan: restaurant projection=Some([0, 1, 2, 3]) | -| logical_plan after simplify_expressions | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | -| | Filter: #restaurant.count Gt Int64(200) And #restaurant.town NotEq Utf8("tewsbury") And #restaurant.system Eq Int64(5) Or #restaurant.town Eq Utf8("lawrence") And #restaurant.count Lt Int64(40000) | -| | TableScan: restaurant projection=Some([0, 1, 2, 3]) | | physical_plan | ProjectionExec: expr=[count@0 as count, system@1 as system, time@2 as time, town@3 as town] | | | FilterExec: CAST(count@0 AS Int64) > 200 AND CAST(town@3 AS Utf8) != tewsbury AND system@1 = CAST(5 AS Float64) OR CAST(town@3 AS Utf8) = lawrence AND CAST(count@0 AS Int64) < 40000 | | | IOxReadFilterNode: table_name=restaurant, chunks=1 predicate=Predicate | @@ -167,12 +127,6 @@ | logical_plan after simplify_expressions | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | | | Filter: #restaurant.count Gt Int64(200) And #restaurant.count Lt Int64(40000) | | | TableScan: restaurant projection=Some([0, 1, 2, 3]) | -| logical_plan after projection_push_down | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | -| | Filter: #restaurant.count Gt Int64(200) And #restaurant.count Lt Int64(40000) | -| | TableScan: restaurant projection=Some([0, 1, 2, 3]) | -| logical_plan after simplify_expressions | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | -| | Filter: #restaurant.count Gt Int64(200) And #restaurant.count Lt Int64(40000) | -| | TableScan: restaurant projection=Some([0, 1, 2, 3]) | | physical_plan | ProjectionExec: expr=[count@0 as count, system@1 as system, time@2 as time, town@3 as town] | | | FilterExec: CAST(count@0 AS Int64) > 200 AND CAST(count@0 AS Int64) < 40000 | | | IOxReadFilterNode: table_name=restaurant, chunks=1 predicate=Predicate | @@ -190,12 +144,6 @@ | logical_plan after simplify_expressions | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | | | Filter: #restaurant.system Gt Float64(4) And #restaurant.system Lt Float64(7) | | | TableScan: restaurant projection=Some([0, 1, 2, 3]) | -| logical_plan after projection_push_down | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | -| | Filter: #restaurant.system Gt Float64(4) And #restaurant.system Lt Float64(7) | -| | TableScan: restaurant projection=Some([0, 1, 2, 3]) | -| logical_plan after simplify_expressions | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | -| | Filter: #restaurant.system Gt Float64(4) And #restaurant.system Lt Float64(7) | -| | TableScan: restaurant projection=Some([0, 1, 2, 3]) | | physical_plan | ProjectionExec: expr=[count@0 as count, system@1 as system, time@2 as time, town@3 as town] | | | FilterExec: system@1 > 4 AND system@1 < 7 | | | IOxReadFilterNode: table_name=restaurant, chunks=1 predicate=Predicate | @@ -213,12 +161,6 @@ | logical_plan after simplify_expressions | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | | | Filter: #restaurant.system Gt Float64(5) And #restaurant.system Lt Float64(7) | | | TableScan: restaurant projection=Some([0, 1, 2, 3]) | -| logical_plan after projection_push_down | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | -| | Filter: #restaurant.system Gt Float64(5) And #restaurant.system Lt Float64(7) | -| | TableScan: restaurant projection=Some([0, 1, 2, 3]) | -| logical_plan after simplify_expressions | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | -| | Filter: #restaurant.system Gt Float64(5) And #restaurant.system Lt Float64(7) | -| | TableScan: restaurant projection=Some([0, 1, 2, 3]) | | physical_plan | ProjectionExec: expr=[count@0 as count, system@1 as system, time@2 as time, town@3 as town] | | | FilterExec: system@1 > 5 AND system@1 < 7 | | | IOxReadFilterNode: table_name=restaurant, chunks=1 predicate=Predicate | @@ -236,12 +178,6 @@ | logical_plan after simplify_expressions | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | | | Filter: #restaurant.system Gt Float64(5) And #restaurant.town NotEq Utf8("tewsbury") And Float64(7) Gt #restaurant.system | | | TableScan: restaurant projection=Some([0, 1, 2, 3]) | -| logical_plan after projection_push_down | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | -| | Filter: #restaurant.system Gt Float64(5) And #restaurant.town NotEq Utf8("tewsbury") And Float64(7) Gt #restaurant.system | -| | TableScan: restaurant projection=Some([0, 1, 2, 3]) | -| logical_plan after simplify_expressions | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | -| | Filter: #restaurant.system Gt Float64(5) And #restaurant.town NotEq Utf8("tewsbury") And Float64(7) Gt #restaurant.system | -| | TableScan: restaurant projection=Some([0, 1, 2, 3]) | | physical_plan | ProjectionExec: expr=[count@0 as count, system@1 as system, time@2 as time, town@3 as town] | | | FilterExec: system@1 > 5 AND CAST(town@3 AS Utf8) != tewsbury AND 7 > system@1 | | | IOxReadFilterNode: table_name=restaurant, chunks=1 predicate=Predicate | @@ -259,12 +195,6 @@ | logical_plan after simplify_expressions | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | | | Filter: #restaurant.system Gt Float64(5) And Utf8("tewsbury") NotEq #restaurant.town And #restaurant.system Lt Float64(7) And #restaurant.count Eq Int64(632) Or #restaurant.town Eq Utf8("reading") | | | TableScan: restaurant projection=Some([0, 1, 2, 3]) | -| logical_plan after projection_push_down | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | -| | Filter: #restaurant.system Gt Float64(5) And Utf8("tewsbury") NotEq #restaurant.town And #restaurant.system Lt Float64(7) And #restaurant.count Eq Int64(632) Or #restaurant.town Eq Utf8("reading") | -| | TableScan: restaurant projection=Some([0, 1, 2, 3]) | -| logical_plan after simplify_expressions | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | -| | Filter: #restaurant.system Gt Float64(5) And Utf8("tewsbury") NotEq #restaurant.town And #restaurant.system Lt Float64(7) And #restaurant.count Eq Int64(632) Or #restaurant.town Eq Utf8("reading") | -| | TableScan: restaurant projection=Some([0, 1, 2, 3]) | | physical_plan | ProjectionExec: expr=[count@0 as count, system@1 as system, time@2 as time, town@3 as town] | | | FilterExec: system@1 > 5 AND tewsbury != CAST(town@3 AS Utf8) AND system@1 < 7 AND CAST(count@0 AS Int64) = 632 OR CAST(town@3 AS Utf8) = reading | | | IOxReadFilterNode: table_name=restaurant, chunks=1 predicate=Predicate | @@ -282,12 +212,6 @@ | logical_plan after simplify_expressions | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | | | Filter: Float64(5) Lt #restaurant.system And #restaurant.town NotEq Utf8("tewsbury") And #restaurant.system Lt Float64(7) And #restaurant.count Eq Int64(632) Or #restaurant.town Eq Utf8("reading") And #restaurant.time Gt totimestamp(Utf8("1970-01-01T00:00:00.000000130+00:00")) | | | TableScan: restaurant projection=Some([0, 1, 2, 3]) | -| logical_plan after projection_push_down | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | -| | Filter: Float64(5) Lt #restaurant.system And #restaurant.town NotEq Utf8("tewsbury") And #restaurant.system Lt Float64(7) And #restaurant.count Eq Int64(632) Or #restaurant.town Eq Utf8("reading") And #restaurant.time Gt totimestamp(Utf8("1970-01-01T00:00:00.000000130+00:00")) | -| | TableScan: restaurant projection=Some([0, 1, 2, 3]) | -| logical_plan after simplify_expressions | Projection: #restaurant.count, #restaurant.system, #restaurant.time, #restaurant.town | -| | Filter: Float64(5) Lt #restaurant.system And #restaurant.town NotEq Utf8("tewsbury") And #restaurant.system Lt Float64(7) And #restaurant.count Eq Int64(632) Or #restaurant.town Eq Utf8("reading") And #restaurant.time Gt totimestamp(Utf8("1970-01-01T00:00:00.000000130+00:00")) | -| | TableScan: restaurant projection=Some([0, 1, 2, 3]) | | physical_plan | ProjectionExec: expr=[count@0 as count, system@1 as system, time@2 as time, town@3 as town] | | | FilterExec: 5 < system@1 AND CAST(town@3 AS Utf8) != tewsbury AND system@1 < 7 AND CAST(count@0 AS Int64) = 632 OR CAST(town@3 AS Utf8) = reading AND time@2 > totimestamp(1970-01-01T00:00:00.000000130+00:00) | | | IOxReadFilterNode: table_name=restaurant, chunks=1 predicate=Predicate |