From da91c9a7f1b15e75ca4d81721a965da10e9345e3 Mon Sep 17 00:00:00 2001 From: Michael Greenberg Date: Wed, 9 Apr 2025 16:58:39 -0400 Subject: [PATCH 01/14] tracking column names --- .../checks/all_checks/explain_catalog_item.py | 8 +- src/adapter/src/catalog/apply.rs | 2 +- .../src/catalog/builtin_table_updates.rs | 2 +- src/adapter/src/coord/peek.rs | 4 +- src/adapter/src/optimize/peek.rs | 2 +- src/compute-types/src/plan/lowering.rs | 2 +- src/compute-types/src/plan/reduce.rs | 2 +- src/compute-types/src/plan/threshold.rs | 2 +- src/compute/src/logging.rs | 2 +- src/compute/src/render/context.rs | 2 +- src/environmentd/tests/testdata/http/ws | 8 +- src/expr-parser/src/parser.rs | 2 +- src/expr-test-util/src/lib.rs | 9 +- src/expr/src/explain.rs | 4 +- src/expr/src/explain/text.rs | 35 +- src/expr/src/interpret.rs | 30 +- src/expr/src/linear.rs | 31 +- src/expr/src/relation.rs | 20 +- src/expr/src/relation/canonicalize.rs | 16 +- src/expr/src/relation/join_input_mapper.rs | 34 +- src/expr/src/scalar.rs | 85 +- src/expr/src/scalar/func.rs | 6 +- src/expr/src/scalar/func/impls/string.rs | 2 +- src/lowertest/src/lib.rs | 5 + src/ore/BUILD.bazel | 2 - src/ore/Cargo.toml | 8 +- src/ore/src/lib.rs | 1 + src/ore/src/treat_as_equal.rs | 63 + src/sql/src/func.rs | 268 ++-- src/sql/src/plan/explain.rs | 6 +- src/sql/src/plan/explain/text.rs | 35 +- src/sql/src/plan/hir.rs | 297 ++-- src/sql/src/plan/lowering.rs | 106 +- src/sql/src/plan/lowering/variadic_left.rs | 15 +- src/sql/src/plan/query.rs | 387 +++-- src/sql/src/plan/scope.rs | 71 +- src/sql/src/plan/statement/ddl.rs | 11 +- src/sql/src/plan/transform_ast.rs | 14 +- src/sql/src/plan/transform_hir.rs | 190 +-- src/sql/src/plan/typeconv.rs | 23 +- src/sql/src/pure/postgres.rs | 26 +- src/transform/src/analysis.rs | 28 +- src/transform/src/analysis/equivalences.rs | 16 +- .../canonicalization/projection_extraction.rs | 4 +- src/transform/src/column_knowledge.rs | 16 +- src/transform/src/dataflow.rs | 2 +- src/transform/src/demand.rs | 2 +- src/transform/src/equivalence_propagation.rs | 2 +- src/transform/src/fusion/filter.rs | 6 +- src/transform/src/fusion/join.rs | 4 +- src/transform/src/fusion/reduce.rs | 4 +- src/transform/src/join_implementation.rs | 12 +- src/transform/src/literal_constraints.rs | 6 +- src/transform/src/literal_lifting.rs | 16 +- src/transform/src/non_null_requirements.rs | 4 +- src/transform/src/predicate_pushdown.rs | 19 +- src/transform/src/reduce_elision.rs | 2 +- src/transform/src/reduction_pushdown.rs | 8 +- src/transform/src/redundant_join.rs | 12 +- src/transform/src/semijoin_idempotence.rs | 19 +- src/transform/src/typecheck.rs | 2 +- .../advent-of-code/2023/aoc_1201.slt | 22 +- .../advent-of-code/2023/aoc_1202.slt | 56 +- .../advent-of-code/2023/aoc_1203.slt | 78 +- .../advent-of-code/2023/aoc_1204.slt | 60 +- .../advent-of-code/2023/aoc_1205.slt | 140 +- .../advent-of-code/2023/aoc_1207.slt | 116 +- .../advent-of-code/2023/aoc_1208.slt | 16 +- .../advent-of-code/2023/aoc_1209.slt | 52 +- .../advent-of-code/2023/aoc_1210.slt | 108 +- .../advent-of-code/2023/aoc_1211.slt | 28 +- .../advent-of-code/2023/aoc_1212.slt | 48 +- .../advent-of-code/2023/aoc_1213.slt | 68 +- .../advent-of-code/2023/aoc_1214.slt | 102 +- .../advent-of-code/2023/aoc_1215.slt | 66 +- .../advent-of-code/2023/aoc_1216.slt | 56 +- .../advent-of-code/2023/aoc_1217.slt | 88 +- .../advent-of-code/2023/aoc_1218.slt | 38 +- .../advent-of-code/2023/aoc_1219.slt | 46 +- .../advent-of-code/2023/aoc_1220.slt | 86 +- .../advent-of-code/2023/aoc_1222.slt | 56 +- .../advent-of-code/2023/aoc_1223.slt | 78 +- .../advent-of-code/2023/aoc_1224.slt | 16 +- .../advent-of-code/2023/aoc_1225.slt | 34 +- test/sqllogictest/aggregates.slt | 4 +- test/sqllogictest/attributes/mir_arity.slt | 4 +- .../autogenerated/all_parts_essential.slt | 54 +- test/sqllogictest/cardinality.slt | 40 +- test/sqllogictest/chbench.slt | 150 +- test/sqllogictest/cluster_features.slt | 36 +- test/sqllogictest/cte_lowering.slt | 42 +- test/sqllogictest/distinct_arrangements.slt | 22 +- .../explain/decorrelated_plan_as_json.slt | 795 ++++++++-- .../explain/decorrelated_plan_as_text.slt | 62 +- .../explain/enable_eager_delta_joins.slt | 20 +- .../explain/locally_optimized_plan.slt | 46 +- .../explain/materialized_view.slt | 14 +- .../explain/optimized_plan_as_json.slt | 825 ++++++++-- .../explain/optimized_plan_as_text.slt | 22 +- .../explain/physical_plan_aggregates.slt | 122 +- .../explain/physical_plan_as_json.slt | 1360 +++++++++++++---- .../explain/physical_plan_as_text.slt | 390 ++--- .../physical_plan_as_text_redacted.slt | 374 ++--- test/sqllogictest/explain/plan_insights.slt | 15 +- .../sqllogictest/explain/raw_plan_as_json.slt | 443 ++++-- .../sqllogictest/explain/raw_plan_as_text.slt | 76 +- test/sqllogictest/freshmart.slt | 10 +- test/sqllogictest/github-16036.slt | 44 +- test/sqllogictest/github-2746.slt | 6 +- test/sqllogictest/github-2969.slt | 2 +- test/sqllogictest/github-5126.slt | 4 +- test/sqllogictest/github-6464.slt | 4 +- test/sqllogictest/joins.slt | 32 +- test/sqllogictest/jsonb.slt | 4 +- test/sqllogictest/ldbc_bi.slt | 542 +++---- test/sqllogictest/ldbc_bi_eager.slt | 542 +++---- test/sqllogictest/not-null-propagation.slt | 6 +- test/sqllogictest/outer_join_lowering.slt | 2 +- .../outer_join_simplification.slt | 6 +- test/sqllogictest/record.slt | 2 +- test/sqllogictest/reduce_mfp.slt | 18 +- .../scalar_subqueries_select_list.slt | 30 +- test/sqllogictest/subquery.slt | 18 +- test/sqllogictest/table_func.slt | 14 +- test/sqllogictest/tpch_create_index.slt | 144 +- .../tpch_create_materialized_view.slt | 160 +- test/sqllogictest/tpch_select.slt | 160 +- .../transform/aggregation_nullability.slt | 62 +- .../transform/column_knowledge.slt | 2 +- test/sqllogictest/transform/demand.slt | 8 +- test/sqllogictest/transform/filter_index.slt | 2 +- .../2_number_fns_dataflow.slt | 2 +- .../fold_vs_dataflow/6_bytea_dataflow.slt | 2 +- test/sqllogictest/transform/join_fusion.slt | 30 +- test/sqllogictest/transform/join_index.slt | 56 +- .../transform/literal_constraints.slt | 14 +- .../transform/literal_lifting.slt | 4 +- test/sqllogictest/transform/monotonic.slt | 20 +- .../sqllogictest/transform/normalize_lets.slt | 50 +- .../transform/predicate_pushdown.slt | 62 +- .../transform/predicate_reduction.slt | 2 +- .../sqllogictest/transform/reduce_elision.slt | 2 +- .../transform/reduction_pushdown.slt | 6 +- test/sqllogictest/transform/relation_cse.slt | 20 +- .../transform/relax_must_consolidate.slt | 48 +- test/sqllogictest/transform/scalar_cse.slt | 2 +- .../transform/threshold_elision.slt | 14 +- test/sqllogictest/transform/union.slt | 4 +- test/sqllogictest/window_funcs.slt | 80 +- .../materializations.td | 29 +- .../monotonic.td | 48 +- .../top-1-monotonic.td | 38 +- .../top-k-monotonic.td | 12 +- test/testdrive/index-source-stuck.td | 3 +- test/testdrive/materializations.td | 8 +- test/testdrive/monotonic.td | 40 +- test/testdrive/primary-key-optimizations.td | 6 +- test/testdrive/render-delta-join.td | 10 +- test/testdrive/source-linear-operators.td | 56 +- test/testdrive/subexpression-replacement.td | 36 +- test/testdrive/temporal.td | 2 +- test/testdrive/testdrive.td | 2 +- test/testdrive/top-1-monotonic.td | 12 +- test/testdrive/top-k-monotonic.td | 4 +- 164 files changed, 6695 insertions(+), 4249 deletions(-) create mode 100644 src/ore/src/treat_as_equal.rs diff --git a/misc/python/materialize/checks/all_checks/explain_catalog_item.py b/misc/python/materialize/checks/all_checks/explain_catalog_item.py index d81fefb42623a..390b73f821d91 100644 --- a/misc/python/materialize/checks/all_checks/explain_catalog_item.py +++ b/misc/python/materialize/checks/all_checks/explain_catalog_item.py @@ -76,22 +76,22 @@ def validate(self) -> Testdrive: ?[version>=13500] EXPLAIN OPTIMIZED PLAN AS VERBOSE TEXT FOR MATERIALIZED VIEW explain_mv2; materialize.public.explain_mv2: - Filter (#1 = 7) + Filter (#1{y} = 7) ReadStorage materialize.public.explain_item_t2 Source materialize.public.explain_item_t2 - filter=((#1 = 7)) + filter=((#1{y} = 7)) Target cluster: quickstart ?[version<13500] EXPLAIN OPTIMIZED PLAN FOR MATERIALIZED VIEW explain_mv2; materialize.public.explain_mv2: - Filter (#1 = 7) + Filter (#1{y} = 7) ReadStorage materialize.public.explain_item_t2 Source materialize.public.explain_item_t2 - filter=((#1 = 7)) + filter=((#1{y} = 7)) Target cluster: quickstart diff --git a/src/adapter/src/catalog/apply.rs b/src/adapter/src/catalog/apply.rs index c726026d4d004..4822c89454154 100644 --- a/src/adapter/src/catalog/apply.rs +++ b/src/adapter/src/catalog/apply.rs @@ -1753,7 +1753,7 @@ impl CatalogState { .variant .index_by() .into_iter() - .map(MirScalarExpr::Column) + .map(MirScalarExpr::column) .collect(), create_sql: index_sql( index_item_name, diff --git a/src/adapter/src/catalog/builtin_table_updates.rs b/src/adapter/src/catalog/builtin_table_updates.rs index 499850f9e1934..77fb4b381799e 100644 --- a/src/adapter/src/catalog/builtin_table_updates.rs +++ b/src/adapter/src/catalog/builtin_table_updates.rs @@ -1661,7 +1661,7 @@ impl CatalogState { .expect("missing sql information for index key") .to_ast_string_simple(); let (field_number, expression) = match key { - MirScalarExpr::Column(col) => { + MirScalarExpr::Column(col, _) => { (Datum::UInt64(u64::cast_from(*col + 1)), Datum::Null) } _ => (Datum::Null, Datum::String(&key_sql)), diff --git a/src/adapter/src/coord/peek.rs b/src/adapter/src/coord/peek.rs index a78250d533a26..b0fa45dd6dc68 100644 --- a/src/adapter/src/coord/peek.rs +++ b/src/adapter/src/coord/peek.rs @@ -95,7 +95,7 @@ impl PeekDataflowPlan { let key = typ .default_key() .into_iter() - .map(MirScalarExpr::Column) + .map(MirScalarExpr::column) .collect::>(); let (permutation, thinning) = permutation_for_arrangement(&key, arity); Self { @@ -397,7 +397,7 @@ pub fn create_fast_path_plan( if !preserves_order(&col.scalar_type) { break; } - let col_expr = MirScalarExpr::Column(idx); + let col_expr = MirScalarExpr::column(idx); let Some((literal, _)) = filters .iter() diff --git a/src/adapter/src/optimize/peek.rs b/src/adapter/src/optimize/peek.rs index f3d24a76c6d87..f34eee3b065c4 100644 --- a/src/adapter/src/optimize/peek.rs +++ b/src/adapter/src/optimize/peek.rs @@ -244,7 +244,7 @@ impl<'s> Optimize>> for Optimizer { let key = typ .default_key() .iter() - .map(|k| MirScalarExpr::Column(*k)) + .map(|k| MirScalarExpr::column(*k)) .collect(); // The assembled dataflow contains a view and an index of that view. diff --git a/src/compute-types/src/plan/lowering.rs b/src/compute-types/src/plan/lowering.rs index e3e2050b8b92c..4d2977d977565 100644 --- a/src/compute-types/src/plan/lowering.rs +++ b/src/compute-types/src/plan/lowering.rs @@ -575,7 +575,7 @@ impl Context { // All columns of the constant input will be part of the arrangement key. let source_arrangement = ( (0..key.len()) - .map(MirScalarExpr::Column) + .map(MirScalarExpr::column) .collect::>(), (0..key.len()).collect::>(), Vec::::new(), diff --git a/src/compute-types/src/plan/reduce.rs b/src/compute-types/src/plan/reduce.rs index 7d205c24a5fd4..6d9e9b6903396 100644 --- a/src/compute-types/src/plan/reduce.rs +++ b/src/compute-types/src/plan/reduce.rs @@ -807,7 +807,7 @@ impl ReducePlan { /// that key a single arrangement. pub fn keys(&self, key_arity: usize, arity: usize) -> AvailableCollections { let key = (0..key_arity) - .map(MirScalarExpr::Column) + .map(MirScalarExpr::column) .collect::>(); let (permutation, thinning) = permutation_for_arrangement(&key, arity); AvailableCollections::new_arranged(vec![(key, permutation, thinning)], None) diff --git a/src/compute-types/src/plan/threshold.rs b/src/compute-types/src/plan/threshold.rs index 37f98f62f13e9..95c61e7465c85 100644 --- a/src/compute-types/src/plan/threshold.rs +++ b/src/compute-types/src/plan/threshold.rs @@ -126,7 +126,7 @@ impl ThresholdPlan { // Arrange the input by all columns in order. let mut all_columns = Vec::new(); for column in 0..arity { - all_columns.push(mz_expr::MirScalarExpr::Column(column)); + all_columns.push(mz_expr::MirScalarExpr::column(column)); } let (permutation, thinning) = permutation_for_arrangement(&all_columns, arity); let ensure_arrangement = (all_columns, permutation, thinning); diff --git a/src/compute/src/logging.rs b/src/compute/src/logging.rs index 89af51578b1f6..f8bf69f50fd2f 100644 --- a/src/compute/src/logging.rs +++ b/src/compute/src/logging.rs @@ -175,7 +175,7 @@ impl PermutedRowPacker { let (_, value) = permutation_for_arrangement( &key.iter() .cloned() - .map(MirScalarExpr::Column) + .map(MirScalarExpr::column) .collect::>(), variant.desc().arity(), ); diff --git a/src/compute/src/render/context.rs b/src/compute/src/render/context.rs index 2c7224aa49dab..6e4298fcabb77 100644 --- a/src/compute/src/render/context.rs +++ b/src/compute/src/render/context.rs @@ -506,7 +506,7 @@ where ) -> Self { let mut keys = Vec::new(); for column in columns { - keys.push(MirScalarExpr::Column(column)); + keys.push(MirScalarExpr::column(column)); } Self::from_expressions(keys, arrangements) } diff --git a/src/environmentd/tests/testdata/http/ws b/src/environmentd/tests/testdata/http/ws index e6c377bcfb080..520cd10732d42 100644 --- a/src/environmentd/tests/testdata/http/ws +++ b/src/environmentd/tests/testdata/http/ws @@ -384,7 +384,7 @@ ws-text ws-text {"query": "SELECT 1"} ---- -{"type":"Notice","payload":{"message":"{\n \"plans\": {\n \"raw\": {\n \"text\": \"Finish output=[#0]\\n Map (1)\\n Constant\\n - ()\\n\\nTarget cluster: mz_catalog_server\\n\",\n \"json\": {\n \"Map\": {\n \"input\": {\n \"Constant\": {\n \"rows\": [\n {\n \"data\": []\n }\n ],\n \"typ\": {\n \"column_types\": [],\n \"keys\": []\n }\n }\n },\n \"scalars\": [\n {\n \"Literal\": [\n {\n \"data\": [\n 45,\n 1\n ]\n },\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n }\n ]\n }\n ]\n }\n }\n },\n \"optimized\": {\n \"global\": {\n \"text\": \"t66:\\n Finish output=[#0]\\n ArrangeBy keys=[[#0]]\\n ReadGlobalFromSameDataflow t65\\n\\nt65:\\n Constant\\n - (1)\\n\\nTarget cluster: mz_catalog_server\\n\",\n \"json\": {\n \"plans\": [\n {\n \"id\": \"t66\",\n \"plan\": {\n \"ArrangeBy\": {\n \"input\": {\n \"Get\": {\n \"id\": {\n \"Global\": {\n \"Transient\": 65\n }\n },\n \"typ\": {\n \"column_types\": [\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n }\n ],\n \"keys\": [\n []\n ]\n },\n \"access_strategy\": \"SameDataflow\"\n }\n },\n \"keys\": [\n [\n {\n \"Column\": 0\n }\n ]\n ]\n }\n }\n },\n {\n \"id\": \"t65\",\n \"plan\": {\n \"Constant\": {\n \"rows\": {\n \"Ok\": [\n [\n {\n \"data\": [\n 45,\n 1\n ]\n },\n 1\n ]\n ]\n },\n \"typ\": {\n \"column_types\": [\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n }\n ],\n \"keys\": []\n }\n }\n }\n }\n ],\n \"sources\": []\n }\n },\n \"fast_path\": {\n \"text\": \"Explained Query (fast path):\\n Finish output=[#0]\\n Constant\\n - (1)\\n\\nTarget cluster: mz_catalog_server\\n\",\n \"json\": {\n \"plans\": [\n {\n \"id\": \"Explained Query (fast path)\",\n \"plan\": {\n \"Constant\": [\n {\n \"Ok\": [\n [\n {\n \"data\": [\n 45,\n 1\n ]\n },\n 1\n ]\n ]\n },\n {\n \"column_types\": [\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n }\n ],\n \"keys\": []\n }\n ]\n }\n }\n ],\n \"sources\": []\n }\n }\n }\n },\n \"insights\": {\n \"imports\": {},\n \"fast_path_clusters\": {},\n \"fast_path_limit\": null,\n \"persist_count\": []\n },\n \"cluster\": {\n \"name\": \"mz_catalog_server\",\n \"id\": {\n \"System\": 2\n }\n },\n \"redacted_sql\": \"SELECT ''\"\n}","code":"MZ001","severity":"notice"}} +{"type":"Notice","payload":{"message":"{\n \"plans\": {\n \"raw\": {\n \"text\": \"Finish output=[#0]\\n Map (1)\\n Constant\\n - ()\\n\\nTarget cluster: mz_catalog_server\\n\",\n \"json\": {\n \"Map\": {\n \"input\": {\n \"Constant\": {\n \"rows\": [\n {\n \"data\": []\n }\n ],\n \"typ\": {\n \"column_types\": [],\n \"keys\": []\n }\n }\n },\n \"scalars\": [\n {\n \"Literal\": [\n {\n \"data\": [\n 45,\n 1\n ]\n },\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n },\n null\n ]\n }\n ]\n }\n }\n },\n \"optimized\": {\n \"global\": {\n \"text\": \"t66:\\n Finish output=[#0]\\n ArrangeBy keys=[[#0]]\\n ReadGlobalFromSameDataflow t65\\n\\nt65:\\n Constant\\n - (1)\\n\\nTarget cluster: mz_catalog_server\\n\",\n \"json\": {\n \"plans\": [\n {\n \"id\": \"t66\",\n \"plan\": {\n \"ArrangeBy\": {\n \"input\": {\n \"Get\": {\n \"id\": {\n \"Global\": {\n \"Transient\": 65\n }\n },\n \"typ\": {\n \"column_types\": [\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n }\n ],\n \"keys\": [\n []\n ]\n },\n \"access_strategy\": \"SameDataflow\"\n }\n },\n \"keys\": [\n [\n {\n \"Column\": [\n 0,\n null\n ]\n }\n ]\n ]\n }\n }\n },\n {\n \"id\": \"t65\",\n \"plan\": {\n \"Constant\": {\n \"rows\": {\n \"Ok\": [\n [\n {\n \"data\": [\n 45,\n 1\n ]\n },\n 1\n ]\n ]\n },\n \"typ\": {\n \"column_types\": [\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n }\n ],\n \"keys\": []\n }\n }\n }\n }\n ],\n \"sources\": []\n }\n },\n \"fast_path\": {\n \"text\": \"Explained Query (fast path):\\n Finish output=[#0]\\n Constant\\n - (1)\\n\\nTarget cluster: mz_catalog_server\\n\",\n \"json\": {\n \"plans\": [\n {\n \"id\": \"Explained Query (fast path)\",\n \"plan\": {\n \"Constant\": [\n {\n \"Ok\": [\n [\n {\n \"data\": [\n 45,\n 1\n ]\n },\n 1\n ]\n ]\n },\n {\n \"column_types\": [\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n }\n ],\n \"keys\": []\n }\n ]\n }\n }\n ],\n \"sources\": []\n }\n }\n }\n },\n \"insights\": {\n \"imports\": {},\n \"fast_path_clusters\": {},\n \"fast_path_limit\": null,\n \"persist_count\": []\n },\n \"cluster\": {\n \"name\": \"mz_catalog_server\",\n \"id\": {\n \"System\": 2\n }\n },\n \"redacted_sql\": \"SELECT ''\"\n}","code":"MZ001","severity":"notice"}} {"type":"CommandStarting","payload":{"has_rows":true,"is_streaming":false}} {"type":"Rows","payload":{"columns":[{"name":"?column?","type_oid":23,"type_len":4,"type_mod":-1}]}} {"type":"Row","payload":["1"]} @@ -394,7 +394,7 @@ ws-text ws-text {"query": "SELECT 1 / 0"} ---- -{"type":"Notice","payload":{"message":"{\n \"plans\": {\n \"raw\": {\n \"text\": \"Finish output=[#0]\\n Map ((1 / 0))\\n Constant\\n - ()\\n\\nTarget cluster: quickstart\\n\",\n \"json\": {\n \"Map\": {\n \"input\": {\n \"Constant\": {\n \"rows\": [\n {\n \"data\": []\n }\n ],\n \"typ\": {\n \"column_types\": [],\n \"keys\": []\n }\n }\n },\n \"scalars\": [\n {\n \"CallBinary\": {\n \"func\": \"DivInt32\",\n \"expr1\": {\n \"Literal\": [\n {\n \"data\": [\n 45,\n 1\n ]\n },\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n }\n ]\n },\n \"expr2\": {\n \"Literal\": [\n {\n \"data\": [\n 44\n ]\n },\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n }\n ]\n }\n }\n }\n ]\n }\n }\n },\n \"optimized\": {\n \"global\": {\n \"text\": \"t69:\\n Finish output=[#0]\\n ArrangeBy keys=[[#0]]\\n ReadGlobalFromSameDataflow t68\\n\\nt68:\\n Error \\\"division by zero\\\"\\n\\nTarget cluster: quickstart\\n\",\n \"json\": {\n \"plans\": [\n {\n \"id\": \"t69\",\n \"plan\": {\n \"ArrangeBy\": {\n \"input\": {\n \"Get\": {\n \"id\": {\n \"Global\": {\n \"Transient\": 68\n }\n },\n \"typ\": {\n \"column_types\": [\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n }\n ],\n \"keys\": []\n },\n \"access_strategy\": \"SameDataflow\"\n }\n },\n \"keys\": [\n [\n {\n \"Column\": 0\n }\n ]\n ]\n }\n }\n },\n {\n \"id\": \"t68\",\n \"plan\": {\n \"Constant\": {\n \"rows\": {\n \"Err\": \"DivisionByZero\"\n },\n \"typ\": {\n \"column_types\": [\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n }\n ],\n \"keys\": []\n }\n }\n }\n }\n ],\n \"sources\": []\n }\n },\n \"fast_path\": {\n \"text\": \"Explained Query (fast path):\\n Finish output=[#0]\\n Error \\\"division by zero\\\"\\n\\nTarget cluster: quickstart\\n\",\n \"json\": {\n \"plans\": [\n {\n \"id\": \"Explained Query (fast path)\",\n \"plan\": {\n \"Constant\": [\n {\n \"Err\": \"DivisionByZero\"\n },\n {\n \"column_types\": [\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n }\n ],\n \"keys\": []\n }\n ]\n }\n }\n ],\n \"sources\": []\n }\n }\n }\n },\n \"insights\": {\n \"imports\": {},\n \"fast_path_clusters\": {},\n \"fast_path_limit\": null,\n \"persist_count\": []\n },\n \"cluster\": {\n \"name\": \"quickstart\",\n \"id\": {\n \"User\": 1\n }\n },\n \"redacted_sql\": \"SELECT '' / ''\"\n}","code":"MZ001","severity":"notice"}} +{"type":"Notice","payload":{"message":"{\n \"plans\": {\n \"raw\": {\n \"text\": \"Finish output=[#0]\\n Map ((1 / 0))\\n Constant\\n - ()\\n\\nTarget cluster: quickstart\\n\",\n \"json\": {\n \"Map\": {\n \"input\": {\n \"Constant\": {\n \"rows\": [\n {\n \"data\": []\n }\n ],\n \"typ\": {\n \"column_types\": [],\n \"keys\": []\n }\n }\n },\n \"scalars\": [\n {\n \"CallBinary\": {\n \"func\": \"DivInt32\",\n \"expr1\": {\n \"Literal\": [\n {\n \"data\": [\n 45,\n 1\n ]\n },\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n },\n null\n ]\n },\n \"expr2\": {\n \"Literal\": [\n {\n \"data\": [\n 44\n ]\n },\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n },\n null\n ]\n },\n \"name\": null\n }\n }\n ]\n }\n }\n },\n \"optimized\": {\n \"global\": {\n \"text\": \"t69:\\n Finish output=[#0]\\n ArrangeBy keys=[[#0]]\\n ReadGlobalFromSameDataflow t68\\n\\nt68:\\n Error \\\"division by zero\\\"\\n\\nTarget cluster: quickstart\\n\",\n \"json\": {\n \"plans\": [\n {\n \"id\": \"t69\",\n \"plan\": {\n \"ArrangeBy\": {\n \"input\": {\n \"Get\": {\n \"id\": {\n \"Global\": {\n \"Transient\": 68\n }\n },\n \"typ\": {\n \"column_types\": [\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n }\n ],\n \"keys\": []\n },\n \"access_strategy\": \"SameDataflow\"\n }\n },\n \"keys\": [\n [\n {\n \"Column\": [\n 0,\n null\n ]\n }\n ]\n ]\n }\n }\n },\n {\n \"id\": \"t68\",\n \"plan\": {\n \"Constant\": {\n \"rows\": {\n \"Err\": \"DivisionByZero\"\n },\n \"typ\": {\n \"column_types\": [\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n }\n ],\n \"keys\": []\n }\n }\n }\n }\n ],\n \"sources\": []\n }\n },\n \"fast_path\": {\n \"text\": \"Explained Query (fast path):\\n Finish output=[#0]\\n Error \\\"division by zero\\\"\\n\\nTarget cluster: quickstart\\n\",\n \"json\": {\n \"plans\": [\n {\n \"id\": \"Explained Query (fast path)\",\n \"plan\": {\n \"Constant\": [\n {\n \"Err\": \"DivisionByZero\"\n },\n {\n \"column_types\": [\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n }\n ],\n \"keys\": []\n }\n ]\n }\n }\n ],\n \"sources\": []\n }\n }\n }\n },\n \"insights\": {\n \"imports\": {},\n \"fast_path_clusters\": {},\n \"fast_path_limit\": null,\n \"persist_count\": []\n },\n \"cluster\": {\n \"name\": \"quickstart\",\n \"id\": {\n \"User\": 1\n }\n },\n \"redacted_sql\": \"SELECT '' / ''\"\n}","code":"MZ001","severity":"notice"}} {"type":"CommandStarting","payload":{"has_rows":false,"is_streaming":false}} {"type":"Error","payload":{"message":"division by zero","code":"XX000"}} {"type":"ReadyForQuery","payload":"I"} @@ -402,7 +402,7 @@ ws-text ws-text {"query": "SELECT 1 FROM mz_sources LIMIT 1"} ---- -{"type":"Notice","payload":{"message":"{\n \"plans\": {\n \"raw\": {\n \"text\": \"Finish limit=1 output=[#0]\\n Project (#15)\\n Map (1)\\n Get mz_catalog.mz_sources\\n\\nTarget cluster: mz_catalog_server\\n\",\n \"json\": {\n \"Project\": {\n \"input\": {\n \"Map\": {\n \"input\": {\n \"Get\": {\n \"id\": {\n \"Global\": {\n \"System\": 466\n }\n },\n \"typ\": {\n \"column_types\": [\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"Oid\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": {\n \"Array\": \"MzAclItem\"\n },\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n }\n ],\n \"keys\": [\n [\n 0\n ],\n [\n 1\n ]\n ]\n }\n }\n },\n \"scalars\": [\n {\n \"Literal\": [\n {\n \"data\": [\n 45,\n 1\n ]\n },\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n }\n ]\n }\n ]\n }\n },\n \"outputs\": [\n 15\n ]\n }\n }\n },\n \"optimized\": {\n \"global\": {\n \"text\": \"t72:\\n Finish limit=1 output=[#0]\\n ArrangeBy keys=[[#0]]\\n ReadGlobalFromSameDataflow t71\\n\\nt71:\\n Project (#15)\\n Map (1)\\n ReadIndex on=mz_sources mz_sources_ind=[*** full scan ***]\\n\\nTarget cluster: mz_catalog_server\\n\",\n \"json\": {\n \"plans\": [\n {\n \"id\": \"t72\",\n \"plan\": {\n \"ArrangeBy\": {\n \"input\": {\n \"Get\": {\n \"id\": {\n \"Global\": {\n \"Transient\": 71\n }\n },\n \"typ\": {\n \"column_types\": [\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n }\n ],\n \"keys\": []\n },\n \"access_strategy\": \"SameDataflow\"\n }\n },\n \"keys\": [\n [\n {\n \"Column\": 0\n }\n ]\n ]\n }\n }\n },\n {\n \"id\": \"t71\",\n \"plan\": {\n \"Project\": {\n \"input\": {\n \"Map\": {\n \"input\": {\n \"Get\": {\n \"id\": {\n \"Global\": {\n \"System\": 466\n }\n },\n \"typ\": {\n \"column_types\": [\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"Oid\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": {\n \"Array\": \"MzAclItem\"\n },\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n }\n ],\n \"keys\": [\n [\n 0\n ],\n [\n 1\n ]\n ]\n },\n \"access_strategy\": {\n \"Index\": [\n [\n {\n \"System\": 747\n },\n \"FullScan\"\n ]\n ]\n }\n }\n },\n \"scalars\": [\n {\n \"Literal\": [\n {\n \"Ok\": {\n \"data\": [\n 45,\n 1\n ]\n }\n },\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n }\n ]\n }\n ]\n }\n },\n \"outputs\": [\n 15\n ]\n }\n }\n }\n ],\n \"sources\": []\n }\n },\n \"fast_path\": {\n \"text\": \"Explained Query (fast path):\\n Finish limit=1 output=[#0]\\n Project (#15)\\n Map (1)\\n ReadIndex on=mz_catalog.mz_sources mz_sources_ind=[*** full scan ***]\\n\\nTarget cluster: mz_catalog_server\\n\",\n \"json\": {\n \"plans\": [\n {\n \"id\": \"Explained Query (fast path)\",\n \"plan\": {\n \"PeekExisting\": [\n {\n \"System\": 466\n },\n {\n \"System\": 747\n },\n null,\n {\n \"mfp\": {\n \"expressions\": [\n {\n \"Literal\": [\n {\n \"Ok\": {\n \"data\": [\n 45,\n 1\n ]\n }\n },\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n }\n ]\n }\n ],\n \"predicates\": [],\n \"projection\": [\n 15\n ],\n \"input_arity\": 15\n }\n }\n ]\n }\n }\n ],\n \"sources\": []\n }\n }\n }\n },\n \"insights\": {\n \"imports\": {\n \"s747\": {\n \"name\": {\n \"schema\": \"mz_catalog\",\n \"item\": \"mz_sources_ind\"\n },\n \"type\": \"compute\"\n }\n },\n \"fast_path_clusters\": {},\n \"fast_path_limit\": null,\n \"persist_count\": []\n },\n \"cluster\": {\n \"name\": \"mz_catalog_server\",\n \"id\": {\n \"System\": 2\n }\n },\n \"redacted_sql\": \"SELECT '' FROM [s466 AS mz_catalog.mz_sources] LIMIT ''\"\n}","code":"MZ001","severity":"notice"}} +{"type":"Notice","payload":{"message":"{\n \"plans\": {\n \"raw\": {\n \"text\": \"Finish limit=1 output=[#0]\\n Project (#15)\\n Map (1)\\n Get mz_catalog.mz_sources\\n\\nTarget cluster: mz_catalog_server\\n\",\n \"json\": {\n \"Project\": {\n \"input\": {\n \"Map\": {\n \"input\": {\n \"Get\": {\n \"id\": {\n \"Global\": {\n \"System\": 466\n }\n },\n \"typ\": {\n \"column_types\": [\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"Oid\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": {\n \"Array\": \"MzAclItem\"\n },\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n }\n ],\n \"keys\": [\n [\n 0\n ],\n [\n 1\n ]\n ]\n }\n }\n },\n \"scalars\": [\n {\n \"Literal\": [\n {\n \"data\": [\n 45,\n 1\n ]\n },\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n },\n null\n ]\n }\n ]\n }\n },\n \"outputs\": [\n 15\n ]\n }\n }\n },\n \"optimized\": {\n \"global\": {\n \"text\": \"t72:\\n Finish limit=1 output=[#0]\\n ArrangeBy keys=[[#0]]\\n ReadGlobalFromSameDataflow t71\\n\\nt71:\\n Project (#15)\\n Map (1)\\n ReadIndex on=mz_sources mz_sources_ind=[*** full scan ***]\\n\\nTarget cluster: mz_catalog_server\\n\",\n \"json\": {\n \"plans\": [\n {\n \"id\": \"t72\",\n \"plan\": {\n \"ArrangeBy\": {\n \"input\": {\n \"Get\": {\n \"id\": {\n \"Global\": {\n \"Transient\": 71\n }\n },\n \"typ\": {\n \"column_types\": [\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n }\n ],\n \"keys\": []\n },\n \"access_strategy\": \"SameDataflow\"\n }\n },\n \"keys\": [\n [\n {\n \"Column\": [\n 0,\n null\n ]\n }\n ]\n ]\n }\n }\n },\n {\n \"id\": \"t71\",\n \"plan\": {\n \"Project\": {\n \"input\": {\n \"Map\": {\n \"input\": {\n \"Get\": {\n \"id\": {\n \"Global\": {\n \"System\": 466\n }\n },\n \"typ\": {\n \"column_types\": [\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"Oid\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": {\n \"Array\": \"MzAclItem\"\n },\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n }\n ],\n \"keys\": [\n [\n 0\n ],\n [\n 1\n ]\n ]\n },\n \"access_strategy\": {\n \"Index\": [\n [\n {\n \"System\": 747\n },\n \"FullScan\"\n ]\n ]\n }\n }\n },\n \"scalars\": [\n {\n \"Literal\": [\n {\n \"Ok\": {\n \"data\": [\n 45,\n 1\n ]\n }\n },\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n }\n ]\n }\n ]\n }\n },\n \"outputs\": [\n 15\n ]\n }\n }\n }\n ],\n \"sources\": []\n }\n },\n \"fast_path\": {\n \"text\": \"Explained Query (fast path):\\n Finish limit=1 output=[#0]\\n Project (#15)\\n Map (1)\\n ReadIndex on=mz_catalog.mz_sources mz_sources_ind=[*** full scan ***]\\n\\nTarget cluster: mz_catalog_server\\n\",\n \"json\": {\n \"plans\": [\n {\n \"id\": \"Explained Query (fast path)\",\n \"plan\": {\n \"PeekExisting\": [\n {\n \"System\": 466\n },\n {\n \"System\": 747\n },\n null,\n {\n \"mfp\": {\n \"expressions\": [\n {\n \"Literal\": [\n {\n \"Ok\": {\n \"data\": [\n 45,\n 1\n ]\n }\n },\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n }\n ]\n }\n ],\n \"predicates\": [],\n \"projection\": [\n 15\n ],\n \"input_arity\": 15\n }\n }\n ]\n }\n }\n ],\n \"sources\": []\n }\n }\n }\n },\n \"insights\": {\n \"imports\": {\n \"s747\": {\n \"name\": {\n \"schema\": \"mz_catalog\",\n \"item\": \"mz_sources_ind\"\n },\n \"type\": \"compute\"\n }\n },\n \"fast_path_clusters\": {},\n \"fast_path_limit\": null,\n \"persist_count\": []\n },\n \"cluster\": {\n \"name\": \"mz_catalog_server\",\n \"id\": {\n \"System\": 2\n }\n },\n \"redacted_sql\": \"SELECT '' FROM [s466 AS mz_catalog.mz_sources] LIMIT ''\"\n}","code":"MZ001","severity":"notice"}} {"type":"CommandStarting","payload":{"has_rows":true,"is_streaming":false}} {"type":"Rows","payload":{"columns":[{"name":"?column?","type_oid":23,"type_len":4,"type_mod":-1}]}} {"type":"Row","payload":["1"]} @@ -412,7 +412,7 @@ ws-text ws-text {"query": "SELECT 1 / 0 FROM mz_sources LIMIT 1"} ---- -{"type":"Notice","payload":{"message":"{\n \"plans\": {\n \"raw\": {\n \"text\": \"Finish limit=1 output=[#0]\\n Project (#15)\\n Map ((1 / 0))\\n Get mz_catalog.mz_sources\\n\\nTarget cluster: mz_catalog_server\\n\",\n \"json\": {\n \"Project\": {\n \"input\": {\n \"Map\": {\n \"input\": {\n \"Get\": {\n \"id\": {\n \"Global\": {\n \"System\": 466\n }\n },\n \"typ\": {\n \"column_types\": [\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"Oid\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": {\n \"Array\": \"MzAclItem\"\n },\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n }\n ],\n \"keys\": [\n [\n 0\n ],\n [\n 1\n ]\n ]\n }\n }\n },\n \"scalars\": [\n {\n \"CallBinary\": {\n \"func\": \"DivInt32\",\n \"expr1\": {\n \"Literal\": [\n {\n \"data\": [\n 45,\n 1\n ]\n },\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n }\n ]\n },\n \"expr2\": {\n \"Literal\": [\n {\n \"data\": [\n 44\n ]\n },\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n }\n ]\n }\n }\n }\n ]\n }\n },\n \"outputs\": [\n 15\n ]\n }\n }\n },\n \"optimized\": {\n \"global\": {\n \"text\": \"t75:\\n Finish limit=1 output=[#0]\\n ArrangeBy keys=[[#0]]\\n ReadGlobalFromSameDataflow t74\\n\\nt74:\\n Project (#15)\\n Map (error(\\\"division by zero\\\"))\\n ReadIndex on=mz_sources mz_sources_ind=[*** full scan ***]\\n\\nTarget cluster: mz_catalog_server\\n\",\n \"json\": {\n \"plans\": [\n {\n \"id\": \"t75\",\n \"plan\": {\n \"ArrangeBy\": {\n \"input\": {\n \"Get\": {\n \"id\": {\n \"Global\": {\n \"Transient\": 74\n }\n },\n \"typ\": {\n \"column_types\": [\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n }\n ],\n \"keys\": []\n },\n \"access_strategy\": \"SameDataflow\"\n }\n },\n \"keys\": [\n [\n {\n \"Column\": 0\n }\n ]\n ]\n }\n }\n },\n {\n \"id\": \"t74\",\n \"plan\": {\n \"Project\": {\n \"input\": {\n \"Map\": {\n \"input\": {\n \"Get\": {\n \"id\": {\n \"Global\": {\n \"System\": 466\n }\n },\n \"typ\": {\n \"column_types\": [\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"Oid\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": {\n \"Array\": \"MzAclItem\"\n },\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n }\n ],\n \"keys\": [\n [\n 0\n ],\n [\n 1\n ]\n ]\n },\n \"access_strategy\": {\n \"Index\": [\n [\n {\n \"System\": 747\n },\n \"FullScan\"\n ]\n ]\n }\n }\n },\n \"scalars\": [\n {\n \"Literal\": [\n {\n \"Err\": \"DivisionByZero\"\n },\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n }\n ]\n }\n ]\n }\n },\n \"outputs\": [\n 15\n ]\n }\n }\n }\n ],\n \"sources\": []\n }\n },\n \"fast_path\": {\n \"text\": \"Explained Query (fast path):\\n Finish limit=1 output=[#0]\\n Project (#15)\\n Map (error(\\\"division by zero\\\"))\\n ReadIndex on=mz_catalog.mz_sources mz_sources_ind=[*** full scan ***]\\n\\nTarget cluster: mz_catalog_server\\n\",\n \"json\": {\n \"plans\": [\n {\n \"id\": \"Explained Query (fast path)\",\n \"plan\": {\n \"PeekExisting\": [\n {\n \"System\": 466\n },\n {\n \"System\": 747\n },\n null,\n {\n \"mfp\": {\n \"expressions\": [\n {\n \"Literal\": [\n {\n \"Err\": \"DivisionByZero\"\n },\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n }\n ]\n }\n ],\n \"predicates\": [],\n \"projection\": [\n 15\n ],\n \"input_arity\": 15\n }\n }\n ]\n }\n }\n ],\n \"sources\": []\n }\n }\n }\n },\n \"insights\": {\n \"imports\": {\n \"s747\": {\n \"name\": {\n \"schema\": \"mz_catalog\",\n \"item\": \"mz_sources_ind\"\n },\n \"type\": \"compute\"\n }\n },\n \"fast_path_clusters\": {},\n \"fast_path_limit\": null,\n \"persist_count\": []\n },\n \"cluster\": {\n \"name\": \"mz_catalog_server\",\n \"id\": {\n \"System\": 2\n }\n },\n \"redacted_sql\": \"SELECT '' / '' FROM [s466 AS mz_catalog.mz_sources] LIMIT ''\"\n}","code":"MZ001","severity":"notice"}} +{"type":"Notice","payload":{"message":"{\n \"plans\": {\n \"raw\": {\n \"text\": \"Finish limit=1 output=[#0]\\n Project (#15)\\n Map ((1 / 0))\\n Get mz_catalog.mz_sources\\n\\nTarget cluster: mz_catalog_server\\n\",\n \"json\": {\n \"Project\": {\n \"input\": {\n \"Map\": {\n \"input\": {\n \"Get\": {\n \"id\": {\n \"Global\": {\n \"System\": 466\n }\n },\n \"typ\": {\n \"column_types\": [\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"Oid\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": {\n \"Array\": \"MzAclItem\"\n },\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n }\n ],\n \"keys\": [\n [\n 0\n ],\n [\n 1\n ]\n ]\n }\n }\n },\n \"scalars\": [\n {\n \"CallBinary\": {\n \"func\": \"DivInt32\",\n \"expr1\": {\n \"Literal\": [\n {\n \"data\": [\n 45,\n 1\n ]\n },\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n },\n null\n ]\n },\n \"expr2\": {\n \"Literal\": [\n {\n \"data\": [\n 44\n ]\n },\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n },\n null\n ]\n },\n \"name\": null\n }\n }\n ]\n }\n },\n \"outputs\": [\n 15\n ]\n }\n }\n },\n \"optimized\": {\n \"global\": {\n \"text\": \"t75:\\n Finish limit=1 output=[#0]\\n ArrangeBy keys=[[#0]]\\n ReadGlobalFromSameDataflow t74\\n\\nt74:\\n Project (#15)\\n Map (error(\\\"division by zero\\\"))\\n ReadIndex on=mz_sources mz_sources_ind=[*** full scan ***]\\n\\nTarget cluster: mz_catalog_server\\n\",\n \"json\": {\n \"plans\": [\n {\n \"id\": \"t75\",\n \"plan\": {\n \"ArrangeBy\": {\n \"input\": {\n \"Get\": {\n \"id\": {\n \"Global\": {\n \"Transient\": 74\n }\n },\n \"typ\": {\n \"column_types\": [\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n }\n ],\n \"keys\": []\n },\n \"access_strategy\": \"SameDataflow\"\n }\n },\n \"keys\": [\n [\n {\n \"Column\": [\n 0,\n null\n ]\n }\n ]\n ]\n }\n }\n },\n {\n \"id\": \"t74\",\n \"plan\": {\n \"Project\": {\n \"input\": {\n \"Map\": {\n \"input\": {\n \"Get\": {\n \"id\": {\n \"Global\": {\n \"System\": 466\n }\n },\n \"typ\": {\n \"column_types\": [\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"Oid\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": false\n },\n {\n \"scalar_type\": {\n \"Array\": \"MzAclItem\"\n },\n \"nullable\": false\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n },\n {\n \"scalar_type\": \"String\",\n \"nullable\": true\n }\n ],\n \"keys\": [\n [\n 0\n ],\n [\n 1\n ]\n ]\n },\n \"access_strategy\": {\n \"Index\": [\n [\n {\n \"System\": 747\n },\n \"FullScan\"\n ]\n ]\n }\n }\n },\n \"scalars\": [\n {\n \"Literal\": [\n {\n \"Err\": \"DivisionByZero\"\n },\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n }\n ]\n }\n ]\n }\n },\n \"outputs\": [\n 15\n ]\n }\n }\n }\n ],\n \"sources\": []\n }\n },\n \"fast_path\": {\n \"text\": \"Explained Query (fast path):\\n Finish limit=1 output=[#0]\\n Project (#15)\\n Map (error(\\\"division by zero\\\"))\\n ReadIndex on=mz_catalog.mz_sources mz_sources_ind=[*** full scan ***]\\n\\nTarget cluster: mz_catalog_server\\n\",\n \"json\": {\n \"plans\": [\n {\n \"id\": \"Explained Query (fast path)\",\n \"plan\": {\n \"PeekExisting\": [\n {\n \"System\": 466\n },\n {\n \"System\": 747\n },\n null,\n {\n \"mfp\": {\n \"expressions\": [\n {\n \"Literal\": [\n {\n \"Err\": \"DivisionByZero\"\n },\n {\n \"scalar_type\": \"Int32\",\n \"nullable\": false\n }\n ]\n }\n ],\n \"predicates\": [],\n \"projection\": [\n 15\n ],\n \"input_arity\": 15\n }\n }\n ]\n }\n }\n ],\n \"sources\": []\n }\n }\n }\n },\n \"insights\": {\n \"imports\": {\n \"s747\": {\n \"name\": {\n \"schema\": \"mz_catalog\",\n \"item\": \"mz_sources_ind\"\n },\n \"type\": \"compute\"\n }\n },\n \"fast_path_clusters\": {},\n \"fast_path_limit\": null,\n \"persist_count\": []\n },\n \"cluster\": {\n \"name\": \"mz_catalog_server\",\n \"id\": {\n \"System\": 2\n }\n },\n \"redacted_sql\": \"SELECT '' / '' FROM [s466 AS mz_catalog.mz_sources] LIMIT ''\"\n}","code":"MZ001","severity":"notice"}} {"type":"CommandStarting","payload":{"has_rows":false,"is_streaming":false}} {"type":"Error","payload":{"message":"division by zero","code":"XX000"}} {"type":"ReadyForQuery","payload":"I"} diff --git a/src/expr-parser/src/parser.rs b/src/expr-parser/src/parser.rs index 51cc7b95f8266..3658763d13712 100644 --- a/src/expr-parser/src/parser.rs +++ b/src/expr-parser/src/parser.rs @@ -973,7 +973,7 @@ mod scalar { } pub fn parse_column(input: ParseStream) -> Result { - Ok(MirScalarExpr::Column(parse_column_index(input)?)) + Ok(MirScalarExpr::column(parse_column_index(input)?)) } pub fn parse_column_index(input: ParseStream) -> syn::Result { diff --git a/src/expr-test-util/src/lib.rs b/src/expr-test-util/src/lib.rs index 704b909341c10..442f2a579cb01 100644 --- a/src/expr-test-util/src/lib.rs +++ b/src/expr-test-util/src/lib.rs @@ -217,7 +217,7 @@ pub struct MirScalarExprDeserializeContext; impl MirScalarExprDeserializeContext { fn build_column(&self, token: Option) -> Result { if let Some(TokenTree::Literal(literal)) = token { - return Ok(MirScalarExpr::Column( + return Ok(MirScalarExpr::column( literal .to_string() .parse::() @@ -321,7 +321,12 @@ impl TestDeserializeContext for MirScalarExprDeserializeContext { assert_eq!(map.len(), 1); for (variant, data) in map.iter() { match &variant[..] { - "Column" => return Some(format!("#{}", data.as_u64().unwrap())), + "Column" => { + return Some(format!( + "#{}", + data.as_array().unwrap()[0].as_u64().unwrap() + )); + } "Literal" => { let column_type: ColumnType = serde_json::from_value(data.as_array().unwrap()[1].clone()).unwrap(); diff --git a/src/expr/src/explain.rs b/src/expr/src/explain.rs index bfbb20078d732..edfbeb983c6e2 100644 --- a/src/expr/src/explain.rs +++ b/src/expr/src/explain.rs @@ -302,14 +302,14 @@ fn id_gen(expr: &MirRelationExpr) -> impl Iterator + use<> { impl ScalarOps for MirScalarExpr { fn match_col_ref(&self) -> Option { match self { - MirScalarExpr::Column(c) => Some(*c), + MirScalarExpr::Column(c, _name) => Some(*c), _ => None, } } fn references(&self, column: usize) -> bool { match self { - MirScalarExpr::Column(c) => *c == column, + MirScalarExpr::Column(c, _name) => *c == column, _ => false, } } diff --git a/src/expr/src/explain/text.rs b/src/expr/src/explain/text.rs index c1ab438adca34..5db392ac2840a 100644 --- a/src/expr/src/explain/text.rs +++ b/src/expr/src/explain/text.rs @@ -11,9 +11,11 @@ use std::collections::BTreeMap; use std::fmt; +use std::sync::Arc; use mz_ore::soft_assert_eq_or_log; use mz_ore::str::{Indent, IndentLike, StrExt, closure_to_display, separated}; +use mz_ore::treat_as_equal::TreatAsEqual; use mz_repr::explain::text::DisplayText; use mz_repr::explain::{ CompactScalars, ExprHumanizer, HumanizedAnalyses, IndexUsageType, Indices, @@ -1173,6 +1175,31 @@ where } } +// A column reference with a stored name. +// We defer to the inferred name, if available. +impl<'a, M> fmt::Display for HumanizedExpr<'a, (&usize, &Arc), M> +where + M: HumanizerMode, +{ + #[inline] + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self.cols { + // We have a name inferred for the column indexed by `self.expr`. Write `ident`. + Some(cols) if cols.len() > *self.expr.0 && !cols[*self.expr.0].is_empty() => { + // Note: using unchecked here is okay since we're directly + // converting to a string afterwards. + let ident = Ident::new_unchecked(cols[*self.expr.0].clone()); // TODO: try to avoid the `.clone()` here. + M::humanize_ident(*self.expr.0, ident, f) + } + // We don't have name inferred for this column. + _ => { + // Write the stored name. + write!(f, "#{}{{{}}}", self.expr.0, self.expr.1) + } + } + } +} + impl<'a, M> ScalarOps for HumanizedExpr<'a, MirScalarExpr, M> { fn match_col_ref(&self) -> Option { self.expr.match_col_ref() @@ -1201,10 +1228,14 @@ where use MirScalarExpr::*; match self.expr { - Column(i) => { - // Delegate to the `HumanizedExpr<'a, _>` implementation. + Column(i, TreatAsEqual(None)) => { + // Delegate to the `HumanizedExpr<'a, _>` implementation (plain column reference). self.child(i).fmt(f) } + Column(i, TreatAsEqual(Some(name))) => { + // Delegate to the `HumanizedExpr<'a, _>` implementation (with stored name information) + self.child(&(i, name)).fmt(f) + } Literal(row, _) => { // Delegate to the `HumanizedExpr<'a, _>` implementation. self.child(row).fmt(f) diff --git a/src/expr/src/interpret.rs b/src/expr/src/interpret.rs index 7b36373af42b7..bf3bc1555ac42 100644 --- a/src/expr/src/interpret.rs +++ b/src/expr/src/interpret.rs @@ -395,7 +395,7 @@ pub trait Interpreter { /// Evaluate an entire expression, by delegating to the fine-grained methods on [Interpreter]. fn expr(&self, expr: &MirScalarExpr) -> Self::Summary { match expr { - MirScalarExpr::Column(id) => self.column(*id), + MirScalarExpr::Column(id, _name) => self.column(*id), MirScalarExpr::Literal(value, col_type) => self.literal(value, col_type), MirScalarExpr::CallUnmaterializable(func) => self.unmaterializable(func), MirScalarExpr::CallUnary { func, expr } => { @@ -559,7 +559,7 @@ impl SpecialUnary { func: UnaryFunc::TryParseMonotonicIso8601Timestamp( crate::func::TryParseMonotonicIso8601Timestamp, ), - expr: Box::new(MirScalarExpr::Column(0)), + expr: Box::new(MirScalarExpr::column(0)), }; let eval = |d| specs.eval_result(expr.eval(&[d], specs.arena)); @@ -1268,7 +1268,7 @@ mod tests { any::() .prop_map(move |idx| { let id = idx.index(column_types.len()); - (MirScalarExpr::Column(id), column_types[id].clone()) + (MirScalarExpr::column(id), column_types[id].clone()) }) .boxed() }; @@ -1443,8 +1443,8 @@ mod tests { func: UnaryFunc::IsNull(IsNull), expr: Box::new(CallBinary { func: BinaryFunc::MulInt32, - expr1: Box::new(Column(0)), - expr2: Box::new(Column(0)), + expr1: Box::new(MirScalarExpr::column(0)), + expr2: Box::new(MirScalarExpr::column(0)), }), }, ), @@ -1453,7 +1453,7 @@ mod tests { 1, CallBinary { func: BinaryFunc::Eq, - expr1: Box::new(Column(0)), + expr1: Box::new(MirScalarExpr::column(0)), expr2: Box::new(Literal( Ok(Row::pack_slice(&[Datum::Int32(1727694505)])), ScalarType::Int32.nullable(false), @@ -1478,7 +1478,7 @@ mod tests { let expr = MirScalarExpr::CallVariadic { func: VariadicFunc::Concat, exprs: vec![ - MirScalarExpr::Column(0), + MirScalarExpr::column(0), MirScalarExpr::literal_ok(Datum::String("a"), ScalarType::String), MirScalarExpr::literal_ok(Datum::String("b"), ScalarType::String), ], @@ -1510,7 +1510,7 @@ mod tests { expr1: Box::new(period_ms.clone()), expr2: Box::new(MirScalarExpr::CallBinary { func: BinaryFunc::DivInt64, - expr1: Box::new(MirScalarExpr::Column(0)), + expr1: Box::new(MirScalarExpr::column(0)), expr2: Box::new(period_ms), }), }), @@ -1568,7 +1568,7 @@ mod tests { func: UnaryFunc::CastJsonbToNumeric(CastJsonbToNumeric(None)), expr: Box::new(MirScalarExpr::CallBinary { func: BinaryFunc::JsonbGetString, - expr1: Box::new(MirScalarExpr::Column(0)), + expr1: Box::new(MirScalarExpr::column(0)), expr2: Box::new(MirScalarExpr::Literal( Ok(Row::pack_slice(&["ts".into()])), ScalarType::String.nullable(false), @@ -1607,7 +1607,7 @@ mod tests { func: UnaryFunc::IsLikeMatch(IsLikeMatch( crate::like_pattern::compile("%whatever%", true).unwrap(), )), - expr: Box::new(MirScalarExpr::Column(0)), + expr: Box::new(MirScalarExpr::column(0)), }; let relation = RelationType::new(vec![ScalarType::String.nullable(true)]); @@ -1635,7 +1635,7 @@ mod tests { let expr = MirScalarExpr::CallUnary { func: UnaryFunc::TryParseMonotonicIso8601Timestamp(TryParseMonotonicIso8601Timestamp), - expr: Box::new(MirScalarExpr::Column(0)), + expr: Box::new(MirScalarExpr::column(0)), }; let relation = RelationType::new(vec![ScalarType::String.nullable(true)]); @@ -1721,7 +1721,7 @@ mod tests { let expr = MirScalarExpr::CallBinary { func: BinaryFunc::Gte, - expr1: Box::new(MirScalarExpr::Column(0)), + expr1: Box::new(MirScalarExpr::column(0)), expr2: Box::new(MirScalarExpr::CallUnmaterializable( UnmaterializableFunc::MzNow, )), @@ -1761,13 +1761,13 @@ mod tests { let expr = MirScalarExpr::CallBinary { func: BinaryFunc::Gte, - expr1: Box::new(MirScalarExpr::Column(0)), + expr1: Box::new(MirScalarExpr::column(0)), expr2: Box::new(MirScalarExpr::CallBinary { func: BinaryFunc::AddInt64, - expr1: Box::new(MirScalarExpr::Column(1)), + expr1: Box::new(MirScalarExpr::column(1)), expr2: Box::new(MirScalarExpr::CallUnary { func: UnaryFunc::NegInt64(NegInt64), - expr: Box::new(MirScalarExpr::Column(3)), + expr: Box::new(MirScalarExpr::column(3)), }), }), }; diff --git a/src/expr/src/linear.rs b/src/expr/src/linear.rs index 8e5dc72e6e5fd..3ade6c88e528f 100644 --- a/src/expr/src/linear.rs +++ b/src/expr/src/linear.rs @@ -1037,14 +1037,14 @@ impl MapFilterProject { expr2, } = predicate { - if let MirScalarExpr::Column(c) = &**expr1 { + if let MirScalarExpr::Column(c, name) = &**expr1 { if *c < index + self.input_arity && &**expr2 == expr { - *expr = MirScalarExpr::Column(*c); + *expr = MirScalarExpr::Column(*c, name.clone()); } } - if let MirScalarExpr::Column(c) = &**expr2 { + if let MirScalarExpr::Column(c, name) = &**expr2 { if *c < index + self.input_arity && &**expr1 == expr { - *expr = MirScalarExpr::Column(*c); + *expr = MirScalarExpr::Column(*c, name.clone()); } } } @@ -1296,14 +1296,14 @@ impl MapFilterProject { // Increment reference counts for each use for expr in self.expressions.iter() { expr.visit_pre(|e| { - if let MirScalarExpr::Column(i) = e { + if let MirScalarExpr::Column(i, _name) = e { reference_count[*i] += 1; } }); } for (_, pred) in self.predicates.iter() { pred.visit_pre(|e| { - if let MirScalarExpr::Column(i) = e { + if let MirScalarExpr::Column(i, _name) = e { reference_count[*i] += 1; } }); @@ -1326,7 +1326,7 @@ impl MapFilterProject { // or 2c. reference temporal expressions (which cannot be evaluated). let mut should_inline = vec![false; reference_count.len()]; for i in (input_arity..reference_count.len()).rev() { - if let MirScalarExpr::Column(c) = self.expressions[i - input_arity] { + if let MirScalarExpr::Column(c, _) = self.expressions[i - input_arity] { should_inline[i] = true; // The reference count of the referenced column should be // incremented with the number of references @@ -1343,7 +1343,8 @@ impl MapFilterProject { // We can only inline column references in `self.projection`, but we should. for proj in self.projection.iter_mut() { if *proj >= self.input_arity { - if let MirScalarExpr::Column(i) = self.expressions[*proj - self.input_arity] { + if let MirScalarExpr::Column(i, _) = self.expressions[*proj - self.input_arity] { + // TODO(mgree) !!! propagate name information to projection *proj = i; } } @@ -1357,7 +1358,7 @@ impl MapFilterProject { let (prior, expr) = self.expressions.split_at_mut(index); #[allow(deprecated)] expr[0].visit_mut_post_nolimit(&mut |e| { - if let MirScalarExpr::Column(i) = e { + if let MirScalarExpr::Column(i, _name) = e { if should_inline[*i] { *e = prior[*i - self.input_arity].clone(); } @@ -1368,7 +1369,7 @@ impl MapFilterProject { let expressions = &self.expressions; #[allow(deprecated)] pred.visit_mut_post_nolimit(&mut |e| { - if let MirScalarExpr::Column(i) = e { + if let MirScalarExpr::Column(i, _name) = e { if should_inline[*i] { *e = expressions[*i - self.input_arity].clone(); } @@ -1496,11 +1497,13 @@ pub fn memoize_expr( MirScalarExpr::Literal(_, _) => { // Literals do not need to be memoized. } - MirScalarExpr::Column(col) => { + MirScalarExpr::Column(col, _) => { // Column references do not need to be memoized, but may need to be // updated if they reference a column reference themselves. if *col > input_arity { - if let MirScalarExpr::Column(col2) = memoized_parts[*col - input_arity] { + if let MirScalarExpr::Column(col2, _) = memoized_parts[*col - input_arity] { + // We do _not_ propagate column names, since mis-associationg names and column + // references will be very confusing (and possibly bug inducing). *col = col2; } } @@ -1509,13 +1512,13 @@ pub fn memoize_expr( if let Some(position) = memoized_parts.iter().position(|e2| e2 == e) { // Any complex expression that already exists as a prior column can // be replaced by a reference to that column. - *e = MirScalarExpr::Column(input_arity + position); + *e = MirScalarExpr::column(input_arity + position); } else { // A complex expression that does not exist should be memoized, and // replaced by a reference to the column. memoized_parts.push(std::mem::replace( e, - MirScalarExpr::Column(input_arity + memoized_parts.len()), + MirScalarExpr::column(input_arity + memoized_parts.len()), )); } } diff --git a/src/expr/src/relation.rs b/src/expr/src/relation.rs index 73224d405a635..d2dcfe63ad6ba 100644 --- a/src/expr/src/relation.rs +++ b/src/expr/src/relation.rs @@ -682,7 +682,7 @@ impl MirRelationExpr { let col_inds = equivalence .iter() .filter_map(|expr| match expr { - MirScalarExpr::Column(col) => Some(*col), + MirScalarExpr::Column(col, _name) => Some(*col), _ => None, }) .collect_vec(); @@ -838,7 +838,7 @@ impl MirRelationExpr { None } } - MirScalarExpr::Column(c) => Some(*c), + MirScalarExpr::Column(c, _name) => Some(*c), _ => None, } } @@ -905,12 +905,12 @@ impl MirRelationExpr { expr2, } = expr { - if let MirScalarExpr::Column(c) = &**expr1 { + if let MirScalarExpr::Column(c, _name) = &**expr1 { if expr2.is_literal_ok() { cols_equal_to_literal.insert(c); } } - if let MirScalarExpr::Column(c) = &**expr2 { + if let MirScalarExpr::Column(c, _name) = &**expr2 { if expr1.is_literal_ok() { cols_equal_to_literal.insert(c); } @@ -1024,7 +1024,7 @@ impl MirRelationExpr { for key_set in input_keys.next().unwrap() { if key_set .iter() - .all(|k| group_key.contains(&MirScalarExpr::Column(*k))) + .all(|k| group_key.contains(&MirScalarExpr::column(*k))) { result.push( key_set @@ -1032,7 +1032,7 @@ impl MirRelationExpr { .map(|i| { group_key .iter() - .position(|k| k == &MirScalarExpr::Column(*i)) + .position(|k| k == &MirScalarExpr::column(*i)) .unwrap() }) .collect::>(), @@ -1485,7 +1485,7 @@ impl MirRelationExpr { .into_iter() .map(|vs| { vs.into_iter() - .map(|(r, c)| input_mapper.map_expr_to_global(MirScalarExpr::Column(c), r)) + .map(|(r, c)| input_mapper.map_expr_to_global(MirScalarExpr::column(c), r)) .collect::>() }) .collect::>(); @@ -1521,7 +1521,7 @@ impl MirRelationExpr { ) -> Self { MirRelationExpr::Reduce { input: Box::new(self), - group_key: group_key.into_iter().map(MirScalarExpr::Column).collect(), + group_key: group_key.into_iter().map(MirScalarExpr::column).collect(), aggregates, monotonic: false, expected_group_size, @@ -2149,7 +2149,7 @@ impl MirRelationExpr { use MirScalarExpr::*; if let Err(_) = self.try_visit_scalars::<_, RecursionLimitError>(&mut |scalar| { result |= match scalar { - Column(_) | Literal(_, _) | CallUnmaterializable(_) | If { .. } => false, + Column(_, _) | Literal(_, _) | CallUnmaterializable(_) | If { .. } => false, // Function calls are considered expensive CallUnary { .. } | CallBinary { .. } | CallVariadic { .. } => true, }; @@ -2376,7 +2376,7 @@ pub fn non_nullable_columns(predicates: &[MirScalarExpr]) -> BTreeSet { expr, } = &**expr { - if let MirScalarExpr::Column(c) = &**expr { + if let MirScalarExpr::Column(c, _name) = &**expr { nonnull_required_columns.insert(*c); } } diff --git a/src/expr/src/relation/canonicalize.rs b/src/expr/src/relation/canonicalize.rs index 42b87b7860b93..914a5044091c9 100644 --- a/src/expr/src/relation/canonicalize.rs +++ b/src/expr/src/relation/canonicalize.rs @@ -111,16 +111,16 @@ pub fn canonicalize_equivalences<'a, I>( /// use mz_expr::canonicalize::canonicalize_equivalence_classes; /// /// let mut equivalences = vec![ -/// vec![MirScalarExpr::Column(1), MirScalarExpr::Column(4)], -/// vec![MirScalarExpr::Column(3), MirScalarExpr::Column(5)], -/// vec![MirScalarExpr::Column(0), MirScalarExpr::Column(3)], -/// vec![MirScalarExpr::Column(2), MirScalarExpr::Column(2)], +/// vec![MirScalarExpr::column(1), MirScalarExpr::column(4)], +/// vec![MirScalarExpr::column(3), MirScalarExpr::column(5)], +/// vec![MirScalarExpr::column(0), MirScalarExpr::column(3)], +/// vec![MirScalarExpr::column(2), MirScalarExpr::column(2)], /// ]; /// let expected = vec![ -/// vec![MirScalarExpr::Column(0), -/// MirScalarExpr::Column(3), -/// MirScalarExpr::Column(5)], -/// vec![MirScalarExpr::Column(1), MirScalarExpr::Column(4)], +/// vec![MirScalarExpr::column(0), +/// MirScalarExpr::column(3), +/// MirScalarExpr::column(5)], +/// vec![MirScalarExpr::column(1), MirScalarExpr::column(4)], /// ]; /// canonicalize_equivalence_classes(&mut equivalences); /// assert_eq!(expected, equivalences) diff --git a/src/expr/src/relation/join_input_mapper.rs b/src/expr/src/relation/join_input_mapper.rs index 5d5cc7fe7f415..41737c5a96c9a 100644 --- a/src/expr/src/relation/join_input_mapper.rs +++ b/src/expr/src/relation/join_input_mapper.rs @@ -129,7 +129,7 @@ impl JoinInputMapper { for expr in equivalence { // then store all columns in the constraint that don't come // from the first input - if let MirScalarExpr::Column(c) = expr { + if let MirScalarExpr::Column(c, _name) = expr { let (col, input) = self.map_column_to_local(*c); if input > min_bound_input { column_with_prior_bound_by_input[input - 1].insert(col); @@ -181,7 +181,7 @@ impl JoinInputMapper { /// Assumes that all columns in `expr` are from the same input. pub fn map_expr_to_local(&self, mut expr: MirScalarExpr) -> MirScalarExpr { expr.visit_pre_mut(|e| { - if let MirScalarExpr::Column(c) = e { + if let MirScalarExpr::Column(c, _name) = e { *c -= self.prior_arities[self.input_relation[*c]]; } }); @@ -193,7 +193,7 @@ impl JoinInputMapper { /// global context. pub fn map_expr_to_global(&self, mut expr: MirScalarExpr, index: usize) -> MirScalarExpr { expr.visit_pre_mut(|e| { - if let MirScalarExpr::Column(c) = e { + if let MirScalarExpr::Column(c, _name) = e { *c += self.prior_arities[index]; } }); @@ -281,18 +281,18 @@ impl JoinInputMapper { /// /// // [input0(#0) = input2(#1)], [input0(#1) = input1(#0) = input2(#0)] /// let equivalences = vec![ - /// vec![MirScalarExpr::Column(0), MirScalarExpr::Column(5)], - /// vec![MirScalarExpr::Column(1), MirScalarExpr::Column(2), MirScalarExpr::Column(4)], + /// vec![MirScalarExpr::column(0), MirScalarExpr::column(5)], + /// vec![MirScalarExpr::column(1), MirScalarExpr::column(2), MirScalarExpr::column(4)], /// ]; /// /// let input_mapper = JoinInputMapper::new(&[input0, input1, input2]); /// assert_eq!( - /// Some(MirScalarExpr::Column(4)), - /// input_mapper.find_bound_expr(&MirScalarExpr::Column(2), &[2], &equivalences) + /// Some(MirScalarExpr::column(4)), + /// input_mapper.find_bound_expr(&MirScalarExpr::column(2), &[2], &equivalences) /// ); /// assert_eq!( /// None, - /// input_mapper.find_bound_expr(&MirScalarExpr::Column(0), &[1], &equivalences) + /// input_mapper.find_bound_expr(&MirScalarExpr::column(0), &[1], &equivalences) /// ); /// ``` pub fn find_bound_expr( @@ -461,9 +461,9 @@ mod tests { }; // keys are numbered by (equivalence class #, input #) - let key10 = MirScalarExpr::Column(0); - let key12 = MirScalarExpr::Column(6); - let localized_key12 = MirScalarExpr::Column(1); + let key10 = MirScalarExpr::column(0); + let key12 = MirScalarExpr::column(6); + let localized_key12 = MirScalarExpr::column(1); let mut equivalences = vec![vec![key10.clone(), key12.clone()]]; @@ -471,7 +471,7 @@ mod tests { // is that it gets localized let mut cloned = key12.clone(); input_mapper.try_localize_to_input_with_bound_expr(&mut cloned, 2, &equivalences); - assert_eq!(MirScalarExpr::Column(1), cloned,); + assert_eq!(MirScalarExpr::column(1), cloned); // basic tests that we can find a column's corresponding column in a // different input @@ -486,18 +486,18 @@ mod tests { let key20 = MirScalarExpr::CallUnary { func: UnaryFunc::NegInt32(crate::func::NegInt32), - expr: Box::new(MirScalarExpr::Column(1)), + expr: Box::new(MirScalarExpr::column(1)), }; let key21 = MirScalarExpr::CallBinary { func: BinaryFunc::AddInt32, - expr1: Box::new(MirScalarExpr::Column(2)), + expr1: Box::new(MirScalarExpr::column(2)), expr2: Box::new(MirScalarExpr::literal( Ok(Datum::Int32(4)), ScalarType::Int32, )), }; - let key22 = MirScalarExpr::Column(5); - let localized_key22 = MirScalarExpr::Column(0); + let key22 = MirScalarExpr::column(5); + let localized_key22 = MirScalarExpr::column(0); equivalences.push(vec![key22.clone(), key20.clone(), key21.clone()]); // basic tests that we can find an expression's corresponding expression in a @@ -538,7 +538,7 @@ mod tests { let key_comp_plus_non_key = MirScalarExpr::CallBinary { func: BinaryFunc::Eq, expr1: Box::new(key_comp), - expr2: Box::new(MirScalarExpr::Column(7)), + expr2: Box::new(MirScalarExpr::column(7)), }; let mut mutab = key_comp_plus_non_key; assert_eq!( diff --git a/src/expr/src/scalar.rs b/src/expr/src/scalar.rs index 6d55e3dc98bbd..798ef692080b1 100644 --- a/src/expr/src/scalar.rs +++ b/src/expr/src/scalar.rs @@ -9,6 +9,7 @@ use std::collections::{BTreeMap, BTreeSet}; use std::ops::BitOrAssign; +use std::sync::Arc; use std::{fmt, mem}; use itertools::Itertools; @@ -18,6 +19,7 @@ use mz_ore::collections::CollectionExt; use mz_ore::iter::IteratorExt; use mz_ore::stack::RecursionLimitError; use mz_ore::str::StrExt; +use mz_ore::treat_as_equal::TreatAsEqual; use mz_ore::vec::swap_remove_multiple; use mz_pgrepr::TypeFromOidError; use mz_pgtz::timezone::TimezoneSpec; @@ -48,10 +50,10 @@ pub mod like_pattern; include!(concat!(env!("OUT_DIR"), "/mz_expr.scalar.rs")); -#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, MzReflect)] +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, MzReflect)] pub enum MirScalarExpr { /// A column of the input row - Column(usize), + Column(usize, TreatAsEqual>>), /// A literal value. /// (Stored as a row, because we can't own a Datum) Literal(Result, ColumnType), @@ -89,13 +91,42 @@ pub enum MirScalarExpr { }, } +// We need a custom Debug because we don't want to show `None` for name information. +// Sadly, the `derivative` crate doesn't support this use case. +impl std::fmt::Debug for MirScalarExpr { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + MirScalarExpr::Column(i, TreatAsEqual(Some(name))) => { + write!(f, "Column({i}, {name:?})") + } + MirScalarExpr::Column(i, TreatAsEqual(None)) => write!(f, "Column({i})"), + MirScalarExpr::Literal(lit, typ) => write!(f, "Literal({lit:?}, {typ:?})"), + MirScalarExpr::CallUnmaterializable(func) => { + write!(f, "CallUnmaterializable({func:?})") + } + MirScalarExpr::CallUnary { func, expr } => { + write!(f, "CallUnary({func:?}, {expr:?})") + } + MirScalarExpr::CallBinary { func, expr1, expr2 } => { + write!(f, "CallBinary({func:?}, {expr1:?}, {expr2:?})") + } + MirScalarExpr::CallVariadic { func, exprs } => { + write!(f, "CallVariadic({func:?}, {exprs:?})") + } + MirScalarExpr::If { cond, then, els } => { + write!(f, "If({cond:?}, {then:?}, {els:?})") + } + } + } +} + impl Arbitrary for MirScalarExpr { type Parameters = (); type Strategy = BoxedStrategy; fn arbitrary_with(_: Self::Parameters) -> Self::Strategy { let leaf = prop::strategy::Union::new(vec![ - (0..10_usize).prop_map(MirScalarExpr::Column).boxed(), + (0..10_usize).prop_map(MirScalarExpr::column).boxed(), (arb_datum(), any::()) .prop_map(|(datum, typ)| MirScalarExpr::literal(Ok((&datum).into()), typ)) .boxed(), @@ -145,7 +176,7 @@ impl RustType for MirScalarExpr { use proto_mir_scalar_expr::Kind::*; ProtoMirScalarExpr { kind: Some(match self { - MirScalarExpr::Column(i) => Column(i.into_proto()), + MirScalarExpr::Column(i, _) => Column(i.into_proto()), MirScalarExpr::Literal(lit, typ) => Literal(ProtoLiteral { lit: Some(lit.into_proto()), typ: Some(typ.into_proto()), @@ -183,7 +214,7 @@ impl RustType for MirScalarExpr { .kind .ok_or_else(|| TryFromProtoError::missing_field("ProtoMirScalarExpr::kind"))?; Ok(match kind { - Column(i) => MirScalarExpr::Column(usize::from_proto(i)?), + Column(i) => MirScalarExpr::column(usize::from_proto(i)?), Literal(ProtoLiteral { lit, typ }) => MirScalarExpr::Literal( lit.into_rust_if_some("ProtoLiteral::lit")?, typ.into_rust_if_some("ProtoLiteral::typ")?, @@ -244,11 +275,15 @@ impl RustType for Result { impl MirScalarExpr { pub fn columns(is: &[usize]) -> Vec { - is.iter().map(|i| MirScalarExpr::Column(*i)).collect() + is.iter().map(|i| MirScalarExpr::column(*i)).collect() } pub fn column(column: usize) -> Self { - MirScalarExpr::Column(column) + MirScalarExpr::Column(column, TreatAsEqual(None)) + } + + pub fn named_column(column: usize, name: Option>) -> Self { + MirScalarExpr::Column(column, TreatAsEqual(name)) } pub fn literal(res: Result, typ: ScalarType) -> Self { @@ -580,7 +615,7 @@ impl MirScalarExpr { F: FnMut(&mut usize), { self.visit_pre_mut(|e| { - if let MirScalarExpr::Column(col) = e { + if let MirScalarExpr::Column(col, _) = e { action(col); } }); @@ -594,7 +629,7 @@ impl MirScalarExpr { pub fn support_into(&self, support: &mut BTreeSet) { self.visit_pre(|e| { - if let MirScalarExpr::Column(i) = e { + if let MirScalarExpr::Column(i, _) = e { support.insert(*i); } }); @@ -663,7 +698,7 @@ impl MirScalarExpr { } pub fn is_column(&self) -> bool { - matches!(self, MirScalarExpr::Column(_)) + matches!(self, MirScalarExpr::Column(_col, _name)) } pub fn is_error_if_null(&self) -> bool { @@ -706,7 +741,7 @@ impl MirScalarExpr { /// If self is a column, return the column index, otherwise `None`. pub fn as_column(&self) -> Option { - if let MirScalarExpr::Column(c) = self { + if let MirScalarExpr::Column(c, _) = self { Some(*c) } else { None @@ -730,7 +765,7 @@ impl MirScalarExpr { /// use mz_expr::MirScalarExpr; /// use mz_repr::{ColumnType, Datum, ScalarType}; /// - /// let expr_0 = MirScalarExpr::Column(0); + /// let expr_0 = MirScalarExpr::column(0); /// let expr_t = MirScalarExpr::literal_true(); /// let expr_f = MirScalarExpr::literal_false(); /// @@ -801,7 +836,7 @@ impl MirScalarExpr { }, &mut |e| match e { // Evaluate and pull up constants - MirScalarExpr::Column(_) + MirScalarExpr::Column(_, _) | MirScalarExpr::Literal(_, _) | MirScalarExpr::CallUnmaterializable(_) => (), MirScalarExpr::CallUnary { func, expr } => { @@ -1919,7 +1954,7 @@ impl MirScalarExpr { /// Adds any columns that *must* be non-Null for `self` to be non-Null. pub fn non_null_requirements(&self, columns: &mut BTreeSet) { match self { - MirScalarExpr::Column(col) => { + MirScalarExpr::Column(col, _name) => { columns.insert(*col); } MirScalarExpr::Literal(..) => {} @@ -1948,7 +1983,7 @@ impl MirScalarExpr { pub fn typ(&self, column_types: &[ColumnType]) -> ColumnType { match self { - MirScalarExpr::Column(i) => column_types[*i].clone(), + MirScalarExpr::Column(i, _name) => column_types[*i].clone(), MirScalarExpr::Literal(_, typ) => typ.clone(), MirScalarExpr::CallUnmaterializable(func) => func.output_type(), MirScalarExpr::CallUnary { expr, func } => func.output_type(expr.typ(column_types)), @@ -1972,7 +2007,7 @@ impl MirScalarExpr { temp_storage: &'a RowArena, ) -> Result, EvalError> { match self { - MirScalarExpr::Column(index) => Ok(datums[*index].clone()), + MirScalarExpr::Column(index, _name) => Ok(datums[*index].clone()), MirScalarExpr::Literal(res, _column_type) => match res { Ok(row) => Ok(row.unpack_first()), Err(e) => Err(e.clone()), @@ -2036,7 +2071,7 @@ impl MirScalarExpr { pub fn contains_column(&self) -> bool { let mut contains = false; self.visit_pre(|e| { - if let MirScalarExpr::Column(_) = e { + if let MirScalarExpr::Column(_col, _name) = e { contains = true; } }); @@ -2070,7 +2105,7 @@ impl MirScalarExpr { /// True iff evaluation could possibly error on non-error input `Datum`. pub fn could_error(&self) -> bool { match self { - MirScalarExpr::Column(_col) => false, + MirScalarExpr::Column(_col, _name) => false, MirScalarExpr::Literal(row, ..) => row.is_err(), MirScalarExpr::CallUnmaterializable(_) => true, MirScalarExpr::CallUnary { func, expr } => func.could_error() || expr.could_error(), @@ -2094,7 +2129,7 @@ impl VisitChildren for MirScalarExpr { { use MirScalarExpr::*; match self { - Column(_) | Literal(_, _) | CallUnmaterializable(_) => (), + Column(_, _) | Literal(_, _) | CallUnmaterializable(_) => (), CallUnary { expr, .. } => { f(expr); } @@ -2121,7 +2156,7 @@ impl VisitChildren for MirScalarExpr { { use MirScalarExpr::*; match self { - Column(_) | Literal(_, _) | CallUnmaterializable(_) => (), + Column(_, _) | Literal(_, _) | CallUnmaterializable(_) => (), CallUnary { expr, .. } => { f(expr); } @@ -2149,7 +2184,7 @@ impl VisitChildren for MirScalarExpr { { use MirScalarExpr::*; match self { - Column(_) | Literal(_, _) | CallUnmaterializable(_) => (), + Column(_, _) | Literal(_, _) | CallUnmaterializable(_) => (), CallUnary { expr, .. } => { f(expr)?; } @@ -2178,7 +2213,7 @@ impl VisitChildren for MirScalarExpr { { use MirScalarExpr::*; match self { - Column(_) | Literal(_, _) | CallUnmaterializable(_) => (), + Column(_, _) | Literal(_, _) | CallUnmaterializable(_) => (), CallUnary { expr, .. } => { f(expr)?; } @@ -2211,7 +2246,7 @@ impl MirScalarExpr { use MirScalarExpr::*; match self { - Column(_) | Literal(_, _) | CallUnmaterializable(_) => (), + Column(_, _) | Literal(_, _) | CallUnmaterializable(_) => (), CallUnary { expr, .. } => { first = Some(&**expr); } @@ -2245,7 +2280,7 @@ impl MirScalarExpr { use MirScalarExpr::*; match self { - Column(_) | Literal(_, _) | CallUnmaterializable(_) => (), + Column(_, _) | Literal(_, _) | CallUnmaterializable(_) => (), CallUnary { expr, .. } => { first = Some(&mut **expr); } @@ -3256,7 +3291,7 @@ mod tests { ScalarType::Int64.nullable(true), ScalarType::Int64.nullable(false), ]; - let col = MirScalarExpr::Column; + let col = MirScalarExpr::column; let err = |e| MirScalarExpr::literal(Err(e), ScalarType::Int64); let lit = |i| MirScalarExpr::literal_ok(Datum::Int64(i), ScalarType::Int64); let null = || MirScalarExpr::literal_null(ScalarType::Int64); diff --git a/src/expr/src/scalar/func.rs b/src/expr/src/scalar/func.rs index 4856017b5bd38..431b4b30d8db3 100644 --- a/src/expr/src/scalar/func.rs +++ b/src/expr/src/scalar/func.rs @@ -9604,7 +9604,7 @@ mod test { let is_monotone = func.is_monotone(); let expr = MirScalarExpr::CallUnary { func, - expr: Box::new(MirScalarExpr::Column(0)), + expr: Box::new(MirScalarExpr::column(0)), }; if is_monotone { proptest!(|( @@ -9626,8 +9626,8 @@ mod test { let (left_monotone, right_monotone) = func.is_monotone(); let expr = MirScalarExpr::CallBinary { func, - expr1: Box::new(MirScalarExpr::Column(0)), - expr2: Box::new(MirScalarExpr::Column(1)), + expr1: Box::new(MirScalarExpr::column(0)), + expr2: Box::new(MirScalarExpr::column(1)), }; proptest!(|( mut left in proptest::array::uniform3(left), diff --git a/src/expr/src/scalar/func/impls/string.rs b/src/expr/src/scalar/func/impls/string.rs index 4c284912397f0..4c07bec418d3b 100644 --- a/src/expr/src/scalar/func/impls/string.rs +++ b/src/expr/src/scalar/func/impls/string.rs @@ -742,7 +742,7 @@ impl fmt::Display for CastStringToVarChar { // position akin to array parsing. static INT2VECTOR_CAST_EXPR: LazyLock = LazyLock::new(|| MirScalarExpr::CallUnary { func: UnaryFunc::CastStringToInt16(CastStringToInt16), - expr: Box::new(MirScalarExpr::Column(0)), + expr: Box::new(MirScalarExpr::column(0)), }); #[derive( diff --git a/src/lowertest/src/lib.rs b/src/lowertest/src/lib.rs index 60403188c15c7..dfdf084180824 100644 --- a/src/lowertest/src/lib.rs +++ b/src/lowertest/src/lib.rs @@ -16,6 +16,7 @@ use std::collections::BTreeMap; pub use mz_lowertest_derive::MzReflect; use mz_ore::result::ResultExt; use mz_ore::str::{StrExt, separated}; +use mz_ore::treat_as_equal::TreatAsEqual; use proc_macro2::{Delimiter, TokenStream, TokenTree}; use serde::de::DeserializeOwned; use serde_json::Value; @@ -40,6 +41,10 @@ impl MzReflect for Vec { } } +impl MzReflect for TreatAsEqual { + fn add_to_reflected_type_info(_rti: &mut ReflectedTypeInfo) {} +} + /// Info that must be combined with a spec to form deserializable JSON. /// /// To add information required to construct a struct or enum, diff --git a/src/ore/BUILD.bazel b/src/ore/BUILD.bazel index 34bde4ea52b8d..5fc2264fd8427 100644 --- a/src/ore/BUILD.bazel +++ b/src/ore/BUILD.bazel @@ -40,7 +40,6 @@ rust_library( "console-subscriber", "ctor", "default", - "derivative", "differential-dataflow", "futures", "hibitset", @@ -128,7 +127,6 @@ rust_test( "console-subscriber", "ctor", "default", - "derivative", "differential-dataflow", "futures", "hibitset", diff --git a/src/ore/Cargo.toml b/src/ore/Cargo.toml index 9e54dd3d83520..057fc272eae09 100644 --- a/src/ore/Cargo.toml +++ b/src/ore/Cargo.toml @@ -30,7 +30,7 @@ columnar = { version = "0.4.1", optional = true } compact_bytes = { version = "0.1.3", optional = true } ctor = { version = "0.4.2", optional = true } differential-dataflow = { version = "0.14.2", optional = true } -derivative = { version = "2.2.0", optional = true } +derivative = { version = "2.2.0" } either = "1.15.0" futures = { version = "0.3.31", optional = true } hibitset = { version = "0.6.4", optional = true } @@ -151,11 +151,11 @@ tracing = [ tokio-console = ["console-subscriber", "tokio", "tokio/tracing", "network"] cli = ["clap"] stack = ["stacker"] -test = ["anyhow", "ctor", "tracing-subscriber", "derivative", "assert"] -metrics = ["prometheus", "derivative", "assert"] +test = ["anyhow", "ctor", "tracing-subscriber", "assert"] +metrics = ["prometheus", "assert"] id_gen = ["hibitset", "rand", "uuid"] capture = ["tracing-capture"] -assert = ["derivative", "ctor"] +assert = ["ctor"] proptest = ["dep:proptest", "proptest-derive"] [[test]] diff --git a/src/ore/src/lib.rs b/src/ore/src/lib.rs index 74fbf015f3309..ee8d58c39f30d 100644 --- a/src/ore/src/lib.rs +++ b/src/ore/src/lib.rs @@ -97,6 +97,7 @@ pub mod time; #[cfg_attr(nightly_doc_features, doc(cfg(feature = "tracing")))] #[cfg(feature = "tracing")] pub mod tracing; +pub mod treat_as_equal; pub mod url; pub mod vec; diff --git a/src/ore/src/treat_as_equal.rs b/src/ore/src/treat_as_equal.rs new file mode 100644 index 0000000000000..660d1397e55d0 --- /dev/null +++ b/src/ore/src/treat_as_equal.rs @@ -0,0 +1,63 @@ +// Copyright Materialize, Inc. and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License in the LICENSE file at the +// root of this repository, or online at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! A newtype for values that should be ignored when comparing two values for equality. + +use derivative::Derivative; +use serde::{Deserialize, Deserializer, Serialize}; +use std::cmp::Ordering; +use std::hash::{Hash, Hasher}; + +/// Behaves like `T`, but has trivial `Hash`, `Eq`, `MzReflect`, and `Ord` +/// implementations. Does not appear in `Debug` output. +#[derive(Clone, Default, Derivative)] +#[derivative(Debug = "transparent")] +pub struct TreatAsEqual(pub T); + +impl Hash for TreatAsEqual { + fn hash(&self, _state: &mut H) {} +} + +impl Eq for TreatAsEqual {} + +impl PartialEq for TreatAsEqual { + fn eq(&self, _other: &Self) -> bool { + true + } +} + +impl PartialOrd for TreatAsEqual { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl Ord for TreatAsEqual { + fn cmp(&self, _other: &Self) -> Ordering { + Ordering::Equal + } +} + +impl Serialize for TreatAsEqual { + fn serialize(&self, serializer: S) -> Result { + self.0.serialize(serializer) + } +} + +impl<'de, T: Deserialize<'de>> Deserialize<'de> for TreatAsEqual { + fn deserialize>(deserializer: D) -> Result { + Ok(TreatAsEqual(T::deserialize(deserializer)?)) + } +} diff --git a/src/sql/src/func.rs b/src/sql/src/func.rs index d1a9ce4ac02d5..ebac1098ff6d1 100644 --- a/src/sql/src/func.rs +++ b/src/sql/src/func.rs @@ -21,7 +21,7 @@ use mz_ore::collections::CollectionExt; use mz_ore::str::StrExt; use mz_pgrepr::oid; use mz_repr::role_id::RoleId; -use mz_repr::{ColumnName, ColumnType, Datum, RelationType, Row, ScalarBaseType, ScalarType}; +use mz_repr::{ColumnName, Datum, RelationType, ScalarBaseType, ScalarType}; use crate::ast::{SelectStatement, Statement}; use crate::catalog::{CatalogType, TypeCategory, TypeReference}; @@ -520,7 +520,7 @@ impl fmt::Debug for FuncImpl { impl From for Operation { fn from(n: UnmaterializableFunc) -> Operation { - Operation::nullary(move |_ecx| Ok(HirScalarExpr::CallUnmaterializable(n.clone()))) + Operation::nullary(move |_ecx| Ok(HirScalarExpr::call_unmaterializable(n.clone()))) } } @@ -538,12 +538,7 @@ impl From for Operation { impl From for Operation { fn from(v: VariadicFunc) -> Operation { - Operation::variadic(move |_ecx, exprs| { - Ok(HirScalarExpr::CallVariadic { - func: v.clone(), - exprs, - }) - }) + Operation::variadic(move |_ecx, exprs| Ok(HirScalarExpr::call_variadic(v.clone(), exprs))) } } @@ -1812,7 +1807,7 @@ pub static PG_CATALOG_BUILTINS: LazyLock> = LazyLoc ), }; - Ok(HirScalarExpr::CallVariadic { func: VariadicFunc::ArrayFill { elem_type }, exprs: vec![elem, dims] }) + Ok(HirScalarExpr::call_variadic(VariadicFunc::ArrayFill { elem_type }, vec![elem, dims])) }) => ArrayAny, 1193; params!( AnyElement, @@ -1828,7 +1823,7 @@ pub static PG_CATALOG_BUILTINS: LazyLock> = LazyLoc ), }; - Ok(HirScalarExpr::CallVariadic { func: VariadicFunc::ArrayFill { elem_type }, exprs }) + Ok(HirScalarExpr::call_variadic(VariadicFunc::ArrayFill { elem_type }, exprs)) }) => ArrayAny, 1286; }, "array_length" => Scalar { @@ -1917,7 +1912,7 @@ pub static PG_CATALOG_BUILTINS: LazyLock> = LazyLoc _ => typeconv::to_string(ecx, expr) }); } - Ok(HirScalarExpr::CallVariadic { func: VariadicFunc::Concat, exprs }) + Ok(HirScalarExpr::call_variadic(VariadicFunc::Concat, exprs)) }) => String, 3058; }, "concat_ws" => Scalar { @@ -1937,7 +1932,7 @@ pub static PG_CATALOG_BUILTINS: LazyLock> = LazyLoc _ => typeconv::to_string(ecx, expr) }); } - Ok(HirScalarExpr::CallVariadic { func: VariadicFunc::ConcatWs, exprs }) + Ok(HirScalarExpr::call_variadic(VariadicFunc::ConcatWs, exprs)) }) => String, 3059; }, "convert_from" => Scalar { @@ -1966,11 +1961,11 @@ pub static PG_CATALOG_BUILTINS: LazyLock> = LazyLoc }, "current_schemas" => Scalar { params!(Bool) => Operation::unary(|_ecx, e| { - Ok(HirScalarExpr::If { - cond: Box::new(e), - then: Box::new(HirScalarExpr::CallUnmaterializable(UnmaterializableFunc::CurrentSchemasWithSystem)), - els: Box::new(HirScalarExpr::CallUnmaterializable(UnmaterializableFunc::CurrentSchemasWithoutSystem)), - }) + Ok(HirScalarExpr::if_then_else( + e, + HirScalarExpr::call_unmaterializable(UnmaterializableFunc::CurrentSchemasWithSystem), + HirScalarExpr::call_unmaterializable(UnmaterializableFunc::CurrentSchemasWithoutSystem), + )) // TODO: this should be `name[]`. This is tricky in Materialize // because `name` truncates to 63 characters but Materialize // does not have a limit on identifier length. @@ -2046,16 +2041,12 @@ pub static PG_CATALOG_BUILTINS: LazyLock> = LazyLoc "daterange" => Scalar { params!(Date, Date) => Operation::variadic(|_ecx, mut exprs| { exprs.push(HirScalarExpr::literal(Datum::String("[)"), ScalarType::String)); - Ok(HirScalarExpr::CallVariadic { - func: VariadicFunc::RangeCreate { elem_type: ScalarType::Date }, - exprs - }) + Ok(HirScalarExpr::call_variadic(VariadicFunc::RangeCreate { elem_type: ScalarType::Date }, + exprs)) }) => ScalarType::Range { element_type: Box::new(ScalarType::Date)}, 3941; params!(Date, Date, String) => Operation::variadic(|_ecx, exprs| { - Ok(HirScalarExpr::CallVariadic { - func: VariadicFunc::RangeCreate { elem_type: ScalarType::Date }, - exprs - }) + Ok(HirScalarExpr::call_variadic(VariadicFunc::RangeCreate { elem_type: ScalarType::Date }, + exprs)) }) => ScalarType::Range { element_type: Box::new(ScalarType::Date)}, 3942; }, "degrees" => Scalar { @@ -2131,32 +2122,24 @@ pub static PG_CATALOG_BUILTINS: LazyLock> = LazyLoc "int4range" => Scalar { params!(Int32, Int32) => Operation::variadic(|_ecx, mut exprs| { exprs.push(HirScalarExpr::literal(Datum::String("[)"), ScalarType::String)); - Ok(HirScalarExpr::CallVariadic { - func: VariadicFunc::RangeCreate { elem_type: ScalarType::Int32 }, - exprs - }) + Ok(HirScalarExpr::call_variadic(VariadicFunc::RangeCreate { elem_type: ScalarType::Int32 }, + exprs)) }) => ScalarType::Range { element_type: Box::new(ScalarType::Int32)}, 3840; params!(Int32, Int32, String) => Operation::variadic(|_ecx, exprs| { - Ok(HirScalarExpr::CallVariadic { - func: VariadicFunc::RangeCreate { elem_type: ScalarType::Int32 }, - exprs - }) + Ok(HirScalarExpr::call_variadic(VariadicFunc::RangeCreate { elem_type: ScalarType::Int32 }, + exprs)) }) => ScalarType::Range { element_type: Box::new(ScalarType::Int32)}, 3841; }, "int8range" => Scalar { params!(Int64, Int64) => Operation::variadic(|_ecx, mut exprs| { exprs.push(HirScalarExpr::literal(Datum::String("[)"), ScalarType::String)); - Ok(HirScalarExpr::CallVariadic { - func: VariadicFunc::RangeCreate { elem_type: ScalarType::Int64 }, - exprs - }) + Ok(HirScalarExpr::call_variadic(VariadicFunc::RangeCreate { elem_type: ScalarType::Int64 }, + exprs)) }) => ScalarType::Range { element_type: Box::new(ScalarType::Int64)}, 3945; params!(Int64, Int64, String) => Operation::variadic(|_ecx, exprs| { - Ok(HirScalarExpr::CallVariadic { - func: VariadicFunc::RangeCreate { elem_type: ScalarType::Int64 }, - exprs - }) - }) => ScalarType::Range { element_type: Box::new(ScalarType::Int64)}, 3946; + Ok(HirScalarExpr::call_variadic(VariadicFunc::RangeCreate { elem_type: ScalarType::Int64 }, + exprs)) + }) => ScalarType::Range { element_type: Box::new(ScalarType::Int64)}, 3946; }, "isempty" => Scalar { params!(RangeAny) => UnaryFunc::RangeEmpty(func::RangeEmpty) => Bool, 3850; @@ -2166,10 +2149,8 @@ pub static PG_CATALOG_BUILTINS: LazyLock> = LazyLoc }, "jsonb_build_array" => Scalar { params!() => VariadicFunc::JsonbBuildArray => Jsonb, 3272; - params!(Any...) => Operation::variadic(|ecx, exprs| Ok(HirScalarExpr::CallVariadic { - func: VariadicFunc::JsonbBuildArray, - exprs: exprs.into_iter().map(|e| typeconv::to_jsonb(ecx, e)).collect(), - })) => Jsonb, 3271; + params!(Any...) => Operation::variadic(|ecx, exprs| Ok(HirScalarExpr::call_variadic(VariadicFunc::JsonbBuildArray, + exprs.into_iter().map(|e| typeconv::to_jsonb(ecx, e)).collect()))) => Jsonb, 3271; }, "jsonb_build_object" => Scalar { params!() => VariadicFunc::JsonbBuildObject => Jsonb, 3274; @@ -2177,14 +2158,13 @@ pub static PG_CATALOG_BUILTINS: LazyLock> = LazyLoc if exprs.len() % 2 != 0 { sql_bail!("argument list must have even number of elements") } - Ok(HirScalarExpr::CallVariadic { - func: VariadicFunc::JsonbBuildObject, - exprs: exprs.into_iter().tuples().map(|(key, val)| { + Ok(HirScalarExpr::call_variadic( + VariadicFunc::JsonbBuildObject, + exprs.into_iter().tuples().map(|(key, val)| { let key = typeconv::to_string(ecx, key); let val = typeconv::to_jsonb(ecx, val); vec![key, val] - }).flatten().collect(), - }) + }).flatten().collect())) }) => Jsonb, 3273; }, "jsonb_pretty" => Scalar { @@ -2281,16 +2261,12 @@ pub static PG_CATALOG_BUILTINS: LazyLock> = LazyLoc "numrange" => Scalar { params!(Numeric, Numeric) => Operation::variadic(|_ecx, mut exprs| { exprs.push(HirScalarExpr::literal(Datum::String("[)"), ScalarType::String)); - Ok(HirScalarExpr::CallVariadic { - func: VariadicFunc::RangeCreate { elem_type: ScalarType::Numeric { max_scale: None } }, - exprs - }) + Ok(HirScalarExpr::call_variadic(VariadicFunc::RangeCreate { elem_type: ScalarType::Numeric { max_scale: None } }, + exprs)) }) => ScalarType::Range { element_type: Box::new(ScalarType::Numeric { max_scale: None })}, 3844; params!(Numeric, Numeric, String) => Operation::variadic(|_ecx, exprs| { - Ok(HirScalarExpr::CallVariadic { - func: VariadicFunc::RangeCreate { elem_type: ScalarType::Numeric { max_scale: None } }, - exprs - }) + Ok(HirScalarExpr::call_variadic(VariadicFunc::RangeCreate { elem_type: ScalarType::Numeric { max_scale: None } }, + exprs)) }) => ScalarType::Range { element_type: Box::new(ScalarType::Numeric { max_scale: None })}, 3845; }, "octet_length" => Scalar { @@ -2677,14 +2653,14 @@ pub static PG_CATALOG_BUILTINS: LazyLock> = LazyLoc // should properly support the `timetz` type and adjust this // overload accordingly. ecx.require_feature_flag(&ENABLE_TIME_AT_TIME_ZONE)?; - Ok(HirScalarExpr::CallVariadic { - func: VariadicFunc::TimezoneTime, - exprs: vec![ + Ok(HirScalarExpr::call_variadic( + VariadicFunc::TimezoneTime, + vec![ lhs, rhs, - HirScalarExpr::CallUnmaterializable(UnmaterializableFunc::CurrentTimestamp), + HirScalarExpr::call_unmaterializable(UnmaterializableFunc::CurrentTimestamp), ], - }) + )) }) => Time, 2037; params!(Interval, Timestamp) => BinaryFunc::TimezoneIntervalTimestamp => TimestampTz, 2070; params!(Interval, TimestampTz) => BinaryFunc::TimezoneIntervalTimestampTz => Timestamp, 1026; @@ -2729,31 +2705,23 @@ pub static PG_CATALOG_BUILTINS: LazyLock> = LazyLoc "tsrange" => Scalar { params!(Timestamp, Timestamp) => Operation::variadic(|_ecx, mut exprs| { exprs.push(HirScalarExpr::literal(Datum::String("[)"), ScalarType::String)); - Ok(HirScalarExpr::CallVariadic { - func: VariadicFunc::RangeCreate { elem_type: ScalarType::Timestamp {precision: None}}, - exprs - }) + Ok(HirScalarExpr::call_variadic(VariadicFunc::RangeCreate { elem_type: ScalarType::Timestamp {precision: None}}, + exprs)) }) => ScalarType::Range { element_type: Box::new(ScalarType::Timestamp { precision: None})}, 3933; params!(Timestamp, Timestamp, String) => Operation::variadic(|_ecx, exprs| { - Ok(HirScalarExpr::CallVariadic { - func: VariadicFunc::RangeCreate { elem_type: ScalarType::Timestamp {precision: None}}, - exprs - }) + Ok(HirScalarExpr::call_variadic(VariadicFunc::RangeCreate { elem_type: ScalarType::Timestamp {precision: None}}, + exprs)) }) => ScalarType::Range { element_type: Box::new(ScalarType::Timestamp { precision: None})}, 3934; }, "tstzrange" => Scalar { params!(TimestampTz, TimestampTz) => Operation::variadic(|_ecx, mut exprs| { exprs.push(HirScalarExpr::literal(Datum::String("[)"), ScalarType::String)); - Ok(HirScalarExpr::CallVariadic { - func: VariadicFunc::RangeCreate { elem_type: ScalarType::TimestampTz {precision: None}}, - exprs - }) + Ok(HirScalarExpr::call_variadic(VariadicFunc::RangeCreate { elem_type: ScalarType::TimestampTz {precision: None}}, + exprs,)) }) => ScalarType::Range { element_type: Box::new(ScalarType::TimestampTz { precision: None})}, 3937; params!(TimestampTz, TimestampTz, String) => Operation::variadic(|_ecx, exprs| { - Ok(HirScalarExpr::CallVariadic { - func: VariadicFunc::RangeCreate { elem_type: ScalarType::TimestampTz {precision: None}}, - exprs - }) + Ok(HirScalarExpr::call_variadic(VariadicFunc::RangeCreate { elem_type: ScalarType::TimestampTz {precision: None}}, + exprs)) }) => ScalarType::Range { element_type: Box::new(ScalarType::TimestampTz { precision: None})}, 3938; }, "upper" => Scalar { @@ -3028,10 +2996,10 @@ pub static PG_CATALOG_BUILTINS: LazyLock> = LazyLoc // ArrayConcat excepts all inputs to be arrays, so wrap all input datums into // arrays. - let e_arr = HirScalarExpr::CallVariadic{ - func: VariadicFunc::ArrayCreate { elem_type }, - exprs: vec![e], - }; + let e_arr = HirScalarExpr::call_variadic( + VariadicFunc::ArrayCreate { elem_type }, + vec![e], + ); Ok((e_arr, AggregateFunc::ArrayConcat { order_by })) }) => ArrayAny, 2335; params!(ArrayAny) => Operation::unary(|_ecx, _e| bail_unsupported!("array_agg on arrays")) => ArrayAny, 4053; @@ -3106,10 +3074,10 @@ pub static PG_CATALOG_BUILTINS: LazyLock> = LazyLoc // as `Datum::JsonbNull`. This call to `coalesce` converts // between the two semantics. let json_null = HirScalarExpr::literal(Datum::JsonNull, ScalarType::Jsonb); - let e = HirScalarExpr::CallVariadic { - func: VariadicFunc::Coalesce, - exprs: vec![typeconv::to_jsonb(ecx, e), json_null], - }; + let e = HirScalarExpr::call_variadic( + VariadicFunc::Coalesce, + vec![typeconv::to_jsonb(ecx, e), json_null], + ); Ok((e, AggregateFunc::JsonbAgg { order_by })) }) => Jsonb, 3267; }, @@ -3133,27 +3101,27 @@ pub static PG_CATALOG_BUILTINS: LazyLock> = LazyLoc // SQL nulls to JSON nulls; otherwise the produced `Datum::Map` // can contain `Datum::Null` values that are not valid for the // `ScalarType::Jsonb` type. - let val = HirScalarExpr::CallVariadic { - func: VariadicFunc::Coalesce, - exprs: vec![typeconv::to_jsonb(ecx, val), json_null], - }; - let e = HirScalarExpr::CallVariadic { - func: VariadicFunc::RecordCreate { + let val = HirScalarExpr::call_variadic( + VariadicFunc::Coalesce, + vec![typeconv::to_jsonb(ecx, val), json_null], + ); + let e = HirScalarExpr::call_variadic( + VariadicFunc::RecordCreate { field_names: vec![ColumnName::from("key"), ColumnName::from("val")], }, - exprs: vec![key, val], - }; + vec![key, val], + ); Ok((e, AggregateFunc::JsonbObjectAgg { order_by })) }) => Jsonb, 3270; }, "string_agg" => Aggregate { params!(String, String) => Operation::binary_ordered(|_ecx, value, sep, order_by| { - let e = HirScalarExpr::CallVariadic { - func: VariadicFunc::RecordCreate { + let e = HirScalarExpr::call_variadic( + VariadicFunc::RecordCreate { field_names: vec![ColumnName::from("value"), ColumnName::from("sep")], }, - exprs: vec![value, sep], - }; + vec![value, sep], + ); Ok((e, AggregateFunc::StringAgg { order_by })) }) => String, 3538; params!(Bytes, Bytes) => Operation::binary(|_ecx, _l, _r| bail_unsupported!("string_agg on BYTEA")) => Bytes, 3545; @@ -3195,31 +3163,31 @@ pub static PG_CATALOG_BUILTINS: LazyLock> = LazyLoc // All args are encoded into a single record to be handled later params!(AnyElement) => Operation::unary(|ecx, e| { let typ = ecx.scalar_type(&e); - let e = HirScalarExpr::CallVariadic { - func: VariadicFunc::RecordCreate { - field_names: vec![ColumnName::from("expr"), ColumnName::from("offset"), ColumnName::from("default")] + let e = HirScalarExpr::call_variadic( + VariadicFunc::RecordCreate { + field_names: vec![ColumnName::from("expr"), ColumnName::from("offset"), ColumnName::from("default")], }, - exprs: vec![e, HirScalarExpr::literal(Datum::Int32(1), ScalarType::Int32), HirScalarExpr::literal_null(typ)], - }; + vec![e, HirScalarExpr::literal(Datum::Int32(1), ScalarType::Int32), HirScalarExpr::literal_null(typ)], + ); Ok((e, ValueWindowFunc::Lag)) }) => AnyElement, 3106; params!(AnyElement, Int32) => Operation::binary(|ecx, e, offset| { let typ = ecx.scalar_type(&e); - let e = HirScalarExpr::CallVariadic { - func: VariadicFunc::RecordCreate { - field_names: vec![ColumnName::from("expr"), ColumnName::from("offset"), ColumnName::from("default")] + let e = HirScalarExpr::call_variadic( + VariadicFunc::RecordCreate { + field_names: vec![ColumnName::from("expr"), ColumnName::from("offset"), ColumnName::from("default")], }, - exprs: vec![e, offset, HirScalarExpr::literal_null(typ)], - }; + vec![e, offset, HirScalarExpr::literal_null(typ)], + ); Ok((e, ValueWindowFunc::Lag)) }) => AnyElement, 3107; params!(AnyCompatible, Int32, AnyCompatible) => Operation::variadic(|_ecx, exprs| { - let e = HirScalarExpr::CallVariadic { - func: VariadicFunc::RecordCreate { - field_names: vec![ColumnName::from("expr"), ColumnName::from("offset"), ColumnName::from("default")] + let e = HirScalarExpr::call_variadic( + VariadicFunc::RecordCreate { + field_names: vec![ColumnName::from("expr"), ColumnName::from("offset"), ColumnName::from("default")], }, exprs, - }; + ); Ok((e, ValueWindowFunc::Lag)) }) => AnyCompatible, 3108; }, @@ -3227,31 +3195,31 @@ pub static PG_CATALOG_BUILTINS: LazyLock> = LazyLoc // All args are encoded into a single record to be handled later params!(AnyElement) => Operation::unary(|ecx, e| { let typ = ecx.scalar_type(&e); - let e = HirScalarExpr::CallVariadic { - func: VariadicFunc::RecordCreate { - field_names: vec![ColumnName::from("expr"), ColumnName::from("offset"), ColumnName::from("default")] + let e = HirScalarExpr::call_variadic( + VariadicFunc::RecordCreate { + field_names: vec![ColumnName::from("expr"), ColumnName::from("offset"), ColumnName::from("default")], }, - exprs: vec![e, HirScalarExpr::literal(Datum::Int32(1), ScalarType::Int32), HirScalarExpr::literal_null(typ)], - }; + vec![e, HirScalarExpr::literal(Datum::Int32(1), ScalarType::Int32), HirScalarExpr::literal_null(typ)], + ); Ok((e, ValueWindowFunc::Lead)) }) => AnyElement, 3109; params!(AnyElement, Int32) => Operation::binary(|ecx, e, offset| { let typ = ecx.scalar_type(&e); - let e = HirScalarExpr::CallVariadic { - func: VariadicFunc::RecordCreate { - field_names: vec![ColumnName::from("expr"), ColumnName::from("offset"), ColumnName::from("default")] + let e = HirScalarExpr::call_variadic( + VariadicFunc::RecordCreate { + field_names: vec![ColumnName::from("expr"), ColumnName::from("offset"), ColumnName::from("default")], }, - exprs: vec![e, offset, HirScalarExpr::literal_null(typ)], - }; + vec![e, offset, HirScalarExpr::literal_null(typ)], + ); Ok((e, ValueWindowFunc::Lead)) }) => AnyElement, 3110; params!(AnyCompatible, Int32, AnyCompatible) => Operation::variadic(|_ecx, exprs| { - let e = HirScalarExpr::CallVariadic { - func: VariadicFunc::RecordCreate { - field_names: vec![ColumnName::from("expr"), ColumnName::from("offset"), ColumnName::from("default")] + let e = HirScalarExpr::call_variadic( + VariadicFunc::RecordCreate { + field_names: vec![ColumnName::from("expr"), ColumnName::from("offset"), ColumnName::from("default")], }, exprs, - }; + ); Ok((e, ValueWindowFunc::Lead)) }) => AnyCompatible, 3111; }, @@ -3292,12 +3260,10 @@ pub static PG_CATALOG_BUILTINS: LazyLock> = LazyLoc }) }) => ReturnType::set_of(Int64.into()), 1068; params!(Int64, Int64) => Operation::binary(move |_ecx, start, stop| { - let row = Row::pack([Datum::Int64(1)]); - let column_type = ColumnType { scalar_type: ScalarType::Int64, nullable: false }; Ok(TableFuncPlan { expr: HirRelationExpr::CallTable { func: TableFunc::GenerateSeriesInt64, - exprs: vec![start, stop, HirScalarExpr::Literal(row, column_type)], + exprs: vec![start, stop, HirScalarExpr::literal(Datum::Int64(1), ScalarType::Int64)], }, column_names: vec!["generate_series".into()], }) @@ -3707,10 +3673,10 @@ pub static MZ_CATALOG_BUILTINS: LazyLock> = LazyLoc }; // ListConcat excepts all inputs to be lists, so wrap all input datums into // lists. - let e_arr = HirScalarExpr::CallVariadic{ - func: VariadicFunc::ListCreate { elem_type: ecx.scalar_type(&e) }, - exprs: vec![e], - }; + let e_arr = HirScalarExpr::call_variadic( + VariadicFunc::ListCreate { elem_type: ecx.scalar_type(&e) }, + vec![e], + ); Ok((e_arr, AggregateFunc::ListConcat { order_by })) }) => ListAnyCompatible, oid::FUNC_LIST_AGG_OID; }, @@ -3758,12 +3724,12 @@ pub static MZ_CATALOG_BUILTINS: LazyLock> = LazyLoc typ => (typ, val), }; - let e = HirScalarExpr::CallVariadic { - func: VariadicFunc::RecordCreate { + let e = HirScalarExpr::call_variadic( + VariadicFunc::RecordCreate { field_names: vec![ColumnName::from("key"), ColumnName::from("val")], }, - exprs: vec![key, val], - }; + vec![key, val], + ); Ok((e, AggregateFunc::MapAgg { order_by, value_type })) }) => MapAny, oid::FUNC_MAP_AGG; @@ -4434,10 +4400,10 @@ fn array_to_string( ScalarType::Array(elem_type) => *elem_type, _ => unreachable!("array_to_string is guaranteed to receive array as first argument"), }; - Ok(HirScalarExpr::CallVariadic { - func: VariadicFunc::ArrayToString { elem_type }, + Ok(HirScalarExpr::call_variadic( + VariadicFunc::ArrayToString { elem_type }, exprs, - }) + )) } /// Correlates an operator with all of its implementations. @@ -5081,23 +5047,23 @@ fn current_settings( ) -> Result { // MapGetValue returns Null if the key doesn't exist in the map. let expr = HirScalarExpr::call_binary( - HirScalarExpr::CallUnmaterializable(UnmaterializableFunc::ViewableVariables), + HirScalarExpr::call_unmaterializable(UnmaterializableFunc::ViewableVariables), HirScalarExpr::call_unary(name, UnaryFunc::Lower(func::Lower)), BinaryFunc::MapGetValue, ); - let expr = HirScalarExpr::If { - cond: Box::new(missing_ok), - then: Box::new(expr.clone()), - els: Box::new(HirScalarExpr::CallVariadic { - func: VariadicFunc::ErrorIfNull, - exprs: vec![ + let expr = HirScalarExpr::if_then_else( + missing_ok, + expr.clone(), + HirScalarExpr::call_variadic( + VariadicFunc::ErrorIfNull, + vec![ expr, HirScalarExpr::literal( Datum::String("unrecognized configuration parameter"), ScalarType::String, ), ], - }), - }; + ), + ); Ok(expr) } diff --git a/src/sql/src/plan/explain.rs b/src/sql/src/plan/explain.rs index ce6518eb0ece3..27da8708ed12c 100644 --- a/src/sql/src/plan/explain.rs +++ b/src/sql/src/plan/explain.rs @@ -113,7 +113,7 @@ pub fn normalize_subqueries<'a>(expr: &'a mut HirRelationExpr) -> Result<(), Rec use HirRelationExpr::Get; use HirScalarExpr::{Exists, Select}; expr.visit_mut_post(&mut |expr: &mut HirScalarExpr| match expr { - Exists(expr) | Select(expr) => match expr.as_mut() { + Exists(expr, _) | Select(expr, _) => match expr.as_mut() { Get { .. } => (), expr => { // generate fresh local id @@ -181,14 +181,14 @@ fn id_gen( impl ScalarOps for HirScalarExpr { fn match_col_ref(&self) -> Option { match self { - HirScalarExpr::Column(c) if c.level == 0 => Some(c.column), + HirScalarExpr::Column(c, _name) if c.level == 0 => Some(c.column), _ => None, } } fn references(&self, column: usize) -> bool { match self { - HirScalarExpr::Column(c) => c.column == column && c.level == 0, + HirScalarExpr::Column(c, _name) => c.column == column && c.level == 0, _ => false, } } diff --git a/src/sql/src/plan/explain/text.rs b/src/sql/src/plan/explain/text.rs index be0b64f2f22c6..f1762d508858a 100644 --- a/src/sql/src/plan/explain/text.rs +++ b/src/sql/src/plan/explain/text.rs @@ -19,6 +19,7 @@ //! default, can be turned off with `WITH(raw_syntax)`). use itertools::Itertools; +use mz_ore::treat_as_equal::TreatAsEqual; use std::fmt; use mz_expr::explain::{HumanizedExplain, HumanizerMode, fmt_text_constant_rows}; @@ -284,18 +285,24 @@ impl fmt::Display for HirScalarExpr { use HirRelationExpr::Get; use HirScalarExpr::*; match self { - Column(i) => write!( + Column(i, TreatAsEqual(None)) => write!( f, "#{}{}", (0..i.level).map(|_| '^').collect::(), i.column ), - Parameter(i) => write!(f, "${}", i), - Literal(row, _) => write!(f, "{}", row.unpack_first()), - CallUnmaterializable(func) => write!(f, "{}()", func), - CallUnary { func, expr } => { + Column(i, TreatAsEqual(Some(name))) => write!( + f, + "#{}{}{{{name}}}", + (0..i.level).map(|_| '^').collect::(), + i.column, + ), + Parameter(i, _name) => write!(f, "${}", i), + Literal(row, _, _name) => write!(f, "{}", row.unpack_first()), + CallUnmaterializable(func, _name) => write!(f, "{}()", func), + CallUnary { func, expr, .. } => { if let mz_expr::UnaryFunc::Not(_) = *func { - if let CallUnary { func, expr } = expr.as_ref() { + if let CallUnary { func, expr, .. } = expr.as_ref() { if let Some(is) = func.is() { return write!(f, "({}) IS NOT {}", expr, is); } @@ -307,14 +314,16 @@ impl fmt::Display for HirScalarExpr { write!(f, "{}({})", func, expr) } } - CallBinary { func, expr1, expr2 } => { + CallBinary { + func, expr1, expr2, .. + } => { if func.is_infix_op() { write!(f, "({} {} {})", expr1, func, expr2) } else { write!(f, "{}({}, {})", func, expr1, expr2) } } - CallVariadic { func, exprs } => { + CallVariadic { func, exprs, .. } => { use mz_expr::VariadicFunc::*; match func { ArrayCreate { .. } => { @@ -340,10 +349,12 @@ impl fmt::Display for HirScalarExpr { } } } - If { cond, then, els } => { + If { + cond, then, els, .. + } => { write!(f, "case when {} then {} else {} end", cond, then, els) } - Windowing(expr) => { + Windowing(expr, _name) => { // First, print // - the window function name // - the arguments. @@ -420,11 +431,11 @@ impl fmt::Display for HirScalarExpr { Ok(()) } - Exists(expr) => match expr.as_ref() { + Exists(expr, _name) => match expr.as_ref() { Get { id, .. } => write!(f, "exists(Get {})", id), // TODO: optional humanizer _ => write!(f, "exists(???)"), }, - Select(expr) => match expr.as_ref() { + Select(expr, _name) => match expr.as_ref() { Get { id, .. } => write!(f, "select(Get {})", id), // TODO: optional humanizer _ => write!(f, "select(???)"), }, diff --git a/src/sql/src/plan/hir.rs b/src/sql/src/plan/hir.rs index d46bef11f63f9..53bff13f0158a 100644 --- a/src/sql/src/plan/hir.rs +++ b/src/sql/src/plan/hir.rs @@ -13,6 +13,7 @@ use std::collections::{BTreeMap, BTreeSet}; use std::fmt::{Display, Formatter}; +use std::sync::Arc; use std::{fmt, mem}; use itertools::Itertools; @@ -28,6 +29,7 @@ use mz_ore::collections::CollectionExt; use mz_ore::stack; use mz_ore::stack::RecursionLimitError; use mz_ore::str::separated; +use mz_ore::treat_as_equal::TreatAsEqual; use mz_repr::adt::array::ArrayDimension; use mz_repr::adt::numeric::NumericMaxScale; use mz_repr::*; @@ -183,36 +185,43 @@ pub enum HirRelationExpr { }, } +/// Stored column metadata. +pub type NameMetadata = TreatAsEqual>>; + #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] /// Just like [`mz_expr::MirScalarExpr`], except where otherwise noted below. pub enum HirScalarExpr { /// Unlike mz_expr::MirScalarExpr, we can nest HirRelationExprs via eg Exists. This means that a /// variable could refer to a column of the current input, or to a column of an outer relation. /// We use ColumnRef to denote the difference. - Column(ColumnRef), - Parameter(usize), - Literal(Row, ColumnType), - CallUnmaterializable(UnmaterializableFunc), + Column(ColumnRef, NameMetadata), + Parameter(usize, NameMetadata), + Literal(Row, ColumnType, NameMetadata), + CallUnmaterializable(UnmaterializableFunc, NameMetadata), CallUnary { func: UnaryFunc, expr: Box, + name: NameMetadata, }, CallBinary { func: BinaryFunc, expr1: Box, expr2: Box, + name: NameMetadata, }, CallVariadic { func: VariadicFunc, exprs: Vec, + name: NameMetadata, }, If { cond: Box, then: Box, els: Box, + name: NameMetadata, }, /// Returns true if `expr` returns any rows - Exists(Box), + Exists(Box, NameMetadata), /// Given `expr` with arity 1. If expr returns: /// * 0 rows, return NULL /// * 1 row, return the value of that row @@ -222,8 +231,8 @@ pub enum HirScalarExpr { /// If there are multiple `Select` expressions in a single SQL query, the result is that we take the product of all of them. /// This is counter to the spec, but is consistent with eg postgres' treatment of multiple set-returning-functions /// (see ). - Select(Box), - Windowing(WindowExpr), + Select(Box, NameMetadata), + Windowing(WindowExpr, NameMetadata), } #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] @@ -1720,11 +1729,11 @@ impl HirRelationExpr { } pub fn exists(self) -> HirScalarExpr { - HirScalarExpr::Exists(Box::new(self)) + HirScalarExpr::Exists(Box::new(self), NameMetadata::default()) } pub fn select(self) -> HirScalarExpr { - HirScalarExpr::Select(Box::new(self)) + HirScalarExpr::Select(Box::new(self), NameMetadata::default()) } pub fn join( @@ -2159,9 +2168,9 @@ impl HirRelationExpr { self.visit_children(|scalar: &HirScalarExpr| { if let Err(_) = scalar.visit_pre(&mut |scalar: &HirScalarExpr| { result |= match scalar { - Column(_) - | Literal(_, _) - | CallUnmaterializable(_) + Column(..) + | Literal(..) + | CallUnmaterializable(..) | If { .. } | Parameter(..) | Select(..) @@ -2226,7 +2235,9 @@ impl VisitChildren for HirRelationExpr { VisitChildren::visit_children(self, |expr: &HirScalarExpr| { #[allow(deprecated)] Visit::visit_post_nolimit(expr, &mut |expr| match expr { - HirScalarExpr::Exists(expr) | HirScalarExpr::Select(expr) => f(expr.as_ref()), + HirScalarExpr::Exists(expr, _name) | HirScalarExpr::Select(expr, _name) => { + f(expr.as_ref()) + } _ => (), }); }); @@ -2313,7 +2324,9 @@ impl VisitChildren for HirRelationExpr { VisitChildren::visit_mut_children(self, |expr: &mut HirScalarExpr| { #[allow(deprecated)] Visit::visit_mut_post_nolimit(expr, &mut |expr| match expr { - HirScalarExpr::Exists(expr) | HirScalarExpr::Select(expr) => f(expr.as_mut()), + HirScalarExpr::Exists(expr, _name) | HirScalarExpr::Select(expr, _name) => { + f(expr.as_mut()) + } _ => (), }); }); @@ -2400,7 +2413,9 @@ impl VisitChildren for HirRelationExpr { // attached at the current node, and we want to visit them as well VisitChildren::try_visit_children(self, |expr: &HirScalarExpr| { Visit::try_visit_post(expr, &mut |expr| match expr { - HirScalarExpr::Exists(expr) | HirScalarExpr::Select(expr) => f(expr.as_ref()), + HirScalarExpr::Exists(expr, _name) | HirScalarExpr::Select(expr, _name) => { + f(expr.as_ref()) + } _ => Ok(()), }) })?; @@ -2488,7 +2503,9 @@ impl VisitChildren for HirRelationExpr { // attached at the current node, and we want to visit them as well VisitChildren::try_visit_mut_children(self, |expr: &mut HirScalarExpr| { Visit::try_visit_mut_post(expr, &mut |expr| match expr { - HirScalarExpr::Exists(expr) | HirScalarExpr::Select(expr) => f(expr.as_mut()), + HirScalarExpr::Exists(expr, _name) | HirScalarExpr::Select(expr, _name) => { + f(expr.as_mut()) + } _ => Ok(()), }) })?; @@ -2866,12 +2883,29 @@ impl VisitChildren for HirRelationExpr { } impl HirScalarExpr { + pub fn name(&self) -> Option> { + use HirScalarExpr::*; + match self { + Column(_, name) + | Parameter(_, name) + | Literal(_, _, name) + | CallUnmaterializable(_, name) + | CallUnary { name, .. } + | CallBinary { name, .. } + | CallVariadic { name, .. } + | If { name, .. } + | Exists(_, name) + | Select(_, name) + | Windowing(_, name) => name.0.clone(), + } + } + /// Replaces any parameter references in the expression with the /// corresponding datum in `params`. pub fn bind_parameters(&mut self, params: &Params) -> Result<(), PlanError> { #[allow(deprecated)] self.visit_recursively_mut(0, &mut |_: usize, e: &mut HirScalarExpr| { - if let HirScalarExpr::Parameter(n) = e { + if let HirScalarExpr::Parameter(n, name) = e { let datum = match params.datums.iter().nth(*n - 1) { None => sql_bail!("there is no parameter ${}", n), Some(datum) => datum, @@ -2879,7 +2913,14 @@ impl HirScalarExpr { let scalar_type = ¶ms.types[*n - 1]; let row = Row::pack([datum]); let column_type = scalar_type.clone().nullable(datum.is_null()); - *e = HirScalarExpr::Literal(row, column_type); + + let name = if let Some(name) = &name.0 { + Some(Arc::clone(name)) + } else { + Some(Arc::from(format!("${n}"))) + }; + + *e = HirScalarExpr::Literal(row, column_type, TreatAsEqual(name)); } Ok(()) }) @@ -2900,7 +2941,7 @@ impl HirScalarExpr { let _ = self.visit_recursively_mut(depth, &mut |depth: usize, e: &mut HirScalarExpr| -> Result<(), ()> { - if let HirScalarExpr::Parameter(i) = e { + if let HirScalarExpr::Parameter(i, _name) = e { *e = params[*i - 1].clone(); // Correct any column references in the parameter expression for // its new depth. @@ -2919,7 +2960,7 @@ impl HirScalarExpr { let mut contains = false; #[allow(deprecated)] self.visit_post_nolimit(&mut |e| { - if let Self::CallUnmaterializable(UnmaterializableFunc::MzNow) = e { + if let Self::CallUnmaterializable(UnmaterializableFunc::MzNow, _name) = e { contains = true; } }); @@ -2928,15 +2969,30 @@ impl HirScalarExpr { /// Constructs a column reference in the current scope. pub fn column(index: usize) -> HirScalarExpr { - HirScalarExpr::Column(ColumnRef { - level: 0, - column: index, - }) + HirScalarExpr::Column( + ColumnRef { + level: 0, + column: index, + }, + TreatAsEqual(None), + ) + } + + pub fn named_column(cr: ColumnRef, name: Option>) -> HirScalarExpr { + HirScalarExpr::Column(cr, TreatAsEqual(name)) + } + + pub fn parameter(n: usize) -> HirScalarExpr { + HirScalarExpr::Parameter(n, TreatAsEqual(None)) } pub fn literal(datum: Datum, scalar_type: ScalarType) -> HirScalarExpr { let row = Row::pack([datum]); - HirScalarExpr::Literal(row, scalar_type.nullable(datum.is_null())) + HirScalarExpr::Literal( + row, + scalar_type.nullable(datum.is_null()), + TreatAsEqual(None), + ) } pub fn literal_true() -> HirScalarExpr { @@ -2973,11 +3029,11 @@ impl HirScalarExpr { ) .expect("array constructed to be valid"); - Ok(HirScalarExpr::Literal(row, scalar_type)) + Ok(HirScalarExpr::Literal(row, scalar_type, TreatAsEqual(None))) } pub fn as_literal(&self) -> Option { - if let HirScalarExpr::Literal(row, _column_type) = self { + if let HirScalarExpr::Literal(row, _column_type, _name) = self { Some(row.unpack_first()) } else { None @@ -3002,7 +3058,7 @@ impl HirScalarExpr { let mut worklist = vec![self]; while let Some(expr) = worklist.pop() { match expr { - Self::Literal(_, _) => { + Self::Literal(..) => { // leaf node, do nothing } Self::CallUnary { expr, .. } => { @@ -3012,14 +3068,24 @@ impl HirScalarExpr { func: _, expr1, expr2, + name: _, } => { worklist.push(expr1); worklist.push(expr2); } - Self::CallVariadic { func: _, exprs } => { + Self::CallVariadic { + func: _, + exprs, + name: _, + } => { worklist.extend(exprs.iter()); } - Self::If { cond, then, els } => { + Self::If { + cond, + then, + els, + name: _, + } => { worklist.push(cond); worklist.push(then); worklist.push(els); @@ -3036,6 +3102,7 @@ impl HirScalarExpr { HirScalarExpr::CallUnary { func, expr: Box::new(self), + name: NameMetadata::default(), } } @@ -3044,23 +3111,43 @@ impl HirScalarExpr { func, expr1: Box::new(self), expr2: Box::new(other), + name: NameMetadata::default(), } } - pub fn or(self, other: Self) -> Self { + pub fn call_unmaterializable(func: UnmaterializableFunc) -> Self { + HirScalarExpr::CallUnmaterializable(func, NameMetadata::default()) + } + + pub fn call_variadic(func: VariadicFunc, exprs: Vec) -> Self { HirScalarExpr::CallVariadic { - func: VariadicFunc::Or, - exprs: vec![self, other], + func, + exprs, + name: NameMetadata::default(), } } - pub fn and(self, other: Self) -> Self { - HirScalarExpr::CallVariadic { - func: VariadicFunc::And, - exprs: vec![self, other], + pub fn if_then_else(cond: Self, then: Self, els: Self) -> Self { + HirScalarExpr::If { + cond: Box::new(cond), + then: Box::new(then), + els: Box::new(els), + name: NameMetadata::default(), } } + pub fn windowing(expr: WindowExpr) -> Self { + HirScalarExpr::Windowing(expr, TreatAsEqual(None)) + } + + pub fn or(self, other: Self) -> Self { + HirScalarExpr::call_variadic(VariadicFunc::Or, vec![self, other]) + } + + pub fn and(self, other: Self) -> Self { + HirScalarExpr::call_variadic(VariadicFunc::And, vec![self, other]) + } + pub fn not(self) -> Self { self.call_unary(UnaryFunc::Not(func::Not)) } @@ -3074,10 +3161,7 @@ impl HirScalarExpr { match args.len() { 0 => HirScalarExpr::literal_true(), // Same as unit_of_and_or, but that's MirScalarExpr 1 => args.swap_remove(0), - _ => HirScalarExpr::CallVariadic { - func: VariadicFunc::And, - exprs: args, - }, + _ => HirScalarExpr::call_variadic(VariadicFunc::And, args), } } @@ -3086,10 +3170,7 @@ impl HirScalarExpr { match args.len() { 0 => HirScalarExpr::literal_false(), // Same as unit_of_and_or, but that's MirScalarExpr 1 => args.swap_remove(0), - _ => HirScalarExpr::CallVariadic { - func: VariadicFunc::Or, - exprs: args, - }, + _ => HirScalarExpr::call_variadic(VariadicFunc::Or, args), } } @@ -3111,7 +3192,7 @@ impl HirScalarExpr { let _ = self.visit_recursively(depth, &mut |depth: usize, e: &HirScalarExpr| -> Result<(), ()> { - if let HirScalarExpr::Column(col) = e { + if let HirScalarExpr::Column(col, _name) = e { f(depth, col) } Ok(()) @@ -3128,7 +3209,7 @@ impl HirScalarExpr { let _ = self.visit_recursively_mut(depth, &mut |depth: usize, e: &mut HirScalarExpr| -> Result<(), ()> { - if let HirScalarExpr::Column(col) = e { + if let HirScalarExpr::Column(col, _name) = e { f(depth, col) } Ok(()) @@ -3148,7 +3229,7 @@ impl HirScalarExpr { let _ = self.visit_recursively(0, &mut |depth: usize, e: &HirScalarExpr| -> Result<(), ()> { - if let HirScalarExpr::Column(col) = e { + if let HirScalarExpr::Column(col, _name) = e { if col.level == depth { f(col.column) } @@ -3166,7 +3247,7 @@ impl HirScalarExpr { let _ = self.visit_recursively_mut(0, &mut |depth: usize, e: &mut HirScalarExpr| -> Result<(), ()> { - if let HirScalarExpr::Column(col) = e { + if let HirScalarExpr::Column(col, _name) = e { if col.level == depth { f(&mut col.column) } @@ -3184,10 +3265,10 @@ impl HirScalarExpr { F: FnMut(usize, &HirScalarExpr) -> Result<(), E>, { match self { - HirScalarExpr::Literal(_, _) - | HirScalarExpr::Parameter(_) - | HirScalarExpr::CallUnmaterializable(_) - | HirScalarExpr::Column(_) => (), + HirScalarExpr::Literal(..) + | HirScalarExpr::Parameter(..) + | HirScalarExpr::CallUnmaterializable(..) + | HirScalarExpr::Column(..) => (), HirScalarExpr::CallUnary { expr, .. } => expr.visit_recursively(depth, f)?, HirScalarExpr::CallBinary { expr1, expr2, .. } => { expr1.visit_recursively(depth, f)?; @@ -3198,18 +3279,23 @@ impl HirScalarExpr { expr.visit_recursively(depth, f)?; } } - HirScalarExpr::If { cond, then, els } => { + HirScalarExpr::If { + cond, + then, + els, + name: _, + } => { cond.visit_recursively(depth, f)?; then.visit_recursively(depth, f)?; els.visit_recursively(depth, f)?; } - HirScalarExpr::Exists(expr) | HirScalarExpr::Select(expr) => { + HirScalarExpr::Exists(expr, _name) | HirScalarExpr::Select(expr, _name) => { #[allow(deprecated)] expr.visit_scalar_expressions(depth + 1, &mut |e, depth| { e.visit_recursively(depth, f) })?; } - HirScalarExpr::Windowing(expr) => { + HirScalarExpr::Windowing(expr, _name) => { expr.visit_expressions(&mut |e| e.visit_recursively(depth, f))?; } } @@ -3223,10 +3309,10 @@ impl HirScalarExpr { F: FnMut(usize, &mut HirScalarExpr) -> Result<(), E>, { match self { - HirScalarExpr::Literal(_, _) - | HirScalarExpr::Parameter(_) - | HirScalarExpr::CallUnmaterializable(_) - | HirScalarExpr::Column(_) => (), + HirScalarExpr::Literal(..) + | HirScalarExpr::Parameter(..) + | HirScalarExpr::CallUnmaterializable(..) + | HirScalarExpr::Column(..) => (), HirScalarExpr::CallUnary { expr, .. } => expr.visit_recursively_mut(depth, f)?, HirScalarExpr::CallBinary { expr1, expr2, .. } => { expr1.visit_recursively_mut(depth, f)?; @@ -3237,18 +3323,23 @@ impl HirScalarExpr { expr.visit_recursively_mut(depth, f)?; } } - HirScalarExpr::If { cond, then, els } => { + HirScalarExpr::If { + cond, + then, + els, + name: _, + } => { cond.visit_recursively_mut(depth, f)?; then.visit_recursively_mut(depth, f)?; els.visit_recursively_mut(depth, f)?; } - HirScalarExpr::Exists(expr) | HirScalarExpr::Select(expr) => { + HirScalarExpr::Exists(expr, _name) | HirScalarExpr::Select(expr, _name) => { #[allow(deprecated)] expr.visit_scalar_expressions_mut(depth + 1, &mut |e, depth| { e.visit_recursively_mut(depth, f) })?; } - HirScalarExpr::Windowing(expr) => { + HirScalarExpr::Windowing(expr, _name) => { expr.visit_expressions_mut(&mut |e| e.visit_recursively_mut(depth, f))?; } } @@ -3343,13 +3434,18 @@ impl VisitChildren for HirScalarExpr { f(expr); } } - If { cond, then, els } => { + If { + cond, + then, + els, + name: _, + } => { f(cond); f(then); f(els); } Exists(..) | Select(..) => (), - Windowing(expr) => expr.visit_children(f), + Windowing(expr, _name) => expr.visit_children(f), } } @@ -3370,13 +3466,18 @@ impl VisitChildren for HirScalarExpr { f(expr); } } - If { cond, then, els } => { + If { + cond, + then, + els, + name: _, + } => { f(cond); f(then); f(els); } Exists(..) | Select(..) => (), - Windowing(expr) => expr.visit_mut_children(f), + Windowing(expr, _name) => expr.visit_mut_children(f), } } @@ -3398,13 +3499,18 @@ impl VisitChildren for HirScalarExpr { f(expr)?; } } - If { cond, then, els } => { + If { + cond, + then, + els, + name: _, + } => { f(cond)?; f(then)?; f(els)?; } Exists(..) | Select(..) => (), - Windowing(expr) => expr.try_visit_children(f)?, + Windowing(expr, _name) => expr.try_visit_children(f)?, } Ok(()) } @@ -3427,13 +3533,18 @@ impl VisitChildren for HirScalarExpr { f(expr)?; } } - If { cond, then, els } => { + If { + cond, + then, + els, + name: _, + } => { f(cond)?; f(then)?; f(els)?; } Exists(..) | Select(..) => (), - Windowing(expr) => expr.try_visit_mut_children(f)?, + Windowing(expr, _name) => expr.try_visit_mut_children(f)?, } Ok(()) } @@ -3449,33 +3560,47 @@ impl AbstractExpr for HirScalarExpr { params: &BTreeMap, ) -> Self::Type { stack::maybe_grow(|| match self { - HirScalarExpr::Column(ColumnRef { level, column }) => { + HirScalarExpr::Column(ColumnRef { level, column }, _name) => { if *level == 0 { inner.column_types[*column].clone() } else { outers[*level - 1].column_types[*column].clone() } } - HirScalarExpr::Parameter(n) => params[n].clone().nullable(true), - HirScalarExpr::Literal(_, typ) => typ.clone(), - HirScalarExpr::CallUnmaterializable(func) => func.output_type(), - HirScalarExpr::CallUnary { expr, func } => { - func.output_type(expr.typ(outers, inner, params)) - } - HirScalarExpr::CallBinary { expr1, expr2, func } => func.output_type( + HirScalarExpr::Parameter(n, _name) => params[n].clone().nullable(true), + HirScalarExpr::Literal(_, typ, _name) => typ.clone(), + HirScalarExpr::CallUnmaterializable(func, _name) => func.output_type(), + HirScalarExpr::CallUnary { + expr, + func, + name: _, + } => func.output_type(expr.typ(outers, inner, params)), + HirScalarExpr::CallBinary { + expr1, + expr2, + func, + name: _, + } => func.output_type( expr1.typ(outers, inner, params), expr2.typ(outers, inner, params), ), - HirScalarExpr::CallVariadic { exprs, func } => { - func.output_type(exprs.iter().map(|e| e.typ(outers, inner, params)).collect()) - } - HirScalarExpr::If { cond: _, then, els } => { + HirScalarExpr::CallVariadic { + exprs, + func, + name: _, + } => func.output_type(exprs.iter().map(|e| e.typ(outers, inner, params)).collect()), + HirScalarExpr::If { + cond: _, + then, + els, + name: _, + } => { let then_type = then.typ(outers, inner, params); let else_type = els.typ(outers, inner, params); then_type.union(&else_type).unwrap() } - HirScalarExpr::Exists(_) => ScalarType::Bool.nullable(true), - HirScalarExpr::Select(expr) => { + HirScalarExpr::Exists(_, _name) => ScalarType::Bool.nullable(true), + HirScalarExpr::Select(expr, _name) => { let mut outers = outers.to_vec(); outers.insert(0, inner.clone()); expr.typ(&outers, params) @@ -3483,7 +3608,7 @@ impl AbstractExpr for HirScalarExpr { .into_element() .nullable(true) } - HirScalarExpr::Windowing(expr) => expr.func.typ(outers, inner, params), + HirScalarExpr::Windowing(expr, _name) => expr.func.typ(outers, inner, params), }) } } diff --git a/src/sql/src/plan/lowering.rs b/src/sql/src/plan/lowering.rs index c54b39cfc2f04..7fdacb57d410d 100644 --- a/src/sql/src/plan/lowering.rs +++ b/src/sql/src/plan/lowering.rs @@ -289,8 +289,8 @@ impl HirRelationExpr { let equivalences = (0..cte_outer_columns) .map(|pos| { vec![ - MirScalarExpr::Column(pos), - MirScalarExpr::Column(pos + oa), + MirScalarExpr::column(pos), + MirScalarExpr::column(pos + oa), ] }) .collect(); @@ -951,16 +951,22 @@ impl HirScalarExpr { if let Some(subquery_map) = subquery_map { if let Some(col) = subquery_map.get(&self) { - return Ok(SS::Column(*col)); + return Ok(SS::column(*col)); } } Ok::(match self { - Column(col_ref) => SS::Column(col_map.get(&col_ref)), - Literal(row, typ) => SS::Literal(Ok(row), typ), - Parameter(_) => panic!("cannot decorrelate expression with unbound parameters"), - CallUnmaterializable(func) => SS::CallUnmaterializable(func), - CallUnary { func, expr } => SS::CallUnary { + Column(col_ref, name) => SS::Column(col_map.get(&col_ref), name), + Literal(row, typ, _name) => SS::Literal(Ok(row), typ), + Parameter(_, _name) => { + panic!("cannot decorrelate expression with unbound parameters") + } + CallUnmaterializable(func, _name) => SS::CallUnmaterializable(func), + CallUnary { + func, + expr, + name: _, + } => SS::CallUnary { func, expr: Box::new(expr.applied_to( id_gen, @@ -971,7 +977,12 @@ impl HirScalarExpr { context, )?), }, - CallBinary { func, expr1, expr2 } => SS::CallBinary { + CallBinary { + func, + expr1, + expr2, + name: _, + } => SS::CallBinary { func, expr1: Box::new(expr1.applied_to( id_gen, @@ -990,7 +1001,11 @@ impl HirScalarExpr { context, )?), }, - CallVariadic { func, exprs } => SS::CallVariadic { + CallVariadic { + func, + exprs, + name: _, + } => SS::CallVariadic { func, exprs: exprs .into_iter() @@ -999,7 +1014,12 @@ impl HirScalarExpr { }) .collect::, _>>()?, }, - If { cond, then, els } => { + If { + cond, + then, + els, + name: _, + } => { // The `If` case is complicated by the fact that we do not want to // apply the `then` or `else` logic to tuples that respectively do // not or do pass the `cond` test. Our strategy is to independently @@ -1092,7 +1112,7 @@ impl HirScalarExpr { Ok::(then_inner.union(else_inner)) })?; - SS::Column(inner_arity) + SS::column(inner_arity) } } @@ -1107,7 +1127,7 @@ impl HirScalarExpr { // When the subquery would return 0 rows for some row in the outer query, `subquery.applied_to(get_inner)` will not have any corresponding row. // Use `lookup` if you need to add default values for cases when the subquery returns 0 rows. - Exists(expr) => { + Exists(expr, _name) => { let apply_requires_distinct_outer = true; *inner = apply_existential_subquery( id_gen, @@ -1118,10 +1138,10 @@ impl HirScalarExpr { apply_requires_distinct_outer, context, )?; - SS::Column(inner.arity() - 1) + SS::column(inner.arity() - 1) } - Select(expr) => { + Select(expr, _name) => { let apply_requires_distinct_outer = true; *inner = apply_scalar_subquery( id_gen, @@ -1132,9 +1152,9 @@ impl HirScalarExpr { apply_requires_distinct_outer, context, )?; - SS::Column(inner.arity() - 1) + SS::column(inner.arity() - 1) } - Windowing(expr) => { + Windowing(expr, _name) => { let partition_by = expr.partition_by; let order_by = expr.order_by; @@ -1427,7 +1447,7 @@ impl HirScalarExpr { subquery_map, context, )?; - if let MirScalarExpr::Column(c) = key { + if let MirScalarExpr::Column(c, _name) = key { group_key.push(c); } else { get_inner = get_inner.map_one(key); @@ -1449,7 +1469,7 @@ impl HirScalarExpr { func: mz_expr::VariadicFunc::RecordCreate { field_names: fields.iter().map(|(name, _)| name.clone()).collect_vec(), }, - exprs: (0..input_arity).map(MirScalarExpr::Column).collect_vec(), + exprs: (0..input_arity).map(MirScalarExpr::column).collect_vec(), }; let original_row_record_type = ScalarType::Record { fields, @@ -1487,7 +1507,7 @@ impl HirScalarExpr { .unwrap_list_element_type() .clone(), }, - vec![MirScalarExpr::Column(group_key.len())], + vec![MirScalarExpr::column(group_key.len())], ); let record_col = reduce.arity() - 1; @@ -1497,7 +1517,7 @@ impl HirScalarExpr { func: mz_expr::UnaryFunc::RecordGet(mz_expr::func::RecordGet(c)), expr: Box::new(MirScalarExpr::CallUnary { func: mz_expr::UnaryFunc::RecordGet(mz_expr::func::RecordGet(1)), - expr: Box::new(MirScalarExpr::Column(record_col)), + expr: Box::new(MirScalarExpr::column(record_col)), }), }); } @@ -1505,14 +1525,14 @@ impl HirScalarExpr { // Append the column with the result of the window function. reduce = reduce.take_dangerous().map_one(MirScalarExpr::CallUnary { func: mz_expr::UnaryFunc::RecordGet(mz_expr::func::RecordGet(0)), - expr: Box::new(MirScalarExpr::Column(record_col)), + expr: Box::new(MirScalarExpr::column(record_col)), }); let agg_col = record_col + 1 + input_arity; Ok::<_, PlanError>(reduce.project((record_col + 1..agg_col + 1).collect_vec())) }) })?; - Ok(MirScalarExpr::Column(inner.arity() - 1)) + Ok(MirScalarExpr::column(inner.arity() - 1)) } /// Applies the subqueries in the given list of scalar expressions to every distinct @@ -1540,7 +1560,7 @@ impl HirScalarExpr { _ => None, }, &mut |e| match e { - HirScalarExpr::Select(expr) => { + HirScalarExpr::Select(expr, _name) => { let apply_requires_distinct_outer = false; let subquery = apply_scalar_subquery( id_gen, @@ -1555,7 +1575,7 @@ impl HirScalarExpr { subqueries.push((e.clone(), subquery)); } - HirScalarExpr::Exists(expr) => { + HirScalarExpr::Exists(expr, _name) => { let apply_requires_distinct_outer = false; let subquery = apply_existential_subquery( id_gen, @@ -1605,7 +1625,7 @@ impl HirScalarExpr { .iter() .enumerate() .map(|(input, _)| { - MirScalarExpr::Column(input_mapper.map_column_to_global(col, input)) + MirScalarExpr::column(input_mapper.map_column_to_global(col, input)) }) .collect_vec() }) @@ -1623,26 +1643,44 @@ impl HirScalarExpr { use HirScalarExpr::*; Ok(match self { - Column(ColumnRef { level: 0, column }) => SS::Column(column), - Literal(datum, typ) => SS::Literal(Ok(datum), typ), - CallUnmaterializable(func) => SS::CallUnmaterializable(func), - CallUnary { func, expr } => SS::CallUnary { + Column(ColumnRef { level: 0, column }, name) => SS::Column(column, name), + Literal(datum, typ, _name) => SS::Literal(Ok(datum), typ), + CallUnmaterializable(func, _name) => SS::CallUnmaterializable(func), + CallUnary { + func, + expr, + name: _, + } => SS::CallUnary { func, expr: Box::new(expr.lower_uncorrelated()?), }, - CallBinary { func, expr1, expr2 } => SS::CallBinary { + CallBinary { + func, + expr1, + expr2, + name: _, + } => SS::CallBinary { func, expr1: Box::new(expr1.lower_uncorrelated()?), expr2: Box::new(expr2.lower_uncorrelated()?), }, - CallVariadic { func, exprs } => SS::CallVariadic { + CallVariadic { + func, + exprs, + name: _, + } => SS::CallVariadic { func, exprs: exprs .into_iter() .map(|expr| expr.lower_uncorrelated()) .collect::>()?, }, - If { cond, then, els } => SS::If { + If { + cond, + then, + els, + name: _, + } => SS::If { cond: Box::new(cond.lower_uncorrelated()?), then: Box::new(then.lower_uncorrelated()?), els: Box::new(els.lower_uncorrelated()?), @@ -1903,7 +1941,7 @@ fn apply_scalar_subquery( ); // Errors should result from counts > 1. let errors = counts - .filter(vec![MirScalarExpr::Column(inner_arity).call_binary( + .filter(vec![MirScalarExpr::column(inner_arity).call_binary( MirScalarExpr::literal_ok(Datum::Int64(1), ScalarType::Int64), mz_expr::BinaryFunc::Gt, )]) diff --git a/src/sql/src/plan/lowering/variadic_left.rs b/src/sql/src/plan/lowering/variadic_left.rs index 67ca092aaace3..1d6ab4443d1aa 100644 --- a/src/sql/src/plan/lowering/variadic_left.rs +++ b/src/sql/src/plan/lowering/variadic_left.rs @@ -342,11 +342,11 @@ pub(crate) fn attempt_left_join_magic( .map( (oa + ba..oa + ba + ra) .map(|col| MirScalarExpr::If { - cond: Box::new(MirScalarExpr::Column(oa + ba + ra).call_is_null()), + cond: Box::new(MirScalarExpr::column(oa + ba + ra).call_is_null()), then: Box::new(MirScalarExpr::literal_null( rt[col - (oa + ba)].scalar_type.clone(), )), - els: Box::new(MirScalarExpr::Column(col)), + els: Box::new(MirScalarExpr::column(col)), }) .collect(), ) @@ -410,7 +410,8 @@ fn decompose_equations(predicate: &MirScalarExpr) -> Option> expr1, expr2, } => { - if let (MirScalarExpr::Column(c1), MirScalarExpr::Column(c2)) = (&**expr1, &**expr2) + if let (MirScalarExpr::Column(c1, _name1), MirScalarExpr::Column(c2, _name2)) = + (&**expr1, &**expr2) { if c1 < c2 { equations.push((*c1, *c2)); @@ -450,14 +451,14 @@ fn recompose_equations(pairs: Vec<(usize, usize)>) -> Vec { exprs: vec![ MirScalarExpr::CallBinary { func: BinaryFunc::Eq, - expr1: Box::new(MirScalarExpr::Column(*x)), - expr2: Box::new(MirScalarExpr::Column(*y)), + expr1: Box::new(MirScalarExpr::column(*x)), + expr2: Box::new(MirScalarExpr::column(*y)), }, MirScalarExpr::CallVariadic { func: VariadicFunc::And, exprs: vec![ - MirScalarExpr::Column(*x).call_is_null(), - MirScalarExpr::Column(*y).call_is_null(), + MirScalarExpr::column(*x).call_is_null(), + MirScalarExpr::column(*y).call_is_null(), ], }, ], diff --git a/src/sql/src/plan/query.rs b/src/sql/src/plan/query.rs index eff2da8eddf39..028d400cb5dba 100644 --- a/src/sql/src/plan/query.rs +++ b/src/sql/src/plan/query.rs @@ -41,6 +41,8 @@ use std::cell::RefCell; use std::collections::{BTreeMap, BTreeSet}; use std::convert::{TryFrom, TryInto}; use std::num::NonZeroU64; +use std::rc::Rc; +use std::sync::Arc; use std::{iter, mem}; use itertools::Itertools; @@ -50,6 +52,7 @@ use mz_expr::{ }; use mz_ore::assert_none; use mz_ore::collections::CollectionExt; +use mz_ore::id_gen::IdGen; use mz_ore::option::FallibleMapExt; use mz_ore::stack::{CheckedRecursion, RecursionGuard}; use mz_ore::str::StrExt; @@ -75,7 +78,6 @@ use mz_sql_parser::ast::{ WindowFrameBound, WindowFrameUnits, WindowSpec, visit, }; use mz_sql_parser::ident; -use uuid::Uuid; use crate::catalog::{CatalogItemType, CatalogType, SessionCatalog}; use crate::func::{self, Func, FuncSpec}; @@ -942,7 +944,7 @@ fn handle_mutation_using_clause( // local import to not get confused with `mz_sql_parser::ast::visit::Visit` use mz_expr::visit::Visit; expr.visit_mut_post(&mut |e| { - if let HirScalarExpr::Column(c) = e { + if let HirScalarExpr::Column(c, _name) = e { if c.column >= using_rel_arity { c.level += 1; c.column -= using_rel_arity; @@ -2317,10 +2319,13 @@ fn plan_select_from_where( } } - let mut scope_item = if let HirScalarExpr::Column(ColumnRef { - level: 0, - column: old_column, - }) = &expr + let mut scope_item = if let HirScalarExpr::Column( + ColumnRef { + level: 0, + column: old_column, + }, + _name, + ) = &expr { // If we later have `SELECT foo.*` then we have to find all // the `foo` items in `from_scope` and figure out where they @@ -2507,7 +2512,7 @@ fn plan_select_from_where( } ExpandedSelectItem::Expr(expr) => plan_expr(ecx, expr)?.type_as_any(ecx)?, }; - if let HirScalarExpr::Column(ColumnRef { level: 0, column }) = expr { + if let HirScalarExpr::Column(ColumnRef { level: 0, column }, _name) = expr { // Simple column reference; no need to map on a new expression. output_columns.push((column, column_name)); } else { @@ -2603,6 +2608,9 @@ fn plan_select_from_where( for ord in order_by.iter().take(distinct_exprs.len()) { // The unusual construction of `expr` here is to ensure the // temporary column expression lives long enough. + // + // We then have to make sure we do a `NamelessHirScalarExpr` + // comparison, since this raw column reference has no name information. let mut expr = &HirScalarExpr::column(ord.column); if ord.column >= arity { expr = &map_exprs[ord.column - arity]; @@ -2623,7 +2631,7 @@ fn plan_select_from_where( // If the expression is a reference to an existing column, // do not introduce a new column to support it. let column = match expr { - HirScalarExpr::Column(ColumnRef { level: 0, column }) => column, + HirScalarExpr::Column(ColumnRef { level: 0, column }, _name) => column, _ => { map_exprs.push(expr); arity + map_exprs.len() - 1 @@ -2816,7 +2824,7 @@ pub(crate) fn plan_order_by_exprs( // If the expression is a reference to an existing column, // do not introduce a new column to support it. let column = match expr { - HirScalarExpr::Column(ColumnRef { level: 0, column }) => column, + HirScalarExpr::Column(ColumnRef { level: 0, column }, _name) => column, _ => { map_exprs.push(expr); ecx.relation_type.arity() + map_exprs.len() - 1 @@ -3080,20 +3088,20 @@ fn plan_rows_from_internal<'a>( num_cols.push(right_scope.len() - 1); let left_col = left_scope.len() - 1; let right_col = left_scope.len() + right_scope.len() - 1; - let on = HirScalarExpr::CallBinary { - func: BinaryFunc::Eq, - expr1: Box::new(HirScalarExpr::column(left_col)), - expr2: Box::new(HirScalarExpr::column(right_col)), - }; + let on = HirScalarExpr::call_binary( + HirScalarExpr::column(left_col), + HirScalarExpr::column(right_col), + BinaryFunc::Eq, + ); left_expr = left_expr .join(right_expr, on, JoinKind::FullOuter) - .map(vec![HirScalarExpr::CallVariadic { - func: VariadicFunc::Coalesce, - exprs: vec![ + .map(vec![HirScalarExpr::call_variadic( + VariadicFunc::Coalesce, + vec![ HirScalarExpr::column(left_col), HirScalarExpr::column(right_col), ], - }]); + )]); // Project off the previous iteration's coalesced column, but keep both of this // iteration's ordinality columns. @@ -3254,7 +3262,7 @@ fn plan_table_function_internal( }; if with_ordinality { - expr = expr.map(vec![HirScalarExpr::Windowing(WindowExpr { + expr = expr.map(vec![HirScalarExpr::windowing(WindowExpr { func: WindowExprType::Scalar(ScalarWindowExpr { func: ScalarWindowFunc::RowNumber, order_by: vec![], @@ -3747,8 +3755,17 @@ fn plan_using_constraint( let mut hidden_cols = vec![]; for column_name in column_names { - let lhs = left_scope.resolve_using_column(column_name, JoinSide::Left)?; - let mut rhs = right_scope.resolve_using_column(column_name, JoinSide::Right)?; + // the two sides will have different names (e.g., `t1.a` and `t2.a`) + let (lhs, lhs_name) = left_scope.resolve_using_column( + column_name, + JoinSide::Left, + &mut left_qcx.name_manager.borrow_mut(), + )?; + let (mut rhs, rhs_name) = right_scope.resolve_using_column( + column_name, + JoinSide::Right, + &mut right_qcx.name_manager.borrow_mut(), + )?; // Adjust the RHS reference to its post-join location. rhs.column += left_scope.len(); @@ -3760,8 +3777,14 @@ fn plan_using_constraint( column_name.as_str().quoted() )), vec![ - CoercibleScalarExpr::Coerced(HirScalarExpr::Column(lhs)), - CoercibleScalarExpr::Coerced(HirScalarExpr::Column(rhs)), + CoercibleScalarExpr::Coerced(HirScalarExpr::named_column( + lhs, + Some(Arc::clone(&lhs_name)), + )), + CoercibleScalarExpr::Coerced(HirScalarExpr::named_column( + rhs, + Some(Arc::clone(&rhs_name)), + )), ], None, )?; @@ -3782,10 +3805,10 @@ fn plan_using_constraint( join_cols.push(both_scope.items.len() + map_exprs.len()); hidden_cols.push(lhs.column); hidden_cols.push(rhs.column); - map_exprs.push(HirScalarExpr::CallVariadic { - func: VariadicFunc::Coalesce, - exprs: vec![expr1.clone(), expr2.clone()], - }); + map_exprs.push(HirScalarExpr::call_variadic( + VariadicFunc::Coalesce, + vec![expr1.clone(), expr2.clone()], + )); new_items.push(ScopeItem::from_column_name(column_name)); } } @@ -3806,14 +3829,14 @@ fn plan_using_constraint( // Should be safe to use either `lhs` or `rhs` here since the column // is available in both scopes and must have the same type of the new item. - map_exprs.push(HirScalarExpr::Column(lhs)); + // We (arbitrarily) choose the left name. + map_exprs.push(HirScalarExpr::named_column( + lhs, + Some(Arc::clone(&lhs_name)), + )); } - join_exprs.push(HirScalarExpr::CallBinary { - func: BinaryFunc::Eq, - expr1: Box::new(expr1), - expr2: Box::new(expr2), - }); + join_exprs.push(expr1.call_binary(expr2, BinaryFunc::Eq)); } both_scope.items.extend(new_items); @@ -3853,9 +3876,13 @@ fn plan_expr_inner<'a>( ecx: &'a ExprContext, e: &Expr, ) -> Result { - if let Some(i) = ecx.scope.resolve_expr(e) { + if let Some((i, item)) = ecx.scope.resolve_expr(e) { // We've already calculated this expression. - return Ok(HirScalarExpr::Column(i).into()); + return Ok(HirScalarExpr::named_column( + i, + Some(ecx.qcx.name_manager.borrow_mut().intern_scope_item(item)), + ) + .into()); } match e { @@ -3958,7 +3985,7 @@ fn plan_parameter(ecx: &ExprContext, n: usize) -> Result) -> Result { let ecx = ecx.with_name("NOT argument"); - Ok(HirScalarExpr::CallUnary { - func: UnaryFunc::Not(expr_func::Not), - expr: Box::new(plan_expr(&ecx, expr)?.type_as(&ecx, &ScalarType::Bool)?), - } - .into()) + Ok(plan_expr(&ecx, expr)? + .type_as(&ecx, &ScalarType::Bool)? + .call_unary(UnaryFunc::Not(expr_func::Not)) + .into()) } fn plan_and( @@ -4062,18 +4088,18 @@ fn plan_homogenizing_function( exprs: &[Expr], ) -> Result { assert!(!exprs.is_empty()); // `COALESCE()` is a syntax error - let expr = HirScalarExpr::CallVariadic { - func: match function { + let expr = HirScalarExpr::call_variadic( + match function { HomogenizingFunction::Coalesce => VariadicFunc::Coalesce, HomogenizingFunction::Greatest => VariadicFunc::Greatest, HomogenizingFunction::Least => VariadicFunc::Least, }, - exprs: coerce_homogeneous_exprs( + coerce_homogeneous_exprs( &ecx.with_name(&function.to_string().to_lowercase()), plan_exprs(ecx, exprs)?, None, )?, - }; + ); Ok(expr.into()) } @@ -4179,11 +4205,7 @@ fn plan_subscript_array( exprs.push(plan_expr(ecx, i)?.cast_to(ecx, CastContext::Explicit, &ScalarType::Int64)?); } - Ok(HirScalarExpr::CallVariadic { - func: VariadicFunc::ArrayIndex { offset }, - exprs, - } - .into()) + Ok(HirScalarExpr::call_variadic(VariadicFunc::ArrayIndex { offset }, exprs).into()) } fn plan_subscript_list( @@ -4266,10 +4288,7 @@ fn plan_index_list( Ok(( n_layers - depth, - HirScalarExpr::CallVariadic { - func: VariadicFunc::ListIndex, - exprs, - }, + HirScalarExpr::call_variadic(VariadicFunc::ListIndex, exprs), )) } @@ -4303,10 +4322,10 @@ fn plan_slice_list( exprs.push(end); } - Ok(HirScalarExpr::CallVariadic { - func: VariadicFunc::ListSliceLinear, + Ok(HirScalarExpr::call_variadic( + VariadicFunc::ListSliceLinear, exprs, - }) + )) } fn plan_like( @@ -4372,12 +4391,12 @@ fn plan_subscript_jsonb( // Subscripting works like `expr #> ARRAY[subscript]` rather than // `expr->subscript` as you might expect. let expr = expr.call_binary( - HirScalarExpr::CallVariadic { - func: VariadicFunc::ArrayCreate { + HirScalarExpr::call_variadic( + VariadicFunc::ArrayCreate { elem_type: ScalarType::String, }, exprs, - }, + ), BinaryFunc::JsonbGetPath, ); Ok(expr.into()) @@ -4518,10 +4537,10 @@ where // `ColumnRef`s in `aggregation_exprs` refers to the columns produced by planning the // subquery above. - let aggregation_exprs: Vec<_> = iter::once(HirScalarExpr::CallVariadic { - func: vector_create(elem_type.clone()), - exprs: vec![HirScalarExpr::column(project_column)], - }) + let aggregation_exprs: Vec<_> = iter::once(HirScalarExpr::call_variadic( + vector_create(elem_type.clone()), + vec![HirScalarExpr::column(project_column)], + )) .chain( planned_query .order_by @@ -4547,14 +4566,14 @@ where vec![], vec![AggregateExpr { func: aggregate_concat(aggregation_order_by), - expr: Box::new(HirScalarExpr::CallVariadic { - func: VariadicFunc::RecordCreate { + expr: Box::new(HirScalarExpr::call_variadic( + VariadicFunc::RecordCreate { field_names: iter::repeat(ColumnName::from("")) .take(aggregation_exprs.len()) .collect(), }, - exprs: aggregation_exprs, - }), + aggregation_exprs, + )), distinct: false, }], None, @@ -4562,12 +4581,10 @@ where .project(aggregation_projection); // If `expr` has no rows, return an empty array/list rather than NULL. - Ok(HirScalarExpr::CallBinary { - func: binary_concat, - expr1: Box::new(HirScalarExpr::Select(Box::new(reduced_expr))), - expr2: Box::new(empty_literal(elem_type)), - } - .into()) + Ok(reduced_expr + .select() + .call_binary(empty_literal(elem_type), binary_concat) + .into()) } fn plan_map_subquery( @@ -4607,15 +4624,15 @@ fn plan_map_subquery( sql_bail!("cannot build map from subquery because first column is not of type text"); } - let aggregation_exprs: Vec<_> = iter::once(HirScalarExpr::CallVariadic { - func: VariadicFunc::RecordCreate { + let aggregation_exprs: Vec<_> = iter::once(HirScalarExpr::call_variadic( + VariadicFunc::RecordCreate { field_names: vec![ColumnName::from("key"), ColumnName::from("value")], }, - exprs: vec![ + vec![ HirScalarExpr::column(key_column), HirScalarExpr::column(value_column), ], - }) + )) .chain( query .order_by @@ -4638,14 +4655,14 @@ fn plan_map_subquery( .collect(), value_type: value_type.clone(), }, - expr: Box::new(HirScalarExpr::CallVariadic { - func: VariadicFunc::RecordCreate { + expr: Box::new(HirScalarExpr::call_variadic( + VariadicFunc::RecordCreate { field_names: iter::repeat(ColumnName::from("")) .take(aggregation_exprs.len()) .collect(), }, - exprs: aggregation_exprs, - }), + aggregation_exprs, + )), distinct: false, }], None, @@ -4653,10 +4670,10 @@ fn plan_map_subquery( .project(vec![0]); // If `expr` has no rows, return an empty map rather than NULL. - let expr = HirScalarExpr::CallVariadic { - func: VariadicFunc::Coalesce, - exprs: vec![ - HirScalarExpr::Select(Box::new(expr)), + let expr = HirScalarExpr::call_variadic( + VariadicFunc::Coalesce, + vec![ + expr.select(), HirScalarExpr::literal( Datum::empty_map(), ScalarType::Map { @@ -4665,7 +4682,7 @@ fn plan_map_subquery( }, ), ], - }; + ); Ok(expr.into()) } @@ -4770,11 +4787,7 @@ fn plan_array( bail_unsupported!(format!("{}[]", ecx.humanize_scalar_type(&elem_type, false))); } - Ok(HirScalarExpr::CallVariadic { - func: VariadicFunc::ArrayCreate { elem_type }, - exprs, - } - .into()) + Ok(HirScalarExpr::call_variadic(VariadicFunc::ArrayCreate { elem_type }, exprs).into()) } fn plan_list( @@ -4811,11 +4824,7 @@ fn plan_list( bail_unsupported!("char list"); } - Ok(HirScalarExpr::CallVariadic { - func: VariadicFunc::ListCreate { elem_type }, - exprs, - } - .into()) + Ok(HirScalarExpr::call_variadic(VariadicFunc::ListCreate { elem_type }, exprs).into()) } fn plan_map( @@ -4858,10 +4867,7 @@ fn plan_map( bail_unsupported!("char map"); } - let expr = HirScalarExpr::CallVariadic { - func: VariadicFunc::MapBuild { value_type }, - exprs, - }; + let expr = HirScalarExpr::call_variadic(VariadicFunc::MapBuild { value_type }, exprs); Ok(expr.into()) } @@ -5031,11 +5037,11 @@ fn plan_aggregate_common( // where is the identity input for . let cond = plan_expr(&ecx.with_name("FILTER"), filter)?.type_as(ecx, &ScalarType::Bool)?; let expr_typ = ecx.scalar_type(&expr); - expr = HirScalarExpr::If { - cond: Box::new(cond), - then: Box::new(expr), - els: Box::new(HirScalarExpr::literal(func.identity_datum(), expr_typ)), - }; + expr = HirScalarExpr::if_then_else( + cond, + expr, + HirScalarExpr::literal(func.identity_datum(), expr_typ), + ); } let mut seen_outer = false; @@ -5063,10 +5069,7 @@ fn plan_aggregate_common( .collect(); let mut exprs = vec![expr]; exprs.extend(order_by_exprs); - expr = HirScalarExpr::CallVariadic { - func: VariadicFunc::RecordCreate { field_names }, - exprs, - }; + expr = HirScalarExpr::call_variadic(VariadicFunc::RecordCreate { field_names }, exprs); } Ok(AggregateExpr { @@ -5083,16 +5086,25 @@ fn plan_identifier(ecx: &ExprContext, names: &[Ident]) -> Result return Ok(HirScalarExpr::Column(i)), + let similar_names = match ecx.scope.resolve_column( + &ecx.qcx.outer_scopes, + &col_name, + &mut ecx.qcx.name_manager.borrow_mut(), + ) { + Ok((i, i_name)) => { + return Ok(HirScalarExpr::named_column(i, Some(i_name))); + } Err(PlanError::UnknownColumn { similar, .. }) => similar, Err(e) => return Err(e), }; @@ -5118,7 +5130,10 @@ fn plan_identifier(ecx: &ExprContext, names: &[Ident]) -> Result Ok(HirScalarExpr::Column(*column)), + [(column, item)] if item.from_single_column_function => Ok(HirScalarExpr::named_column( + *column, + Some(ecx.qcx.name_manager.borrow_mut().intern_scope_item(item)), + )), // The name refers to a normal table. Return a record containing all the // columns of the table. _ => { @@ -5130,7 +5145,10 @@ fn plan_identifier(ecx: &ExprContext, names: &[Ident]) -> Result Result( bail_unsupported!(IGNORE_NULLS_ERROR_MSG); } - return Ok(HirScalarExpr::Windowing(WindowExpr { + return Ok(HirScalarExpr::windowing(WindowExpr { func: WindowExprType::Scalar(ScalarWindowExpr { func, order_by: col_orders, @@ -5263,7 +5276,7 @@ fn plan_function<'a>( } } - return Ok(HirScalarExpr::Windowing(WindowExpr { + return Ok(HirScalarExpr::windowing(WindowExpr { func: WindowExprType::Value(ValueWindowExpr { func, args: Box::new(args_encoded), @@ -5333,7 +5346,7 @@ fn plan_function<'a>( bail_unsupported!("DISTINCT in window aggregates"); } - return Ok(HirScalarExpr::Windowing(WindowExpr { + return Ok(HirScalarExpr::windowing(WindowExpr { func: WindowExprType::Aggregate(AggregateWindowExpr { aggregate_expr, order_by: col_orders, @@ -5528,11 +5541,7 @@ fn plan_case<'a>( let mut expr = result_exprs.pop().unwrap(); assert_eq!(cond_exprs.len(), result_exprs.len()); for (cexpr, rexpr) in cond_exprs.into_iter().zip(result_exprs).rev() { - expr = HirScalarExpr::If { - cond: Box::new(cexpr), - then: Box::new(rexpr), - els: Box::new(expr), - } + expr = HirScalarExpr::if_then_else(cexpr, rexpr, expr); } Ok(expr) } @@ -6037,6 +6046,7 @@ struct AggregateTableFuncVisitor<'a> { tables: BTreeMap, String>, table_disallowed_context: Vec<&'static str>, in_select_item: bool, + id_gen: IdGen, err: Option, } @@ -6049,6 +6059,7 @@ impl<'a> AggregateTableFuncVisitor<'a> { tables: BTreeMap::new(), table_disallowed_context: Vec::new(), in_select_item: false, + id_gen: Default::default(), err: None, } } @@ -6166,11 +6177,12 @@ impl<'a> VisitMut<'_, Aug> for AggregateTableFuncVisitor<'a> { } = &func { // Identical table functions can be de-duplicated. + let unique_id = self.id_gen.allocate_id(); let id = self .tables .entry(func) - .or_insert_with(|| format!("table_func_{}", Uuid::new_v4())); - // We know this is okay because id is is 11 characters + 36 characters, which is + .or_insert_with(|| format!("table_func_{unique_id}")); + // We know this is okay because id is is 11 characters + <=20 characters, which is // less than our max length. *expr = Expr::Identifier(vec![Ident::new_unchecked(id.clone())]); } @@ -6313,6 +6325,8 @@ pub struct QueryContext<'a> { pub outer_relation_types: Vec, /// CTEs for this query, mapping their assigned LocalIds to their definition. pub ctes: BTreeMap, + /// A name manager, for interning column names that will be stored in HIR and MIR. + pub name_manager: Rc>, pub recursion_guard: RecursionGuard, } @@ -6330,6 +6344,7 @@ impl<'a> QueryContext<'a> { outer_scopes: vec![], outer_relation_types: vec![], ctes: BTreeMap::new(), + name_manager: Rc::new(RefCell::new(NameManager::new())), recursion_guard: RecursionGuard::with_limit(1024), // chosen arbitrarily } } @@ -6346,6 +6361,8 @@ impl<'a> QueryContext<'a> { let outer_relation_types = iter::once(relation_type) .chain(self.outer_relation_types.clone()) .collect(); + // These shenanigans are simpler than adding `&mut NameManager` arguments everywhere. + let name_manager = Rc::clone(&self.name_manager); QueryContext { scx: self.scx, @@ -6353,6 +6370,7 @@ impl<'a> QueryContext<'a> { outer_scopes, outer_relation_types, ctes, + name_manager, recursion_guard: self.recursion_guard.clone(), } } @@ -6501,4 +6519,93 @@ impl<'a> ExprContext<'a> { pub fn humanize_scalar_type(&self, typ: &ScalarType, postgres_compat: bool) -> String { self.qcx.scx.humanize_scalar_type(typ, postgres_compat) } + + pub fn intern(&self, item: &ScopeItem) -> Arc { + self.qcx.name_manager.borrow_mut().intern_scope_item(item) + } +} + +/// Manages column names, doing lightweight string internment. +/// +/// Names are stored in `HirScalarExpr` and `MirScalarExpr` using +/// `Option>`; we use the `NameManager` when lowering from SQL to HIR +/// to ensure maximal sharing. +#[derive(Debug, Clone)] +pub struct NameManager(BTreeSet>); + +impl NameManager { + /// Creates a new `NameManager`, with no interned names + pub fn new() -> Self { + Self(BTreeSet::new()) + } + + /// Interns a string, returning a reference-counted pointer to the interned + /// string. + fn intern>(&mut self, s: S) -> Arc { + let s = s.as_ref(); + if let Some(interned) = self.0.get(s) { + Arc::clone(interned) + } else { + let interned: Arc = Arc::from(s); + self.0.insert(Arc::clone(&interned)); + interned + } + } + + /// Interns a string representing a reference to a `ScopeItem`, returning a + /// reference-counted pointer to the interned string. + pub fn intern_scope_item(&mut self, item: &ScopeItem) -> Arc { + // TODO(mgree): extracting the table name from `item` leads to an issue with the catalog + // + // After an `ALTER ... RENAME` on a table, the catalog will have out-of-date + // name information. Note that as of 2025-04-09, we don't support column + // renames. + // + // A few bad alternatives: + // + // (1) Store it but don't write it down. This fails because the expression + // cache will erase our names on restart. + // (2) When `ALTER ... RENAME` is run, re-optimize all downstream objects to + // get the right names. But the world now and the world when we made + // those objects may be different. + // (3) Just don't write down the table name. Nothing fails... for now. + + self.intern(item.column_name.as_str()) + } +} + +#[cfg(test)] +mod test { + use super::*; + + /// Ensure that `NameManager`'s string interning works as expected. + /// + /// In particular, structurally but not referentially identical strings should + /// be interned to the same `Arc`ed pointer. + #[mz_ore::test] + pub fn test_name_manager_string_interning() { + let mut nm = NameManager::new(); + + let orig_hi = "hi"; + let hi = nm.intern(orig_hi); + let hello = nm.intern("hello"); + + assert_ne!(hi.as_ptr(), hello.as_ptr()); + + // this static string is _likely_ the same as `orig_hi`` + let hi2 = nm.intern("hi"); + assert_eq!(hi.as_ptr(), hi2.as_ptr()); + + // generate a "hi" string that doesn't get optimized to the same static string + let s = format!( + "{}{}", + hi.chars().nth(0).unwrap(), + hi2.chars().nth(1).unwrap() + ); + // make sure that we're testing with a fresh string! + assert_ne!(orig_hi.as_ptr(), s.as_ptr()); + + let hi3 = nm.intern(s); + assert_eq!(hi.as_ptr(), hi3.as_ptr()); + } } diff --git a/src/sql/src/plan/scope.rs b/src/sql/src/plan/scope.rs index 6e99c0cb91b03..ba9f556d2bf49 100644 --- a/src/sql/src/plan/scope.rs +++ b/src/sql/src/plan/scope.rs @@ -43,6 +43,7 @@ use std::collections::BTreeSet; use std::iter; +use std::sync::Arc; use mz_ore::iter::IteratorExt; use mz_repr::ColumnName; @@ -52,6 +53,7 @@ use crate::names::{Aug, PartialItemName}; use crate::plan::error::PlanError; use crate::plan::hir::ColumnRef; use crate::plan::plan_utils::JoinSide; +use crate::plan::query::NameManager; #[derive(Debug, Clone)] pub struct ScopeItem { @@ -315,7 +317,8 @@ impl Scope { mut matches: M, table_name: Option<&PartialItemName>, column_name: &ColumnName, - ) -> Result + name_manager: &mut NameManager, + ) -> Result<(ColumnRef, Arc), PlanError> where M: FnMut(&ScopeCursor) -> bool, { @@ -379,7 +382,7 @@ impl Scope { if let Some(error_if_referenced) = item.error_if_referenced { return Err(error_if_referenced(table_name, column_name)); } - Ok(column) + Ok((column, name_manager.intern_scope_item(item))) } } } @@ -392,13 +395,15 @@ impl Scope { &'a self, outer_scopes: &[Scope], column_name: &ColumnName, - ) -> Result { + name_manager: &mut NameManager, + ) -> Result<(ColumnRef, Arc), PlanError> { let table_name = None; self.resolve_internal( outer_scopes, |c| c.allow_unqualified_references(), table_name, column_name, + name_manager, ) } @@ -407,18 +412,20 @@ impl Scope { &self, column_name: &ColumnName, join_side: JoinSide, - ) -> Result { - self.resolve_column(&[], column_name).map_err(|e| match e { - // Attach a bit more context to unknown and ambiguous column - // errors to match PostgreSQL. - PlanError::AmbiguousColumn(column) => { - PlanError::AmbiguousColumnInUsingClause { column, join_side } - } - PlanError::UnknownColumn { column, .. } => { - PlanError::UnknownColumnInUsingClause { column, join_side } - } - _ => e, - }) + name_manager: &mut NameManager, + ) -> Result<(ColumnRef, Arc), PlanError> { + self.resolve_column(&[], column_name, name_manager) + .map_err(|e| match e { + // Attach a bit more context to unknown and ambiguous column + // errors to match PostgreSQL. + PlanError::AmbiguousColumn(column) => { + PlanError::AmbiguousColumnInUsingClause { column, join_side } + } + PlanError::UnknownColumn { column, .. } => { + PlanError::UnknownColumnInUsingClause { column, join_side } + } + _ => e, + }) } pub fn resolve_table_column<'a>( @@ -426,7 +433,8 @@ impl Scope { outer_scopes: &[Scope], table_name: &PartialItemName, column_name: &ColumnName, - ) -> Result { + name_manager: &mut NameManager, + ) -> Result<(ColumnRef, Arc), PlanError> { let mut seen_at_level = None; self.resolve_internal( outer_scopes, @@ -448,24 +456,16 @@ impl Scope { }, Some(table_name), column_name, + name_manager, ) } - pub fn resolve<'a>( - &'a self, - outer_scopes: &[Scope], - table_name: Option<&PartialItemName>, - column_name: &ColumnName, - ) -> Result { - match table_name { - None => self.resolve_column(outer_scopes, column_name), - Some(table_name) => self.resolve_table_column(outer_scopes, table_name, column_name), - } - } - /// Look to see if there is an already-calculated instance of this expr. - /// Failing to find one is not an error, so this just returns Option - pub fn resolve_expr<'a>(&'a self, expr: &Expr) -> Option { + /// Failing to find one is not an error, so this just returns an Option. + /// + /// We do, however, return the `ScopeItem`, so that we can resolve and + /// intern the column name. + pub fn resolve_expr<'a>(&'a self, expr: &Expr) -> Option<(ColumnRef, &'a ScopeItem)> { // Literal values should not be treated as "cached" because their types // in scope will have already been determined, but the type of the // reoccurence of the expr might want to have a different type. @@ -481,9 +481,14 @@ impl Scope { .iter() .enumerate() .find(|(_, item)| item.exprs.contains(expr)) - .map(|(i, _)| ColumnRef { - level: 0, - column: i, + .map(|(i, item)| { + ( + ColumnRef { + level: 0, + column: i, + }, + item, + ) }) } diff --git a/src/sql/src/plan/statement/ddl.rs b/src/sql/src/plan/statement/ddl.rs index 544d8a19a06d9..a18ea2b00138c 100644 --- a/src/sql/src/plan/statement/ddl.rs +++ b/src/sql/src/plan/statement/ddl.rs @@ -3973,10 +3973,13 @@ pub fn plan_create_index( let index_name_col_suffix = keys .iter() .map(|k| match k { - mz_expr::MirScalarExpr::Column(i) => match on_desc.get_unambiguous_name(*i) { - Some(col_name) => col_name.to_string(), - None => format!("{}", i + 1), - }, + mz_expr::MirScalarExpr::Column(i, name) => { + match (on_desc.get_unambiguous_name(*i), &name.0) { + (Some(col_name), _) => col_name.to_string(), + (None, Some(name)) => name.to_string(), + (None, None) => format!("{}", i + 1), + } + } _ => "expr".to_string(), }) .join("_"); diff --git a/src/sql/src/plan/transform_ast.rs b/src/sql/src/plan/transform_ast.rs index 3955256c1a763..431f27ba05318 100644 --- a/src/sql/src/plan/transform_ast.rs +++ b/src/sql/src/plan/transform_ast.rs @@ -13,6 +13,7 @@ //! are much easier to perform in SQL. Someday, we'll want our own SQL IR, //! but for now we just use the parser's AST directly. +use mz_ore::id_gen::IdGen; use mz_ore::stack::{CheckedRecursion, RecursionGuard}; use mz_repr::namespaces::{MZ_CATALOG_SCHEMA, MZ_UNSAFE_SCHEMA, PG_CATALOG_SCHEMA}; use mz_sql_parser::ast::visit_mut::{self, VisitMut, VisitMutNode}; @@ -21,7 +22,6 @@ use mz_sql_parser::ast::{ Query, Select, SelectItem, TableAlias, TableFactor, TableWithJoins, Value, WindowSpec, }; use mz_sql_parser::ident; -use uuid::Uuid; use crate::names::{Aug, PartialItemName, ResolvedDataType, ResolvedItemName}; use crate::normalize; @@ -553,6 +553,7 @@ impl<'ast> VisitMut<'ast, Aug> for FuncRewriter<'_> { struct Desugarer<'a> { scx: &'a StatementContext<'a>, status: Result<(), PlanError>, + id_gen: IdGen, recursion_guard: RecursionGuard, } @@ -587,6 +588,7 @@ impl<'a> Desugarer<'a> { Desugarer { scx, status: Ok(()), + id_gen: Default::default(), recursion_guard: RecursionGuard::with_limit(1024), // chosen arbitrarily } } @@ -745,14 +747,20 @@ impl<'a> Desugarer<'a> { let bindings: Vec<_> = (0..arity) // Note: using unchecked is okay here because we know the value will be less than // our maximum length. - .map(|_| Ident::new_unchecked(format!("right_{}", Uuid::new_v4()))) + .map(|col| { + let unique_id = self.id_gen.allocate_id(); + Ident::new_unchecked(format!("right_col{col}_{unique_id}")) + }) .collect(); + let subquery_unique_id = self.id_gen.allocate_id(); + // Note: kay to use unchecked here because we know the value will be small enough. + let subquery_name = Ident::new_unchecked(format!("subquery{subquery_unique_id}")); let select = Select::default() .from(TableWithJoins::subquery( right.take(), TableAlias { - name: ident!("subquery"), + name: subquery_name, columns: bindings.clone(), strict: true, }, diff --git a/src/sql/src/plan/transform_hir.rs b/src/sql/src/plan/transform_hir.rs index 7c2e4927b6666..bef4f0515b3a3 100644 --- a/src/sql/src/plan/transform_hir.rs +++ b/src/sql/src/plan/transform_hir.rs @@ -21,7 +21,7 @@ use mz_ore::stack::RecursionLimitError; use mz_repr::{ColumnName, ColumnType, RelationType, ScalarType}; use crate::plan::hir::{ - AbstractExpr, AggregateFunc, AggregateWindowExpr, ColumnRef, HirRelationExpr, HirScalarExpr, + AbstractExpr, AggregateFunc, AggregateWindowExpr, HirRelationExpr, HirScalarExpr, ValueWindowExpr, ValueWindowFunc, WindowExpr, }; use crate::plan::{AggregateExpr, WindowExprType}; @@ -95,7 +95,7 @@ pub fn split_subquery_predicates(expr: &mut HirRelationExpr) -> Result<(), Recur fn walk_scalar(expr: &mut HirScalarExpr) -> Result<(), RecursionLimitError> { expr.try_visit_mut_post(&mut |expr| { match expr { - HirScalarExpr::Exists(input) | HirScalarExpr::Select(input) => { + HirScalarExpr::Exists(input, _name) | HirScalarExpr::Select(input, _name) => { walk_relation(input)? } _ => (), @@ -107,7 +107,7 @@ pub fn split_subquery_predicates(expr: &mut HirRelationExpr) -> Result<(), Recur fn contains_subquery(expr: &HirScalarExpr) -> Result { let mut found = false; expr.visit_pre(&mut |expr| match expr { - HirScalarExpr::Exists(_) | HirScalarExpr::Select(_) => found = true, + HirScalarExpr::Exists(..) | HirScalarExpr::Select(..) => found = true, _ => (), })?; Ok(found) @@ -137,6 +137,7 @@ pub fn split_subquery_predicates(expr: &mut HirRelationExpr) -> Result<(), Recur HirScalarExpr::CallVariadic { func: VariadicFunc::And, exprs, + name: _, } => { exprs .into_iter() @@ -232,8 +233,8 @@ pub fn try_simplify_quantified_comparisons( ) -> Result<(), RecursionLimitError> { expr.try_visit_mut_pre(&mut |e| { match e { - HirScalarExpr::Exists(input) => walk_relation(input, outers)?, - HirScalarExpr::Select(input) => { + HirScalarExpr::Exists(input, _name) => walk_relation(input, outers)?, + HirScalarExpr::Select(input, _name) => { walk_relation(input, outers)?; // We're inside a `(SELECT ...)` subquery. Now let's see if @@ -423,39 +424,45 @@ pub fn fuse_window_functions( /// Helper function to extract the above options. fn extract_options(call: &HirScalarExpr) -> WindowFuncCallOptions { match call { - HirScalarExpr::Windowing(WindowExpr { - func: - WindowExprType::Value(ValueWindowExpr { - order_by: inner_order_by, - window_frame, - ignore_nulls, - func: _, - args: _, - }), - partition_by, - order_by: outer_order_by, - }) => WindowFuncCallOptions::Value(ValueWindowFuncCallOptions { + HirScalarExpr::Windowing( + WindowExpr { + func: + WindowExprType::Value(ValueWindowExpr { + order_by: inner_order_by, + window_frame, + ignore_nulls, + func: _, + args: _, + }), + partition_by, + order_by: outer_order_by, + }, + _name, + ) => WindowFuncCallOptions::Value(ValueWindowFuncCallOptions { partition_by: partition_by.clone(), outer_order_by: outer_order_by.clone(), inner_order_by: inner_order_by.clone(), window_frame: window_frame.clone(), ignore_nulls: ignore_nulls.clone(), }), - HirScalarExpr::Windowing(WindowExpr { - func: - WindowExprType::Aggregate(AggregateWindowExpr { - aggregate_expr: - AggregateExpr { - distinct, - func: _, - expr: _, - }, - order_by: inner_order_by, - window_frame, - }), - partition_by, - order_by: outer_order_by, - }) => WindowFuncCallOptions::Agg(AggregateWindowFuncCallOptions { + HirScalarExpr::Windowing( + WindowExpr { + func: + WindowExprType::Aggregate(AggregateWindowExpr { + aggregate_expr: + AggregateExpr { + distinct, + func: _, + expr: _, + }, + order_by: inner_order_by, + window_frame, + }), + partition_by, + order_by: outer_order_by, + }, + _name, + ) => WindowFuncCallOptions::Agg(AggregateWindowFuncCallOptions { partition_by: partition_by.clone(), outer_order_by: outer_order_by.clone(), inner_order_by: inner_order_by.clone(), @@ -489,18 +496,21 @@ pub fn fuse_window_functions( .calls .iter() .map(|(_idx, call)| { - if let HirScalarExpr::Windowing(WindowExpr { - func: - WindowExprType::Value(ValueWindowExpr { - func, - args, - order_by: _, - window_frame: _, - ignore_nulls: _, - }), - partition_by: _, - order_by: _, - }) = call + if let HirScalarExpr::Windowing( + WindowExpr { + func: + WindowExprType::Value(ValueWindowExpr { + func, + args, + order_by: _, + window_frame: _, + ignore_nulls: _, + }), + partition_by: _, + order_by: _, + }, + _name, + ) = call { (func.clone(), (**args).clone()) } else { @@ -508,8 +518,8 @@ pub fn fuse_window_functions( } }) .unzip(); - let fused_args = HirScalarExpr::CallVariadic { - func: VariadicFunc::RecordCreate { + let fused_args = HirScalarExpr::call_variadic( + VariadicFunc::RecordCreate { // These field names are not important, because this record will only be an // intermediate expression, which we'll manipulate further before it ends up // anywhere where a column name would be visible. @@ -517,9 +527,9 @@ pub fn fuse_window_functions( .take(fused_args.len()) .collect(), }, - exprs: fused_args, - }; - HirScalarExpr::Windowing(WindowExpr { + fused_args, + ); + HirScalarExpr::windowing(WindowExpr { func: WindowExprType::Value(ValueWindowExpr { func: ValueWindowFunc::Fused(fused_funcs), args: Box::new(fused_args), @@ -536,21 +546,24 @@ pub fn fuse_window_functions( .calls .iter() .map(|(_idx, call)| { - if let HirScalarExpr::Windowing(WindowExpr { - func: - WindowExprType::Aggregate(AggregateWindowExpr { - aggregate_expr: - AggregateExpr { - func, - expr, - distinct: _, - }, - order_by: _, - window_frame: _, - }), - partition_by: _, - order_by: _, - }) = call + if let HirScalarExpr::Windowing( + WindowExpr { + func: + WindowExprType::Aggregate(AggregateWindowExpr { + aggregate_expr: + AggregateExpr { + func, + expr, + distinct: _, + }, + order_by: _, + window_frame: _, + }), + partition_by: _, + order_by: _, + }, + _name, + ) = call { (func.clone(), (**expr).clone()) } else { @@ -558,15 +571,15 @@ pub fn fuse_window_functions( } }) .unzip(); - let fused_args = HirScalarExpr::CallVariadic { - func: VariadicFunc::RecordCreate { + let fused_args = HirScalarExpr::call_variadic( + VariadicFunc::RecordCreate { field_names: iter::repeat(ColumnName::from("")) .take(fused_args.len()) .collect(), }, - exprs: fused_args, - }; - HirScalarExpr::Windowing(WindowExpr { + fused_args, + ); + HirScalarExpr::windowing(WindowExpr { func: WindowExprType::Aggregate(AggregateWindowExpr { aggregate_expr: AggregateExpr { func: AggregateFunc::FusedWindowAgg { funcs: fused_funcs }, @@ -583,12 +596,9 @@ pub fn fuse_window_functions( }; let decompositions = (0..self.calls.len()) - .map(|field| HirScalarExpr::CallUnary { - func: UnaryFunc::RecordGet(mz_expr::func::RecordGet(field)), - expr: Box::new(HirScalarExpr::Column(ColumnRef { - level: 0, - column: new_col, - })), + .map(|field| { + HirScalarExpr::column(new_col) + .call_unary(UnaryFunc::RecordGet(mz_expr::func::RecordGet(field))) }) .collect(); @@ -600,23 +610,29 @@ pub fn fuse_window_functions( // Look for calls only at the root of scalar expressions. This is enough // because they are always there, see 72e84bb78. match scalar_expr { - HirScalarExpr::Windowing(WindowExpr { - func: WindowExprType::Value(ValueWindowExpr { func, .. }), - .. - }) => { + HirScalarExpr::Windowing( + WindowExpr { + func: WindowExprType::Value(ValueWindowExpr { func, .. }), + .. + }, + _name, + ) => { // Exclude those calls that are already fused. (We shouldn't currently // encounter these, because we just do one pass, but it's better to be // robust against future code changes.) !matches!(func, ValueWindowFunc::Fused(..)) } - HirScalarExpr::Windowing(WindowExpr { - func: - WindowExprType::Aggregate(AggregateWindowExpr { - aggregate_expr: AggregateExpr { func, .. }, - .. - }), - .. - }) => !matches!(func, AggregateFunc::FusedWindowAgg { .. }), + HirScalarExpr::Windowing( + WindowExpr { + func: + WindowExprType::Aggregate(AggregateWindowExpr { + aggregate_expr: AggregateExpr { func, .. }, + .. + }), + .. + }, + _name, + ) => !matches!(func, AggregateFunc::FusedWindowAgg { .. }), _ => false, } }; diff --git a/src/sql/src/plan/typeconv.rs b/src/sql/src/plan/typeconv.rs index fba150bc5b2c4..c4abe14723a1e 100644 --- a/src/sql/src/plan/typeconv.rs +++ b/src/sql/src/plan/typeconv.rs @@ -24,8 +24,7 @@ use mz_repr::{ColumnName, ColumnType, Datum, RelationType, ScalarBaseType, Scala use crate::catalog::TypeCategory; use crate::plan::error::PlanError; use crate::plan::hir::{ - AbstractColumnType, CoercibleScalarExpr, CoercibleScalarType, ColumnRef, HirScalarExpr, - UnaryFunc, + AbstractColumnType, CoercibleScalarExpr, CoercibleScalarType, HirScalarExpr, UnaryFunc, }; use crate::plan::query::{ExprContext, QueryContext}; use crate::plan::scope::Scope; @@ -934,10 +933,7 @@ pub fn to_jsonb(ecx: &ExprContext, expr: HirScalarExpr) -> HirScalarExpr { .call_unary(UnaryFunc::RecordGet(func::RecordGet(i))), )); } - HirScalarExpr::CallVariadic { - func: VariadicFunc::JsonbBuildObject, - exprs, - } + HirScalarExpr::call_variadic(VariadicFunc::JsonbBuildObject, exprs) } ref ty @ List { ref element_type, .. @@ -1126,20 +1122,20 @@ pub fn plan_coerce<'a>( for (e, coerce_to) in exprs.into_iter().zip(coercions) { out.push(plan_coerce(ecx, e, &coerce_to)?); } - HirScalarExpr::CallVariadic { - func: VariadicFunc::RecordCreate { + HirScalarExpr::call_variadic( + VariadicFunc::RecordCreate { field_names: (0..arity) .map(|i| ColumnName::from(format!("f{}", i + 1))) .collect(), }, - exprs: out, - } + out, + ) } Parameter(n) => { let prev = ecx.param_types().borrow_mut().insert(n, coerce_to.clone()); assert_none!(prev); - HirScalarExpr::Parameter(n) + HirScalarExpr::parameter(n) } }) } @@ -1179,10 +1175,7 @@ pub fn plan_hypothetical_cast( allow_windows: false, }; - let col_expr = HirScalarExpr::Column(ColumnRef { - level: 0, - column: 0, - }); + let col_expr = HirScalarExpr::column(0); // Determine the `ScalarExpr` required to cast our column to the target // component type. diff --git a/src/sql/src/pure/postgres.rs b/src/sql/src/pure/postgres.rs index 1c9da73c312b8..3b00c59d1fb7b 100644 --- a/src/sql/src/pure/postgres.rs +++ b/src/sql/src/pure/postgres.rs @@ -10,6 +10,7 @@ //! Postgres utilities for SQL purification. use std::collections::{BTreeMap, BTreeSet}; +use std::sync::Arc; use mz_expr::MirScalarExpr; use mz_postgres_util::Config; @@ -514,9 +515,9 @@ pub(crate) fn generate_column_casts( Err(_) => { table_cast.push(( CastType::Natural, - HirScalarExpr::CallVariadic { - func: mz_expr::VariadicFunc::ErrorIfNull, - exprs: vec![ + HirScalarExpr::call_variadic( + mz_expr::VariadicFunc::ErrorIfNull, + vec![ HirScalarExpr::literal_null(ScalarType::String), HirScalarExpr::literal( mz_repr::Datum::from( @@ -526,7 +527,7 @@ pub(crate) fn generate_column_casts( ScalarType::String, ), ], - } + ) .lower_uncorrelated() .expect("no correlation"), )); @@ -538,10 +539,13 @@ pub(crate) fn generate_column_casts( let data_type = scx.resolve_type(ty)?; let scalar_type = crate::plan::query::scalar_type_from_sql(scx, &data_type)?; - let col_expr = HirScalarExpr::Column(ColumnRef { - level: 0, - column: i, - }); + let col_expr = HirScalarExpr::named_column( + ColumnRef { + level: 0, + column: i, + }, + Some(Arc::from(column.name.as_str())), + ); let cast_expr = plan_cast(&cast_ecx, CastContext::Explicit, col_expr, &scalar_type)?; @@ -553,9 +557,7 @@ pub(crate) fn generate_column_casts( // constraint changes and we want to error subsource if // e.g. the constraint is dropped and we don't notice // it. - HirScalarExpr::CallVariadic { - func: mz_expr::VariadicFunc::ErrorIfNull, - exprs: vec![ + HirScalarExpr::call_variadic(mz_expr::VariadicFunc::ErrorIfNull, vec![ cast_expr, HirScalarExpr::literal( mz_repr::Datum::from( @@ -569,7 +571,7 @@ pub(crate) fn generate_column_casts( ScalarType::String, ), ], - } + ) }; // We expect only reg* types to encounter this issue. Users diff --git a/src/transform/src/analysis.rs b/src/transform/src/analysis.rs index a163398ce803f..f894a04402bc0 100644 --- a/src/transform/src/analysis.rs +++ b/src/transform/src/analysis.rs @@ -938,6 +938,7 @@ mod non_negative { mod column_names { use std::ops::Range; + use std::sync::Arc; use super::Analysis; use mz_expr::{AggregateFunc, Id, MirRelationExpr, MirScalarExpr}; @@ -951,6 +952,8 @@ mod column_names { Global(GlobalId, usize), /// An anonymous expression named after the top-level function name. Aggregate(AggregateFunc, Box), + /// A column with a name that has been saved from the original SQL query. + Annotated(Arc), /// An column with an unknown name. Unknown, } @@ -958,7 +961,10 @@ mod column_names { impl ColumnName { /// Return `true` iff this the variant is not unknown. pub fn is_known(&self) -> bool { - matches!(self, Self::Global(..) | Self::Aggregate(..)) + matches!( + self, + Self::Global(..) | Self::Aggregate(..) | Self::Annotated(..) + ) } /// Humanize the column to a [`String`], returns an empty [`String`] for @@ -975,9 +981,21 @@ mod column_names { format!("{func}_{expr}") } } + Self::Annotated(name) => name.to_string(), Self::Unknown => String::new(), } } + + /// Clone this column name if it is known, otherwise try to use the provided + /// name if it is available. + pub fn cloned_or_annotated(&self, name: &Option>) -> Self { + match self { + Self::Global(..) | Self::Aggregate(..) | Self::Annotated(..) => self.clone(), + Self::Unknown => name + .as_ref() + .map_or_else(|| Self::Unknown, |name| Self::Annotated(Arc::clone(name))), + } + } } /// Compute the column types of each subtree of a [MirRelationExpr] from the @@ -995,7 +1013,7 @@ mod column_names { fn extend_with_scalars(column_names: &mut Vec, scalars: &Vec) { for scalar in scalars { column_names.push(match scalar { - MirScalarExpr::Column(c) => column_names[*c].clone(), + MirScalarExpr::Column(c, name) => column_names[*c].cloned_or_annotated(&name.0), _ => ColumnName::Unknown, }); } @@ -1569,7 +1587,7 @@ mod cardinality { ) -> OrderedFloat { let index_selectivity = |expr: &MirScalarExpr| -> Option> { match expr { - MirScalarExpr::Column(col) => { + MirScalarExpr::Column(col, _) => { if unique_columns.contains(col) { // TODO(mgree): when we have index cardinality statistics, they should go here when `expr` is a `MirScalarExpr::Column` that's in `unique_columns` None @@ -1582,7 +1600,7 @@ mod cardinality { }; match predicate_expr { - MirScalarExpr::Column(_) + MirScalarExpr::Column(_, _) | MirScalarExpr::Literal(_, _) | MirScalarExpr::CallUnmaterializable(_) => OrderedFloat(1.0), MirScalarExpr::CallUnary { func, expr } => match func { @@ -1701,7 +1719,7 @@ mod cardinality { let mut all_unique = true; for expr in equiv { - if let MirScalarExpr::Column(col) = expr { + if let MirScalarExpr::Column(col, _) = expr { if let Some(idx) = unique_columns.get(col) { unique_sources.insert(*idx); } else { diff --git a/src/transform/src/analysis/equivalences.rs b/src/transform/src/analysis/equivalences.rs index d2f65c7cc26f0..edc4cbf4cf5ac 100644 --- a/src/transform/src/analysis/equivalences.rs +++ b/src/transform/src/analysis/equivalences.rs @@ -83,7 +83,7 @@ impl Analysis for Equivalences { for (index, common) in common.into_iter().enumerate() { if let Some(datum) = common { equivalences.classes.push(vec![ - MirScalarExpr::Column(index), + MirScalarExpr::column(index), MirScalarExpr::literal_ok( datum, typ.column_types[index].scalar_type.clone(), @@ -152,7 +152,7 @@ impl Analysis for Equivalences { for (pos, expr) in scalars.iter().enumerate() { equivalences .classes - .push(vec![MirScalarExpr::Column(input_arity + pos), expr.clone()]); + .push(vec![MirScalarExpr::column(input_arity + pos), expr.clone()]); } } equivalences @@ -215,7 +215,7 @@ impl Analysis for Equivalences { for (pos, expr) in group_key.iter().enumerate() { equivalences .classes - .push(vec![MirScalarExpr::Column(input_arity + pos), expr.clone()]); + .push(vec![MirScalarExpr::column(input_arity + pos), expr.clone()]); } // Having added classes to `equivalences`, we should minimize the classes to fold the @@ -402,9 +402,9 @@ impl EquivalenceClasses { (Literal(_, _), Literal(_, _)) => e1.cmp(e2), (Literal(_, _), _) => Less, (_, Literal(_, _)) => Greater, - (Column(_), Column(_)) => e1.cmp(e2), - (Column(_), _) => Less, - (_, Column(_)) => Greater, + (Column(_, _), Column(_, _)) => e1.cmp(e2), + (Column(_, _), _) => Less, + (_, Column(_, _)) => Greater, (x, y) => { // General expressions should be ordered by their size, // to ensure we only simplify expressions by substitution. @@ -931,8 +931,8 @@ impl EquivalenceClasses { // We introduce only the equivalence to the first occurrence, and rely on minimization to collect them. for (col1, col2) in dupes { self.classes.push(vec![ - MirScalarExpr::Column(col1), - MirScalarExpr::Column(col2), + MirScalarExpr::column(col1), + MirScalarExpr::column(col2), ]); } self.remap.clear(); diff --git a/src/transform/src/canonicalization/projection_extraction.rs b/src/transform/src/canonicalization/projection_extraction.rs index 3e6cb28192123..398d6e5be2350 100644 --- a/src/transform/src/canonicalization/projection_extraction.rs +++ b/src/transform/src/canonicalization/projection_extraction.rs @@ -46,13 +46,13 @@ impl ProjectionExtraction { if let MirRelationExpr::Map { input, scalars } = relation { if scalars .iter() - .any(|s| matches!(s, MirScalarExpr::Column(_))) + .any(|s| matches!(s, MirScalarExpr::Column(_, _))) { let input_arity = input.arity(); let mut outputs: Vec<_> = (0..input_arity).collect(); let mut dropped = 0; scalars.retain(|scalar| { - if let MirScalarExpr::Column(col) = scalar { + if let MirScalarExpr::Column(col, _) = scalar { dropped += 1; // We may need to chase down a few levels of indirection; // find the original input column in `outputs[*col]`. diff --git a/src/transform/src/column_knowledge.rs b/src/transform/src/column_knowledge.rs index 9748f1ad86fac..703733d7616fd 100644 --- a/src/transform/src/column_knowledge.rs +++ b/src/transform/src/column_knowledge.rs @@ -269,10 +269,10 @@ impl ColumnKnowledge { { // Collect knowledge about the inputs (for columns and literals). let mut knowledge = DatumKnowledge::top(); - if let MirScalarExpr::Column(c) = &**expr1 { + if let MirScalarExpr::Column(c, _) = &**expr1 { knowledge.meet_assign(&input_knowledge[*c]); } - if let MirScalarExpr::Column(c) = &**expr2 { + if let MirScalarExpr::Column(c, _) = &**expr2 { knowledge.meet_assign(&input_knowledge[*c]); } @@ -285,10 +285,10 @@ impl ColumnKnowledge { } // Write back unified knowledge to each column. - if let MirScalarExpr::Column(c) = &**expr1 { + if let MirScalarExpr::Column(c, _) = &**expr1 { input_knowledge[*c].meet_assign(&knowledge); } - if let MirScalarExpr::Column(c) = &**expr2 { + if let MirScalarExpr::Column(c, _) = &**expr2 { input_knowledge[*c].meet_assign(&knowledge); } } @@ -302,7 +302,7 @@ impl ColumnKnowledge { expr, } = &**expr { - if let MirScalarExpr::Column(c) = &**expr { + if let MirScalarExpr::Column(c, _) = &**expr { input_knowledge[*c].meet_assign(&DatumKnowledge::any(false)); } } @@ -354,7 +354,7 @@ impl ColumnKnowledge { knowledge_stack, )?; } - if let MirScalarExpr::Column(c) = expr { + if let MirScalarExpr::Column(c, _) = expr { knowledge.meet_assign(&knowledges[*c]); } if let MirScalarExpr::Literal(..) = expr { @@ -362,7 +362,7 @@ impl ColumnKnowledge { } } for expr in equivalence.iter_mut() { - if let MirScalarExpr::Column(c) = expr { + if let MirScalarExpr::Column(c, _) = expr { knowledges[*c] = knowledge.clone(); } } @@ -793,7 +793,7 @@ fn optimize( }, &mut |e| { let result = match e { - MirScalarExpr::Column(index) => { + MirScalarExpr::Column(index, _) => { let index = *index; if let DatumKnowledge::Lit { value, typ } = &column_knowledge[index] { let nullable = column_knowledge[index].nullable(); diff --git a/src/transform/src/dataflow.rs b/src/transform/src/dataflow.rs index f1b2a5643689b..1fce14f283666 100644 --- a/src/transform/src/dataflow.rs +++ b/src/transform/src/dataflow.rs @@ -489,7 +489,7 @@ fn prune_and_annotate_dataflow_index_imports( key.iter() // Convert the Vec key to Vec, so that // later we can more easily compare index keys to these keys. - .map(|col_idx| MirScalarExpr::Column(*col_idx)) + .map(|col_idx| MirScalarExpr::column(*col_idx)) .collect() }) .collect() diff --git a/src/transform/src/demand.rs b/src/transform/src/demand.rs index 629f112faeb6f..b4d5d4a39baaa 100644 --- a/src/transform/src/demand.rs +++ b/src/transform/src/demand.rs @@ -245,7 +245,7 @@ impl Demand { for equivalence in equivalences.iter() { let mut first_column = None; for expr in equivalence.iter() { - if let MirScalarExpr::Column(c) = expr { + if let MirScalarExpr::Column(c, _) = expr { if let Some(prior) = &first_column { permutation[*c] = *prior; } else { diff --git a/src/transform/src/equivalence_propagation.rs b/src/transform/src/equivalence_propagation.rs index 6ceb437d5a2eb..8f63759eb1035 100644 --- a/src/transform/src/equivalence_propagation.rs +++ b/src/transform/src/equivalence_propagation.rs @@ -573,7 +573,7 @@ impl EquivalencePropagation { outer_equivalences.permute(&permutation[..]); for (index, group) in group_key.iter().enumerate() { outer_equivalences.classes.push(vec![ - MirScalarExpr::Column(input_arity + index), + MirScalarExpr::column(input_arity + index), group.clone(), ]); } diff --git a/src/transform/src/fusion/filter.rs b/src/transform/src/fusion/filter.rs index 1a52a5845488a..761b64298533b 100644 --- a/src/transform/src/fusion/filter.rs +++ b/src/transform/src/fusion/filter.rs @@ -24,9 +24,9 @@ //! ScalarType::Bool.nullable(false), //! ])); //! -//! let predicate0 = MirScalarExpr::Column(0); -//! let predicate1 = MirScalarExpr::Column(0); -//! let predicate2 = MirScalarExpr::Column(0); +//! let predicate0 = MirScalarExpr::column(0); +//! let predicate1 = MirScalarExpr::column(0); +//! let predicate2 = MirScalarExpr::column(0); //! //! let mut expr = input //! .clone() diff --git a/src/transform/src/fusion/join.rs b/src/transform/src/fusion/join.rs index 28e1bd16b23bf..ac7d9bf7710c7 100644 --- a/src/transform/src/fusion/join.rs +++ b/src/transform/src/fusion/join.rs @@ -176,7 +176,7 @@ impl Join { // the applied map elements will be at the end, starting at `outer_arity`. for expr in map.iter_mut() { expr.visit_pre_mut(|e| { - if let MirScalarExpr::Column(c) = e { + if let MirScalarExpr::Column(c, _) = e { if *c >= mfp.input_arity { *c -= mfp.input_arity; *c += outer_arity; @@ -188,7 +188,7 @@ impl Join { } for expr in filter.iter_mut() { expr.visit_pre_mut(|e| { - if let MirScalarExpr::Column(c) = e { + if let MirScalarExpr::Column(c, _) = e { if *c >= mfp.input_arity { *c -= mfp.input_arity; *c += outer_arity; diff --git a/src/transform/src/fusion/reduce.rs b/src/transform/src/fusion/reduce.rs index 01ae2071f94f1..34091c0486b4b 100644 --- a/src/transform/src/fusion/reduce.rs +++ b/src/transform/src/fusion/reduce.rs @@ -60,7 +60,7 @@ impl Reduce { let mut outer_cols = vec![]; for expr in group_key.iter() { expr.visit_pre(|e| { - if let MirScalarExpr::Column(i) = e { + if let MirScalarExpr::Column(i, _) = e { outer_cols.push(*i); } }); @@ -79,7 +79,7 @@ impl Reduce { let arity = inner_input.arity(); for e in inner_group_key { - if let MirScalarExpr::Column(i) = e { + if let MirScalarExpr::Column(i, _) = e { outputs.push(*i); } else { outputs.push(arity + scalars.len()); diff --git a/src/transform/src/join_implementation.rs b/src/transform/src/join_implementation.rs index 0185e56625d54..d809e04c01687 100644 --- a/src/transform/src/join_implementation.rs +++ b/src/transform/src/join_implementation.rs @@ -105,7 +105,7 @@ impl JoinImplementation { MirRelationExpr::Reduce { group_key, .. } => { indexes.add_local( *id, - (0..group_key.len()).map(MirScalarExpr::Column).collect(), + (0..group_key.len()).map(MirScalarExpr::column).collect(), ); } _ => {} @@ -311,7 +311,7 @@ impl JoinImplementation { MirRelationExpr::Reduce { group_key, .. } => { // The first `group_key.len()` columns form an arrangement key. available_arrangements[index] - .push((0..group_key.len()).map(MirScalarExpr::Column).collect()); + .push((0..group_key.len()).map(MirScalarExpr::column).collect()); } MirRelationExpr::Join { implementation: IndexedFilter(id, ..), @@ -958,7 +958,7 @@ fn install_lifted_mfp( // wouldn't be called on it again. (The visitation continues with the // children of the new expression, but won't visit the new expression // itself again.) - while let MirScalarExpr::Column(c) = e { + while let MirScalarExpr::Column(c, _) = e { if *c >= mfp.input_arity { *e = map[*c - mfp.input_arity].clone(); } else { @@ -1081,7 +1081,7 @@ impl<'a> Orderer<'a> { for key in keys.iter() { unique_arrangement[input].push(unique_keys[input].iter().any(|cols| { cols.iter() - .all(|c| key.contains(&MirScalarExpr::Column(*c))) + .all(|c| key.contains(&MirScalarExpr::column(*c))) })); } } @@ -1218,7 +1218,7 @@ impl<'a> Orderer<'a> { let cardinality = self.cardinalities[start]; let is_unique = self.unique_keys[start].iter().any(|cols| { cols.iter() - .all(|c| candidate_start_key.contains(&MirScalarExpr::Column(*c))) + .all(|c| candidate_start_key.contains(&MirScalarExpr::column(*c))) }); let arranged = self.arrangements[start] .iter() @@ -1335,7 +1335,7 @@ impl<'a> Orderer<'a> { // does the relation we're joining on have a unique key wrt what's already bound? let is_unique = self.unique_keys[rel].iter().any(|cols| { cols.iter().all(|c| { - self.bound[rel].contains(&MirScalarExpr::Column(*c)) + self.bound[rel].contains(&MirScalarExpr::column(*c)) }) }); self.priority_queue.push(( diff --git a/src/transform/src/literal_constraints.rs b/src/transform/src/literal_constraints.rs index 814518ce6b8d7..90bb3878fa3c8 100644 --- a/src/transform/src/literal_constraints.rs +++ b/src/transform/src/literal_constraints.rs @@ -166,7 +166,7 @@ impl LiteralConstraints { keys: vec![(0..key.len()).collect()], }, } - .arrange_by(&[(0..key.len()).map(MirScalarExpr::Column).collect_vec()]); + .arrange_by(&[(0..key.len()).map(MirScalarExpr::column).collect_vec()]); if possible_vals.is_empty() { // Even better than what we were hoping for: Found contradicting @@ -575,14 +575,14 @@ impl LiteralConstraints { } = e { if matches!(**expr1, MirScalarExpr::Literal(..)) { - if let MirScalarExpr::Column(col) = **expr2 { + if let MirScalarExpr::Column(col, _) = **expr2 { if col >= mfp.input_arity { should_inline[col] = true; } } } if matches!(**expr2, MirScalarExpr::Literal(..)) { - if let MirScalarExpr::Column(col) = **expr1 { + if let MirScalarExpr::Column(col, _) = **expr1 { if col >= mfp.input_arity { should_inline[col] = true; } diff --git a/src/transform/src/literal_lifting.rs b/src/transform/src/literal_lifting.rs index 8d886c7a79b09..f4aa0bd807b9e 100644 --- a/src/transform/src/literal_lifting.rs +++ b/src/transform/src/literal_lifting.rs @@ -395,7 +395,7 @@ impl LiteralLifting { let mut cloned_scalar = scalar.clone(); // Propagate literals through expressions and remap columns. cloned_scalar.visit_mut_post(&mut |e| { - if let MirScalarExpr::Column(old_id) = e { + if let MirScalarExpr::Column(old_id, _) = e { let new_id = projection[*old_id]; if new_id >= first_literal_id { *e = projected_literals[new_id - first_literal_id] @@ -422,7 +422,7 @@ impl LiteralLifting { let input_arity = input.arity(); for expr in exprs.iter_mut() { expr.visit_mut_post(&mut |e| { - if let MirScalarExpr::Column(c) = e { + if let MirScalarExpr::Column(c, _) = e { if *c >= input_arity { *e = literals[*c - input_arity].clone(); } @@ -448,7 +448,7 @@ impl LiteralLifting { let input_arity = input.arity(); for expr in predicates.iter_mut() { expr.visit_mut_post(&mut |e| { - if let MirScalarExpr::Column(c) = e { + if let MirScalarExpr::Column(c, _) = e { if *c >= input_arity { *e = literals[*c - input_arity].clone(); } @@ -502,7 +502,7 @@ impl LiteralLifting { for equivalence in equivalences.iter_mut() { for expr in equivalence.iter_mut() { expr.visit_mut_post(&mut |e| { - if let MirScalarExpr::Column(c) = e { + if let MirScalarExpr::Column(c, _) = e { let (col, input) = old_input_mapper.map_column_to_local(*c); if col >= new_input_mapper.input_arity(input) { @@ -573,7 +573,7 @@ impl LiteralLifting { // Inline literals into group key expressions. for expr in group_key.iter_mut() { expr.visit_mut_post(&mut |e| { - if let MirScalarExpr::Column(c) = e { + if let MirScalarExpr::Column(c, _) = e { if *c >= input_arity { *e = literals[*c - input_arity].clone(); } @@ -583,7 +583,7 @@ impl LiteralLifting { // Inline literals into aggregate value selector expressions. for aggr in aggregates.iter_mut() { aggr.expr.visit_mut_post(&mut |e| { - if let MirScalarExpr::Column(c) = e { + if let MirScalarExpr::Column(c, _) = e { if *c >= input_arity { *e = literals[*c - input_arity].clone(); } @@ -685,7 +685,7 @@ impl LiteralLifting { // Inline literals into the limit expression. if let Some(limit) = limit { limit.visit_mut_post(&mut |e| { - if let MirScalarExpr::Column(c) = e { + if let MirScalarExpr::Column(c, _) = e { if *c >= input_arity { *e = literals[*c - input_arity].clone(); } @@ -753,7 +753,7 @@ impl LiteralLifting { for key in keys.iter_mut() { for expr in key.iter_mut() { expr.visit_mut_post(&mut |e| { - if let MirScalarExpr::Column(c) = e { + if let MirScalarExpr::Column(c, _) = e { if *c >= input_arity { *e = literals[*c - input_arity].clone(); } diff --git a/src/transform/src/non_null_requirements.rs b/src/transform/src/non_null_requirements.rs index 413cfa03cff28..a8d8ba633a576 100644 --- a/src/transform/src/non_null_requirements.rs +++ b/src/transform/src/non_null_requirements.rs @@ -233,7 +233,7 @@ impl NonNullRequirements { // Also, any non-nullable columns impose constraints on their equivalence class. for equivalence in equivalences { let exists_constraint = equivalence.iter().any(|expr| { - if let MirScalarExpr::Column(c) = expr { + if let MirScalarExpr::Column(c, _) = expr { let (col, rel) = input_mapper.map_column_to_local(*c); new_columns[rel].contains(&col) || !input_types[rel].column_types[col].nullable @@ -244,7 +244,7 @@ impl NonNullRequirements { if exists_constraint { for expr in equivalence.iter() { - if let MirScalarExpr::Column(c) = expr { + if let MirScalarExpr::Column(c, _) = expr { let (col, rel) = input_mapper.map_column_to_local(*c); new_columns[rel].insert(col); } diff --git a/src/transform/src/predicate_pushdown.rs b/src/transform/src/predicate_pushdown.rs index c8332db95dc4f..f517acc56a6af 100644 --- a/src/transform/src/predicate_pushdown.rs +++ b/src/transform/src/predicate_pushdown.rs @@ -308,7 +308,7 @@ impl PredicatePushdown { let mut supported = true; let mut new_predicate = predicate.clone(); new_predicate.visit_pre(|e| { - if let MirScalarExpr::Column(c) = e { + if let MirScalarExpr::Column(c, _) = e { if *c >= group_key.len() { supported = false; } @@ -316,12 +316,12 @@ impl PredicatePushdown { }); if supported { new_predicate.visit_mut_post(&mut |e| { - if let MirScalarExpr::Column(i) = e { + if let MirScalarExpr::Column(i, _) = e { *e = group_key[*i].clone(); } })?; push_down.push(new_predicate); - } else if let MirScalarExpr::Column(col) = &predicate { + } else if let MirScalarExpr::Column(col, _) = &predicate { if *col == group_key.len() && aggregates.len() == 1 && aggregates[0].func == AggregateFunc::Any @@ -684,13 +684,14 @@ impl PredicatePushdown { .iter() .enumerate() .filter_map(|(pos, expr)| { - if let MirScalarExpr::Column(col_pos) = &expr { + if let MirScalarExpr::Column(col_pos, _) = &expr { let local_col = input_mapper.map_column_to_local(*col_pos); if input == local_col.1 { + // TODO(mgree) !!! is it safe to propagate the name here? return Some(( Some(pos), - MirScalarExpr::Column(local_col.0), + MirScalarExpr::column(local_col.0), )); } else { return None; @@ -967,7 +968,7 @@ impl PredicatePushdown { // Seed with `map_exprs` support in `expr`. expr.visit_pre(|e| { - if let MirScalarExpr::Column(c) = e { + if let MirScalarExpr::Column(c, _) = e { if *c >= input_arity { support.insert(*c); } @@ -983,7 +984,7 @@ impl PredicatePushdown { // Drain the `buffer` and update `support` and `workset`. for c in buffer.drain(..) { map_exprs[c - input_arity].visit_pre(|e| { - if let MirScalarExpr::Column(c) = e { + if let MirScalarExpr::Column(c, _) = e { if *c >= input_arity { if support.insert(*c) { workset.push(*c); @@ -1005,7 +1006,7 @@ impl PredicatePushdown { let mut new_size = 0; new_expr.visit_mut_post(&mut |expr| { new_size += 1; - if let MirScalarExpr::Column(c) = expr { + if let MirScalarExpr::Column(c, _) = expr { if *c >= input_arity && new_size <= size_limit { // (inlined[c] is safe, because we proceed in column order, and we break out // of the loop when we stop inserting into memo.) @@ -1031,7 +1032,7 @@ impl PredicatePushdown { let mut new_size = 0; new_expr.visit_mut_post(&mut |expr| { new_size += 1; - if let MirScalarExpr::Column(c) = expr { + if let MirScalarExpr::Column(c, _) = expr { if *c >= input_arity && new_size <= size_limit { // (inlined[c] is safe because of the outer if condition.) let (m_expr, m_size): &(MirScalarExpr, _) = &inlined[c]; diff --git a/src/transform/src/reduce_elision.rs b/src/transform/src/reduce_elision.rs index 63438a3d9f86d..f0d522e3283e7 100644 --- a/src/transform/src/reduce_elision.rs +++ b/src/transform/src/reduce_elision.rs @@ -80,7 +80,7 @@ impl ReduceElision { if input_keys.iter().any(|keys| { keys.iter() - .all(|k| group_key.contains(&mz_expr::MirScalarExpr::Column(*k))) + .all(|k| group_key.iter().any(|gk| gk.as_column() == Some(*k))) }) { let map_scalars = aggregates .iter() diff --git a/src/transform/src/reduction_pushdown.rs b/src/transform/src/reduction_pushdown.rs index 52131ff5d6551..a477c147fa13e 100644 --- a/src/transform/src/reduction_pushdown.rs +++ b/src/transform/src/reduction_pushdown.rs @@ -112,7 +112,7 @@ impl ReductionPushdown { for index in 0..scalars.len() { let (lower, upper) = scalars.split_at_mut(index); upper[0].visit_mut_post(&mut |e| { - if let mz_expr::MirScalarExpr::Column(c) = e { + if let mz_expr::MirScalarExpr::Column(c, _) = e { if *c >= arity { *e = lower[*c - arity].clone(); } @@ -121,7 +121,7 @@ impl ReductionPushdown { } for key in group_key.iter_mut() { key.visit_mut_post(&mut |e| { - if let mz_expr::MirScalarExpr::Column(c) = e { + if let mz_expr::MirScalarExpr::Column(c, _) = e { if *c >= arity { *e = scalars[*c - arity].clone(); } @@ -130,7 +130,7 @@ impl ReductionPushdown { } for agg in aggregates.iter_mut() { agg.expr.visit_mut_post(&mut |e| { - if let mz_expr::MirScalarExpr::Column(c) = e { + if let mz_expr::MirScalarExpr::Column(c, _) = e { if *c >= arity { *e = scalars[*c - arity].clone(); } @@ -339,7 +339,7 @@ fn try_push_reduce_through_join( .map(|cls| { cls.into_iter() .map(|(idx, col)| { - MirScalarExpr::Column(new_join_mapper.map_column_to_global(col, idx)) + MirScalarExpr::column(new_join_mapper.map_column_to_global(col, idx)) }) .collect::>() }) diff --git a/src/transform/src/redundant_join.rs b/src/transform/src/redundant_join.rs index b1006d3dc76b9..51e7f32b45c8b 100644 --- a/src/transform/src/redundant_join.rs +++ b/src/transform/src/redundant_join.rs @@ -219,7 +219,7 @@ impl RedundantJoin { // up with the removal of `remove_input_idx`. for expr in bindings.iter_mut() { expr.visit_pre_mut(|e| { - if let MirScalarExpr::Column(c) = e { + if let MirScalarExpr::Column(c, _) = e { let (_local_col, input_relation) = old_input_mapper.map_column_to_local(*c); if input_relation > remove_input_idx { @@ -235,7 +235,7 @@ impl RedundantJoin { for equivalence in equivalences.iter_mut() { for expr in equivalence.iter_mut() { expr.visit_mut_post(&mut |e| { - if let MirScalarExpr::Column(c) = e { + if let MirScalarExpr::Column(c, _) = e { let (local_col, input_relation) = old_input_mapper.map_column_to_local(*c); if input_relation == remove_input_idx { @@ -390,7 +390,7 @@ impl RedundantJoin { for prov in result.iter_mut() { let projection = outputs .iter() - .map(|c| prov.dereference(&MirScalarExpr::Column(*c))) + .map(|c| prov.dereference(&MirScalarExpr::column(*c))) .collect_vec(); prov.dereferenced_projection = projection; } @@ -476,7 +476,7 @@ impl ProvInfo { /// of the columns of the projected source. fn dereference(&self, expr: &MirScalarExpr) -> Option { match expr { - MirScalarExpr::Column(c) => { + MirScalarExpr::Column(c, _) => { if let Some(expr) = &self.dereferenced_projection[*c] { Some(expr.clone()) } else { @@ -703,7 +703,7 @@ fn try_build_expression_using_other( for (other_col, derefed) in other_prov.dereferenced_projection.iter().enumerate() { if let Some(derefed) = derefed { if derefed == root_expr { - return Some(MirScalarExpr::Column( + return Some(MirScalarExpr::column( input_mapper.map_column_to_global(other_col, other), )); } @@ -713,7 +713,7 @@ fn try_build_expression_using_other( // Otherwise, try to build root_expr's sub-expressions recursively // other's projection. match root_expr { - MirScalarExpr::Column(_) => None, + MirScalarExpr::Column(_, _) => None, MirScalarExpr::CallUnary { func, expr } => { try_build_expression_using_other(expr, other, other_prov, input_mapper).and_then( |expr| { diff --git a/src/transform/src/semijoin_idempotence.rs b/src/transform/src/semijoin_idempotence.rs index 67e8e4f6adb7d..23258420fcda5 100644 --- a/src/transform/src/semijoin_idempotence.rs +++ b/src/transform/src/semijoin_idempotence.rs @@ -237,7 +237,7 @@ fn attempt_join_simplification( if !typ1.column_types[*col1].nullable && typ0.column_types[*col0].nullable { - is_not_nulls.push(MirScalarExpr::Column(*col0).call_is_null().not()) + is_not_nulls.push(MirScalarExpr::column(*col0).call_is_null().not()) } } if !is_not_nulls.is_empty() { @@ -269,7 +269,7 @@ fn attempt_join_simplification( if !typ0.column_types[*col0].nullable && typ1.column_types[*col1].nullable { - is_not_nulls.push(MirScalarExpr::Column(*col1).call_is_null().not()) + is_not_nulls.push(MirScalarExpr::column(*col1).call_is_null().not()) } } if !is_not_nulls.is_empty() { @@ -395,7 +395,7 @@ fn list_replacements( .filter_map(|(c0, c1, c2)| { group_key .iter() - .position(|o| o == &MirScalarExpr::Column(*c1)) + .position(|o| o.as_column() == Some(*c1)) .map(|c| (*c0, c, *c2)) }) .collect::>(); @@ -544,6 +544,7 @@ fn semijoin_bijection( let mut equiv_pairs = Vec::with_capacity(equivalences.len()); // Populate `equiv_pairs`, ideally finding exactly one pair for each equivalence class. + // TODO(mgree) !!! store the column names for eq in equivalences.iter() { if eq.len() == 2 { // The equivalence class could reference the inputs in either order, or be some @@ -555,8 +556,10 @@ fn semijoin_bijection( (Some(0), Some(1)) => { let expr0 = input_mapper.map_expr_to_local(eq[0].clone()); let expr1 = input_mapper.map_expr_to_local(eq[1].clone()); - if let (MirScalarExpr::Column(col0), MirScalarExpr::Column(col1)) = - (expr0, expr1) + if let ( + MirScalarExpr::Column(col0, _name0), + MirScalarExpr::Column(col1, _name1), + ) = (expr0, expr1) { equiv_pairs.push((col0, col1)); } @@ -564,8 +567,10 @@ fn semijoin_bijection( (Some(1), Some(0)) => { let expr0 = input_mapper.map_expr_to_local(eq[1].clone()); let expr1 = input_mapper.map_expr_to_local(eq[0].clone()); - if let (MirScalarExpr::Column(col0), MirScalarExpr::Column(col1)) = - (expr0, expr1) + if let ( + MirScalarExpr::Column(col0, _name0), + MirScalarExpr::Column(col1, _name1), + ) = (expr0, expr1) { equiv_pairs.push((col0, col1)); } diff --git a/src/transform/src/typecheck.rs b/src/transform/src/typecheck.rs index d004769c0a485..5bb54e13e84ba 100644 --- a/src/transform/src/typecheck.rs +++ b/src/transform/src/typecheck.rs @@ -1097,7 +1097,7 @@ impl Typecheck { use MirScalarExpr::*; self.checked_recur(|tc| match expr { - Column(i) => match column_types.get(*i) { + Column(i, _) => match column_types.get(*i) { Some(ty) => Ok(ty.clone()), None => Err(TypeError::NoSuchColumn { source, diff --git a/test/sqllogictest/advent-of-code/2023/aoc_1201.slt b/test/sqllogictest/advent-of-code/2023/aoc_1201.slt index 4c7f72fe0c5c8..aa25cbed0238e 100644 --- a/test/sqllogictest/advent-of-code/2023/aoc_1201.slt +++ b/test/sqllogictest/advent-of-code/2023/aoc_1201.slt @@ -130,15 +130,15 @@ Explained Query: With cte l0 = Project (#0, #1, #4) // { arity: 3 } - Join on=(#3 = substr(#0, #1, #2)) type=delta // { arity: 5 } + Join on=(#3{t} = substr(#0{line}, #1{index}, #2{width})) type=delta // { arity: 5 } implementation - %0 » %1[×] » %2[#0]UK - %1 » %0[×] » %2[#0]UK + %0 » %1[×] » %2[#0{t}]UK + %1 » %0[×] » %2[#0{t}]UK %2 » %0[×] » %1[×] ArrangeBy keys=[[]] // { arity: 2 } - FlatMap generate_series(1, char_length(#0), 1) // { arity: 2 } + FlatMap generate_series(1, char_length(#0{line}), 1) // { arity: 2 } Project (#1) // { arity: 1 } - Filter (#1) IS NOT NULL // { arity: 2 } + Filter (#1{line}) IS NOT NULL // { arity: 2 } FlatMap unnest_array(regexp_split_to_array["\n", case_insensitive=false](#0{input})) // { arity: 2 } ReadStorage materialize.public.aoc_1201 // { arity: 1 } ArrangeBy keys=[[]] // { arity: 1 } @@ -148,7 +148,7 @@ Explained Query: - (3) - (4) - (5) - ArrangeBy keys=[[#0]] // { arity: 2 } + ArrangeBy keys=[[#0{t}]] // { arity: 2 } Constant // { arity: 2 } - ("0", 0) - ("1", 1) @@ -171,16 +171,16 @@ Explained Query: - ("seven", 7) - ("three", 3) cte l1 = - Reduce aggregates=[sum(((#0 * 10) + #1))] // { arity: 1 } + Reduce aggregates=[sum(((#0{f} * 10) + #1{l}))] // { arity: 1 } Project (#1, #3) // { arity: 2 } - Join on=(#0 = #2) type=differential // { arity: 4 } + Join on=(#0{line} = #2{line}) type=differential // { arity: 4 } implementation - %0[#0]UK » %1[#0]UK - ArrangeBy keys=[[#0]] // { arity: 2 } + %0[#0{line}]UK » %1[#0{line}]UK + ArrangeBy keys=[[#0{line}]] // { arity: 2 } Project (#0, #2) // { arity: 2 } TopK group_by=[#0] order_by=[#1 asc nulls_last] limit=1 // { arity: 3 } Get l0 // { arity: 3 } - ArrangeBy keys=[[#0]] // { arity: 2 } + ArrangeBy keys=[[#0{line}]] // { arity: 2 } Project (#0, #2) // { arity: 2 } TopK group_by=[#0] order_by=[#1 desc nulls_first] limit=1 // { arity: 3 } Get l0 // { arity: 3 } diff --git a/test/sqllogictest/advent-of-code/2023/aoc_1202.slt b/test/sqllogictest/advent-of-code/2023/aoc_1202.slt index 92a4f01a0cf13..63fa27ce05c54 100644 --- a/test/sqllogictest/advent-of-code/2023/aoc_1202.slt +++ b/test/sqllogictest/advent-of-code/2023/aoc_1202.slt @@ -218,45 +218,45 @@ Explained Query: With cte l0 = Project (#3, #5, #6) // { arity: 3 } - Map (text_to_integer(substr(#0, 5)), regexp_split_to_array[" ", case_insensitive=false](#2), array_index(#4, 3), text_to_integer(array_index(#4, 2))) // { arity: 7 } - FlatMap unnest_array(regexp_split_to_array[",", case_insensitive=false](#1)) // { arity: 3 } + Map (text_to_integer(substr(#0{game}, 5)), regexp_split_to_array[" ", case_insensitive=false](#2{color}), array_index(#4, 3), text_to_integer(array_index(#4, 2))) // { arity: 7 } + FlatMap unnest_array(regexp_split_to_array[",", case_insensitive=false](#1{visible})) // { arity: 3 } Project (#0, #2) // { arity: 2 } - FlatMap unnest_array(regexp_split_to_array[";", case_insensitive=false](#1)) // { arity: 3 } + FlatMap unnest_array(regexp_split_to_array[";", case_insensitive=false](#1{report})) // { arity: 3 } Project (#3, #4) // { arity: 2 } - Map (regexp_split_to_array[":", case_insensitive=false](#1), array_index(#2, 1), array_index(#2, 2)) // { arity: 5 } + Map (regexp_split_to_array[":", case_insensitive=false](#1{line}), array_index(#2, 1), array_index(#2, 2)) // { arity: 5 } FlatMap unnest_array(regexp_split_to_array["\n", case_insensitive=false](#0{input})) // { arity: 2 } ReadStorage materialize.public.input // { arity: 1 } cte l1 = - Filter (#0) IS NOT NULL // { arity: 3 } + Filter (#0{game}) IS NOT NULL // { arity: 3 } Get l0 // { arity: 3 } cte l2 = - ArrangeBy keys=[[#0]] // { arity: 1 } + ArrangeBy keys=[[#0{game}]] // { arity: 1 } Project (#0) // { arity: 1 } Get l1 // { arity: 3 } cte l3 = - Reduce aggregates=[sum(#0)] // { arity: 1 } + Reduce aggregates=[sum(#0{game})] // { arity: 1 } Distinct project=[#0] // { arity: 1 } Union // { arity: 1 } Negate // { arity: 1 } Project (#0) // { arity: 1 } - Join on=(#0 = #1) type=differential // { arity: 2 } + Join on=(#0{game} = #1) type=differential // { arity: 2 } implementation - %1[#0]UKA » %0:l2[#0]K + %1[#0]UKA » %0:l2[#0{game}]K Get l2 // { arity: 1 } ArrangeBy keys=[[#0]] // { arity: 1 } Distinct project=[#0] // { arity: 1 } Project (#0) // { arity: 1 } - Filter (#3 > #5) // { arity: 6 } - Join on=(#0 = #1 AND #2 = #4) type=delta // { arity: 6 } + Filter (#3{number} > #5{number}) // { arity: 6 } + Join on=(#0{game} = #1{game} AND #2{color} = #4{color}) type=delta // { arity: 6 } implementation - %0:l2 » %1:l0[#0]K » %2[#0]UK - %1:l0 » %2[#0]UK » %0:l2[#0]K - %2 » %1:l0[#1]K » %0:l2[#0]K + %0:l2 » %1:l0[#0{game}]K » %2[#0{color}]UK + %1:l0 » %2[#0{color}]UK » %0:l2[#0{game}]K + %2 » %1:l0[#1{color}]K » %0:l2[#0{game}]K Get l2 // { arity: 1 } - ArrangeBy keys=[[#0], [#1]] // { arity: 3 } - Filter (#0) IS NOT NULL AND (#1) IS NOT NULL // { arity: 3 } + ArrangeBy keys=[[#0{game}], [#1{color}]] // { arity: 3 } + Filter (#0{game}) IS NOT NULL AND (#1{color}) IS NOT NULL // { arity: 3 } Get l0 // { arity: 3 } - ArrangeBy keys=[[#0]] // { arity: 2 } + ArrangeBy keys=[[#0{color}]] // { arity: 2 } Constant // { arity: 2 } - ("red", 12) - ("blue", 14) @@ -264,35 +264,35 @@ Explained Query: Project (#0) // { arity: 1 } Get l0 // { arity: 3 } cte l4 = - Reduce group_by=[#0, #1] aggregates=[max(#2)] // { arity: 3 } + Reduce group_by=[#0, #1] aggregates=[max(#2{number})] // { arity: 3 } Get l1 // { arity: 3 } cte l5 = Reduce aggregates=[sum(#0{count})] // { arity: 1 } Project (#1{count}) // { arity: 1 } Reduce group_by=[#0] aggregates=[count(*)] // { arity: 2 } Project (#0) // { arity: 1 } - Join on=(#0 = #1 = #2) type=delta // { arity: 3 } + Join on=(#0{game} = #1{game} = #2{game}) type=delta // { arity: 3 } implementation - %0 » %1[#0]K » %2[#0]K - %1 » %0[#0]K » %2[#0]K - %2 » %0[#0]K » %1[#0]K - ArrangeBy keys=[[#0]] // { arity: 1 } + %0 » %1[#0{game}]K » %2[#0{game}]K + %1 » %0[#0{game}]K » %2[#0{game}]K + %2 » %0[#0{game}]K » %1[#0{game}]K + ArrangeBy keys=[[#0{game}]] // { arity: 1 } Project (#0) // { arity: 1 } FlatMap generate_series(1, #1{max}, 1) // { arity: 3 } Project (#0, #2{max}) // { arity: 2 } - Filter (#1 = "red") // { arity: 3 } + Filter (#1{color} = "red") // { arity: 3 } Get l4 // { arity: 3 } - ArrangeBy keys=[[#0]] // { arity: 1 } + ArrangeBy keys=[[#0{game}]] // { arity: 1 } Project (#0) // { arity: 1 } FlatMap generate_series(1, #1{max}, 1) // { arity: 3 } Project (#0, #2{max}) // { arity: 2 } - Filter (#1 = "blue") // { arity: 3 } + Filter (#1{color} = "blue") // { arity: 3 } Get l4 // { arity: 3 } - ArrangeBy keys=[[#0]] // { arity: 1 } + ArrangeBy keys=[[#0{game}]] // { arity: 1 } Project (#0) // { arity: 1 } FlatMap generate_series(1, #1{max}, 1) // { arity: 3 } Project (#0, #2{max}) // { arity: 2 } - Filter (#1 = "green") // { arity: 3 } + Filter (#1{color} = "green") // { arity: 3 } Get l4 // { arity: 3 } Return // { arity: 2 } CrossJoin type=differential // { arity: 2 } diff --git a/test/sqllogictest/advent-of-code/2023/aoc_1203.slt b/test/sqllogictest/advent-of-code/2023/aoc_1203.slt index 0e689fd2f6f0d..a2920543f3bbf 100644 --- a/test/sqllogictest/advent-of-code/2023/aoc_1203.slt +++ b/test/sqllogictest/advent-of-code/2023/aoc_1203.slt @@ -238,10 +238,10 @@ Explained Query: cte l1 = Project (#0, #2, #3) // { arity: 3 } Filter (#3 != ".") // { arity: 4 } - Map (substr(#1, #2, 1)) // { arity: 4 } - FlatMap generate_series(1, char_length(#1), 1) // { arity: 3 } + Map (substr(#1{line}, #2{start}, 1)) // { arity: 4 } + FlatMap generate_series(1, char_length(#1{line}), 1) // { arity: 3 } Project (#1, #2) // { arity: 2 } - Map (array_index(regexp_split_to_array["\n", case_insensitive=false](#0{input}), integer_to_bigint(#1))) // { arity: 3 } + Map (array_index(regexp_split_to_array["\n", case_insensitive=false](#0{input}), integer_to_bigint(#1{row_idx}))) // { arity: 3 } CrossJoin type=differential // { arity: 2 } implementation %0:input[×] » %1[×] @@ -268,7 +268,7 @@ Explained Query: cte l3 = Distinct project=[#0] // { arity: 1 } Project (#0) // { arity: 1 } - Filter (#0 = #1) // { arity: 2 } + Filter (#0{symbol} = #1{right_col0_0}) // { arity: 2 } FlatMap wrap1("0", "1", "2", "3", "4", "5", "6", "7", "8", "9") // { arity: 2 } Get l2 // { arity: 1 } cte l4 = @@ -300,7 +300,7 @@ Explained Query: - (-1) - (1) cte l8 = - ArrangeBy keys=[[#0, #1]] // { arity: 3 } + ArrangeBy keys=[[#0{row_idx}, #1{col_idx}]] // { arity: 3 } Get l5 // { arity: 3 } Return // { arity: 2 } With Mutually Recursive @@ -311,7 +311,7 @@ Explained Query: Union // { arity: 4 } Project (#2, #0, #1, #7) // { arity: 4 } Map (1) // { arity: 8 } - Join on=(#0 = (#3 + #5) AND #1 = (#4 + #6)) type=delta // { arity: 7 } + Join on=(#0{row_idx} = (#3{row_idx} + #5{row_off}) AND #1{col_idx} = (#4{col_idx} + #6{col_off})) type=delta // { arity: 7 } implementation %0:l5 » %1:l6[×] » %2:l7[×] » %3:l7[×] %1:l6 » %0:l5[×] » %2:l7[×] » %3:l7[×] @@ -325,20 +325,20 @@ Explained Query: Get l7 // { arity: 1 } Get l7 // { arity: 1 } Project (#7, #0, #1, #8) // { arity: 4 } - Map ((#2 || #3), (#6 + 1)) // { arity: 9 } - Join on=(#0 = #4 AND #1 = (#5 - 1)) type=differential // { arity: 7 } + Map ((#2{number} || #3{number}), (#6{length} + 1)) // { arity: 9 } + Join on=(#0{row_idx} = #4{row_idx} AND #1{col_idx} = (#5{col_idx} - 1)) type=differential // { arity: 7 } implementation - %0:l8[#0, #1]KK » %1:l9[#1, (#2 - 1)]KK + %0:l8[#0{row_idx}, #1{col_idx}]KK » %1:l9[#1{row_idx}, (#2{col_idx} - 1)]KK Get l8 // { arity: 3 } - ArrangeBy keys=[[#1, (#2 - 1)]] // { arity: 4 } + ArrangeBy keys=[[#1{row_idx}, (#2{col_idx} - 1)]] // { arity: 4 } Get l9 // { arity: 4 } Project (#7, #0, #5, #8) // { arity: 4 } - Map ((#3 || #2), (#6 + 1)) // { arity: 9 } - Join on=(#0 = #4 AND #1 = (#5 + #6)) type=differential // { arity: 7 } + Map ((#3{number} || #2{number}), (#6{length} + 1)) // { arity: 9 } + Join on=(#0{row_idx} = #4{row_idx} AND #1{col_idx} = (#5{col_idx} + #6{length})) type=differential // { arity: 7 } implementation - %0:l8[#0, #1]KK » %1:l9[#1, (#2 + #3)]KK + %0:l8[#0{row_idx}, #1{col_idx}]KK » %1:l9[#1{row_idx}, (#2{col_idx} + #3{length})]KK Get l8 // { arity: 3 } - ArrangeBy keys=[[#1, (#2 + #3)]] // { arity: 4 } + ArrangeBy keys=[[#1{row_idx}, (#2{col_idx} + #3{length})]] // { arity: 4 } Get l9 // { arity: 4 } Return // { arity: 2 } With @@ -347,7 +347,7 @@ Explained Query: Project (#1, #2) // { arity: 2 } Get l9 // { arity: 4 } cte l11 = - ArrangeBy keys=[[#0, #1]] // { arity: 2 } + ArrangeBy keys=[[#0{right_col0_4}, #1{right_col1_5}]] // { arity: 2 } Project (#0, #1) // { arity: 2 } Get l5 // { arity: 3 } cte l12 = @@ -362,10 +362,10 @@ Explained Query: Negate // { arity: 2 } Distinct project=[#0, #1] // { arity: 2 } Project (#0, #1) // { arity: 2 } - Join on=(#0 = #2 AND #3 = (#1 - 1)) type=differential // { arity: 4 } + Join on=(#0{row_idx} = #2{right_col0_4} AND #3{right_col1_5} = (#1{col_idx} - 1)) type=differential // { arity: 4 } implementation - %0:l10[#0, (#1 - 1)]KK » %1:l11[#0, #1]KK - ArrangeBy keys=[[#0, (#1 - 1)]] // { arity: 2 } + %0:l10[#0{row_idx}, (#1{col_idx} - 1)]KK » %1:l11[#0{right_col0_4}, #1{right_col1_5}]KK + ArrangeBy keys=[[#0{row_idx}, (#1{col_idx} - 1)]] // { arity: 2 } Get l10 // { arity: 2 } Get l11 // { arity: 2 } Get l10 // { arity: 2 } @@ -375,7 +375,7 @@ Explained Query: Get l12 // { arity: 4 } cte l14 = Project (#1..=#3, #7) // { arity: 4 } - Map (text_to_integer(#0)) // { arity: 8 } + Map (text_to_integer(#0{number})) // { arity: 8 } Join on=(#1 = #4 AND #2 = #5 AND #3 = #6) type=differential // { arity: 7 } implementation %0:l12[#1..=#3]KKK » %1[#0..=#2]KKK @@ -386,15 +386,15 @@ Explained Query: Negate // { arity: 3 } Distinct project=[#0..=#2] // { arity: 3 } Project (#0..=#2) // { arity: 3 } - Join on=(#0 = #3 AND #4 = (#1 + #2)) type=differential // { arity: 5 } + Join on=(#0{row_idx} = #3{right_col0_7} AND #4{right_col1_8} = (#1{col_idx} + #2{length})) type=differential // { arity: 5 } implementation - %0:l13[#0, (#1 + #2)]KK » %1:l11[#0, #1]KK - ArrangeBy keys=[[#0, (#1 + #2)]] // { arity: 3 } + %0:l13[#0{row_idx}, (#1{col_idx} + #2{length})]KK » %1:l11[#0{right_col0_7}, #1{right_col1_8}]KK + ArrangeBy keys=[[#0{row_idx}, (#1{col_idx} + #2{length})]] // { arity: 3 } Get l13 // { arity: 3 } Get l11 // { arity: 2 } Get l13 // { arity: 3 } cte l15 = - Reduce aggregates=[sum(#0)] // { arity: 1 } + Reduce aggregates=[sum(#0{number})] // { arity: 1 } Project (#3) // { arity: 1 } Get l14 // { arity: 4 } cte l16 = @@ -406,37 +406,37 @@ Explained Query: cte l17 = Distinct project=[#0, #1, #4, #2, #3] // { arity: 5 } Project (#0, #1, #3, #4, #6) // { arity: 5 } - Filter (#7 = (#1 + #2)) // { arity: 8 } - FlatMap generate_series(#4, ((#4 + #5) - 1), 1) // { arity: 8 } + Filter (#7{part_col} = (#1{col_idx} + #2{gear_c_off})) // { arity: 8 } + FlatMap generate_series(#4{col_idx}, ((#4{col_idx} + #5{length}) - 1), 1) // { arity: 8 } Project (#0, #1, #3..=#7) // { arity: 7 } - Join on=(#4 = (#0 + #2)) type=delta // { arity: 8 } + Join on=(#4{row_idx} = (#0{row_idx} + #2{gear_r_off})) type=delta // { arity: 8 } implementation - %0:l6 » %1:l16[×] » %3:l14[#0]K » %2:l16[×] - %1:l16 » %0:l6[×]ef » %3:l14[#0]K » %2:l16[×] - %2:l16 » %0:l6[×]ef » %1:l16[×] » %3:l14[#0]K + %0:l6 » %1:l16[×] » %3:l14[#0{row_idx}]K » %2:l16[×] + %1:l16 » %0:l6[×]ef » %3:l14[#0{row_idx}]K » %2:l16[×] + %2:l16 » %0:l6[×]ef » %1:l16[×] » %3:l14[#0{row_idx}]K %3:l14 » %0:l6[×]ef » %1:l16[×] » %2:l16[×] ArrangeBy keys=[[]] // { arity: 2 } Project (#0, #1) // { arity: 2 } - Filter (#2 = "*") // { arity: 3 } + Filter (#2{symbol} = "*") // { arity: 3 } Get l6 // { arity: 3 } Get l16 // { arity: 1 } Get l16 // { arity: 1 } - ArrangeBy keys=[[#0]] // { arity: 4 } + ArrangeBy keys=[[#0{row_idx}]] // { arity: 4 } Get l14 // { arity: 4 } cte l18 = - ArrangeBy keys=[[#0, #1]] // { arity: 5 } + ArrangeBy keys=[[#0{row_idx}, #1{col_idx}]] // { arity: 5 } Get l17 // { arity: 5 } cte l19 = - Reduce aggregates=[sum(#0)] // { arity: 1 } + Reduce aggregates=[sum(#0{product})] // { arity: 1 } Project (#2) // { arity: 1 } - Distinct project=[#0, #1, (#2 * #3)] // { arity: 3 } + Distinct project=[#0, #1, (#2{number} * #3{number})] // { arity: 3 } Project (#0, #1, #5, #10) // { arity: 4 } - Filter (#2{count} = 2) AND ((#6 != #11) OR (#7 != #12)) // { arity: 13 } - Join on=(#0 = #3 = #8 AND #1 = #4 = #9) type=delta // { arity: 13 } + Filter (#2{count} = 2) AND ((#6{part_row} != #11{part_row}) OR (#7{part_col} != #12{part_col})) // { arity: 13 } + Join on=(#0{row_idx} = #3{row_idx} = #8{row_idx} AND #1{col_idx} = #4{col_idx} = #9{col_idx}) type=delta // { arity: 13 } implementation - %0 » %1:l18[#0, #1]KK » %2:l18[#0, #1]KK - %1:l18 » %0[#0, #1]UKKAef » %2:l18[#0, #1]KK - %2:l18 » %0[#0, #1]UKKAef » %1:l18[#0, #1]KK + %0 » %1:l18[#0{row_idx}, #1{col_idx}]KK » %2:l18[#0{row_idx}, #1{col_idx}]KK + %1:l18 » %0[#0, #1]UKKAef » %2:l18[#0{row_idx}, #1{col_idx}]KK + %2:l18 » %0[#0, #1]UKKAef » %1:l18[#0{row_idx}, #1{col_idx}]KK ArrangeBy keys=[[#0, #1]] // { arity: 3 } Reduce group_by=[#0, #1] aggregates=[count(*)] // { arity: 3 } Project (#0, #1) // { arity: 2 } diff --git a/test/sqllogictest/advent-of-code/2023/aoc_1204.slt b/test/sqllogictest/advent-of-code/2023/aoc_1204.slt index a59b0243ce08f..3de86456277f1 100644 --- a/test/sqllogictest/advent-of-code/2023/aoc_1204.slt +++ b/test/sqllogictest/advent-of-code/2023/aoc_1204.slt @@ -108,9 +108,9 @@ Explained Query: Filter (#2{count} > 1) // { arity: 3 } Reduce group_by=[#0, #1] aggregates=[count(*)] // { arity: 3 } Project (#0, #2) // { arity: 2 } - FlatMap unnest_array(array_remove(#1, "")) // { arity: 3 } + FlatMap unnest_array(array_remove(#1{nrs_arr}, "")) // { arity: 3 } Project (#2, #3) // { arity: 2 } - Map (split_string(#1, ":", 1), regexp_split_to_array["\s", case_insensitive=false](ltrim(rtrim(replace(split_string(#1, ":", 2), "|", ""))))) // { arity: 4 } + Map (split_string(#1{line}, ":", 1), regexp_split_to_array["\s", case_insensitive=false](ltrim(rtrim(replace(split_string(#1{line}, ":", 2), "|", ""))))) // { arity: 4 } FlatMap unnest_array(regexp_split_to_array["\n", case_insensitive=false](#0{input})) // { arity: 2 } ReadStorage materialize.public.aoc_1204 // { arity: 1 } Return // { arity: 1 } @@ -285,47 +285,47 @@ Explained Query: With cte l0 = Project (#3, #4) // { arity: 2 } - Map (regexp_match["Card +(\d+): (.*)", case_insensitive=false](#1), text_to_integer(array_index(#2, 1)), regexp_split_to_array[" \| ", case_insensitive=false](array_index(#2, 2))) // { arity: 5 } + Map (regexp_match["Card +(\d+): (.*)", case_insensitive=false](#1{line}), text_to_integer(array_index(#2{match}, 1)), regexp_split_to_array[" \| ", case_insensitive=false](array_index(#2{match}, 2))) // { arity: 5 } FlatMap unnest_array(regexp_split_to_array["\n", case_insensitive=false](#0{input})) // { arity: 2 } ReadStorage materialize.public.aoc_1204 // { arity: 1 } cte l1 = Project (#0, #3) // { arity: 2 } - Map (text_to_integer(#2)) // { arity: 4 } - FlatMap unnest_array(regexp_split_to_array["\s+", case_insensitive=false](btrim(array_index(#1, 2)))) // { arity: 3 } + Map (text_to_integer(#2{unnest})) // { arity: 4 } + FlatMap unnest_array(regexp_split_to_array["\s+", case_insensitive=false](btrim(array_index(#1{parts}, 2)))) // { arity: 3 } Get l0 // { arity: 2 } cte l2 = - ArrangeBy keys=[[#0, #1]] // { arity: 2 } - Filter (#0) IS NOT NULL AND (#1) IS NOT NULL // { arity: 2 } + ArrangeBy keys=[[#0{card_id}, #1{val}]] // { arity: 2 } + Filter (#0{card_id}) IS NOT NULL AND (#1{val}) IS NOT NULL // { arity: 2 } Get l1 // { arity: 2 } cte l3 = Project (#0, #1) // { arity: 2 } - Join on=(#0 = #2 AND #1 = #3) type=differential // { arity: 4 } + Join on=(#0{card_id} = #2{card_id} AND #1{val} = #3{val}) type=differential // { arity: 4 } implementation - %0:l2[#0, #1]KK » %1[#0, #1]KK + %0:l2[#0{card_id}, #1{val}]KK » %1[#0{card_id}, #1{val}]KK Get l2 // { arity: 2 } - ArrangeBy keys=[[#0, #1]] // { arity: 2 } + ArrangeBy keys=[[#0{card_id}, #1{val}]] // { arity: 2 } Project (#0, #3) // { arity: 2 } - Filter (#2) IS NOT NULL // { arity: 4 } - Map (text_to_integer(#2)) // { arity: 4 } - FlatMap unnest_array(regexp_split_to_array["\s+", case_insensitive=false](btrim(array_index(#1, 1)))) // { arity: 3 } - Filter (#0) IS NOT NULL // { arity: 2 } + Filter (#2{unnest}) IS NOT NULL // { arity: 4 } + Map (text_to_integer(#2{unnest})) // { arity: 4 } + FlatMap unnest_array(regexp_split_to_array["\s+", case_insensitive=false](btrim(array_index(#1{parts}, 1)))) // { arity: 3 } + Filter (#0{card_id}) IS NOT NULL // { arity: 2 } Get l0 // { arity: 2 } cte l4 = Distinct project=[#0, #1] // { arity: 2 } Union // { arity: 2 } Project (#0, #2) // { arity: 2 } - FlatMap generate_series((#0 + 1), (#0 + #1), 1) // { arity: 3 } + FlatMap generate_series((#0{card_id} + 1), (#0{card_id} + #1{count}), 1) // { arity: 3 } Project (#0, #2) // { arity: 2 } Map (bigint_to_integer(#1{count})) // { arity: 3 } - Reduce group_by=[#0] aggregates=[count(#1)] // { arity: 2 } + Reduce group_by=[#0] aggregates=[count(#1{val})] // { arity: 2 } Union // { arity: 2 } Map (null) // { arity: 2 } Union // { arity: 1 } Negate // { arity: 1 } Project (#0) // { arity: 1 } - Join on=(#0 = #2 AND #1 = #3) type=differential // { arity: 4 } + Join on=(#0{card_id} = #2 AND #1{val} = #3) type=differential // { arity: 4 } implementation - %1[#0, #1]UKKA » %0:l2[#0, #1]KK + %1[#0, #1]UKKA » %0:l2[#0{card_id}, #1{val}]KK Get l2 // { arity: 2 } ArrangeBy keys=[[#0, #1]] // { arity: 2 } Distinct project=[#0, #1] // { arity: 2 } @@ -340,19 +340,19 @@ Explained Query: With Mutually Recursive cte l5 = Project (#1, #3) // { arity: 2 } - Join on=(#0 = #2) type=differential // { arity: 4 } + Join on=(#0{card_id} = #2) type=differential // { arity: 4 } implementation - %1:l6[#0]UK » %0:l4[#0]K - ArrangeBy keys=[[#0]] // { arity: 2 } - Filter (#0) IS NOT NULL // { arity: 2 } + %1:l6[#0]UK » %0:l4[#0{card_id}]K + ArrangeBy keys=[[#0{card_id}]] // { arity: 2 } + Filter (#0{card_id}) IS NOT NULL // { arity: 2 } Get l4 // { arity: 2 } ArrangeBy keys=[[#0]] // { arity: 2 } - Filter (#0) IS NOT NULL // { arity: 2 } + Filter (#0{card_id}) IS NOT NULL // { arity: 2 } Get l6 // { arity: 2 } cte l6 = Project (#0, #2) // { arity: 2 } Map (bigint_to_integer(#1{sum})) // { arity: 3 } - Reduce group_by=[#0] aggregates=[sum(coalesce(#1, 1))] // { arity: 2 } + Reduce group_by=[#0] aggregates=[sum(coalesce(#1{multiplier}, 1))] // { arity: 2 } Union // { arity: 2 } Map (null) // { arity: 2 } Union // { arity: 1 } @@ -365,7 +365,7 @@ Explained Query: Return // { arity: 1 } With cte l7 = - Reduce aggregates=[sum(#0)] // { arity: 1 } + Reduce aggregates=[sum(#0{multiplier})] // { arity: 1 } Project (#1) // { arity: 1 } Get l6 // { arity: 2 } Return // { arity: 1 } @@ -520,7 +520,7 @@ Explained Query: With cte l0 = Project (#3..=#5) // { arity: 3 } - Map (regexp_split_to_array["(:|\|)", case_insensitive=false](#1), text_to_integer(array_index(regexp_match["[0-9]+", case_insensitive=false](btrim(array_index(#2, 1))), 1)), regexp_split_to_array[" ", case_insensitive=false](btrim(array_index(#2, 2))), regexp_split_to_array[" ", case_insensitive=false](btrim(array_index(#2, 3)))) // { arity: 6 } + Map (regexp_split_to_array["(:|\|)", case_insensitive=false](#1{line}), text_to_integer(array_index(regexp_match["[0-9]+", case_insensitive=false](btrim(array_index(#2, 1))), 1)), regexp_split_to_array[" ", case_insensitive=false](btrim(array_index(#2, 2))), regexp_split_to_array[" ", case_insensitive=false](btrim(array_index(#2, 3)))) // { arity: 6 } FlatMap unnest_array(regexp_split_to_array["\n", case_insensitive=false](#0{input})) // { arity: 2 } ReadStorage materialize.public.aoc_1204 // { arity: 1 } cte l1 = @@ -529,7 +529,7 @@ Explained Query: Get l0 // { arity: 3 } cte l2 = Filter (#2 != "") // { arity: 3 } - FlatMap unnest_array(#0) // { arity: 3 } + FlatMap unnest_array(#0{wins}) // { arity: 3 } Get l1 // { arity: 2 } cte l3 = Reduce group_by=[#0, #1] aggregates=[count(*)] // { arity: 3 } @@ -543,7 +543,7 @@ Explained Query: Get l2 // { arity: 3 } Negate // { arity: 3 } Filter (#2 != "") // { arity: 3 } - FlatMap unnest_array(#1) // { arity: 3 } + FlatMap unnest_array(#1{have}) // { arity: 3 } Get l1 // { arity: 2 } cte l4 = Union // { arity: 3 } @@ -581,8 +581,8 @@ Explained Query: Union // { arity: 2 } Get l5 // { arity: 2 } Project (#2, #3{count}) // { arity: 2 } - Filter (integer_to_bigint(#2) = (integer_to_bigint(#0) + #4)) // { arity: 5 } - FlatMap generate_series(1, #1, 1) // { arity: 5 } + Filter (integer_to_bigint(#2{card}) = (integer_to_bigint(#0{card}) + #4{step})) // { arity: 5 } + FlatMap generate_series(1, #1{score}, 1) // { arity: 5 } CrossJoin type=differential // { arity: 4 } implementation %0:l7[×] » %1:l5[×] diff --git a/test/sqllogictest/advent-of-code/2023/aoc_1205.slt b/test/sqllogictest/advent-of-code/2023/aoc_1205.slt index 3fd9d6150d48b..23df1f1907888 100644 --- a/test/sqllogictest/advent-of-code/2023/aoc_1205.slt +++ b/test/sqllogictest/advent-of-code/2023/aoc_1205.slt @@ -745,91 +745,91 @@ WITH seeds AS ( Explained Query: With cte l0 = - Reduce aggregates=[min(coalesce(#1{max}, #0))] // { arity: 1 } - Reduce group_by=[#0] aggregates=[max(case when ((#0 < (#2 + #3)) AND (#0 >= #2)) then (#1 + (#0 - #2)) else null end)] // { arity: 2 } + Reduce aggregates=[min(coalesce(#1{max}, #0{humidity}))] // { arity: 1 } + Reduce group_by=[#0] aggregates=[max(case when ((#0{humidity} < (#2{src_base} + #3{len})) AND (#0{humidity} >= #2{src_base})) then (#1{dst_base} + (#0{humidity} - #2{src_base})) else null end)] // { arity: 2 } CrossJoin type=differential // { arity: 4 } implementation %0[×] » %1[×] ArrangeBy keys=[[]] // { arity: 1 } Project (#2) // { arity: 1 } - Map (coalesce(#1{max}, #0)) // { arity: 3 } - Reduce group_by=[#0] aggregates=[max(case when ((#0 < (#2 + #3)) AND (#0 >= #2)) then (#1 + (#0 - #2)) else null end)] // { arity: 2 } + Map (coalesce(#1{max}, #0{temperature})) // { arity: 3 } + Reduce group_by=[#0] aggregates=[max(case when ((#0{temperature} < (#2{src_base} + #3{len})) AND (#0{temperature} >= #2{src_base})) then (#1{dst_base} + (#0{temperature} - #2{src_base})) else null end)] // { arity: 2 } CrossJoin type=differential // { arity: 4 } implementation %0[×] » %1[×] ArrangeBy keys=[[]] // { arity: 1 } Project (#2) // { arity: 1 } - Map (coalesce(#1{max}, #0)) // { arity: 3 } - Reduce group_by=[#0] aggregates=[max(case when ((#0 < (#2 + #3)) AND (#0 >= #2)) then (#1 + (#0 - #2)) else null end)] // { arity: 2 } + Map (coalesce(#1{max}, #0{light})) // { arity: 3 } + Reduce group_by=[#0] aggregates=[max(case when ((#0{light} < (#2{src_base} + #3{len})) AND (#0{light} >= #2{src_base})) then (#1{dst_base} + (#0{light} - #2{src_base})) else null end)] // { arity: 2 } CrossJoin type=differential // { arity: 4 } implementation %0[×] » %1[×] ArrangeBy keys=[[]] // { arity: 1 } Project (#2) // { arity: 1 } - Map (coalesce(#1{max}, #0)) // { arity: 3 } - Reduce group_by=[#0] aggregates=[max(case when ((#0 < (#2 + #3)) AND (#0 >= #2)) then (#1 + (#0 - #2)) else null end)] // { arity: 2 } + Map (coalesce(#1{max}, #0{water})) // { arity: 3 } + Reduce group_by=[#0] aggregates=[max(case when ((#0{water} < (#2{src_base} + #3{len})) AND (#0{water} >= #2{src_base})) then (#1{dst_base} + (#0{water} - #2{src_base})) else null end)] // { arity: 2 } CrossJoin type=differential // { arity: 4 } implementation %0[×] » %1[×] ArrangeBy keys=[[]] // { arity: 1 } Project (#2) // { arity: 1 } - Map (coalesce(#1{max}, #0)) // { arity: 3 } - Reduce group_by=[#0] aggregates=[max(case when ((#0 < (#2 + #3)) AND (#0 >= #2)) then (#1 + (#0 - #2)) else null end)] // { arity: 2 } + Map (coalesce(#1{max}, #0{fertilizer})) // { arity: 3 } + Reduce group_by=[#0] aggregates=[max(case when ((#0{fertilizer} < (#2{src_base} + #3{len})) AND (#0{fertilizer} >= #2{src_base})) then (#1{dst_base} + (#0{fertilizer} - #2{src_base})) else null end)] // { arity: 2 } CrossJoin type=differential // { arity: 4 } implementation %0[×] » %1[×] ArrangeBy keys=[[]] // { arity: 1 } Project (#2) // { arity: 1 } - Map (coalesce(#1{max}, #0)) // { arity: 3 } - Reduce group_by=[#0] aggregates=[max(case when ((#0 < (#2 + #3)) AND (#0 >= #2)) then (#1 + (#0 - #2)) else null end)] // { arity: 2 } + Map (coalesce(#1{max}, #0{soil})) // { arity: 3 } + Reduce group_by=[#0] aggregates=[max(case when ((#0{soil} < (#2{src_base} + #3{len})) AND (#0{soil} >= #2{src_base})) then (#1{dst_base} + (#0{soil} - #2{src_base})) else null end)] // { arity: 2 } CrossJoin type=differential // { arity: 4 } implementation %0[×] » %1[×] ArrangeBy keys=[[]] // { arity: 1 } Project (#2) // { arity: 1 } - Map (coalesce(#1{max}, #0)) // { arity: 3 } - Reduce group_by=[#0] aggregates=[max(case when ((#0 < (#2 + #3)) AND (#0 >= #2)) then (#1 + (#0 - #2)) else null end)] // { arity: 2 } + Map (coalesce(#1{max}, #0{seed})) // { arity: 3 } + Reduce group_by=[#0] aggregates=[max(case when ((#0{seed} < (#2{src_base} + #3{len})) AND (#0{seed} >= #2{src_base})) then (#1{dst_base} + (#0{seed} - #2{src_base})) else null end)] // { arity: 2 } CrossJoin type=differential // { arity: 4 } implementation %0[×] » %1[×] ArrangeBy keys=[[]] // { arity: 1 } Project (#2) // { arity: 1 } - Map (text_to_bigint(#1)) // { arity: 3 } + Map (text_to_bigint(#1{unnest})) // { arity: 3 } FlatMap unnest_array(regexp_split_to_array[" ", case_insensitive=false](array_index(regexp_split_to_array[": ", case_insensitive=false](array_index(regexp_split_to_array["\n", case_insensitive=false](#0{input}), 1)), 2))) // { arity: 2 } ReadStorage materialize.public.input // { arity: 1 } ArrangeBy keys=[[]] // { arity: 3 } Project (#3..=#5) // { arity: 3 } - Map (arraytoarray(regexp_split_to_array[" ", case_insensitive=false](#1)), array_index(#2, 1), array_index(#2, 2), array_index(#2, 3)) // { arity: 6 } + Map (arraytoarray(regexp_split_to_array[" ", case_insensitive=false](#1{unnest})), array_index(#2{line}, 1), array_index(#2{line}, 2), array_index(#2{line}, 3)) // { arity: 6 } FlatMap unnest_array(regexp_split_to_array["\n", case_insensitive=false](array_index(regexp_match["seed-to-soil map:\n([0-9 \n]*?)\n\n", case_insensitive=false](#0{input}), 1))) // { arity: 2 } ReadStorage materialize.public.input // { arity: 1 } ArrangeBy keys=[[]] // { arity: 3 } Project (#3..=#5) // { arity: 3 } - Map (arraytoarray(regexp_split_to_array[" ", case_insensitive=false](#1)), array_index(#2, 1), array_index(#2, 2), array_index(#2, 3)) // { arity: 6 } + Map (arraytoarray(regexp_split_to_array[" ", case_insensitive=false](#1{unnest})), array_index(#2{line}, 1), array_index(#2{line}, 2), array_index(#2{line}, 3)) // { arity: 6 } FlatMap unnest_array(regexp_split_to_array["\n", case_insensitive=false](array_index(regexp_match["soil-to-fertilizer map:\n([0-9 \n]*?)\n\n", case_insensitive=false](#0{input}), 1))) // { arity: 2 } ReadStorage materialize.public.input // { arity: 1 } ArrangeBy keys=[[]] // { arity: 3 } Project (#3..=#5) // { arity: 3 } - Map (arraytoarray(regexp_split_to_array[" ", case_insensitive=false](#1)), array_index(#2, 1), array_index(#2, 2), array_index(#2, 3)) // { arity: 6 } + Map (arraytoarray(regexp_split_to_array[" ", case_insensitive=false](#1{unnest})), array_index(#2{line}, 1), array_index(#2{line}, 2), array_index(#2{line}, 3)) // { arity: 6 } FlatMap unnest_array(regexp_split_to_array["\n", case_insensitive=false](array_index(regexp_match["fertilizer-to-water map:\n([0-9 \n]*?)\n\n", case_insensitive=false](#0{input}), 1))) // { arity: 2 } ReadStorage materialize.public.input // { arity: 1 } ArrangeBy keys=[[]] // { arity: 3 } Project (#3..=#5) // { arity: 3 } - Map (arraytoarray(regexp_split_to_array[" ", case_insensitive=false](#1)), array_index(#2, 1), array_index(#2, 2), array_index(#2, 3)) // { arity: 6 } + Map (arraytoarray(regexp_split_to_array[" ", case_insensitive=false](#1{unnest})), array_index(#2{line}, 1), array_index(#2{line}, 2), array_index(#2{line}, 3)) // { arity: 6 } FlatMap unnest_array(regexp_split_to_array["\n", case_insensitive=false](array_index(regexp_match["water-to-light map:\n([0-9 \n]*?)\n\n", case_insensitive=false](#0{input}), 1))) // { arity: 2 } ReadStorage materialize.public.input // { arity: 1 } ArrangeBy keys=[[]] // { arity: 3 } Project (#3..=#5) // { arity: 3 } - Map (arraytoarray(regexp_split_to_array[" ", case_insensitive=false](#1)), array_index(#2, 1), array_index(#2, 2), array_index(#2, 3)) // { arity: 6 } + Map (arraytoarray(regexp_split_to_array[" ", case_insensitive=false](#1{unnest})), array_index(#2{line}, 1), array_index(#2{line}, 2), array_index(#2{line}, 3)) // { arity: 6 } FlatMap unnest_array(regexp_split_to_array["\n", case_insensitive=false](array_index(regexp_match["light-to-temperature map:\n([0-9 \n]*?)\n\n", case_insensitive=false](#0{input}), 1))) // { arity: 2 } ReadStorage materialize.public.input // { arity: 1 } ArrangeBy keys=[[]] // { arity: 3 } Project (#3..=#5) // { arity: 3 } - Map (arraytoarray(regexp_split_to_array[" ", case_insensitive=false](#1)), array_index(#2, 1), array_index(#2, 2), array_index(#2, 3)) // { arity: 6 } + Map (arraytoarray(regexp_split_to_array[" ", case_insensitive=false](#1{unnest})), array_index(#2{line}, 1), array_index(#2{line}, 2), array_index(#2{line}, 3)) // { arity: 6 } FlatMap unnest_array(regexp_split_to_array["\n", case_insensitive=false](array_index(regexp_match["temperature-to-humidity map:\n([0-9 \n]*?)\n\n", case_insensitive=false](#0{input}), 1))) // { arity: 2 } ReadStorage materialize.public.input // { arity: 1 } ArrangeBy keys=[[]] // { arity: 3 } Project (#3..=#5) // { arity: 3 } - Map (arraytoarray(regexp_split_to_array[" ", case_insensitive=false](#1)), array_index(#2, 1), array_index(#2, 2), array_index(#2, 3)) // { arity: 6 } + Map (arraytoarray(regexp_split_to_array[" ", case_insensitive=false](#1{unnest})), array_index(#2{line}, 1), array_index(#2{line}, 2), array_index(#2{line}, 3)) // { arity: 6 } FlatMap unnest_array(regexp_split_to_array["\n", case_insensitive=false](array_index(regexp_match["humidity-to-location map:\n([0-9 \n]*)", case_insensitive=false](#0{input}), 1))) // { arity: 2 } ReadStorage materialize.public.input // { arity: 1 } Return // { arity: 1 } @@ -1164,47 +1164,47 @@ Explained Query: With cte l0 = Project (#2, #3) // { arity: 2 } - Map (split_string(#1, ":", 1), split_string(#1, ":", 2)) // { arity: 4 } + Map (split_string(#1{unnest}, ":", 1), split_string(#1{unnest}, ":", 2)) // { arity: 4 } FlatMap unnest_array(regexp_split_to_array["\n\n", case_insensitive=false](#0{input})) // { arity: 2 } ReadStorage materialize.public.input // { arity: 1 } cte l1 = Project (#5..=#9) // { arity: 5 } Filter (#3 != "") // { arity: 10 } - Map (split_string(#2, " ", 2), split_string(#0, " ", 1), split_string(#4, "-", 1), split_string(#4, "-", 3), text_to_bigint(#3), text_to_bigint(split_string(#2, " ", 1)), text_to_bigint(split_string(#2, " ", 3))) // { arity: 10 } - FlatMap unnest_array(regexp_split_to_array["\n", case_insensitive=false](#1)) // { arity: 3 } - Filter (#0 != "seeds") // { arity: 2 } + Map (split_string(#2{unnest}, " ", 2), split_string(#0{head}, " ", 1), split_string(#4, "-", 1), split_string(#4, "-", 3), text_to_bigint(#3{src_idx}), text_to_bigint(split_string(#2{unnest}, " ", 1)), text_to_bigint(split_string(#2{unnest}, " ", 3))) // { arity: 10 } + FlatMap unnest_array(regexp_split_to_array["\n", case_insensitive=false](#1{body})) // { arity: 3 } + Filter (#0{head} != "seeds") // { arity: 2 } Get l0 // { arity: 2 } cte l2 = - ArrangeBy keys=[[#0, #1]] // { arity: 5 } + ArrangeBy keys=[[#0{src_name}, #1{dst_name}]] // { arity: 5 } Get l1 // { arity: 5 } cte l3 = Project (#1) // { arity: 1 } - Filter (#0 = "seeds") // { arity: 2 } + Filter (#0{head} = "seeds") // { arity: 2 } Get l0 // { arity: 2 } cte l4 = - ArrangeBy keys=[[#0]] // { arity: 2 } - Distinct project=[#0, #1] // { arity: 2 } + ArrangeBy keys=[[#0{src_name}]] // { arity: 2 } + Distinct project=[#0{src_name}, #1] // { arity: 2 } Project (#0, #1) // { arity: 2 } Get l1 // { arity: 5 } Return // { arity: 2 } With Mutually Recursive cte l5 = Project (#0..=#2, #5, #6) // { arity: 5 } - Filter (#2 >= #5) AND (#2 <= ((#5 + #7) - 1)) // { arity: 8 } - Join on=(#0 = #3 AND #1 = #4) type=differential // { arity: 8 } + Filter (#2{idx} >= #5{src_idx}) AND (#2{idx} <= ((#5{src_idx} + #7{len}) - 1)) // { arity: 8 } + Join on=(#0{src_name} = #3{src_name} AND #1{dst_name} = #4{dst_name}) type=differential // { arity: 8 } implementation - %0:l7[#0, #1]KK » %1:l2[#0, #1]KK - ArrangeBy keys=[[#0, #1]] // { arity: 3 } + %0:l7[#0{src_name}, #1{dst_name}]KK » %1:l2[#0{src_name}, #1{dst_name}]KK + ArrangeBy keys=[[#0{src_name}, #1{dst_name}]] // { arity: 3 } Get l7 // { arity: 3 } Get l2 // { arity: 5 } cte l6 = Union // { arity: 2 } Project (#3, #2) // { arity: 2 } - Map (text_to_bigint(#1), "seed") // { arity: 4 } - FlatMap unnest_array(regexp_split_to_array[" ", case_insensitive=false](btrim(#0))) // { arity: 2 } + Map (text_to_bigint(#1{unnest}), "seed") // { arity: 4 } + FlatMap unnest_array(regexp_split_to_array[" ", case_insensitive=false](btrim(#0{body}))) // { arity: 2 } Get l3 // { arity: 1 } Project (#0, #4) // { arity: 2 } - Map (coalesce((#1 + (#3 - #2)), #1)) // { arity: 5 } + Map (coalesce((#1{idx} + (#3{dst_idx} - #2{src_idx})), #1{idx})) // { arity: 5 } Union // { arity: 4 } Project (#1..=#4) // { arity: 4 } Get l5 // { arity: 5 } @@ -1223,33 +1223,33 @@ Explained Query: ArrangeBy keys=[[#0..=#2]] // { arity: 3 } Get l7 // { arity: 3 } cte l7 = - Project (#0, #3, #1) // { arity: 3 } - Join on=(#0 = #2) type=differential // { arity: 4 } + Project (#0{name}, #3, #1) // { arity: 3 } + Join on=(#0{name} = #2{src_name}) type=differential // { arity: 4 } implementation %0[#0]K » %1:l4[#0]K - ArrangeBy keys=[[#0]] // { arity: 2 } - Distinct project=[#0, #1] // { arity: 2 } + ArrangeBy keys=[[#0{name}]] // { arity: 2 } + Distinct project=[#0{name}, #1] // { arity: 2 } Get l6 // { arity: 2 } Get l4 // { arity: 2 } cte l8 = - Reduce aggregates=[min(#0)] // { arity: 1 } + Reduce aggregates=[min(#0{idx})] // { arity: 1 } Project (#1) // { arity: 1 } - Filter (#0 = "location") // { arity: 2 } + Filter (#0{name} = "location") // { arity: 2 } Get l6 // { arity: 2 } cte l9 = Distinct project=[#0..=#2] // { arity: 3 } Union // { arity: 3 } Project (#6, #4, #5) // { arity: 3 } - Map (regexp_split_to_array[" ", case_insensitive=false](btrim(#0)), (2 * #1), text_to_bigint(array_index(#2, integer_to_bigint((#3 - 1)))), (#4 + text_to_bigint(array_index(#2, integer_to_bigint(#3)))), "seed") // { arity: 7 } - FlatMap generate_series(1, ((regexp_split_to_array[" ", case_insensitive=false](btrim(#0)) array_length 1) / 2), 1) // { arity: 2 } + Map (regexp_split_to_array[" ", case_insensitive=false](btrim(#0{body})), (2 * #1{x}), text_to_bigint(array_index(#2, integer_to_bigint((#3 - 1)))), (#4{?column?} + text_to_bigint(array_index(#2, integer_to_bigint(#3)))), "seed") // { arity: 7 } + FlatMap generate_series(1, ((regexp_split_to_array[" ", case_insensitive=false](btrim(#0{body})) array_length 1) / 2), 1) // { arity: 2 } Get l3 // { arity: 1 } Project (#1, #10, #11) // { arity: 3 } - Map ((#8 - #4), (#6 + #9), (#7 + #9)) // { arity: 12 } + Map ((#8{entry_dst} - #4{entry_start}), (#6{clipped_start} + #9), (#7{clipped_end} + #9)) // { arity: 12 } Get l11 // { arity: 9 } Get l19 // { arity: 3 } cte l10 = Project (#0..=#2, #4) // { arity: 4 } - Join on=(#0 = #3) type=differential // { arity: 5 } + Join on=(#0 = #3{src_name}) type=differential // { arity: 5 } implementation %0:l9[#0]K » %1:l4[#0]K ArrangeBy keys=[[#0]] // { arity: 3 } @@ -1258,11 +1258,11 @@ Explained Query: cte l11 = Project (#0, #3, #1, #2, #6, #10, #9, #11, #7) // { arity: 9 } Filter (#9 < #11) // { arity: 12 } - Map (greatest(#1, #6), (#6 + #8), least(#2, #10)) // { arity: 12 } - Join on=(#0 = #4 AND #3 = #5) type=differential // { arity: 9 } + Map (greatest(#1{start_idx}, #6{src_idx}), (#6{src_idx} + #8{len}), least(#2{end_idx}, #10)) // { arity: 12 } + Join on=(#0{src_name} = #4{src_name} AND #3{dst_name} = #5{dst_name}) type=differential // { arity: 9 } implementation - %0:l10[#0, #3]KK » %1:l2[#0, #1]KK - ArrangeBy keys=[[#0, #3]] // { arity: 4 } + %0:l10[#0{src_name}, #3{dst_name}]KK » %1:l2[#0{src_name}, #1{dst_name}]KK + ArrangeBy keys=[[#0{src_name}, #3{dst_name}]] // { arity: 4 } Get l10 // { arity: 4 } Get l2 // { arity: 5 } cte l12 = @@ -1273,22 +1273,22 @@ Explained Query: Project (#0..=#3, #7) // { arity: 5 } Get l12 // { arity: 9 } cte l14 = - Reduce group_by=[#0..=#4] aggregates=[min(#5)] // { arity: 6 } + Reduce group_by=[#0..=#4] aggregates=[min(#5{clipped_start})] // { arity: 6 } Project (#0..=#4, #9) // { arity: 6 } - Filter (#9 >= #4) // { arity: 10 } - Join on=(#0 = #5 AND #1 = #6 AND #2 = #7 AND #3 = #8) type=differential // { arity: 10 } + Filter (#9{clipped_start} >= #4{clipped_end}) // { arity: 10 } + Join on=(#0{src_name} = #5{src_name} AND #1{dst_name} = #6{dst_name} AND #2{start_idx} = #7{start_idx} AND #3{end_idx} = #8{end_idx}) type=differential // { arity: 10 } implementation - %1:l11[#0..=#3]KKKKf » %0:l13[#0..=#3]KKKKf - ArrangeBy keys=[[#0..=#3]] // { arity: 5 } - Filter (#2) IS NOT NULL AND (#3) IS NOT NULL // { arity: 5 } + %1:l11[#0{src_name}..=#3{end_idx}]KKKKf » %0:l13[#0{src_name}..=#3{end_idx}]KKKKf + ArrangeBy keys=[[#0{src_name}..=#3{end_idx}]] // { arity: 5 } + Filter (#2{start_idx}) IS NOT NULL AND (#3{end_idx}) IS NOT NULL // { arity: 5 } Get l13 // { arity: 5 } - ArrangeBy keys=[[#0..=#3]] // { arity: 5 } + ArrangeBy keys=[[#0{src_name}..=#3{end_idx}]] // { arity: 5 } Project (#0..=#3, #6) // { arity: 5 } - Filter (#2) IS NOT NULL AND (#6 < #3) // { arity: 9 } + Filter (#2{start_idx}) IS NOT NULL AND (#6{clipped_start} < #3{end_idx}) // { arity: 9 } Get l11 // { arity: 9 } cte l15 = Project (#0..=#4, #6) // { arity: 6 } - Map (coalesce(#5{min}, #3)) // { arity: 7 } + Map (coalesce(#5{min}, #3{end_idx})) // { arity: 7 } Union // { arity: 6 } Get l14 // { arity: 6 } Project (#0..=#4, #10) // { arity: 6 } @@ -1305,24 +1305,24 @@ Explained Query: ArrangeBy keys=[[#0..=#4]] // { arity: 5 } Get l13 // { arity: 5 } cte l16 = - Reduce group_by=[#0, #3, #1, #2] aggregates=[min(#4)] // { arity: 5 } + Reduce group_by=[#0, #3, #1, #2] aggregates=[min(#4{clipped_start})] // { arity: 5 } Project (#0..=#3, #8) // { arity: 5 } - Join on=(#0 = #4 AND #1 = #6 AND #2 = #7 AND #3 = #5) type=differential // { arity: 9 } + Join on=(#0{src_name} = #4{src_name} AND #1{start_idx} = #6{start_idx} AND #2{end_idx} = #7{end_idx} AND #3{dst_name} = #5{dst_name}) type=differential // { arity: 9 } implementation - %1:l11[#0, #2, #3, #1]KKKKf » %0:l10[#0..=#3]KKKKf - ArrangeBy keys=[[#0..=#3]] // { arity: 4 } - Filter (#1) IS NOT NULL AND (#2) IS NOT NULL // { arity: 4 } + %1:l11[#0{src_name}, #2{start_idx}, #3{end_idx}, #1{dst_name}]KKKKf » %0:l10[#0{src_name}..=#3{dst_name}]KKKKf + ArrangeBy keys=[[#0{src_name}..=#3{dst_name}]] // { arity: 4 } + Filter (#1{start_idx}) IS NOT NULL AND (#2{end_idx}) IS NOT NULL // { arity: 4 } Get l10 // { arity: 4 } - ArrangeBy keys=[[#0, #2, #3, #1]] // { arity: 5 } + ArrangeBy keys=[[#0{src_name}, #2{start_idx}, #3{end_idx}, #1{dst_name}]] // { arity: 5 } Project (#0..=#3, #6) // { arity: 5 } - Filter (#6 < #3) AND (#6 >= #2) // { arity: 9 } + Filter (#6{clipped_start} < #3{end_idx}) AND (#6{clipped_start} >= #2{start_idx}) // { arity: 9 } Get l11 // { arity: 9 } cte l17 = ArrangeBy keys=[[#0..=#3]] // { arity: 4 } Get l10 // { arity: 4 } cte l18 = Project (#0..=#3, #5) // { arity: 5 } - Map (coalesce(#4{min}, #3)) // { arity: 6 } + Map (coalesce(#4{min}, #3{end_idx})) // { arity: 6 } Union // { arity: 5 } Get l16 // { arity: 5 } Project (#0..=#3, #8) // { arity: 5 } @@ -1383,9 +1383,9 @@ Explained Query: Return // { arity: 2 } With cte l20 = - Reduce aggregates=[min(#0)] // { arity: 1 } + Reduce aggregates=[min(#0{start_idx})] // { arity: 1 } Project (#1) // { arity: 1 } - Filter (#0 = "location") // { arity: 3 } + Filter (#0{name} = "location") // { arity: 3 } Get l9 // { arity: 3 } Return // { arity: 2 } CrossJoin type=differential // { arity: 2 } diff --git a/test/sqllogictest/advent-of-code/2023/aoc_1207.slt b/test/sqllogictest/advent-of-code/2023/aoc_1207.slt index b9ad8b25894f0..dbfe967aabf8d 100644 --- a/test/sqllogictest/advent-of-code/2023/aoc_1207.slt +++ b/test/sqllogictest/advent-of-code/2023/aoc_1207.slt @@ -272,7 +272,7 @@ Explained Query: With cte l0 = Project (#3, #4) // { arity: 2 } - Map (regexp_split_to_array[" ", case_insensitive=false](#1), array_index(#2, 1), text_to_integer(array_index(#2, 2))) // { arity: 5 } + Map (regexp_split_to_array[" ", case_insensitive=false](#1{line}), array_index(#2, 1), text_to_integer(array_index(#2, 2))) // { arity: 5 } FlatMap unnest_array(regexp_split_to_array["\n", case_insensitive=false](#0{input})) // { arity: 2 } ReadStorage materialize.public.input // { arity: 1 } cte l1 = @@ -287,7 +287,7 @@ Explained Query: - (4) - (5) cte l3 = - Map (substr(#0, #1, 1)) // { arity: 3 } + Map (substr(#0{hand}, #1{pos}, 1)) // { arity: 3 } CrossJoin type=differential // { arity: 2 } implementation %0:l1[×] » %1:l2[×] @@ -304,7 +304,7 @@ Explained Query: Distinct project=[#0] // { arity: 1 } Get l1 // { arity: 1 } cte l6 = - Reduce group_by=[#0] aggregates=[any((#0 = #1))] // { arity: 2 } + Reduce group_by=[#0] aggregates=[any((#0{hand} = #1{right_col0_0}))] // { arity: 2 } CrossJoin type=differential // { arity: 2 } implementation %1:l4[×]ef » %0:l5[×]ef @@ -312,7 +312,7 @@ Explained Query: Get l5 // { arity: 1 } ArrangeBy keys=[[]] // { arity: 1 } Project (#0) // { arity: 1 } - Filter (#1 = 5) // { arity: 2 } + Filter (#1{count} = 5) // { arity: 2 } Get l4 // { arity: 2 } cte l7 = Union // { arity: 2 } @@ -348,7 +348,7 @@ Explained Query: Project (#0) // { arity: 1 } Get l9 // { arity: 2 } cte l11 = - Reduce group_by=[#0] aggregates=[any((#0 = #1))] // { arity: 2 } + Reduce group_by=[#0] aggregates=[any((#0{hand} = #1{right_col0_2}))] // { arity: 2 } CrossJoin type=differential // { arity: 2 } implementation %1:l4[×]ef » %0:l10[×]ef @@ -356,7 +356,7 @@ Explained Query: Get l10 // { arity: 1 } ArrangeBy keys=[[]] // { arity: 1 } Project (#0) // { arity: 1 } - Filter (#1 = 4) // { arity: 2 } + Filter (#1{count} = 4) // { arity: 2 } Get l4 // { arity: 2 } cte l12 = Union // { arity: 2 } @@ -394,10 +394,10 @@ Explained Query: cte l16 = ArrangeBy keys=[[]] // { arity: 1 } Project (#0) // { arity: 1 } - Filter (#1 = 3) // { arity: 2 } + Filter (#1{count} = 3) // { arity: 2 } Get l4 // { arity: 2 } cte l17 = - Reduce group_by=[#0] aggregates=[any((#0 = #1))] // { arity: 2 } + Reduce group_by=[#0] aggregates=[any((#0{hand} = #1{right_col0_4}))] // { arity: 2 } CrossJoin type=differential // { arity: 2 } implementation %1:l16[×]ef » %0:l15[×]ef @@ -436,10 +436,10 @@ Explained Query: cte l21 = ArrangeBy keys=[[]] // { arity: 1 } Project (#0) // { arity: 1 } - Filter (#1 = 2) // { arity: 2 } + Filter (#1{count} = 2) // { arity: 2 } Get l4 // { arity: 2 } cte l22 = - Reduce group_by=[#0] aggregates=[any((#0 = #1))] // { arity: 2 } + Reduce group_by=[#0] aggregates=[any((#0{hand} = #1{right_col0_6}))] // { arity: 2 } CrossJoin type=differential // { arity: 2 } implementation %1:l21[×]ef » %0:l20[×]ef @@ -481,7 +481,7 @@ Explained Query: Project (#0) // { arity: 1 } Get l25 // { arity: 2 } cte l27 = - Reduce group_by=[#0] aggregates=[any((#0 = #1))] // { arity: 2 } + Reduce group_by=[#0] aggregates=[any((#0{hand} = #1{right_col0_8}))] // { arity: 2 } CrossJoin type=differential // { arity: 2 } implementation %1:l16[×]ef » %0:l26[×]ef @@ -522,7 +522,7 @@ Explained Query: Project (#0) // { arity: 1 } Get l30 // { arity: 2 } cte l32 = - Reduce group_by=[#0] aggregates=[any((#0 = #1))] // { arity: 2 } + Reduce group_by=[#0] aggregates=[any((#0{hand} = #1{right_col0_10}))] // { arity: 2 } Project (#0, #1) // { arity: 2 } Filter (#2{count} = 2) // { arity: 3 } Reduce group_by=[#0, #1] aggregates=[count(*)] // { arity: 3 } @@ -566,7 +566,7 @@ Explained Query: Project (#0) // { arity: 1 } Get l35 // { arity: 2 } cte l37 = - Reduce group_by=[#0] aggregates=[any((#0 = #1))] // { arity: 2 } + Reduce group_by=[#0] aggregates=[any((#0{hand} = #1{right_col0_12}))] // { arity: 2 } CrossJoin type=differential // { arity: 2 } implementation %1:l21[×]ef » %0:l36[×]ef @@ -584,7 +584,7 @@ Explained Query: Get l36 // { arity: 1 } cte l39 = Project (#1..=#3) // { arity: 3 } - Map (translate(#0, "AKQJT98765432", "ABCDEFGHIJKLM")) // { arity: 4 } + Map (translate(#0{hand}, "AKQJT98765432", "ABCDEFGHIJKLM")) // { arity: 4 } Union // { arity: 3 } Project (#0, #1, #3) // { arity: 3 } Filter #2{any} // { arity: 4 } @@ -623,9 +623,9 @@ Explained Query: Get l38 // { arity: 2 } Get l36 // { arity: 1 } cte l40 = - Reduce aggregates=[sum(#0)] // { arity: 1 } + Reduce aggregates=[sum(#0{bid})] // { arity: 1 } Project (#0) // { arity: 1 } - Filter ((#1 < #3) OR ((#1 = #3) AND (#2 <= #4))) // { arity: 5 } + Filter ((#1{rank} < #3{rank}) OR ((#1{rank} = #3{rank}) AND (#2{score} <= #4{score}))) // { arity: 5 } CrossJoin type=differential // { arity: 5 } implementation %0:l39[×] » %1:l39[×] @@ -643,45 +643,45 @@ Explained Query: Project (#0, #2, #1) // { arity: 3 } Get l41 // { arity: 3 } Project (#0, #3, #1) // { arity: 3 } - Join on=(#0 = #2) type=differential // { arity: 4 } + Join on=(#0{hand} = #2{hand}) type=differential // { arity: 4 } implementation - %0:l3[#0]Kef » %1:l41[#0]Kef - ArrangeBy keys=[[#0]] // { arity: 2 } + %0:l3[#0{hand}]Kef » %1:l41[#0{hand}]Kef + ArrangeBy keys=[[#0{hand}]] // { arity: 2 } Project (#0, #1) // { arity: 2 } - Filter (#2 = "J") AND (#0) IS NOT NULL // { arity: 3 } + Filter (#2{value} = "J") AND (#0{hand}) IS NOT NULL // { arity: 3 } Get l3 // { arity: 3 } - ArrangeBy keys=[[#0]] // { arity: 2 } + ArrangeBy keys=[[#0{hand}]] // { arity: 2 } Project (#0, #2) // { arity: 2 } Get l41 // { arity: 3 } cte l43 = - Distinct project=[#0, ((((#1 || #2) || #3) || #4) || #5)] // { arity: 2 } + Distinct project=[#0, ((((#1{value} || #2{value}) || #3{value}) || #4{value}) || #5{value})] // { arity: 2 } Project (#0, #1, #3, #5, #7, #9) // { arity: 6 } - Join on=(#0 = #2 = #4 = #6 = #8) type=delta // { arity: 10 } + Join on=(#0{hand} = #2{hand} = #4{hand} = #6{hand} = #8{hand}) type=delta // { arity: 10 } implementation - %0:l42 » %1:l42[#0]Kef » %2:l42[#0]Kef » %3:l42[#0]Kef » %4:l42[#0]Kef - %1:l42 » %0:l42[#0]Kef » %2:l42[#0]Kef » %3:l42[#0]Kef » %4:l42[#0]Kef - %2:l42 » %0:l42[#0]Kef » %1:l42[#0]Kef » %3:l42[#0]Kef » %4:l42[#0]Kef - %3:l42 » %0:l42[#0]Kef » %1:l42[#0]Kef » %2:l42[#0]Kef » %4:l42[#0]Kef - %4:l42 » %0:l42[#0]Kef » %1:l42[#0]Kef » %2:l42[#0]Kef » %3:l42[#0]Kef - ArrangeBy keys=[[#0]] // { arity: 2 } + %0:l42 » %1:l42[#0{hand}]Kef » %2:l42[#0{hand}]Kef » %3:l42[#0{hand}]Kef » %4:l42[#0{hand}]Kef + %1:l42 » %0:l42[#0{hand}]Kef » %2:l42[#0{hand}]Kef » %3:l42[#0{hand}]Kef » %4:l42[#0{hand}]Kef + %2:l42 » %0:l42[#0{hand}]Kef » %1:l42[#0{hand}]Kef » %3:l42[#0{hand}]Kef » %4:l42[#0{hand}]Kef + %3:l42 » %0:l42[#0{hand}]Kef » %1:l42[#0{hand}]Kef » %2:l42[#0{hand}]Kef » %4:l42[#0{hand}]Kef + %4:l42 » %0:l42[#0{hand}]Kef » %1:l42[#0{hand}]Kef » %2:l42[#0{hand}]Kef » %3:l42[#0{hand}]Kef + ArrangeBy keys=[[#0{hand}]] // { arity: 2 } Project (#0, #1) // { arity: 2 } - Filter (#2 = 1) // { arity: 3 } + Filter (#2{position} = 1) // { arity: 3 } Get l42 // { arity: 3 } - ArrangeBy keys=[[#0]] // { arity: 2 } + ArrangeBy keys=[[#0{hand}]] // { arity: 2 } Project (#0, #1) // { arity: 2 } - Filter (#2 = 2) // { arity: 3 } + Filter (#2{position} = 2) // { arity: 3 } Get l42 // { arity: 3 } - ArrangeBy keys=[[#0]] // { arity: 2 } + ArrangeBy keys=[[#0{hand}]] // { arity: 2 } Project (#0, #1) // { arity: 2 } - Filter (#2 = 3) // { arity: 3 } + Filter (#2{position} = 3) // { arity: 3 } Get l42 // { arity: 3 } - ArrangeBy keys=[[#0]] // { arity: 2 } + ArrangeBy keys=[[#0{hand}]] // { arity: 2 } Project (#0, #1) // { arity: 2 } - Filter (#2 = 4) // { arity: 3 } + Filter (#2{position} = 4) // { arity: 3 } Get l42 // { arity: 3 } - ArrangeBy keys=[[#0]] // { arity: 2 } + ArrangeBy keys=[[#0{hand}]] // { arity: 2 } Project (#0, #1) // { arity: 2 } - Filter (#2 = 5) // { arity: 3 } + Filter (#2{position} = 5) // { arity: 3 } Get l42 // { arity: 3 } cte l44 = Project (#1) // { arity: 1 } @@ -691,7 +691,7 @@ Explained Query: Map (bigint_to_integer(#2{count})) // { arity: 4 } Reduce group_by=[#0, #1] aggregates=[count(*)] // { arity: 3 } Project (#0, #1) // { arity: 2 } - Distinct project=[#0, substr(#0, #1, 1), #1] // { arity: 3 } + Distinct project=[#0, substr(#0{new_hand}, #1{pos}, 1), #1] // { arity: 3 } CrossJoin type=differential // { arity: 2 } implementation %0:l44[×] » %1:l2[×] @@ -702,7 +702,7 @@ Explained Query: Distinct project=[#0] // { arity: 1 } Get l44 // { arity: 1 } cte l47 = - Reduce group_by=[#0] aggregates=[any((#0 = #1))] // { arity: 2 } + Reduce group_by=[#0] aggregates=[any((#0{new_hand} = #1{right_col0_14}))] // { arity: 2 } CrossJoin type=differential // { arity: 2 } implementation %1:l45[×]ef » %0:l46[×]ef @@ -710,7 +710,7 @@ Explained Query: Get l46 // { arity: 1 } ArrangeBy keys=[[]] // { arity: 1 } Project (#0) // { arity: 1 } - Filter (#1 = 5) // { arity: 2 } + Filter (#1{count} = 5) // { arity: 2 } Get l45 // { arity: 2 } cte l48 = Union // { arity: 2 } @@ -746,7 +746,7 @@ Explained Query: Project (#1) // { arity: 1 } Get l50 // { arity: 2 } cte l52 = - Reduce group_by=[#0] aggregates=[any((#0 = #1))] // { arity: 2 } + Reduce group_by=[#0] aggregates=[any((#0{new_hand} = #1{right_col0_16}))] // { arity: 2 } CrossJoin type=differential // { arity: 2 } implementation %1:l45[×]ef » %0:l51[×]ef @@ -754,7 +754,7 @@ Explained Query: Get l51 // { arity: 1 } ArrangeBy keys=[[]] // { arity: 1 } Project (#0) // { arity: 1 } - Filter (#1 = 4) // { arity: 2 } + Filter (#1{count} = 4) // { arity: 2 } Get l45 // { arity: 2 } cte l53 = Union // { arity: 2 } @@ -792,10 +792,10 @@ Explained Query: cte l57 = ArrangeBy keys=[[]] // { arity: 1 } Project (#0) // { arity: 1 } - Filter (#1 = 3) // { arity: 2 } + Filter (#1{count} = 3) // { arity: 2 } Get l45 // { arity: 2 } cte l58 = - Reduce group_by=[#0] aggregates=[any((#0 = #1))] // { arity: 2 } + Reduce group_by=[#0] aggregates=[any((#0{new_hand} = #1{right_col0_18}))] // { arity: 2 } CrossJoin type=differential // { arity: 2 } implementation %1:l57[×]ef » %0:l56[×]ef @@ -834,10 +834,10 @@ Explained Query: cte l62 = ArrangeBy keys=[[]] // { arity: 1 } Project (#0) // { arity: 1 } - Filter (#1 = 2) // { arity: 2 } + Filter (#1{count} = 2) // { arity: 2 } Get l45 // { arity: 2 } cte l63 = - Reduce group_by=[#0] aggregates=[any((#0 = #1))] // { arity: 2 } + Reduce group_by=[#0] aggregates=[any((#0{new_hand} = #1{right_col0_20}))] // { arity: 2 } CrossJoin type=differential // { arity: 2 } implementation %1:l62[×]ef » %0:l61[×]ef @@ -879,7 +879,7 @@ Explained Query: Project (#1) // { arity: 1 } Get l66 // { arity: 2 } cte l68 = - Reduce group_by=[#0] aggregates=[any((#0 = #1))] // { arity: 2 } + Reduce group_by=[#0] aggregates=[any((#0{new_hand} = #1{right_col0_22}))] // { arity: 2 } CrossJoin type=differential // { arity: 2 } implementation %1:l57[×]ef » %0:l67[×]ef @@ -920,7 +920,7 @@ Explained Query: Project (#1) // { arity: 1 } Get l71 // { arity: 2 } cte l73 = - Reduce group_by=[#0] aggregates=[any((#0 = #1))] // { arity: 2 } + Reduce group_by=[#0] aggregates=[any((#0{new_hand} = #1{right_col0_24}))] // { arity: 2 } Project (#0, #1) // { arity: 2 } Filter (#2{count} = 2) // { arity: 3 } Reduce group_by=[#0, #1] aggregates=[count(*)] // { arity: 3 } @@ -964,7 +964,7 @@ Explained Query: Project (#1) // { arity: 1 } Get l76 // { arity: 2 } cte l78 = - Reduce group_by=[#0] aggregates=[any((#0 = #1))] // { arity: 2 } + Reduce group_by=[#0] aggregates=[any((#0{new_hand} = #1{right_col0_26}))] // { arity: 2 } CrossJoin type=differential // { arity: 2 } implementation %1:l62[×]ef » %0:l77[×]ef @@ -982,15 +982,15 @@ Explained Query: Get l77 // { arity: 1 } cte l80 = Project (#1, #3, #4) // { arity: 3 } - Join on=(#0 = #2) type=differential // { arity: 5 } + Join on=(#0{hand} = #2{hand}) type=differential // { arity: 5 } implementation - %1[#0]UK » %0:l0[#0]K - ArrangeBy keys=[[#0]] // { arity: 2 } - Filter (#0) IS NOT NULL // { arity: 2 } + %1[#0{hand}]UK » %0:l0[#0{hand}]K + ArrangeBy keys=[[#0{hand}]] // { arity: 2 } + Filter (#0{hand}) IS NOT NULL // { arity: 2 } Get l0 // { arity: 2 } - ArrangeBy keys=[[#0]] // { arity: 3 } + ArrangeBy keys=[[#0{hand}]] // { arity: 3 } TopK group_by=[#0] order_by=[#1 asc nulls_last, #2 asc nulls_last] limit=1 // { arity: 3 } - Map (translate(#0, "AKQT98765432J", "ABCDEFGHIJKLM")) // { arity: 3 } + Map (translate(#0{hand}, "AKQT98765432J", "ABCDEFGHIJKLM")) // { arity: 3 } Union // { arity: 2 } Project (#0, #3) // { arity: 2 } Filter #2{any} // { arity: 4 } @@ -1029,9 +1029,9 @@ Explained Query: Get l79 // { arity: 2 } Get l77 // { arity: 1 } cte l81 = - Reduce aggregates=[sum(#0)] // { arity: 1 } + Reduce aggregates=[sum(#0{bid})] // { arity: 1 } Project (#0) // { arity: 1 } - Filter ((#1 < #3) OR ((#1 = #3) AND (#2 <= #4))) // { arity: 5 } + Filter ((#1{rank} < #3{rank}) OR ((#1{rank} = #3{rank}) AND (#2{score} <= #4{score}))) // { arity: 5 } CrossJoin type=differential // { arity: 5 } implementation %0:l80[×] » %1:l80[×] diff --git a/test/sqllogictest/advent-of-code/2023/aoc_1208.slt b/test/sqllogictest/advent-of-code/2023/aoc_1208.slt index 9b901900796ac..388c2bdf06872 100644 --- a/test/sqllogictest/advent-of-code/2023/aoc_1208.slt +++ b/test/sqllogictest/advent-of-code/2023/aoc_1208.slt @@ -75,21 +75,21 @@ Explained Query: Map (0) // { arity: 4 } ReadStorage materialize.public.paths // { arity: 3 } Project (#3, #8, #9) // { arity: 3 } - Map (case when (#7 = "L") then #1{"left"} else case when (#7 = "R") then #2{"right"} else "???" end end, (#5 + 1)) // { arity: 10 } - Join on=(#0{state} = #4 AND #6 = (1 + (#5 % 263))) type=delta // { arity: 8 } + Map (case when (#7{step} = "L") then #1{"left"} else case when (#7{step} = "R") then #2{"right"} else "???" end end, (#5{steps} + 1)) // { arity: 10 } + Join on=(#0{state} = #4{state} AND #6{steps} = (1 + (#5{steps} % 263))) type=delta // { arity: 8 } implementation - %0:paths » %1:l0[#1]Kf » %2[#0]K - %1:l0 » %0:paths[#0]Kf » %2[#0]K - %2 » %1:l0[(1 + (#2 % 263))]Kf » %0:paths[#0]Kf + %0:paths » %1:l0[#1{state}]Kf » %2[#0{steps}]K + %1:l0 » %0:paths[#0{state}]Kf » %2[#0{steps}]K + %2 » %1:l0[(1 + (#2{steps} % 263))]Kf » %0:paths[#0{state}]Kf ArrangeBy keys=[[#0{state}]] // { arity: 3 } Filter ("Z" != substr(#0{state}, 3, 1)) // { arity: 3 } ReadStorage materialize.public.paths // { arity: 3 } - ArrangeBy keys=[[#1], [(1 + (#2 % 263))]] // { arity: 3 } + ArrangeBy keys=[[#1{state}], [(1 + (#2{steps} % 263))]] // { arity: 3 } Filter ("Z" != substr(#1{state}, 3, 1)) // { arity: 3 } Get l0 // { arity: 3 } - ArrangeBy keys=[[#0]] // { arity: 2 } + ArrangeBy keys=[[#0{steps}]] // { arity: 2 } Project (#1, #2) // { arity: 2 } - Map (substr(#0{input}, #1, 1)) // { arity: 3 } + Map (substr(#0{input}, #1{steps}, 1)) // { arity: 3 } FlatMap generate_series(1, char_length(#0{input}), 1) // { arity: 2 } ReadStorage materialize.public.steps_input // { arity: 1 } Return // { arity: 3 } diff --git a/test/sqllogictest/advent-of-code/2023/aoc_1209.slt b/test/sqllogictest/advent-of-code/2023/aoc_1209.slt index b894f1bc1efc3..66cd0c5a78506 100644 --- a/test/sqllogictest/advent-of-code/2023/aoc_1209.slt +++ b/test/sqllogictest/advent-of-code/2023/aoc_1209.slt @@ -66,19 +66,19 @@ SELECT * FROM part1, part2; Explained Query: With Mutually Recursive cte l0 = - Map ((#2 + 1)) // { arity: 5 } + Map ((#2{col_no} + 1)) // { arity: 5 } Get l3 // { arity: 4 } cte l1 = Project (#0..=#4, #6) // { arity: 6 } - Join on=(#1 = #5 AND #3 = #7 AND #6 = (#2 + 1)) type=differential // { arity: 8 } + Join on=(#1{line_no} = #5{line_no} AND #3{round} = #7{round} AND #6{col_no} = (#2{col_no} + 1)) type=differential // { arity: 8 } implementation - %0:l0[#1, (#2 + 1), #3]KKKif » %1:l3[#1..=#3]KKKiif - ArrangeBy keys=[[#1, (#2 + 1), #3]] // { arity: 4 } + %0:l0[#1{line_no}, (#2{col_no} + 1), #3{round}]KKKif » %1:l3[#1{line_no}..=#3{round}]KKKiif + ArrangeBy keys=[[#1{line_no}, (#2{col_no} + 1), #3{round}]] // { arity: 4 } Project (#0..=#3) // { arity: 4 } - Filter (#4 <= 21) AND (#1) IS NOT NULL AND (#4 > #3) // { arity: 5 } + Filter (#4 <= 21) AND (#1{line_no}) IS NOT NULL AND (#4 > #3{round}) // { arity: 5 } Get l0 // { arity: 5 } - ArrangeBy keys=[[#1..=#3]] // { arity: 4 } - Filter (#2 <= 21) AND (#1) IS NOT NULL AND (#2 > #3) // { arity: 4 } + ArrangeBy keys=[[#1{line_no}..=#3{round}]] // { arity: 4 } + Filter (#2{col_no} <= 21) AND (#1{line_no}) IS NOT NULL AND (#2{col_no} > #3{round}) // { arity: 4 } Get l3 // { arity: 4 } cte l2 = Distinct project=[#0..=#2] // { arity: 3 } @@ -88,60 +88,60 @@ Explained Query: Distinct project=[#0..=#3] // { arity: 4 } Union // { arity: 4 } Project (#3, #0, #2, #4) // { arity: 4 } - Map (text_to_integer(array_index(regexp_split_to_array[" ", case_insensitive=false](#1), integer_to_bigint(#2))), 1) // { arity: 5 } - FlatMap generate_series(1, (regexp_split_to_array[" ", case_insensitive=false](#1) array_length 1), 1) // { arity: 3 } + Map (text_to_integer(array_index(regexp_split_to_array[" ", case_insensitive=false](#1{line}), integer_to_bigint(#2{j}))), 1) // { arity: 5 } + FlatMap generate_series(1, (regexp_split_to_array[" ", case_insensitive=false](#1{line}) array_length 1), 1) // { arity: 3 } Project (#1, #2) // { arity: 2 } - Map (array_index(regexp_split_to_array["\n", case_insensitive=false](#0{input}), integer_to_bigint(#1))) // { arity: 3 } + Map (array_index(regexp_split_to_array["\n", case_insensitive=false](#0{input}), integer_to_bigint(#1{i}))) // { arity: 3 } FlatMap generate_series(1, (regexp_split_to_array["\n", case_insensitive=false](#0{input}) array_length 1), 1) // { arity: 2 } ReadStorage materialize.public.input // { arity: 1 } Project (#8..=#11) // { arity: 4 } - Map ((coalesce(#4, 0) - coalesce(#0, 0)), coalesce(#1, #5), coalesce((#2 + 1), #6), (coalesce(#3, #7) + 1)) // { arity: 12 } + Map ((coalesce(#4{value}, 0) - coalesce(#0{value}, 0)), coalesce(#1{line_no}, #5{line_no}), coalesce((#2{col_no} + 1), #6{col_no}), (coalesce(#3{round}, #7{round}) + 1)) // { arity: 12 } Union // { arity: 8 } Project (#4..=#7, #0..=#3) // { arity: 8 } Map (null, null, null, null) // { arity: 8 } Union // { arity: 4 } Negate // { arity: 4 } Project (#0..=#3) // { arity: 4 } - Join on=(#1 = #4 AND #2 = #6 AND #3 = #5) type=differential // { arity: 7 } + Join on=(#1{line_no} = #4 AND #2{col_no} = #6 AND #3{round} = #5) type=differential // { arity: 7 } implementation - %1:l2[#0, #2, #1]UKKK » %0:l3[#1..=#3]KKKif - ArrangeBy keys=[[#1..=#3]] // { arity: 4 } - Filter (#2 <= 21) AND (#1) IS NOT NULL AND (#2 > #3) AND (0 != (coalesce(#0, 0) - 0)) // { arity: 4 } + %1:l2[#0, #2, #1]UKKK » %0:l3[#1{line_no}..=#3{round}]KKKif + ArrangeBy keys=[[#1{line_no}..=#3{round}]] // { arity: 4 } + Filter (#2{col_no} <= 21) AND (#1{line_no}) IS NOT NULL AND (#2{col_no} > #3{round}) AND (0 != (coalesce(#0{value}, 0) - 0)) // { arity: 4 } Get l3 // { arity: 4 } ArrangeBy keys=[[#0, #2, #1]] // { arity: 3 } Get l2 // { arity: 3 } - Filter (#2 <= 21) AND (#2 > #3) AND (0 != (coalesce(#0, 0) - 0)) // { arity: 4 } + Filter (#2{col_no} <= 21) AND (#2{col_no} > #3{round}) AND (0 != (coalesce(#0{value}, 0) - 0)) // { arity: 4 } Get l3 // { arity: 4 } Map (null, null, null, null) // { arity: 8 } Union // { arity: 4 } Negate // { arity: 4 } Project (#0..=#3) // { arity: 4 } - Join on=(#1 = #4 AND #3 = #5 AND #6 = (#2 + 1)) type=differential // { arity: 7 } + Join on=(#1{line_no} = #4 AND #3{round} = #5 AND #6 = (#2{col_no} + 1)) type=differential // { arity: 7 } implementation - %1:l2[#0..=#2]UKKK » %0:l0[#1, #3, (#2 + 1)]KKKif - ArrangeBy keys=[[#1, #3, (#2 + 1)]] // { arity: 4 } + %1:l2[#0..=#2]UKKK » %0:l0[#1{line_no}, #3{round}, (#2{col_no} + 1)]KKKif + ArrangeBy keys=[[#1{line_no}, #3{round}, (#2{col_no} + 1)]] // { arity: 4 } Project (#0..=#3) // { arity: 4 } - Filter (#4 <= 21) AND (#1) IS NOT NULL AND (#4 > #3) AND (0 != (0 - coalesce(#0, 0))) // { arity: 5 } + Filter (#4 <= 21) AND (#1{line_no}) IS NOT NULL AND (#4 > #3{round}) AND (0 != (0 - coalesce(#0{value}, 0))) // { arity: 5 } Get l0 // { arity: 5 } ArrangeBy keys=[[#0..=#2]] // { arity: 3 } Get l2 // { arity: 3 } Project (#0..=#3) // { arity: 4 } - Filter (#4 <= 21) AND (#4 > #3) AND (0 != (0 - coalesce(#0, 0))) // { arity: 5 } + Filter (#4 <= 21) AND (#4 > #3{round}) AND (0 != (0 - coalesce(#0{value}, 0))) // { arity: 5 } Get l0 // { arity: 5 } Project (#0..=#4, #1, #5, #3) // { arity: 8 } - Filter (0 != (coalesce(#4, 0) - coalesce(#0, 0))) // { arity: 6 } + Filter (0 != (coalesce(#4{value}, 0) - coalesce(#0{value}, 0))) // { arity: 6 } Get l1 // { arity: 6 } Return // { arity: 2 } With cte l4 = - Reduce aggregates=[sum(#0)] // { arity: 1 } + Reduce aggregates=[sum(#0{value})] // { arity: 1 } Project (#0) // { arity: 1 } - Filter (#2 = 21) // { arity: 4 } + Filter (#2{col_no} = 21) // { arity: 4 } Get l3 // { arity: 4 } cte l5 = - Reduce aggregates=[sum((power(-1, integer_to_double((#1 + 1))) * integer_to_double(#0)))] // { arity: 1 } + Reduce aggregates=[sum((power(-1, integer_to_double((#1{col_no} + 1))) * integer_to_double(#0{value})))] // { arity: 1 } Project (#0, #2) // { arity: 2 } - Filter (#2 = #3) // { arity: 4 } + Filter (#2{col_no} = #3{round}) // { arity: 4 } Get l3 // { arity: 4 } Return // { arity: 2 } CrossJoin type=differential // { arity: 2 } diff --git a/test/sqllogictest/advent-of-code/2023/aoc_1210.slt b/test/sqllogictest/advent-of-code/2023/aoc_1210.slt index e1c522c4bfa20..a95a34d45aa6c 100644 --- a/test/sqllogictest/advent-of-code/2023/aoc_1210.slt +++ b/test/sqllogictest/advent-of-code/2023/aoc_1210.slt @@ -374,19 +374,19 @@ Explained Query: With cte l0 = Project (#0, #2, #3) // { arity: 3 } - Map (substr(#1, #2, 1)) // { arity: 4 } - FlatMap generate_series(1, char_length(#1), 1) // { arity: 3 } + Map (substr(#1{line}, #2{j}, 1)) // { arity: 4 } + FlatMap generate_series(1, char_length(#1{line}), 1) // { arity: 3 } Project (#1, #2) // { arity: 2 } - Map (array_index(regexp_split_to_array["\n", case_insensitive=false](#0{input}), integer_to_bigint(#1))) // { arity: 3 } + Map (array_index(regexp_split_to_array["\n", case_insensitive=false](#0{input}), integer_to_bigint(#1{i}))) // { arity: 3 } FlatMap generate_series(1, (regexp_split_to_array["\n", case_insensitive=false](#0{input}) array_length 1), 1) // { arity: 2 } ReadStorage materialize.public.input // { arity: 1 } cte l1 = Project (#0..=#2, #4, #5) // { arity: 5 } - Map ((#2 = "-"), case when #3 then #0 else case when (#2 = "|") then (#0 - 1) else case when (#2 = "F") then (#0 + 1) else case when (#2 = "L") then (#0 - 1) else case when (#2 = "J") then #0 else case when (#2 = "7") then #0 else null end end end end end end, case when #3 then (#1 - 1) else case when (#2 = "|") then #1 else case when (#2 = "F") then #1 else case when (#2 = "L") then #1 else case when (#2 = "J") then (#1 - 1) else case when (#2 = "7") then (#1 - 1) else null end end end end end end) // { arity: 6 } + Map ((#2{symb} = "-"), case when #3 then #0{row_no} else case when (#2{symb} = "|") then (#0{row_no} - 1) else case when (#2{symb} = "F") then (#0{row_no} + 1) else case when (#2{symb} = "L") then (#0{row_no} - 1) else case when (#2{symb} = "J") then #0{row_no} else case when (#2{symb} = "7") then #0{row_no} else null end end end end end end, case when #3 then (#1{col_no} - 1) else case when (#2{symb} = "|") then #1{col_no} else case when (#2{symb} = "F") then #1{col_no} else case when (#2{symb} = "L") then #1{col_no} else case when (#2{symb} = "J") then (#1{col_no} - 1) else case when (#2{symb} = "7") then (#1{col_no} - 1) else null end end end end end end) // { arity: 6 } Get l0 // { arity: 3 } cte l2 = Project (#0..=#2, #4, #5) // { arity: 5 } - Map ((#2 = "-"), case when #3 then #0 else case when (#2 = "|") then (#0 + 1) else case when (#2 = "F") then #0 else case when (#2 = "L") then #0 else case when (#2 = "J") then (#0 - 1) else case when (#2 = "7") then (#0 + 1) else null end end end end end end, case when #3 then (#1 + 1) else case when (#2 = "|") then #1 else case when (#2 = "F") then (#1 + 1) else case when (#2 = "L") then (#1 + 1) else case when (#2 = "J") then #1 else case when (#2 = "7") then #1 else null end end end end end end) // { arity: 6 } + Map ((#2{symb} = "-"), case when #3 then #0{row_no} else case when (#2{symb} = "|") then (#0{row_no} + 1) else case when (#2{symb} = "F") then #0{row_no} else case when (#2{symb} = "L") then #0{row_no} else case when (#2{symb} = "J") then (#0{row_no} - 1) else case when (#2{symb} = "7") then (#0{row_no} + 1) else null end end end end end end, case when #3 then (#1{col_no} + 1) else case when (#2{symb} = "|") then #1{col_no} else case when (#2{symb} = "F") then (#1{col_no} + 1) else case when (#2{symb} = "L") then (#1{col_no} + 1) else case when (#2{symb} = "J") then #1{col_no} else case when (#2{symb} = "7") then #1{col_no} else null end end end end end end) // { arity: 6 } Get l0 // { arity: 3 } cte l3 = Project (#0..=#3) // { arity: 4 } @@ -394,39 +394,39 @@ Explained Query: Reduce group_by=[#0..=#3] aggregates=[count(*)] // { arity: 5 } Union // { arity: 4 } Project (#0, #1, #3, #4) // { arity: 4 } - Filter (#2 != ".") AND (#2 != "S") // { arity: 5 } + Filter (#2{symb} != ".") AND (#2{symb} != "S") // { arity: 5 } Get l1 // { arity: 5 } Project (#0, #1, #3, #4) // { arity: 4 } - Filter (#2 != ".") AND (#2 != "S") // { arity: 5 } + Filter (#2{symb} != ".") AND (#2{symb} != "S") // { arity: 5 } Get l2 // { arity: 5 } Project (#3, #4, #0, #1) // { arity: 4 } - Filter (#2 != ".") AND (#2 != "S") AND (#3) IS NOT NULL AND (#4) IS NOT NULL // { arity: 5 } + Filter (#2{symb} != ".") AND (#2{symb} != "S") AND (#3) IS NOT NULL AND (#4) IS NOT NULL // { arity: 5 } Get l1 // { arity: 5 } Project (#3, #4, #0, #1) // { arity: 4 } - Filter (#2 != ".") AND (#2 != "S") AND (#3) IS NOT NULL AND (#4) IS NOT NULL // { arity: 5 } + Filter (#2{symb} != ".") AND (#2{symb} != "S") AND (#3) IS NOT NULL AND (#4) IS NOT NULL // { arity: 5 } Get l2 // { arity: 5 } Project (#0, #1, #3, #1) // { arity: 4 } - Filter (#2 = "S") // { arity: 4 } - Map ((#0 + 1)) // { arity: 4 } + Filter (#2{symb} = "S") // { arity: 4 } + Map ((#0{row_no} + 1)) // { arity: 4 } Get l0 // { arity: 3 } Project (#0, #1, #0, #3) // { arity: 4 } - Filter (#2 = "S") // { arity: 4 } - Map ((#1 + 1)) // { arity: 4 } + Filter (#2{symb} = "S") // { arity: 4 } + Map ((#1{col_no} + 1)) // { arity: 4 } Get l0 // { arity: 3 } Project (#0, #1, #3, #1) // { arity: 4 } - Filter (#2 = "S") // { arity: 4 } - Map ((#0 - 1)) // { arity: 4 } + Filter (#2{symb} = "S") // { arity: 4 } + Map ((#0{row_no} - 1)) // { arity: 4 } Get l0 // { arity: 3 } Project (#0, #1, #0, #3) // { arity: 4 } - Filter (#2 = "S") // { arity: 4 } - Map ((#1 - 1)) // { arity: 4 } + Filter (#2{symb} = "S") // { arity: 4 } + Map ((#1{col_no} - 1)) // { arity: 4 } Get l0 // { arity: 3 } cte l4 = Project (#0, #1) // { arity: 2 } - Filter (#2 = "S") // { arity: 3 } + Filter (#2{symb} = "S") // { arity: 3 } Get l0 // { arity: 3 } cte l5 = - ArrangeBy keys=[[#0, #1]] // { arity: 4 } + ArrangeBy keys=[[#0{r1}, #1{c1}]] // { arity: 4 } Get l3 // { arity: 4 } Return // { arity: 2 } With Mutually Recursive @@ -435,11 +435,11 @@ Explained Query: Union // { arity: 2 } Get l4 // { arity: 2 } Project (#4, #5) // { arity: 2 } - Join on=(#0 = #2 AND #1 = #3) type=differential // { arity: 6 } + Join on=(#0{r} = #2{r1} AND #1{c} = #3{c1}) type=differential // { arity: 6 } implementation - %0:l6[#0, #1]UKK » %1:l5[#0, #1]KK - ArrangeBy keys=[[#0, #1]] // { arity: 2 } - Filter (#0) IS NOT NULL AND (#1) IS NOT NULL // { arity: 2 } + %0:l6[#0{r}, #1{c}]UKK » %1:l5[#0{r1}, #1{c1}]KK + ArrangeBy keys=[[#0{r}, #1{c}]] // { arity: 2 } + Filter (#0{r}) IS NOT NULL AND (#1{c}) IS NOT NULL // { arity: 2 } Get l6 // { arity: 2 } Get l5 // { arity: 4 } cte l7 = @@ -450,54 +450,54 @@ Explained Query: Distinct project=[#0..=#2] // { arity: 3 } Union // { arity: 3 } Project (#0, #1, #4) // { arity: 3 } - Join on=(#0 = #2 AND #1 = #3) type=differential // { arity: 5 } + Join on=(#0{r} = #2{row_no} AND #1{c} = #3{col_no}) type=differential // { arity: 5 } implementation - %0:l6[#0, #1]UKK » %1:l0[#0, #1]KKf - ArrangeBy keys=[[#0, #1]] // { arity: 2 } - Filter (#0) IS NOT NULL AND (#1) IS NOT NULL // { arity: 2 } + %0:l6[#0{r}, #1{c}]UKK » %1:l0[#0{row_no}, #1{col_no}]KKf + ArrangeBy keys=[[#0{r}, #1{c}]] // { arity: 2 } + Filter (#0{r}) IS NOT NULL AND (#1{c}) IS NOT NULL // { arity: 2 } Get l6 // { arity: 2 } - ArrangeBy keys=[[#0, #1]] // { arity: 3 } - Filter (#2 != "S") // { arity: 3 } + ArrangeBy keys=[[#0{row_no}, #1{col_no}]] // { arity: 3 } + Filter (#2{symb} != "S") // { arity: 3 } Get l0 // { arity: 3 } Project (#0, #1, #8) // { arity: 3 } - Map (case when ((#0 = #0) AND (#0 = (#6 + 1)) AND (#1 = #7) AND (#1 = (#1 + 1))) then "J" else case when ((#0 = #0) AND (#0 = #6) AND (#1 = (#1 + 1)) AND (#1 = (#7 - 1))) then "-" else case when ((#0 = #0) AND (#0 = (#6 - 1)) AND (#1 = #7) AND (#1 = (#1 + 1))) then "7" else case when ((#0 = #6) AND (#0 = (#0 + 1)) AND (#1 = #1) AND (#1 = (#7 - 1))) then "L" else case when ((#0 = (#0 + 1)) AND (#0 = (#6 - 1)) AND (#1 = #1) AND (#1 = #7)) then "|" else case when ((#0 = #0) AND (#0 = #6) AND (#1 = (#1 - 1)) AND (#1 = (#7 - 1))) then "F" else "???" end end end end end end) // { arity: 9 } - Join on=(#0 = #2 = #4 AND #1 = #3 = #5) type=delta // { arity: 8 } + Map (case when ((#0{row_no} = #0{r1}) AND (#0{row_no} = (#6{r2} + 1)) AND (#1{col_no} = #7{c2}) AND (#1{col_no} = (#1{c1} + 1))) then "J" else case when ((#0{row_no} = #0{r1}) AND (#0{row_no} = #6{r2}) AND (#1{col_no} = (#1{c1} + 1)) AND (#1{col_no} = (#7{c2} - 1))) then "-" else case when ((#0{row_no} = #0{r1}) AND (#0{row_no} = (#6{r2} - 1)) AND (#1{col_no} = #7{c2}) AND (#1{col_no} = (#1{c1} + 1))) then "7" else case when ((#0{row_no} = #6{r2}) AND (#0{row_no} = (#0{r1} + 1)) AND (#1{col_no} = #1{c1}) AND (#1{col_no} = (#7{c2} - 1))) then "L" else case when ((#0{row_no} = (#0{r1} + 1)) AND (#0{row_no} = (#6{r2} - 1)) AND (#1{col_no} = #1{c1}) AND (#1{col_no} = #7{c2})) then "|" else case when ((#0{row_no} = #0{r1}) AND (#0{row_no} = #6{r2}) AND (#1{col_no} = (#1{c1} - 1)) AND (#1{col_no} = (#7{c2} - 1))) then "F" else "???" end end end end end end) // { arity: 9 } + Join on=(#0{row_no} = #2{r1} = #4{r1} AND #1{col_no} = #3{c1} = #5{c1}) type=delta // { arity: 8 } implementation - %0:l4 » %1:l3[#0, #1]KK » %2:l5[#0, #1]KK - %1:l3 » %0:l4[#0, #1]KKef » %2:l5[#0, #1]KK - %2:l5 » %0:l4[#0, #1]KKef » %1:l3[#0, #1]KK - ArrangeBy keys=[[#0, #1]] // { arity: 2 } + %0:l4 » %1:l3[#0{r1}, #1{c1}]KK » %2:l5[#0{r1}, #1{c1}]KK + %1:l3 » %0:l4[#0{row_no}, #1{col_no}]KKef » %2:l5[#0{r1}, #1{c1}]KK + %2:l5 » %0:l4[#0{row_no}, #1{col_no}]KKef » %1:l3[#0{r1}, #1{c1}]KK + ArrangeBy keys=[[#0{row_no}, #1{col_no}]] // { arity: 2 } Get l4 // { arity: 2 } - ArrangeBy keys=[[#0, #1]] // { arity: 2 } + ArrangeBy keys=[[#0{r1}, #1{c1}]] // { arity: 2 } Project (#0, #1) // { arity: 2 } Get l3 // { arity: 4 } Get l5 // { arity: 4 } cte l9 = - ArrangeBy keys=[[#0, #1]] // { arity: 3 } + ArrangeBy keys=[[#0{r}, #1{c}]] // { arity: 3 } Get l17 // { arity: 3 } cte l10 = Project (#0..=#2, #5) // { arity: 4 } - Join on=(#0 = #3 AND #1 = #4) type=differential // { arity: 6 } + Join on=(#0{r} = #3{r} AND #1{c} = #4{c}) type=differential // { arity: 6 } implementation - %0:l9[#0, #1]KK » %1:l8[#0, #1]KK + %0:l9[#0{r}, #1{c}]KK » %1:l8[#0{r}, #1{c}]KK Get l9 // { arity: 3 } - ArrangeBy keys=[[#0, #1]] // { arity: 3 } + ArrangeBy keys=[[#0{r}, #1{c}]] // { arity: 3 } Get l8 // { arity: 3 } cte l11 = Project (#2, #3, #6, #7) // { arity: 4 } - Map ((#0 + 1), (#1 + 1)) // { arity: 8 } - Join on=(#0 = #4 AND #1 = #5) type=differential // { arity: 6 } + Map ((#0{r} + 1), (#1{c} + 1)) // { arity: 8 } + Join on=(#0{r} = #4{row_no} AND #1{c} = #5{col_no}) type=differential // { arity: 6 } implementation - %0[#0, #1]KK » %1:l0[#0, #1]KK - ArrangeBy keys=[[#0, #1]] // { arity: 4 } + %0[#0{r}, #1{c}]KK » %1:l0[#0{row_no}, #1{col_no}]KK + ArrangeBy keys=[[#0{r}, #1{c}]] // { arity: 4 } Union // { arity: 4 } Map (null) // { arity: 4 } Union // { arity: 3 } Negate // { arity: 3 } Project (#0..=#2) // { arity: 3 } - Join on=(#0 = #3 AND #1 = #4) type=differential // { arity: 5 } + Join on=(#0{r} = #3 AND #1{c} = #4) type=differential // { arity: 5 } implementation - %1[#0, #1]UKKA » %0:l9[#0, #1]KK + %1[#0, #1]UKKA » %0:l9[#0{r}, #1{c}]KK Get l9 // { arity: 3 } ArrangeBy keys=[[#0, #1]] // { arity: 2 } Distinct project=[#0, #1] // { arity: 2 } @@ -505,7 +505,7 @@ Explained Query: Get l10 // { arity: 4 } Get l17 // { arity: 3 } Get l10 // { arity: 4 } - ArrangeBy keys=[[#0, #1]] // { arity: 2 } + ArrangeBy keys=[[#0{row_no}, #1{col_no}]] // { arity: 2 } Project (#0, #1) // { arity: 2 } Get l0 // { arity: 3 } cte l12 = @@ -513,7 +513,7 @@ Explained Query: Project (#1) // { arity: 1 } Get l11 // { arity: 4 } cte l13 = - Reduce group_by=[#0] aggregates=[any((#0 = #1))] // { arity: 2 } + Reduce group_by=[#0] aggregates=[any((#0{symb} = #1{right_col0_0}))] // { arity: 2 } FlatMap wrap1("J", "-", "|", "F") // { arity: 2 } Get l12 // { arity: 1 } cte l14 = @@ -547,11 +547,11 @@ Explained Query: Distinct project=[#0..=#2] // { arity: 3 } Union // { arity: 3 } Project (#0, #1, #3) // { arity: 3 } - Filter ((#0 = 1) OR (#1 = 1)) // { arity: 4 } + Filter ((#0{row_no} = 1) OR (#1{col_no} = 1)) // { arity: 4 } Map (false) // { arity: 4 } Get l0 // { arity: 3 } Project (#2, #3, #6) // { arity: 3 } - Map (case when #5{any} then NOT(#0) else #0 end) // { arity: 7 } + Map (case when #5{any} then NOT(#0{encl}) else #0{encl} end) // { arity: 7 } Join on=(#1 = #4) type=differential // { arity: 6 } implementation %0:l11[#1]K » %1[#0]K @@ -577,20 +577,20 @@ Explained Query: With cte l18 = Project (#0, #1) // { arity: 2 } - Filter (#2 = true) // { arity: 3 } + Filter (#2{encl} = true) // { arity: 3 } Get l17 // { arity: 3 } cte l19 = Reduce aggregates=[count(*)] // { arity: 1 } Union // { arity: 0 } Negate // { arity: 0 } Project () // { arity: 0 } - Join on=(#0 = #2 AND #1 = #3) type=differential // { arity: 4 } + Join on=(#0 = #2{right_col0_2} AND #1 = #3{right_col1_3}) type=differential // { arity: 4 } implementation %1[#0, #1]UKKA » %0:l18[#0, #1]UKKef ArrangeBy keys=[[#0, #1]] // { arity: 2 } Get l18 // { arity: 2 } - ArrangeBy keys=[[#0, #1]] // { arity: 2 } - Distinct project=[#0, #1] // { arity: 2 } + ArrangeBy keys=[[#0{right_col0_2}, #1{right_col1_3}]] // { arity: 2 } + Distinct project=[#0{right_col0_2}, #1{right_col1_3}] // { arity: 2 } Project (#0, #1) // { arity: 2 } Get l8 // { arity: 3 } Project () // { arity: 0 } diff --git a/test/sqllogictest/advent-of-code/2023/aoc_1211.slt b/test/sqllogictest/advent-of-code/2023/aoc_1211.slt index c4e9b3501c58c..60f396dd6f96d 100644 --- a/test/sqllogictest/advent-of-code/2023/aoc_1211.slt +++ b/test/sqllogictest/advent-of-code/2023/aoc_1211.slt @@ -203,15 +203,15 @@ Explained Query: With cte l0 = Project (#0, #2, #3) // { arity: 3 } - Map (substr(#1, #2, 1)) // { arity: 4 } - FlatMap generate_series(1, char_length(#1), 1) // { arity: 3 } + Map (substr(#1{line}, #2{j}, 1)) // { arity: 4 } + FlatMap generate_series(1, char_length(#1{line}), 1) // { arity: 3 } Project (#1, #2) // { arity: 2 } - Map (array_index(regexp_split_to_array["\n", case_insensitive=false](#0{input}), integer_to_bigint(#1))) // { arity: 3 } + Map (array_index(regexp_split_to_array["\n", case_insensitive=false](#0{input}), integer_to_bigint(#1{i}))) // { arity: 3 } FlatMap generate_series(1, (regexp_split_to_array["\n", case_insensitive=false](#0{input}) array_length 1), 1) // { arity: 2 } ReadStorage materialize.public.input // { arity: 1 } cte l1 = Project (#0, #1) // { arity: 2 } - Filter (#2 = "#") // { arity: 3 } + Filter (#2{symb} = "#") // { arity: 3 } Get l0 // { arity: 3 } cte l2 = Distinct project=[#0, #1] // { arity: 2 } @@ -223,7 +223,7 @@ Explained Query: cte l4 = Reduce group_by=[#0] aggregates=[count(*)] // { arity: 2 } Project (#0) // { arity: 1 } - Filter (#1 < #0) // { arity: 2 } + Filter (#1{r} < #0{r}) // { arity: 2 } CrossJoin type=differential // { arity: 2 } implementation %1[×]ef » %0:l3[×]ef @@ -232,7 +232,7 @@ Explained Query: ArrangeBy keys=[[]] // { arity: 1 } Project (#0) // { arity: 1 } Filter (#1{count} = 0) // { arity: 2 } - Reduce group_by=[#0] aggregates=[count((null OR ((#1) IS NOT NULL AND (#1 = "#"))))] // { arity: 2 } + Reduce group_by=[#0] aggregates=[count((null OR ((#1{symb}) IS NOT NULL AND (#1{symb} = "#"))))] // { arity: 2 } Project (#0, #2) // { arity: 2 } Get l0 // { arity: 3 } cte l5 = @@ -251,7 +251,7 @@ Explained Query: cte l7 = Reduce group_by=[#0] aggregates=[count(*)] // { arity: 2 } Project (#0) // { arity: 1 } - Filter (#1 < #0) // { arity: 2 } + Filter (#1{c} < #0{c}) // { arity: 2 } CrossJoin type=differential // { arity: 2 } implementation %1[×]ef » %0:l6[×]ef @@ -260,7 +260,7 @@ Explained Query: ArrangeBy keys=[[]] // { arity: 1 } Project (#0) // { arity: 1 } Filter (#1{count} = 0) // { arity: 2 } - Reduce group_by=[#0] aggregates=[count((null OR ((#1) IS NOT NULL AND (#1 = "#"))))] // { arity: 2 } + Reduce group_by=[#0] aggregates=[count((null OR ((#1{symb}) IS NOT NULL AND (#1{symb} = "#"))))] // { arity: 2 } Project (#1, #2) // { arity: 2 } Get l0 // { arity: 3 } cte l8 = @@ -302,11 +302,11 @@ Explained Query: cte l10 = ArrangeBy keys=[[]] // { arity: 2 } Project (#4, #5) // { arity: 2 } - Map (bigint_to_integer((integer_to_bigint(#0) + #2{count})), bigint_to_integer((integer_to_bigint(#1) + #3{count}))) // { arity: 6 } + Map (bigint_to_integer((integer_to_bigint(#0{r}) + #2{count})), bigint_to_integer((integer_to_bigint(#1{c}) + #3{count}))) // { arity: 6 } Get l9 // { arity: 4 } cte l11 = - Reduce aggregates=[sum((abs((#0 - #2)) + abs((#1 - #3))))] // { arity: 1 } - Filter ((#0 < #2) OR ((#0 = #2) AND (#1 < #3))) // { arity: 4 } + Reduce aggregates=[sum((abs((#0{r} - #2{r})) + abs((#1{c} - #3{c}))))] // { arity: 1 } + Filter ((#0{r} < #2{r}) OR ((#0{r} = #2{r}) AND (#1{c} < #3{c}))) // { arity: 4 } CrossJoin type=differential // { arity: 4 } implementation %0:l10[×] » %1:l10[×] @@ -315,11 +315,11 @@ Explained Query: cte l12 = ArrangeBy keys=[[]] // { arity: 2 } Project (#4, #5) // { arity: 2 } - Map (bigint_to_integer((integer_to_bigint(#0) + (999999 * #2{count}))), bigint_to_integer((integer_to_bigint(#1) + (999999 * #3{count})))) // { arity: 6 } + Map (bigint_to_integer((integer_to_bigint(#0{r}) + (999999 * #2{count}))), bigint_to_integer((integer_to_bigint(#1{c}) + (999999 * #3{count})))) // { arity: 6 } Get l9 // { arity: 4 } cte l13 = - Reduce aggregates=[sum((abs((#0 - #2)) + abs((#1 - #3))))] // { arity: 1 } - Filter ((#0 < #2) OR ((#0 = #2) AND (#1 < #3))) // { arity: 4 } + Reduce aggregates=[sum((abs((#0{r} - #2{r})) + abs((#1{c} - #3{c}))))] // { arity: 1 } + Filter ((#0{r} < #2{r}) OR ((#0{r} = #2{r}) AND (#1{c} < #3{c}))) // { arity: 4 } CrossJoin type=differential // { arity: 4 } implementation %0:l12[×] » %1:l12[×] diff --git a/test/sqllogictest/advent-of-code/2023/aoc_1212.slt b/test/sqllogictest/advent-of-code/2023/aoc_1212.slt index f1e63f53c2038..f5ce84a41383f 100644 --- a/test/sqllogictest/advent-of-code/2023/aoc_1212.slt +++ b/test/sqllogictest/advent-of-code/2023/aoc_1212.slt @@ -95,35 +95,35 @@ Explained Query: With cte l0 = Project (#1, #3, #4) // { arity: 3 } - Map (regexp_split_to_array[" ", case_insensitive=false](array_index(regexp_split_to_array["\n", case_insensitive=false](#0{input}), integer_to_bigint(#1))), (array_index(#2, 1) || "."), array_index(#2, 2)) // { arity: 5 } + Map (regexp_split_to_array[" ", case_insensitive=false](array_index(regexp_split_to_array["\n", case_insensitive=false](#0{input}), integer_to_bigint(#1{row_id}))), (array_index(#2, 1) || "."), array_index(#2, 2)) // { arity: 5 } FlatMap generate_series(1, (regexp_split_to_array["\n", case_insensitive=false](#0{input}) array_length 1), 1) // { arity: 2 } ReadStorage materialize.public.input // { arity: 1 } cte l1 = Project (#0, #2, #3) // { arity: 3 } - Map (substr(#1, #2, 1)) // { arity: 4 } - FlatMap generate_series(1, char_length(#1), 1) // { arity: 3 } + Map (substr(#1{characters}, #2{pos}, 1)) // { arity: 4 } + FlatMap generate_series(1, char_length(#1{characters}), 1) // { arity: 3 } Project (#0, #1) // { arity: 2 } Get l0 // { arity: 3 } cte l2 = - ArrangeBy keys=[[#0, #1]] // { arity: 2 } + ArrangeBy keys=[[#0{r}, #1{pos}]] // { arity: 2 } Project (#0, #1) // { arity: 2 } - Filter (#2 != "#") // { arity: 3 } + Filter (#2{symb} != "#") // { arity: 3 } Get l1 // { arity: 3 } Return // { arity: 1 } With Mutually Recursive cte l3 = Project (#0..=#2, #5) // { arity: 4 } - Join on=(#0 = #3 = #6 AND #4 = (#2 + 1) AND #7 = ((#1 + #5) + 1)) type=delta // { arity: 8 } + Join on=(#0{r} = #3{r} = #6{r} AND #4{pos} = (#2{spring} + 1) AND #7{pos} = ((#1{chars} + #5{len}) + 1)) type=delta // { arity: 8 } implementation - %0:l5 » %1[#0, #1]KK » %2:l2[#0, #1]KKf - %1 » %0:l5[#0, (#2 + 1)]KK » %2:l2[#0, #1]KKf - %2:l2 » %0:l5[#0]K » %1[#0, #1]KK - ArrangeBy keys=[[#0], [#0, (#2 + 1)]] // { arity: 3 } + %0:l5 » %1[#0{r}, #1{pos}]KK » %2:l2[#0{r}, #1{pos}]KKf + %1 » %0:l5[#0{r}, (#2{spring} + 1)]KK » %2:l2[#0{r}, #1{pos}]KKf + %2:l2 » %0:l5[#0{r}]K » %1[#0{r}, #1{pos}]KK + ArrangeBy keys=[[#0{r}], [#0{r}, (#2{spring} + 1)]] // { arity: 3 } Get l5 // { arity: 3 } - ArrangeBy keys=[[#0, #1]] // { arity: 3 } + ArrangeBy keys=[[#0{r}, #1{pos}]] // { arity: 3 } Project (#0, #2, #3) // { arity: 3 } - Map (text_to_integer(array_index(regexp_split_to_array[",", case_insensitive=false](#1), integer_to_bigint(#2)))) // { arity: 4 } - FlatMap generate_series(1, (regexp_split_to_array[",", case_insensitive=false](#1) array_length 1), 1) // { arity: 3 } + Map (text_to_integer(array_index(regexp_split_to_array[",", case_insensitive=false](#1{springs}), integer_to_bigint(#2{pos})))) // { arity: 4 } + FlatMap generate_series(1, (regexp_split_to_array[",", case_insensitive=false](#1{springs}) array_length 1), 1) // { arity: 3 } Project (#0, #2) // { arity: 2 } Get l0 // { arity: 3 } Get l2 // { arity: 2 } @@ -137,15 +137,15 @@ Explained Query: Map (0, 0) // { arity: 5 } Get l0 // { arity: 3 } Project (#0, #5, #2) // { arity: 3 } - Map ((#1 + 1)) // { arity: 6 } - Join on=(#0 = #3 AND #4 = (#1 + 1)) type=differential // { arity: 5 } + Map ((#1{chars} + 1)) // { arity: 6 } + Join on=(#0{r} = #3{r} AND #4{pos} = (#1{chars} + 1)) type=differential // { arity: 5 } implementation - %1:l2[#0, #1]KKf » %0:l5[#0, (#1 + 1)]KKf - ArrangeBy keys=[[#0, (#1 + 1)]] // { arity: 3 } + %1:l2[#0{r}, #1{pos}]KKf » %0:l5[#0{r}, (#1{chars} + 1)]KKf + ArrangeBy keys=[[#0{r}, (#1{chars} + 1)]] // { arity: 3 } Get l5 // { arity: 3 } Get l2 // { arity: 2 } Project (#0, #7, #8) // { arity: 3 } - Map (((#1 + #3) + 1), (#2 + 1)) // { arity: 9 } + Map (((#1{chars} + #3{len}) + 1), (#2{spring} + 1)) // { arity: 9 } Join on=(#0 = #4 AND #1 = #5 AND #3 = #6) type=differential // { arity: 7 } implementation %0:l3[#0, #1, #3]KKK » %1[#0..=#2]KKK @@ -156,15 +156,15 @@ Explained Query: Negate // { arity: 3 } Distinct project=[#0..=#2] // { arity: 3 } Project (#0..=#2) // { arity: 3 } - Filter (#4 >= (#1 + 1)) AND (#4 <= (#1 + #2)) // { arity: 5 } - Join on=(#0 = #3) type=differential // { arity: 5 } + Filter (#4{pos} >= (#1{chars} + 1)) AND (#4{pos} <= (#1{chars} + #2{len})) // { arity: 5 } + Join on=(#0{r} = #3{r}) type=differential // { arity: 5 } implementation - %1:l1[#0]Kef » %0:l4[#0]Kef - ArrangeBy keys=[[#0]] // { arity: 3 } + %1:l1[#0{r}]Kef » %0:l4[#0{r}]Kef + ArrangeBy keys=[[#0{r}]] // { arity: 3 } Get l4 // { arity: 3 } - ArrangeBy keys=[[#0]] // { arity: 2 } + ArrangeBy keys=[[#0{r}]] // { arity: 2 } Project (#0, #1) // { arity: 2 } - Filter (#2 = ".") // { arity: 3 } + Filter (#2{symb} = ".") // { arity: 3 } Get l1 // { arity: 3 } Get l4 // { arity: 3 } Return // { arity: 1 } diff --git a/test/sqllogictest/advent-of-code/2023/aoc_1213.slt b/test/sqllogictest/advent-of-code/2023/aoc_1213.slt index a884ac60b98e2..930ccab8f11c3 100644 --- a/test/sqllogictest/advent-of-code/2023/aoc_1213.slt +++ b/test/sqllogictest/advent-of-code/2023/aoc_1213.slt @@ -319,16 +319,16 @@ Explained Query: With cte l0 = Project (#0, #2, #3) // { arity: 3 } - Map (array_index(regexp_split_to_array["\n", case_insensitive=false](#1), integer_to_bigint(#2))) // { arity: 4 } - FlatMap generate_series(1, (regexp_split_to_array["\n", case_insensitive=false](#1) array_length 1), 1) // { arity: 3 } + Map (array_index(regexp_split_to_array["\n", case_insensitive=false](#1{block}), integer_to_bigint(#2{r}))) // { arity: 4 } + FlatMap generate_series(1, (regexp_split_to_array["\n", case_insensitive=false](#1{block}) array_length 1), 1) // { arity: 3 } Project (#1, #2) // { arity: 2 } - Map (array_index(regexp_split_to_array["\n\n", case_insensitive=false](#0{input}), integer_to_bigint(#1))) // { arity: 3 } + Map (array_index(regexp_split_to_array["\n\n", case_insensitive=false](#0{input}), integer_to_bigint(#1{b}))) // { arity: 3 } FlatMap generate_series(1, (regexp_split_to_array["\n\n", case_insensitive=false](#0{input}) array_length 1), 1) // { arity: 2 } ReadStorage materialize.public.input // { arity: 1 } cte l1 = Project (#0, #1, #3, #4) // { arity: 4 } - Map (substr(#2, #3, 1)) // { arity: 5 } - FlatMap generate_series(1, char_length(#2), 1) // { arity: 4 } + Map (substr(#2{line}, #3{c}, 1)) // { arity: 5 } + FlatMap generate_series(1, char_length(#2{line}), 1) // { arity: 4 } Get l0 // { arity: 3 } cte l2 = Distinct project=[#0, #1] // { arity: 2 } @@ -339,23 +339,23 @@ Explained Query: Project (#0, #2) // { arity: 2 } Get l1 // { arity: 4 } cte l4 = - ArrangeBy keys=[[#0]] // { arity: 2 } + ArrangeBy keys=[[#0{b}]] // { arity: 2 } Get l2 // { arity: 2 } cte l5 = - Reduce aggregates=[sum((#0 - 1))] // { arity: 1 } + Reduce aggregates=[sum((#0{r} - 1))] // { arity: 1 } Union // { arity: 1 } Negate // { arity: 1 } Project (#1) // { arity: 1 } Distinct project=[#0, #1] // { arity: 2 } Project (#0, #1) // { arity: 2 } Filter (#3{count} > 1) // { arity: 4 } - Reduce group_by=[#0, #1, abs(((2 * #2) - ((2 * #1) - 1)))] aggregates=[count(distinct #3)] // { arity: 4 } + Reduce group_by=[#0, #1, abs(((2 * #2{r}) - ((2 * #1{r}) - 1)))] aggregates=[count(distinct #3{line})] // { arity: 4 } Project (#0, #1, #3, #4) // { arity: 4 } - Join on=(#0 = #2) type=differential // { arity: 5 } + Join on=(#0{b} = #2{b}) type=differential // { arity: 5 } implementation - %0:l4[#0]K » %1:l0[#0]K + %0:l4[#0{b}]K » %1:l0[#0{b}]K Get l4 // { arity: 2 } - ArrangeBy keys=[[#0]] // { arity: 3 } + ArrangeBy keys=[[#0{b}]] // { arity: 3 } Get l0 // { arity: 3 } Project (#1) // { arity: 1 } Get l2 // { arity: 2 } @@ -370,24 +370,24 @@ Explained Query: Constant // { arity: 0 } - () cte l7 = - ArrangeBy keys=[[#0]] // { arity: 2 } + ArrangeBy keys=[[#0{b}]] // { arity: 2 } Get l3 // { arity: 2 } cte l8 = - Reduce aggregates=[sum((#0 - 1))] // { arity: 1 } + Reduce aggregates=[sum((#0{c} - 1))] // { arity: 1 } Union // { arity: 1 } Negate // { arity: 1 } Project (#1) // { arity: 1 } Distinct project=[#0, #1] // { arity: 2 } Project (#0, #1) // { arity: 2 } Filter (#3{count_string_agg} > 1) // { arity: 4 } - Reduce group_by=[#0, #1, abs(((2 * #2) - ((2 * #1) - 1)))] aggregates=[count(distinct #3{string_agg})] // { arity: 4 } + Reduce group_by=[#0, #1, abs(((2 * #2{c}) - ((2 * #1{c}) - 1)))] aggregates=[count(distinct #3{string_agg})] // { arity: 4 } Project (#0, #1, #3, #4{string_agg}) // { arity: 4 } - Join on=(#0 = #2) type=differential // { arity: 5 } + Join on=(#0{b} = #2{b}) type=differential // { arity: 5 } implementation - %0:l7[#0]K » %1[#0]K + %0:l7[#0{b}]K » %1[#0{b}]K Get l7 // { arity: 2 } - ArrangeBy keys=[[#0]] // { arity: 3 } - Reduce group_by=[#0, #2] aggregates=[string_agg[order_by=[#0 asc nulls_last]](row(row(#3, ""), #1))] // { arity: 3 } + ArrangeBy keys=[[#0{b}]] // { arity: 3 } + Reduce group_by=[#0, #2] aggregates=[string_agg[order_by=[#0 asc nulls_last]](row(row(#3{symbol}, ""), #1{r}))] // { arity: 3 } Get l1 // { arity: 4 } Project (#1) // { arity: 1 } Get l3 // { arity: 2 } @@ -402,21 +402,21 @@ Explained Query: Constant // { arity: 0 } - () cte l10 = - Reduce aggregates=[sum((#0 - 1))] // { arity: 1 } + Reduce aggregates=[sum((#0{r} - 1))] // { arity: 1 } Project (#1) // { arity: 1 } Filter (#2{count} = 1) // { arity: 3 } Reduce group_by=[#0, #1] aggregates=[count(*)] // { arity: 3 } Project (#0, #1) // { arity: 2 } - Filter (#5 != #9) AND (#3 < #7) // { arity: 10 } - Join on=(#0 = #2 = #6 AND #4 = #8 AND abs(((2 * #3) - ((2 * #1) - 1))) = abs(((2 * #7) - ((2 * #1) - 1)))) type=delta // { arity: 10 } + Filter (#5{symbol} != #9{symbol}) AND (#3{r} < #7{r}) // { arity: 10 } + Join on=(#0{b} = #2{b} = #6{b} AND #4{c} = #8{c} AND abs(((2 * #3{r}) - ((2 * #1{r}) - 1))) = abs(((2 * #7{r}) - ((2 * #1{r}) - 1)))) type=delta // { arity: 10 } implementation - %0:l4 » %1:l1[#0]K » %2:l1[#0, #2]KK - %1:l1 » %2:l1[#0, #2]KK » %0:l4[#0]K - %2:l1 » %1:l1[#0, #2]KK » %0:l4[#0]K + %0:l4 » %1:l1[#0{b}]K » %2:l1[#0{b}, #2{c}]KK + %1:l1 » %2:l1[#0{b}, #2{c}]KK » %0:l4[#0{b}]K + %2:l1 » %1:l1[#0{b}, #2{c}]KK » %0:l4[#0{b}]K Get l4 // { arity: 2 } - ArrangeBy keys=[[#0], [#0, #2]] // { arity: 4 } + ArrangeBy keys=[[#0{b}], [#0{b}, #2{c}]] // { arity: 4 } Get l1 // { arity: 4 } - ArrangeBy keys=[[#0, #2]] // { arity: 4 } + ArrangeBy keys=[[#0{b}, #2{c}]] // { arity: 4 } Get l1 // { arity: 4 } cte l11 = Union // { arity: 1 } @@ -429,21 +429,21 @@ Explained Query: Constant // { arity: 0 } - () cte l12 = - Reduce aggregates=[sum((#0 - 1))] // { arity: 1 } + Reduce aggregates=[sum((#0{c} - 1))] // { arity: 1 } Project (#1) // { arity: 1 } Filter (#2{count} = 1) // { arity: 3 } Reduce group_by=[#0, #1] aggregates=[count(*)] // { arity: 3 } Project (#0, #1) // { arity: 2 } - Filter (#5 != #9) AND (#4 < #8) // { arity: 10 } - Join on=(#0 = #2 = #6 AND #3 = #7 AND abs(((2 * #4) - ((2 * #1) - 1))) = abs(((2 * #8) - ((2 * #1) - 1)))) type=delta // { arity: 10 } + Filter (#5{symbol} != #9{symbol}) AND (#4{c} < #8{c}) // { arity: 10 } + Join on=(#0{b} = #2{b} = #6{b} AND #3{r} = #7{r} AND abs(((2 * #4{c}) - ((2 * #1{c}) - 1))) = abs(((2 * #8{c}) - ((2 * #1{c}) - 1)))) type=delta // { arity: 10 } implementation - %0:l7 » %1:l1[#0]K » %2:l1[#0, #1]KK - %1:l1 » %2:l1[#0, #1]KK » %0:l7[#0]K - %2:l1 » %1:l1[#0, #1]KK » %0:l7[#0]K + %0:l7 » %1:l1[#0{b}]K » %2:l1[#0{b}, #1{r}]KK + %1:l1 » %2:l1[#0{b}, #1{r}]KK » %0:l7[#0{b}]K + %2:l1 » %1:l1[#0{b}, #1{r}]KK » %0:l7[#0{b}]K Get l7 // { arity: 2 } - ArrangeBy keys=[[#0], [#0, #1]] // { arity: 4 } + ArrangeBy keys=[[#0{b}], [#0{b}, #1{r}]] // { arity: 4 } Get l1 // { arity: 4 } - ArrangeBy keys=[[#0, #1]] // { arity: 4 } + ArrangeBy keys=[[#0{b}, #1{r}]] // { arity: 4 } Get l1 // { arity: 4 } cte l13 = Union // { arity: 1 } diff --git a/test/sqllogictest/advent-of-code/2023/aoc_1214.slt b/test/sqllogictest/advent-of-code/2023/aoc_1214.slt index ae4bd34c3f074..c9a9c25b58a0e 100644 --- a/test/sqllogictest/advent-of-code/2023/aoc_1214.slt +++ b/test/sqllogictest/advent-of-code/2023/aoc_1214.slt @@ -131,11 +131,11 @@ Explained Query: With cte l0 = Project (#1, #2) // { arity: 2 } - Map (array_index(regexp_split_to_array["\n", case_insensitive=false](#0{input}), integer_to_bigint(#1))) // { arity: 3 } + Map (array_index(regexp_split_to_array["\n", case_insensitive=false](#0{input}), integer_to_bigint(#1{r}))) // { arity: 3 } FlatMap generate_series(1, (regexp_split_to_array["\n", case_insensitive=false](#0{input}) array_length 1), 1) // { arity: 2 } ReadStorage materialize.public.input // { arity: 1 } cte l1 = - Reduce aggregates=[max(#0)] // { arity: 1 } + Reduce aggregates=[max(#0{r})] // { arity: 1 } Project (#0) // { arity: 1 } Get l0 // { arity: 2 } cte l2 = @@ -150,8 +150,8 @@ Explained Query: - () cte l3 = Project (#0, #2, #3) // { arity: 3 } - Map (substr(#1, #2, 1)) // { arity: 4 } - FlatMap generate_series(1, char_length(#1), 1) // { arity: 3 } + Map (substr(#1{line}, #2{c}, 1)) // { arity: 4 } + FlatMap generate_series(1, char_length(#1{line}), 1) // { arity: 3 } Get l0 // { arity: 2 } Return // { arity: 1 } With Mutually Recursive @@ -164,11 +164,11 @@ Explained Query: Union // { arity: 3 } Get l4 // { arity: 3 } Project (#2, #1, #3) // { arity: 3 } - Map ((#0 - 1), "O") // { arity: 4 } + Map ((#0{r} - 1), "O") // { arity: 4 } Get l6 // { arity: 2 } Negate // { arity: 3 } Project (#2, #1, #3) // { arity: 3 } - Map ((#0 - 1), ".") // { arity: 4 } + Map ((#0{r} - 1), ".") // { arity: 4 } Get l6 // { arity: 2 } Map (".") // { arity: 3 } Get l6 // { arity: 2 } @@ -180,21 +180,21 @@ Explained Query: Get l8 // { arity: 3 } cte l5 = Project (#0, #1) // { arity: 2 } - Filter (#2 = "O") // { arity: 3 } + Filter (#2{symbol} = "O") // { arity: 3 } Get l4 // { arity: 3 } cte l6 = Project (#0, #1) // { arity: 2 } - Join on=(#0 = (#2 + 1) AND #1 = #3) type=differential // { arity: 4 } + Join on=(#0{r} = (#2{r} + 1) AND #1{c} = #3{c}) type=differential // { arity: 4 } implementation - %0:l5[#1, #0]KKef » %1:l4[#1, (#0 + 1)]KKef - ArrangeBy keys=[[#1, #0]] // { arity: 2 } + %0:l5[#1{c}, #0{r}]KKef » %1:l4[#1{c}, (#0{r} + 1)]KKef + ArrangeBy keys=[[#1{c}, #0{r}]] // { arity: 2 } Get l5 // { arity: 2 } - ArrangeBy keys=[[#1, (#0 + 1)]] // { arity: 2 } + ArrangeBy keys=[[#1{c}, (#0{r} + 1)]] // { arity: 2 } Project (#0, #1) // { arity: 2 } - Filter (#2 = ".") // { arity: 3 } + Filter (#2{symbol} = ".") // { arity: 3 } Get l4 // { arity: 3 } cte l7 = - Reduce aggregates=[sum(((1 + #1{max}) - #0))] // { arity: 1 } + Reduce aggregates=[sum(((1 + #1{max}) - #0{r}))] // { arity: 1 } CrossJoin type=differential // { arity: 2 } implementation %1[×]U » %0:l5[×]ef @@ -579,11 +579,11 @@ Explained Query: With cte l0 = Project (#1, #2) // { arity: 2 } - Map (array_index(regexp_split_to_array["\n", case_insensitive=false](#0{input}), integer_to_bigint(#1))) // { arity: 3 } + Map (array_index(regexp_split_to_array["\n", case_insensitive=false](#0{input}), integer_to_bigint(#1{r}))) // { arity: 3 } FlatMap generate_series(1, (regexp_split_to_array["\n", case_insensitive=false](#0{input}) array_length 1), 1) // { arity: 2 } ReadStorage materialize.public.input // { arity: 1 } cte l1 = - Reduce aggregates=[max(#0)] // { arity: 1 } + Reduce aggregates=[max(#0{r})] // { arity: 1 } Project (#0) // { arity: 1 } Get l0 // { arity: 2 } cte l2 = @@ -598,8 +598,8 @@ Explained Query: - () cte l3 = Project (#0, #2, #3) // { arity: 3 } - Map (substr(#1, #2, 1)) // { arity: 4 } - FlatMap generate_series(1, char_length(#1), 1) // { arity: 3 } + Map (substr(#1{line}, #2{c}, 1)) // { arity: 4 } + FlatMap generate_series(1, char_length(#1{line}), 1) // { arity: 3 } Get l0 // { arity: 2 } Return // { arity: 1 } With Mutually Recursive @@ -621,11 +621,11 @@ Explained Query: Union // { arity: 3 } Get l5 // { arity: 3 } Project (#2, #1, #3) // { arity: 3 } - Map ((#0 - 1), "O") // { arity: 4 } + Map ((#0{r} - 1), "O") // { arity: 4 } Get l6 // { arity: 2 } Negate // { arity: 3 } Project (#2, #1, #3) // { arity: 3 } - Map ((#0 - 1), ".") // { arity: 4 } + Map ((#0{r} - 1), ".") // { arity: 4 } Get l6 // { arity: 2 } Map (".") // { arity: 3 } Get l6 // { arity: 2 } @@ -637,16 +637,16 @@ Explained Query: Get l7 // { arity: 3 } cte l6 = Project (#0, #1) // { arity: 2 } - Join on=(#0 = (#2 + 1) AND #1 = #3) type=differential // { arity: 4 } + Join on=(#0{r} = (#2{r} + 1) AND #1{c} = #3{c}) type=differential // { arity: 4 } implementation - %0:l5[#1, #0]KKef » %1:l5[#1, (#0 + 1)]KKef - ArrangeBy keys=[[#1, #0]] // { arity: 2 } + %0:l5[#1{c}, #0{r}]KKef » %1:l5[#1{c}, (#0{r} + 1)]KKef + ArrangeBy keys=[[#1{c}, #0{r}]] // { arity: 2 } Project (#0, #1) // { arity: 2 } - Filter (#2 = "O") // { arity: 3 } + Filter (#2{symbol} = "O") // { arity: 3 } Get l5 // { arity: 3 } - ArrangeBy keys=[[#1, (#0 + 1)]] // { arity: 2 } + ArrangeBy keys=[[#1{c}, (#0{r} + 1)]] // { arity: 2 } Project (#0, #1) // { arity: 2 } - Filter (#2 = ".") // { arity: 3 } + Filter (#2{symbol} = ".") // { arity: 3 } Get l5 // { arity: 3 } cte l7 = Get l4 // { arity: 3 } @@ -663,11 +663,11 @@ Explained Query: Union // { arity: 3 } Get l9 // { arity: 3 } Project (#0, #2, #3) // { arity: 3 } - Map ((#1 - 1), "O") // { arity: 4 } + Map ((#1{c} - 1), "O") // { arity: 4 } Get l10 // { arity: 2 } Negate // { arity: 3 } Project (#0, #2, #3) // { arity: 3 } - Map ((#1 - 1), ".") // { arity: 4 } + Map ((#1{c} - 1), ".") // { arity: 4 } Get l10 // { arity: 2 } Map (".") // { arity: 3 } Get l10 // { arity: 2 } @@ -679,16 +679,16 @@ Explained Query: Get l11 // { arity: 3 } cte l10 = Project (#0, #1) // { arity: 2 } - Join on=(#0 = #2 AND #1 = (#3 + 1)) type=differential // { arity: 4 } + Join on=(#0{r} = #2{r} AND #1{c} = (#3{c} + 1)) type=differential // { arity: 4 } implementation - %0:l9[#0, #1]KKef » %1:l9[#0, (#1 + 1)]KKef - ArrangeBy keys=[[#0, #1]] // { arity: 2 } + %0:l9[#0{r}, #1{c}]KKef » %1:l9[#0{r}, (#1{c} + 1)]KKef + ArrangeBy keys=[[#0{r}, #1{c}]] // { arity: 2 } Project (#0, #1) // { arity: 2 } - Filter (#2 = "O") // { arity: 3 } + Filter (#2{symbol} = "O") // { arity: 3 } Get l9 // { arity: 3 } - ArrangeBy keys=[[#0, (#1 + 1)]] // { arity: 2 } + ArrangeBy keys=[[#0{r}, (#1{c} + 1)]] // { arity: 2 } Project (#0, #1) // { arity: 2 } - Filter (#2 = ".") // { arity: 3 } + Filter (#2{symbol} = ".") // { arity: 3 } Get l9 // { arity: 3 } cte l11 = Get l8 // { arity: 3 } @@ -705,11 +705,11 @@ Explained Query: Union // { arity: 3 } Get l13 // { arity: 3 } Project (#2, #1, #3) // { arity: 3 } - Map ((#0 + 1), "O") // { arity: 4 } + Map ((#0{r} + 1), "O") // { arity: 4 } Get l14 // { arity: 2 } Negate // { arity: 3 } Project (#2, #1, #3) // { arity: 3 } - Map ((#0 + 1), ".") // { arity: 4 } + Map ((#0{r} + 1), ".") // { arity: 4 } Get l14 // { arity: 2 } Map (".") // { arity: 3 } Get l14 // { arity: 2 } @@ -721,16 +721,16 @@ Explained Query: Get l15 // { arity: 3 } cte l14 = Project (#0, #1) // { arity: 2 } - Join on=(#0 = (#2 - 1) AND #1 = #3) type=differential // { arity: 4 } + Join on=(#0{r} = (#2{r} - 1) AND #1{c} = #3{c}) type=differential // { arity: 4 } implementation - %0:l13[#1, #0]KKef » %1:l13[#1, (#0 - 1)]KKef - ArrangeBy keys=[[#1, #0]] // { arity: 2 } + %0:l13[#1{c}, #0{r}]KKef » %1:l13[#1{c}, (#0{r} - 1)]KKef + ArrangeBy keys=[[#1{c}, #0{r}]] // { arity: 2 } Project (#0, #1) // { arity: 2 } - Filter (#2 = "O") // { arity: 3 } + Filter (#2{symbol} = "O") // { arity: 3 } Get l13 // { arity: 3 } - ArrangeBy keys=[[#1, (#0 - 1)]] // { arity: 2 } + ArrangeBy keys=[[#1{c}, (#0{r} - 1)]] // { arity: 2 } Project (#0, #1) // { arity: 2 } - Filter (#2 = ".") // { arity: 3 } + Filter (#2{symbol} = ".") // { arity: 3 } Get l13 // { arity: 3 } cte l15 = Get l12 // { arity: 3 } @@ -747,11 +747,11 @@ Explained Query: Union // { arity: 3 } Get l17 // { arity: 3 } Project (#0, #2, #3) // { arity: 3 } - Map ((#1 + 1), "O") // { arity: 4 } + Map ((#1{c} + 1), "O") // { arity: 4 } Get l18 // { arity: 2 } Negate // { arity: 3 } Project (#0, #2, #3) // { arity: 3 } - Map ((#1 + 1), ".") // { arity: 4 } + Map ((#1{c} + 1), ".") // { arity: 4 } Get l18 // { arity: 2 } Map (".") // { arity: 3 } Get l18 // { arity: 2 } @@ -763,29 +763,29 @@ Explained Query: Get l19 // { arity: 3 } cte l18 = Project (#0, #1) // { arity: 2 } - Join on=(#0 = #2 AND #1 = (#3 - 1)) type=differential // { arity: 4 } + Join on=(#0{r} = #2{r} AND #1{c} = (#3{c} - 1)) type=differential // { arity: 4 } implementation - %0:l17[#0, #1]KKef » %1:l17[#0, (#1 - 1)]KKef - ArrangeBy keys=[[#0, #1]] // { arity: 2 } + %0:l17[#0{r}, #1{c}]KKef » %1:l17[#0{r}, (#1{c} - 1)]KKef + ArrangeBy keys=[[#0{r}, #1{c}]] // { arity: 2 } Project (#0, #1) // { arity: 2 } - Filter (#2 = "O") // { arity: 3 } + Filter (#2{symbol} = "O") // { arity: 3 } Get l17 // { arity: 3 } - ArrangeBy keys=[[#0, (#1 - 1)]] // { arity: 2 } + ArrangeBy keys=[[#0{r}, (#1{c} - 1)]] // { arity: 2 } Project (#0, #1) // { arity: 2 } - Filter (#2 = ".") // { arity: 3 } + Filter (#2{symbol} = ".") // { arity: 3 } Get l17 // { arity: 3 } cte l19 = Get l16 // { arity: 3 } Return // { arity: 3 } Get l17 // { arity: 3 } cte l21 = - Reduce aggregates=[sum(((1 + #1{max}) - #0))] // { arity: 1 } + Reduce aggregates=[sum(((1 + #1{max}) - #0{r}))] // { arity: 1 } CrossJoin type=differential // { arity: 2 } implementation %1[×]U » %0:l20[×]ef ArrangeBy keys=[[]] // { arity: 1 } Project (#0) // { arity: 1 } - Filter (#2 = "O") // { arity: 3 } + Filter (#2{symbol} = "O") // { arity: 3 } Get l20 // { arity: 3 } ArrangeBy keys=[[]] // { arity: 1 } Union // { arity: 1 } diff --git a/test/sqllogictest/advent-of-code/2023/aoc_1215.slt b/test/sqllogictest/advent-of-code/2023/aoc_1215.slt index ea69ad2c65cc4..b63b0d393c3b5 100644 --- a/test/sqllogictest/advent-of-code/2023/aoc_1215.slt +++ b/test/sqllogictest/advent-of-code/2023/aoc_1215.slt @@ -201,26 +201,26 @@ Explained Query: With cte l0 = Project (#1, #2) // { arity: 2 } - Map (array_index(regexp_split_to_array[",", case_insensitive=false](#0{input}), integer_to_bigint(#1))) // { arity: 3 } + Map (array_index(regexp_split_to_array[",", case_insensitive=false](#0{input}), integer_to_bigint(#1{r}))) // { arity: 3 } FlatMap generate_series(1, (regexp_split_to_array[",", case_insensitive=false](#0{input}) array_length 1), 1) // { arity: 2 } ReadStorage materialize.public.input // { arity: 1 } cte l1 = Distinct project=[#0] // { arity: 1 } Project (#2) // { arity: 1 } - Map (case when ("-" = substr(#1, char_length(#1))) then substr(#1, 1, (char_length(#1) - 1)) else substr(#1, 1, (char_length(#1) - 2)) end) // { arity: 3 } + Map (case when ("-" = substr(#1{string}, char_length(#1{string}))) then substr(#1{string}, 1, (char_length(#1{string}) - 1)) else substr(#1{string}, 1, (char_length(#1{string}) - 2)) end) // { arity: 3 } Get l0 // { arity: 2 } cte l2 = - Reduce group_by=[#0] aggregates=[max(#1)] // { arity: 2 } + Reduce group_by=[#0] aggregates=[max(#1{r})] // { arity: 2 } Project (#0, #1) // { arity: 2 } - Join on=(#0 = #2) type=differential // { arity: 3 } + Join on=(#0{symb} = #2{symb}) type=differential // { arity: 3 } implementation - %0:l1[#0]UKA » %1:l0[#1]Kef - ArrangeBy keys=[[#0]] // { arity: 1 } + %0:l1[#0{symb}]UKA » %1:l0[#1{symb}]Kef + ArrangeBy keys=[[#0{symb}]] // { arity: 1 } Get l1 // { arity: 1 } - ArrangeBy keys=[[#1]] // { arity: 2 } + ArrangeBy keys=[[#1{symb}]] // { arity: 2 } Project (#0, #3) // { arity: 2 } - Filter (#3) IS NOT NULL AND (0 = case when #2 then 0 else text_to_integer(substr(#1, char_length(#1))) end) // { arity: 4 } - Map (("-" = substr(#1, char_length(#1))), case when #2 then substr(#1, 1, (char_length(#1) - 1)) else substr(#1, 1, (char_length(#1) - 2)) end) // { arity: 4 } + Filter (#3) IS NOT NULL AND (0 = case when #2 then 0 else text_to_integer(substr(#1{string}, char_length(#1{string}))) end) // { arity: 4 } + Map (("-" = substr(#1{string}, char_length(#1{string}))), case when #2 then substr(#1{string}, 1, (char_length(#1{string}) - 1)) else substr(#1{string}, 1, (char_length(#1{string}) - 2)) end) // { arity: 4 } Get l0 // { arity: 2 } cte l3 = Union // { arity: 2 } @@ -233,13 +233,13 @@ Explained Query: Get l1 // { arity: 1 } cte l4 = Project (#0..=#2) // { arity: 3 } - Filter (#0 > coalesce(#4{max}, 0)) // { arity: 5 } + Filter (#0{r} > coalesce(#4{max}, 0)) // { arity: 5 } Join on=(#1 = #3) type=differential // { arity: 5 } implementation %1[#0]UK » %0:l0[#1]K ArrangeBy keys=[[#1]] // { arity: 3 } Project (#0, #3, #4) // { arity: 3 } - Map (("-" = substr(#1, char_length(#1))), case when #2 then substr(#1, 1, (char_length(#1) - 1)) else substr(#1, 1, (char_length(#1) - 2)) end, case when #2 then 0 else text_to_integer(substr(#1, char_length(#1))) end) // { arity: 5 } + Map (("-" = substr(#1{string}, char_length(#1{string}))), case when #2 then substr(#1{string}, 1, (char_length(#1{string}) - 1)) else substr(#1{string}, 1, (char_length(#1{string}) - 2)) end, case when #2 then 0 else text_to_integer(substr(#1{string}, char_length(#1{string}))) end) // { arity: 5 } Get l0 // { arity: 2 } ArrangeBy keys=[[#0]] // { arity: 2 } Union // { arity: 2 } @@ -255,16 +255,16 @@ Explained Query: Project (#1) // { arity: 1 } Get l4 // { arity: 3 } cte l6 = - Reduce group_by=[#0] aggregates=[min(#1)] // { arity: 2 } + Reduce group_by=[#0] aggregates=[min(#1{r})] // { arity: 2 } Project (#0, #1) // { arity: 2 } - Join on=(#0 = #2) type=differential // { arity: 3 } + Join on=(#0{symb} = #2{symb}) type=differential // { arity: 3 } implementation - %0:l5[#0]UKA » %1:l4[#1]K - ArrangeBy keys=[[#0]] // { arity: 1 } + %0:l5[#0{symb}]UKA » %1:l4[#1{symb}]K + ArrangeBy keys=[[#0{symb}]] // { arity: 1 } Get l5 // { arity: 1 } - ArrangeBy keys=[[#1]] // { arity: 2 } + ArrangeBy keys=[[#1{symb}]] // { arity: 2 } Project (#0, #1) // { arity: 2 } - Filter (#1) IS NOT NULL // { arity: 3 } + Filter (#1{symb}) IS NOT NULL // { arity: 3 } Get l4 // { arity: 3 } cte l7 = Union // { arity: 2 } @@ -302,13 +302,13 @@ Explained Query: Map (0) // { arity: 3 } Get l0 // { arity: 2 } Project (#2, #3) // { arity: 2 } - Filter (char_length(#0) > 0) // { arity: 4 } - Map (substr(#0, 2), (((#1 + integer_to_bigint(ascii(substr(#0, 1, 1)))) * 17) % 256)) // { arity: 4 } + Filter (char_length(#0{string}) > 0) // { arity: 4 } + Map (substr(#0{string}, 2), (((#1{hash} + integer_to_bigint(ascii(substr(#0{string}, 1, 1)))) * 17) % 256)) // { arity: 4 } Get l9 // { arity: 2 } cte l10 = - Reduce aggregates=[sum(#0)] // { arity: 1 } + Reduce aggregates=[sum(#0{hash})] // { arity: 1 } Project (#1) // { arity: 1 } - Filter (#0 = "") // { arity: 2 } + Filter (#0{string} = "") // { arity: 2 } Get l9 // { arity: 2 } cte [recursion_limit=10, return_at_limit] l11 = Union // { arity: 3 } @@ -316,21 +316,21 @@ Explained Query: Map (0) // { arity: 5 } Get l8 // { arity: 4 } Project (#0, #3, #4) // { arity: 3 } - Filter (char_length(#1) > 0) // { arity: 5 } - Map (substr(#1, 2), (((#2 + integer_to_bigint(ascii(substr(#1, 1, 1)))) * 17) % 256)) // { arity: 5 } + Filter (char_length(#1{string}) > 0) // { arity: 5 } + Map (substr(#1{string}, 2), (((#2{hash} + integer_to_bigint(ascii(substr(#1{string}, 1, 1)))) * 17) % 256)) // { arity: 5 } Get l11 // { arity: 3 } Return // { arity: 2 } With cte l12 = Project (#1, #3, #4{min}) // { arity: 3 } - Join on=(#0 = #2) type=differential // { arity: 5 } + Join on=(#0{start} = #2{symb}) type=differential // { arity: 5 } implementation - %1:l8[#0]UKf » %0:l11[#0]Kef - ArrangeBy keys=[[#0]] // { arity: 2 } + %1:l8[#0{symb}]UKf » %0:l11[#0{start}]Kef + ArrangeBy keys=[[#0{start}]] // { arity: 2 } Project (#0, #2) // { arity: 2 } - Filter (#1 = "") AND (#0) IS NOT NULL // { arity: 3 } + Filter (#1{string} = "") AND (#0{start}) IS NOT NULL // { arity: 3 } Get l11 // { arity: 3 } - ArrangeBy keys=[[#0]] // { arity: 3 } + ArrangeBy keys=[[#0{symb}]] // { arity: 3 } Project (#0..=#2{min}) // { arity: 3 } Filter NOT(#3) // { arity: 4 } Get l8 // { arity: 4 } @@ -344,12 +344,12 @@ Explained Query: Reduce group_by=[#0, #1{min}] aggregates=[count(*)] // { arity: 3 } Project (#0, #1{min}) // { arity: 2 } Filter (#1{min} >= #3{min}) // { arity: 4 } - Join on=(#0 = #2) type=differential // { arity: 4 } + Join on=(#0{hash} = #2{hash}) type=differential // { arity: 4 } implementation - %0:l14[#0]K » %1:l13[#0]K - ArrangeBy keys=[[#0]] // { arity: 2 } + %0:l14[#0{hash}]K » %1:l13[#0{hash}]K + ArrangeBy keys=[[#0{hash}]] // { arity: 2 } Get l14 // { arity: 2 } - ArrangeBy keys=[[#0]] // { arity: 2 } + ArrangeBy keys=[[#0{hash}]] // { arity: 2 } Get l13 // { arity: 2 } cte l16 = Union // { arity: 3 } @@ -361,7 +361,7 @@ Explained Query: Get l15 // { arity: 3 } Get l14 // { arity: 2 } cte l17 = - Reduce aggregates=[sum((((1 + #0) * #2{count}) * integer_to_bigint(#1)))] // { arity: 1 } + Reduce aggregates=[sum((((1 + #0{hash}) * #2{count}) * integer_to_bigint(#1{op})))] // { arity: 1 } Project (#0, #1, #5{count}) // { arity: 3 } Join on=(#0 = #3 AND #2{min} = #4{min}) type=differential // { arity: 6 } implementation diff --git a/test/sqllogictest/advent-of-code/2023/aoc_1216.slt b/test/sqllogictest/advent-of-code/2023/aoc_1216.slt index c20e6ad53a0ba..18b9b5f2ea2b6 100644 --- a/test/sqllogictest/advent-of-code/2023/aoc_1216.slt +++ b/test/sqllogictest/advent-of-code/2023/aoc_1216.slt @@ -227,17 +227,17 @@ Explained Query: With cte l0 = Project (#0, #2, #3) // { arity: 3 } - Map (substr(#1, #2, 1)) // { arity: 4 } - FlatMap generate_series(1, char_length(#1), 1) // { arity: 3 } + Map (substr(#1{line}, #2{c}, 1)) // { arity: 4 } + FlatMap generate_series(1, char_length(#1{line}), 1) // { arity: 3 } Project (#1, #2) // { arity: 2 } - Map (array_index(regexp_split_to_array["\n", case_insensitive=false](#0{input}), integer_to_bigint(#1))) // { arity: 3 } + Map (array_index(regexp_split_to_array["\n", case_insensitive=false](#0{input}), integer_to_bigint(#1{r}))) // { arity: 3 } FlatMap generate_series(1, (regexp_split_to_array["\n", case_insensitive=false](#0{input}) array_length 1), 1) // { arity: 2 } ReadStorage materialize.public.input // { arity: 1 } cte l1 = Project (#1) // { arity: 1 } Get l0 // { arity: 3 } cte l2 = - Reduce aggregates=[min(#0)] // { arity: 1 } + Reduce aggregates=[min(#0{c})] // { arity: 1 } Get l1 // { arity: 1 } cte l3 = Union // { arity: 1 } @@ -250,7 +250,7 @@ Explained Query: Constant // { arity: 0 } - () cte l4 = - Reduce aggregates=[max(#0)] // { arity: 1 } + Reduce aggregates=[max(#0{c})] // { arity: 1 } Get l1 // { arity: 1 } cte l5 = Union // { arity: 1 } @@ -266,7 +266,7 @@ Explained Query: Project (#0) // { arity: 1 } Get l0 // { arity: 3 } cte l7 = - Reduce aggregates=[min(#0)] // { arity: 1 } + Reduce aggregates=[min(#0{r})] // { arity: 1 } Get l6 // { arity: 1 } cte l8 = Union // { arity: 1 } @@ -298,11 +298,11 @@ Explained Query: Constant // { arity: 0 } - () cte l11 = - ArrangeBy keys=[[#0, #1]] // { arity: 3 } - Filter (#2) IS NOT NULL // { arity: 3 } + ArrangeBy keys=[[#0{r}, #1{c}]] // { arity: 3 } + Filter (#2{symbol}) IS NOT NULL // { arity: 3 } Get l0 // { arity: 3 } cte l12 = - ArrangeBy keys=[[#0, #1]] // { arity: 5 } + ArrangeBy keys=[[#0{dir}, #1{symbol}]] // { arity: 5 } Constant // { arity: 5 } total_rows (diffs absed): 24 first_rows: @@ -332,11 +332,11 @@ Explained Query: Distinct project=[#0..=#2] // { arity: 3 } Union // { arity: 3 } Project (#11, #12, #10) // { arity: 3 } - Map ((#0 + #8), (#1 + #9)) // { arity: 13 } - Join on=(#0 = #3 AND #1 = #4 AND #2 = #6 AND #5 = #7) type=differential // { arity: 11 } + Map ((#0{r} + #8{dr}), (#1{c} + #9{dc})) // { arity: 13 } + Join on=(#0{r} = #3{r} AND #1{c} = #4{c} AND #2{dir} = #6{dir} AND #5{symbol} = #7{symbol}) type=differential // { arity: 11 } implementation - %0:l13[#0, #1]KK » %1:l11[#0, #1]KK » %2:l12[#0, #1]KK - ArrangeBy keys=[[#0, #1]] // { arity: 3 } + %0:l13[#0{r}, #1{c}]KK » %1:l11[#0{r}, #1{c}]KK » %2:l12[#0{dir}, #1{symbol}]KK + ArrangeBy keys=[[#0{r}, #1{c}]] // { arity: 3 } Get l13 // { arity: 3 } Get l11 // { arity: 3 } Get l12 // { arity: 5 } @@ -345,21 +345,21 @@ Explained Query: cte l14 = Reduce aggregates=[count(*)] // { arity: 1 } Project () // { arity: 0 } - Join on=(#0 = #2 AND #1 = #3) type=differential // { arity: 4 } + Join on=(#0{r} = #2{r} AND #1{c} = #3{c}) type=differential // { arity: 4 } implementation %0[#0, #1]UKKA » %1[#0, #1]UKKA - ArrangeBy keys=[[#0, #1]] // { arity: 2 } - Distinct project=[#0, #1] // { arity: 2 } + ArrangeBy keys=[[#0{r}, #1{c}]] // { arity: 2 } + Distinct project=[#0{r}, #1{c}] // { arity: 2 } Project (#0, #1) // { arity: 2 } Get l13 // { arity: 3 } - ArrangeBy keys=[[#0, #1]] // { arity: 2 } - Distinct project=[#0, #1] // { arity: 2 } + ArrangeBy keys=[[#0{r}, #1{c}]] // { arity: 2 } + Distinct project=[#0{r}, #1{c}] // { arity: 2 } Get l9 // { arity: 2 } cte l15 = Distinct project=[#0{min}..=#3] // { arity: 4 } Union // { arity: 4 } Project (#0, #1{min}, #3, #2) // { arity: 4 } - Map (("r" || integer_to_text(#0)), "r") // { arity: 4 } + Map (("r" || integer_to_text(#0{r})), "r") // { arity: 4 } CrossJoin type=differential // { arity: 2 } implementation %1[×]U » %0:l6[×] @@ -376,10 +376,10 @@ Explained Query: Constant // { arity: 0 } - () Project (#0, #2{max}, #4, #3) // { arity: 4 } - Map (("l" || integer_to_text(#0)), "l") // { arity: 5 } + Map (("l" || integer_to_text(#0{r})), "l") // { arity: 5 } Get l10 // { arity: 3 } Project (#1{min}, #0, #3, #2) // { arity: 4 } - Map (("d" || integer_to_text(#0)), "d") // { arity: 4 } + Map (("d" || integer_to_text(#0{c})), "d") // { arity: 4 } CrossJoin type=differential // { arity: 2 } implementation %1[×]U » %0:l1[×] @@ -396,13 +396,13 @@ Explained Query: Constant // { arity: 0 } - () Project (#2{max}, #1, #4, #3) // { arity: 4 } - Map (("u" || integer_to_text(#1)), "u") // { arity: 5 } + Map (("u" || integer_to_text(#1{c})), "u") // { arity: 5 } Get l10 // { arity: 3 } Project (#12, #13, #11, #3) // { arity: 4 } - Map ((#0 + #9), (#1 + #10)) // { arity: 14 } - Join on=(#0 = #4 AND #1 = #5 AND #2 = #7 AND #6 = #8) type=differential // { arity: 12 } + Map ((#0{r} + #9{dr}), (#1{c} + #10{dc})) // { arity: 14 } + Join on=(#0{r} = #4{r} AND #1{c} = #5{c} AND #2{dir} = #7{dir} AND #6{symbol} = #8{symbol}) type=differential // { arity: 12 } implementation - %0:l15[#0, #1]KK » %1:l11[#0, #1]KK » %2:l12[#0, #1]KK + %0:l15[#0{r}, #1{c}]KK » %1:l11[#0{r}, #1{c}]KK » %2:l12[#0{dir}, #1{symbol}]KK ArrangeBy keys=[[#0{min}, #1{min}]] // { arity: 4 } Filter (#0{min}) IS NOT NULL AND (#1{min}) IS NOT NULL // { arity: 4 } Get l15 // { arity: 4 } @@ -415,7 +415,7 @@ Explained Query: Project (#1{count}) // { arity: 1 } Reduce group_by=[#0] aggregates=[count(*)] // { arity: 2 } Project (#2) // { arity: 1 } - Join on=(#0{min} = #3 AND #1{min} = #4) type=differential // { arity: 5 } + Join on=(#0{min} = #3{r} AND #1{min} = #4{c}) type=differential // { arity: 5 } implementation %1[#0, #1]UKKA » %0[#0, #1]KK ArrangeBy keys=[[#0{min}, #1{min}]] // { arity: 3 } @@ -423,8 +423,8 @@ Explained Query: Project (#0{min}, #1{min}, #3) // { arity: 3 } Filter (#0{min}) IS NOT NULL AND (#1{min}) IS NOT NULL // { arity: 4 } Get l15 // { arity: 4 } - ArrangeBy keys=[[#0, #1]] // { arity: 2 } - Distinct project=[#0, #1] // { arity: 2 } + ArrangeBy keys=[[#0{r}, #1{c}]] // { arity: 2 } + Distinct project=[#0{r}, #1{c}] // { arity: 2 } Project (#0, #1) // { arity: 2 } Get l0 // { arity: 3 } Return // { arity: 2 } diff --git a/test/sqllogictest/advent-of-code/2023/aoc_1217.slt b/test/sqllogictest/advent-of-code/2023/aoc_1217.slt index 3474a6fb072fd..7b4aa2ffb794a 100644 --- a/test/sqllogictest/advent-of-code/2023/aoc_1217.slt +++ b/test/sqllogictest/advent-of-code/2023/aoc_1217.slt @@ -227,14 +227,14 @@ Explained Query: With cte l0 = Project (#0, #2, #3) // { arity: 3 } - Map (text_to_integer(substr(#1, #2, 1))) // { arity: 4 } - FlatMap generate_series(1, char_length(#1), 1) // { arity: 3 } + Map (text_to_integer(substr(#1{line}, #2{c}, 1))) // { arity: 4 } + FlatMap generate_series(1, char_length(#1{line}), 1) // { arity: 3 } Project (#1, #2) // { arity: 2 } - Map (array_index(regexp_split_to_array["\n", case_insensitive=false](#0{input}), integer_to_bigint(#1))) // { arity: 3 } + Map (array_index(regexp_split_to_array["\n", case_insensitive=false](#0{input}), integer_to_bigint(#1{r}))) // { arity: 3 } FlatMap generate_series(1, (regexp_split_to_array["\n", case_insensitive=false](#0{input}) array_length 1), 1) // { arity: 2 } ReadStorage materialize.public.input // { arity: 1 } cte l1 = - ArrangeBy keys=[[#0, #1]] // { arity: 3 } + ArrangeBy keys=[[#0{r}, #1{c}]] // { arity: 3 } Get l0 // { arity: 3 } Return // { arity: 2 } With Mutually Recursive @@ -242,31 +242,31 @@ Explained Query: Project (#0..=#3, #5{min}) // { arity: 5 } Get l3 // { arity: 6 } cte l3 = - Reduce group_by=[#0..=#4] aggregates=[min(#5)] // { arity: 6 } + Reduce group_by=[#0..=#4] aggregates=[min(#5{cost})] // { arity: 6 } Union // { arity: 6 } Project (#6, #7, #2, #3, #9, #10) // { arity: 6 } - Map ((#4 + 1), (#5 + #8)) // { arity: 11 } - Join on=(#6 = (#0 + #2) AND #7 = (#1 + #3)) type=differential // { arity: 9 } + Map ((#4{steps} + 1), (#5{cost} + #8{cost})) // { arity: 11 } + Join on=(#6{r} = (#0{r} + #2{dr}) AND #7{c} = (#1{c} + #3{dc})) type=differential // { arity: 9 } implementation - %0:l3[(#0 + #2), (#1 + #3)]KKif » %1:l1[#0, #1]KKif - ArrangeBy keys=[[(#0 + #2), (#1 + #3)]] // { arity: 6 } - Filter (#4 < 3) // { arity: 6 } + %0:l3[(#0{r} + #2{dr}), (#1{c} + #3{dc})]KKif » %1:l1[#0{r}, #1{c}]KKif + ArrangeBy keys=[[(#0{r} + #2{dr}), (#1{c} + #3{dc})]] // { arity: 6 } + Filter (#4{steps} < 3) // { arity: 6 } Get l3 // { arity: 6 } Get l1 // { arity: 3 } Project (#5, #6, #3, #2, #9, #8) // { arity: 6 } - Map ((#4 + #7), 1) // { arity: 10 } - Join on=(#5 = (#0 + #3) AND #6 = (#1 + #2)) type=differential // { arity: 8 } + Map ((#4{cost} + #7{cost}), 1) // { arity: 10 } + Join on=(#5{r} = (#0{r} + #3{dc}) AND #6{c} = (#1{c} + #2{dr})) type=differential // { arity: 8 } implementation - %0:l2[(#0 + #3), (#1 + #2)]KK » %1:l1[#0, #1]KK - ArrangeBy keys=[[(#0 + #3), (#1 + #2)]] // { arity: 5 } + %0:l2[(#0{r} + #3{dc}), (#1{c} + #2{dr})]KK » %1:l1[#0{r}, #1{c}]KK + ArrangeBy keys=[[(#0{r} + #3{dc}), (#1{c} + #2{dr})]] // { arity: 5 } Get l2 // { arity: 5 } Get l1 // { arity: 3 } Project (#5, #6, #8, #9, #11, #10) // { arity: 6 } - Map (-(#3), -(#2), (#4 + #7), 1) // { arity: 12 } - Join on=(#5 = (#0 - #3) AND #6 = (#1 - #2)) type=differential // { arity: 8 } + Map (-(#3{dc}), -(#2{dr}), (#4{cost} + #7{cost}), 1) // { arity: 12 } + Join on=(#5{r} = (#0{r} - #3{dc}) AND #6{c} = (#1{c} - #2{dr})) type=differential // { arity: 8 } implementation - %0:l2[(#0 - #3), (#1 - #2)]KK » %1:l1[#0, #1]KK - ArrangeBy keys=[[(#0 - #3), (#1 - #2)]] // { arity: 5 } + %0:l2[(#0{r} - #3{dc}), (#1{c} - #2{dr})]KK » %1:l1[#0{r}, #1{c}]KK + ArrangeBy keys=[[(#0{r} - #3{dc}), (#1{c} - #2{dr})]] // { arity: 5 } Get l2 // { arity: 5 } Get l1 // { arity: 3 } Constant // { arity: 6 } @@ -275,50 +275,50 @@ Explained Query: cte l4 = Reduce aggregates=[min(#0{min})] // { arity: 1 } Project (#2{min}) // { arity: 1 } - Join on=(#0 = #3{max} AND #1 = #4{max}) type=differential // { arity: 5 } + Join on=(#0{r} = #3{max} AND #1{c} = #4{max}) type=differential // { arity: 5 } implementation - %1[×]UA » %2[×]UA » %0:l3[#0, #1]KK - ArrangeBy keys=[[#0, #1]] // { arity: 3 } + %1[×]UA » %2[×]UA » %0:l3[#0{r}, #1{c}]KK + ArrangeBy keys=[[#0{r}, #1{c}]] // { arity: 3 } Project (#0, #1, #5{min}) // { arity: 3 } Get l3 // { arity: 6 } ArrangeBy keys=[[]] // { arity: 1 } - Reduce aggregates=[max(#0)] // { arity: 1 } + Reduce aggregates=[max(#0{r})] // { arity: 1 } Project (#0) // { arity: 1 } Get l0 // { arity: 3 } ArrangeBy keys=[[]] // { arity: 1 } - Reduce aggregates=[max(#0)] // { arity: 1 } + Reduce aggregates=[max(#0{c})] // { arity: 1 } Project (#1) // { arity: 1 } Get l0 // { arity: 3 } cte l5 = Project (#0..=#3, #5{min}) // { arity: 5 } - Filter (#4 >= 4) // { arity: 6 } + Filter (#4{steps} >= 4) // { arity: 6 } Get l6 // { arity: 6 } cte l6 = - Reduce group_by=[#0..=#4] aggregates=[min(#5)] // { arity: 6 } + Reduce group_by=[#0..=#4] aggregates=[min(#5{cost})] // { arity: 6 } Union // { arity: 6 } Project (#6, #7, #2, #3, #9, #10) // { arity: 6 } - Map ((#4 + 1), (#5 + #8)) // { arity: 11 } - Join on=(#6 = (#0 + #2) AND #7 = (#1 + #3)) type=differential // { arity: 9 } + Map ((#4{steps} + 1), (#5{cost} + #8{cost})) // { arity: 11 } + Join on=(#6{r} = (#0{r} + #2{dr}) AND #7{c} = (#1{c} + #3{dc})) type=differential // { arity: 9 } implementation - %0:l6[(#0 + #2), (#1 + #3)]KKif » %1:l1[#0, #1]KKif - ArrangeBy keys=[[(#0 + #2), (#1 + #3)]] // { arity: 6 } - Filter (#4 < 10) // { arity: 6 } + %0:l6[(#0{r} + #2{dr}), (#1{c} + #3{dc})]KKif » %1:l1[#0{r}, #1{c}]KKif + ArrangeBy keys=[[(#0{r} + #2{dr}), (#1{c} + #3{dc})]] // { arity: 6 } + Filter (#4{steps} < 10) // { arity: 6 } Get l6 // { arity: 6 } Get l1 // { arity: 3 } Project (#5, #6, #3, #2, #9, #8) // { arity: 6 } - Map ((#4 + #7), 1) // { arity: 10 } - Join on=(#5 = (#0 + #3) AND #6 = (#1 + #2)) type=differential // { arity: 8 } + Map ((#4{cost} + #7{cost}), 1) // { arity: 10 } + Join on=(#5{r} = (#0{r} + #3{dc}) AND #6{c} = (#1{c} + #2{dr})) type=differential // { arity: 8 } implementation - %0:l5[(#0 + #3), (#1 + #2)]KKif » %1:l1[#0, #1]KKif - ArrangeBy keys=[[(#0 + #3), (#1 + #2)]] // { arity: 5 } + %0:l5[(#0{r} + #3{dc}), (#1{c} + #2{dr})]KKif » %1:l1[#0{r}, #1{c}]KKif + ArrangeBy keys=[[(#0{r} + #3{dc}), (#1{c} + #2{dr})]] // { arity: 5 } Get l5 // { arity: 5 } Get l1 // { arity: 3 } Project (#5, #6, #8, #9, #11, #10) // { arity: 6 } - Map (-(#3), -(#2), (#4 + #7), 1) // { arity: 12 } - Join on=(#5 = (#0 - #3) AND #6 = (#1 - #2)) type=differential // { arity: 8 } + Map (-(#3{dc}), -(#2{dr}), (#4{cost} + #7{cost}), 1) // { arity: 12 } + Join on=(#5{r} = (#0{r} - #3{dc}) AND #6{c} = (#1{c} - #2{dr})) type=differential // { arity: 8 } implementation - %0:l5[(#0 - #3), (#1 - #2)]KKif » %1:l1[#0, #1]KKif - ArrangeBy keys=[[(#0 - #3), (#1 - #2)]] // { arity: 5 } + %0:l5[(#0{r} - #3{dc}), (#1{c} - #2{dr})]KKif » %1:l1[#0{r}, #1{c}]KKif + ArrangeBy keys=[[(#0{r} - #3{dc}), (#1{c} - #2{dr})]] // { arity: 5 } Get l5 // { arity: 5 } Get l1 // { arity: 3 } Constant // { arity: 6 } @@ -329,19 +329,19 @@ Explained Query: cte l7 = Reduce aggregates=[min(#0{min})] // { arity: 1 } Project (#2{min}) // { arity: 1 } - Join on=(#0 = #3{max} AND #1 = #4{max}) type=differential // { arity: 5 } + Join on=(#0{r} = #3{max} AND #1{c} = #4{max}) type=differential // { arity: 5 } implementation - %1[×]UA » %2[×]UA » %0:l6[#0, #1]KKif - ArrangeBy keys=[[#0, #1]] // { arity: 3 } + %1[×]UA » %2[×]UA » %0:l6[#0{r}, #1{c}]KKif + ArrangeBy keys=[[#0{r}, #1{c}]] // { arity: 3 } Project (#0, #1, #5{min}) // { arity: 3 } - Filter (#4 >= 4) // { arity: 6 } + Filter (#4{steps} >= 4) // { arity: 6 } Get l6 // { arity: 6 } ArrangeBy keys=[[]] // { arity: 1 } - Reduce aggregates=[max(#0)] // { arity: 1 } + Reduce aggregates=[max(#0{r})] // { arity: 1 } Project (#0) // { arity: 1 } Get l0 // { arity: 3 } ArrangeBy keys=[[]] // { arity: 1 } - Reduce aggregates=[max(#0)] // { arity: 1 } + Reduce aggregates=[max(#0{c})] // { arity: 1 } Project (#1) // { arity: 1 } Get l0 // { arity: 3 } Return // { arity: 2 } diff --git a/test/sqllogictest/advent-of-code/2023/aoc_1218.slt b/test/sqllogictest/advent-of-code/2023/aoc_1218.slt index e66ec9b89c4e9..bd0ed6e539856 100644 --- a/test/sqllogictest/advent-of-code/2023/aoc_1218.slt +++ b/test/sqllogictest/advent-of-code/2023/aoc_1218.slt @@ -221,13 +221,13 @@ Explained Query: With cte l0 = Project (#1, #2) // { arity: 2 } - Map (array_index(regexp_split_to_array["\n", case_insensitive=false](#0{input}), integer_to_bigint(#1))) // { arity: 3 } + Map (array_index(regexp_split_to_array["\n", case_insensitive=false](#0{input}), integer_to_bigint(#1{r}))) // { arity: 3 } FlatMap generate_series(1, (regexp_split_to_array["\n", case_insensitive=false](#0{input}) array_length 1), 1) // { arity: 2 } ReadStorage materialize.public.input // { arity: 1 } cte l1 = - Reduce aggregates=[sum(#0)] // { arity: 1 } + Reduce aggregates=[sum(#0{steps})] // { arity: 1 } Project (#2) // { arity: 1 } - Map (text_to_integer(array_index(regexp_split_to_array[" ", case_insensitive=false](#1), 2))) // { arity: 3 } + Map (text_to_integer(array_index(regexp_split_to_array[" ", case_insensitive=false](#1{line}), 2))) // { arity: 3 } Get l0 // { arity: 2 } cte l2 = Union // { arity: 1 } @@ -245,21 +245,21 @@ Explained Query: Distinct project=[#0..=#4] // { arity: 5 } Union // { arity: 5 } Project (#0, #1, #7..=#9) // { arity: 5 } - Map ((#0 + (#4 * #6)), (#1 + (#5 * #6)), (#2 + 1)) // { arity: 10 } - Join on=(#2 = #3) type=differential // { arity: 7 } + Map ((#0{r2} + (#4{dr} * #6{steps})), (#1{c2} + (#5{dc} * #6{steps})), (#2{rounds} + 1)) // { arity: 10 } + Join on=(#2{rounds} = #3{r}) type=differential // { arity: 7 } implementation - %0:l3[#2]K » %1:l0[#0]K - ArrangeBy keys=[[#2]] // { arity: 3 } + %0:l3[#2{rounds}]K » %1:l0[#0{r}]K + ArrangeBy keys=[[#2{rounds}]] // { arity: 3 } Project (#2..=#4) // { arity: 3 } Get l3 // { arity: 5 } - ArrangeBy keys=[[#0]] // { arity: 4 } + ArrangeBy keys=[[#0{r}]] // { arity: 4 } Project (#0, #4..=#6) // { arity: 4 } - Map (regexp_split_to_array[" ", case_insensitive=false](#1), array_index(#2, 1), case when (#3 = "U") then -1 else case when ("D" = array_index(regexp_split_to_array[" ", case_insensitive=false](#1), 1)) then 1 else 0 end end, case when (#3 = "L") then -1 else case when ("R" = array_index(regexp_split_to_array[" ", case_insensitive=false](#1), 1)) then 1 else 0 end end, text_to_integer(array_index(#2, 2))) // { arity: 7 } + Map (regexp_split_to_array[" ", case_insensitive=false](#1{line}), array_index(#2, 1), case when (#3 = "U") then -1 else case when ("D" = array_index(regexp_split_to_array[" ", case_insensitive=false](#1{line}), 1)) then 1 else 0 end end, case when (#3 = "L") then -1 else case when ("R" = array_index(regexp_split_to_array[" ", case_insensitive=false](#1{line}), 1)) then 1 else 0 end end, text_to_integer(array_index(#2, 2))) // { arity: 7 } Get l0 // { arity: 2 } Constant // { arity: 5 } - (0, 0, 0, 0, 1) cte l4 = - Reduce aggregates=[sum(((#0 + #2) * (#1 - #3)))] // { arity: 1 } + Reduce aggregates=[sum(((#0{r1} + #2{r2}) * (#1{c1} - #3{c2})))] // { arity: 1 } Project (#0..=#3) // { arity: 4 } Get l3 // { arity: 5 } cte l5 = @@ -276,23 +276,23 @@ Explained Query: Distinct project=[#0..=#4] // { arity: 5 } Union // { arity: 5 } Project (#0, #1, #7..=#9) // { arity: 5 } - Map ((#0 + integer_to_bigint((#4 * #6))), (#1 + integer_to_bigint((#5 * #6))), (#2 + 1)) // { arity: 10 } - Join on=(#2 = #3) type=differential // { arity: 7 } + Map ((#0{r2} + integer_to_bigint((#4{dr} * #6{steps}))), (#1{c2} + integer_to_bigint((#5{dc} * #6{steps}))), (#2{rounds} + 1)) // { arity: 10 } + Join on=(#2{rounds} = #3{r}) type=differential // { arity: 7 } implementation - %0:l6[#2]K » %1:l0[#0]K - ArrangeBy keys=[[#2]] // { arity: 3 } + %0:l6[#2{rounds}]K » %1:l0[#0{r}]K + ArrangeBy keys=[[#2{rounds}]] // { arity: 3 } Project (#2..=#4) // { arity: 3 } Get l6 // { arity: 5 } - ArrangeBy keys=[[#0]] // { arity: 4 } + ArrangeBy keys=[[#0{r}]] // { arity: 4 } Project (#0, #4, #5, #7) // { arity: 4 } - Map (array_index(regexp_split_to_array[" ", case_insensitive=false](#1), 3), substr(#2, 8, 1), case when (#3 = "3") then -1 else case when ("1" = substr(array_index(regexp_split_to_array[" ", case_insensitive=false](#1), 3), 8, 1)) then 1 else 0 end end, case when (#3 = "2") then -1 else case when ("0" = substr(array_index(regexp_split_to_array[" ", case_insensitive=false](#1), 3), 8, 1)) then 1 else 0 end end, decode(("0" || substr(#2, 3, 5)), "hex"), (((65536 * get_byte(#6, 0)) + (256 * get_byte(#6, 1))) + get_byte(#6, 2))) // { arity: 8 } + Map (array_index(regexp_split_to_array[" ", case_insensitive=false](#1{line}), 3), substr(#2, 8, 1), case when (#3 = "3") then -1 else case when ("1" = substr(array_index(regexp_split_to_array[" ", case_insensitive=false](#1{line}), 3), 8, 1)) then 1 else 0 end end, case when (#3 = "2") then -1 else case when ("0" = substr(array_index(regexp_split_to_array[" ", case_insensitive=false](#1{line}), 3), 8, 1)) then 1 else 0 end end, decode(("0" || substr(#2, 3, 5)), "hex"), (((65536 * get_byte(#6, 0)) + (256 * get_byte(#6, 1))) + get_byte(#6, 2))) // { arity: 8 } Get l0 // { arity: 2 } Constant // { arity: 5 } - (0, 0, 0, 0, 1) Return // { arity: 2 } With cte l7 = - Reduce aggregates=[sum(((#0 + #2) * (#1 - #3)))] // { arity: 1 } + Reduce aggregates=[sum(((#0{r1} + #2{r2}) * (#1{c1} - #3{c2})))] // { arity: 1 } Project (#0..=#3) // { arity: 4 } Get l6 // { arity: 5 } cte l8 = @@ -306,9 +306,9 @@ Explained Query: Constant // { arity: 0 } - () cte l9 = - Reduce aggregates=[sum(#0)] // { arity: 1 } + Reduce aggregates=[sum(#0{steps})] // { arity: 1 } Project (#3) // { arity: 1 } - Map (decode(("0" || substr(array_index(regexp_split_to_array[" ", case_insensitive=false](#1), 3), 3, 5)), "hex"), (((65536 * get_byte(#2, 0)) + (256 * get_byte(#2, 1))) + get_byte(#2, 2))) // { arity: 4 } + Map (decode(("0" || substr(array_index(regexp_split_to_array[" ", case_insensitive=false](#1{line}), 3), 3, 5)), "hex"), (((65536 * get_byte(#2, 0)) + (256 * get_byte(#2, 1))) + get_byte(#2, 2))) // { arity: 4 } Get l0 // { arity: 2 } cte l10 = Union // { arity: 1 } diff --git a/test/sqllogictest/advent-of-code/2023/aoc_1219.slt b/test/sqllogictest/advent-of-code/2023/aoc_1219.slt index 9e2ea969f2c30..572b4806fe633 100644 --- a/test/sqllogictest/advent-of-code/2023/aoc_1219.slt +++ b/test/sqllogictest/advent-of-code/2023/aoc_1219.slt @@ -325,12 +325,12 @@ Explained Query: With cte l0 = Project (#0, #2, #6..=#9) // { arity: 6 } - Map (array_index(regexp_split_to_array[",", case_insensitive=false](#1), integer_to_bigint(#2)), substr(#3, 2, 1), ((#4 = "<") OR (#4 = ">")), case when #5 then substr(#3, 1, 1) else "x" end, case when #5 then substr(#3, 2, 1) else ">" end, case when #5 then text_to_integer(array_index(regexp_split_to_array[":", case_insensitive=false](substr(#3, 3)), 1)) else 0 end, case when #5 then array_index(regexp_split_to_array[":", case_insensitive=false](substr(#3, 3)), 2) else #3 end) // { arity: 10 } - FlatMap generate_series(1, (regexp_split_to_array[",", case_insensitive=false](#1) array_length 1), 1) // { arity: 3 } + Map (array_index(regexp_split_to_array[",", case_insensitive=false](#1{trans}), integer_to_bigint(#2{priority})), substr(#3{rule}, 2, 1), ((#4 = "<") OR (#4 = ">")), case when #5 then substr(#3, 1, 1) else "x" end, case when #5 then substr(#3, 2, 1) else ">" end, case when #5 then text_to_integer(array_index(regexp_split_to_array[":", case_insensitive=false](substr(#3, 3)), 1)) else 0 end, case when #5 then array_index(regexp_split_to_array[":", case_insensitive=false](substr(#3, 3)), 2) else #3 end) // { arity: 10 } + FlatMap generate_series(1, (regexp_split_to_array[",", case_insensitive=false](#1{trans}) array_length 1), 1) // { arity: 3 } Project (#3, #4) // { arity: 2 } Filter (#3) IS NOT NULL // { arity: 5 } - Map (regexp_split_to_array["\{", case_insensitive=false](#1), array_index(#2, 1), btrim(array_index(#2, 2), "}")) // { arity: 5 } - FlatMap unnest_array(regexp_split_to_array["\n", case_insensitive=false](#0)) // { arity: 2 } + Map (regexp_split_to_array["\{", case_insensitive=false](#1{line}), array_index(#2, 1), btrim(array_index(#2, 2), "}")) // { arity: 5 } + FlatMap unnest_array(regexp_split_to_array["\n", case_insensitive=false](#0{block1})) // { arity: 2 } Project (#1) // { arity: 1 } Map (array_index(regexp_split_to_array["\n\n", case_insensitive=false](#0{input}), 1)) // { arity: 2 } ReadStorage materialize.public.input // { arity: 1 } @@ -339,54 +339,54 @@ Explained Query: cte l1 = Union // { arity: 5 } Project (#7, #3..=#6) // { arity: 5 } - Map (regexp_split_to_array[",", case_insensitive=false](btrim(btrim(#1, "\}"), "\{")), text_to_integer(substr(array_index(#2, 1), 3)), text_to_integer(substr(array_index(#2, 2), 3)), text_to_integer(substr(array_index(#2, 3), 3)), text_to_integer(substr(array_index(#2, 4), 3)), "in") // { arity: 8 } - FlatMap unnest_array(regexp_split_to_array["\n", case_insensitive=false](#0)) // { arity: 2 } + Map (regexp_split_to_array[",", case_insensitive=false](btrim(btrim(#1{unnest}, "\}"), "\{")), text_to_integer(substr(array_index(#2, 1), 3)), text_to_integer(substr(array_index(#2, 2), 3)), text_to_integer(substr(array_index(#2, 3), 3)), text_to_integer(substr(array_index(#2, 4), 3)), "in") // { arity: 8 } + FlatMap unnest_array(regexp_split_to_array["\n", case_insensitive=false](#0{block2})) // { arity: 2 } Project (#1) // { arity: 1 } Map (array_index(regexp_split_to_array["\n\n", case_insensitive=false](#0{input}), 2)) // { arity: 2 } ReadStorage materialize.public.input // { arity: 1 } Project (#6, #1..=#4) // { arity: 5 } TopK group_by=[#0, #1, #2, #3, #4] order_by=[#5 asc nulls_last] limit=1 // { arity: 7 } Project (#0..=#4, #6, #10) // { arity: 7 } - Filter case when (#8 = "<") then case when (#7 = "x") then (#1 < #9) else case when (#7 = "m") then (#2 < #9) else case when (#7 = "a") then (#3 < #9) else case when (#7 = "s") then (#4 < #9) else false end end end end else case when (#8 = ">") then case when (#7 = "x") then (#1 > #9) else case when (#7 = "m") then (#2 > #9) else case when (#7 = "a") then (#3 > #9) else case when (#7 = "s") then (#4 > #9) else false end end end end else false end end // { arity: 11 } - Join on=(#0 = #5) type=differential // { arity: 11 } + Filter case when (#8{cmp} = "<") then case when (#7{field} = "x") then (#1{x} < #9{val}) else case when (#7{field} = "m") then (#2{m} < #9{val}) else case when (#7{field} = "a") then (#3{a} < #9{val}) else case when (#7{field} = "s") then (#4{s} < #9{val}) else false end end end end else case when (#8{cmp} = ">") then case when (#7{field} = "x") then (#1{x} > #9{val}) else case when (#7{field} = "m") then (#2{m} > #9{val}) else case when (#7{field} = "a") then (#3{a} > #9{val}) else case when (#7{field} = "s") then (#4{s} > #9{val}) else false end end end end else false end end // { arity: 11 } + Join on=(#0{state} = #5{state}) type=differential // { arity: 11 } implementation - %0:l1[#0]K » %1:l0[#0]K - ArrangeBy keys=[[#0]] // { arity: 5 } - Filter (#0) IS NOT NULL // { arity: 5 } + %0:l1[#0{state}]K » %1:l0[#0{state}]K + ArrangeBy keys=[[#0{state}]] // { arity: 5 } + Filter (#0{state}) IS NOT NULL // { arity: 5 } Get l1 // { arity: 5 } - ArrangeBy keys=[[#0]] // { arity: 6 } + ArrangeBy keys=[[#0{state}]] // { arity: 6 } Get l0 // { arity: 6 } cte l2 = - Reduce aggregates=[sum((((#0 + #1) + #2) + #3))] // { arity: 1 } + Reduce aggregates=[sum((((#0{x} + #1{m}) + #2{a}) + #3{s}))] // { arity: 1 } Project (#1..=#4) // { arity: 4 } - Filter (#0 = "A") // { arity: 5 } + Filter (#0{state} = "A") // { arity: 5 } Get l1 // { arity: 5 } cte l3 = Project (#0..=#9, #12..=#15) // { arity: 14 } - Join on=(#0 = #10 AND #1 = #11) type=differential // { arity: 16 } + Join on=(#0{state} = #10{state} AND #1{priority} = #11{priority}) type=differential // { arity: 16 } implementation - %0:l4[#0, #1]KK » %1:l0[#0, #1]KK - ArrangeBy keys=[[#0, #1]] // { arity: 10 } - Filter (#0) IS NOT NULL // { arity: 10 } + %0:l4[#0{state}, #1{priority}]KK » %1:l0[#0{state}, #1{priority}]KK + ArrangeBy keys=[[#0{state}, #1{priority}]] // { arity: 10 } + Filter (#0{state}) IS NOT NULL // { arity: 10 } Get l4 // { arity: 10 } - ArrangeBy keys=[[#0, #1]] // { arity: 6 } + ArrangeBy keys=[[#0{state}, #1{priority}]] // { arity: 6 } Get l0 // { arity: 6 } cte l4 = Union // { arity: 10 } Project (#13, #28, #16, #18, #20, #21, #23, #24, #26, #27) // { arity: 10 } - Map ((#10 = "x"), (#11 = ">"), case when (#14 AND #15) then greatest((#12 + 1), #2) else #2 end, (#11 = "<"), case when (#14 AND #17) then least((#12 - 1), #3) else #3 end, (#10 = "m"), case when (#15 AND #19) then greatest((#12 + 1), #4) else #4 end, case when (#17 AND #19) then least((#12 - 1), #5) else #5 end, (#10 = "a"), case when (#15 AND #22) then greatest((#12 + 1), #6) else #6 end, case when (#17 AND #22) then least((#12 - 1), #7) else #7 end, (#10 = "s"), case when (#15 AND #25) then greatest((#12 + 1), #8) else #8 end, case when (#17 AND #25) then least((#12 - 1), #9) else #9 end, 1) // { arity: 29 } + Map ((#10{field} = "x"), (#11{cmp} = ">"), case when (#14 AND #15) then greatest((#12{val} + 1), #2{xl}) else #2{xl} end, (#11{cmp} = "<"), case when (#14 AND #17) then least((#12{val} - 1), #3{xu}) else #3{xu} end, (#10{field} = "m"), case when (#15 AND #19) then greatest((#12{val} + 1), #4{ml}) else #4{ml} end, case when (#17 AND #19) then least((#12{val} - 1), #5{mu}) else #5{mu} end, (#10{field} = "a"), case when (#15 AND #22) then greatest((#12{val} + 1), #6{al}) else #6{al} end, case when (#17 AND #22) then least((#12{val} - 1), #7{au}) else #7{au} end, (#10{field} = "s"), case when (#15 AND #25) then greatest((#12{val} + 1), #8{sl}) else #8{sl} end, case when (#17 AND #25) then least((#12{val} - 1), #9{su}) else #9{su} end, 1) // { arity: 29 } Get l3 // { arity: 14 } Project (#0, #14, #17, #19, #21, #22, #24, #25, #27, #28) // { arity: 10 } - Map ((#1 + 1), (#10 = "x"), (#11 = "<"), case when (#15 AND #16) then greatest(#12, #2) else #2 end, (#11 = ">"), case when (#15 AND #18) then least(#12, #3) else #3 end, (#10 = "m"), case when (#16 AND #20) then greatest(#12, #4) else #4 end, case when (#18 AND #20) then least(#12, #5) else #5 end, (#10 = "a"), case when (#16 AND #23) then greatest(#12, #6) else #6 end, case when (#18 AND #23) then least(#12, #7) else #7 end, (#10 = "s"), case when (#16 AND #26) then greatest(#12, #8) else #8 end, case when (#18 AND #26) then least(#12, #9) else #9 end) // { arity: 29 } + Map ((#1{priority} + 1), (#10{field} = "x"), (#11{cmp} = "<"), case when (#15 AND #16) then greatest(#12{val}, #2{xl}) else #2{xl} end, (#11{cmp} = ">"), case when (#15 AND #18) then least(#12{val}, #3{xu}) else #3{xu} end, (#10{field} = "m"), case when (#16 AND #20) then greatest(#12{val}, #4{ml}) else #4{ml} end, case when (#18 AND #20) then least(#12{val}, #5{mu}) else #5{mu} end, (#10{field} = "a"), case when (#16 AND #23) then greatest(#12{val}, #6{al}) else #6{al} end, case when (#18 AND #23) then least(#12{val}, #7{au}) else #7{au} end, (#10{field} = "s"), case when (#16 AND #26) then greatest(#12{val}, #8{sl}) else #8{sl} end, case when (#18 AND #26) then least(#12{val}, #9{su}) else #9{su} end) // { arity: 29 } Get l3 // { arity: 14 } Constant // { arity: 10 } - ("in", 1, 1, 4000, 1, 4000, 1, 4000, 1, 4000) Return // { arity: 2 } With cte l5 = - Reduce aggregates=[sum((((integer_to_bigint(((1 + #1) - #0)) * integer_to_bigint(((1 + #3) - #2))) * integer_to_bigint(((1 + #5) - #4))) * integer_to_bigint(((1 + #7) - #6))))] // { arity: 1 } + Reduce aggregates=[sum((((integer_to_bigint(((1 + #1{xu}) - #0{xl})) * integer_to_bigint(((1 + #3{mu}) - #2{ml}))) * integer_to_bigint(((1 + #5{au}) - #4{al}))) * integer_to_bigint(((1 + #7{su}) - #6{sl}))))] // { arity: 1 } Project (#2..=#9) // { arity: 8 } - Filter (#0 = "A") // { arity: 10 } + Filter (#0{state} = "A") // { arity: 10 } Get l4 // { arity: 10 } Return // { arity: 2 } CrossJoin type=differential // { arity: 2 } diff --git a/test/sqllogictest/advent-of-code/2023/aoc_1220.slt b/test/sqllogictest/advent-of-code/2023/aoc_1220.slt index 314aec48ef7a6..35d2f11884f9d 100644 --- a/test/sqllogictest/advent-of-code/2023/aoc_1220.slt +++ b/test/sqllogictest/advent-of-code/2023/aoc_1220.slt @@ -145,12 +145,12 @@ Explained Query: ReadStorage materialize.public.input // { arity: 1 } cte l1 = Project (#3, #4) // { arity: 2 } - Map (regexp_split_to_array[" ", case_insensitive=false](#0), substr(array_index(#2, 1), 2), btrim(array_index(#2, integer_to_bigint(#1)), ",")) // { arity: 5 } - FlatMap generate_series(3, (regexp_split_to_array[" ", case_insensitive=false](#0) array_length 1), 1) // { arity: 2 } + Map (regexp_split_to_array[" ", case_insensitive=false](#0{line}), substr(array_index(#2, 1), 2), btrim(array_index(#2, integer_to_bigint(#1{x})), ",")) // { arity: 5 } + FlatMap generate_series(3, (regexp_split_to_array[" ", case_insensitive=false](#0{line}) array_length 1), 1) // { arity: 2 } Get l0 // { arity: 1 } cte l2 = Project (#1, #2) // { arity: 2 } - Map (array_index(regexp_split_to_array[" ", case_insensitive=false](#0), 1), substr(#1, 2)) // { arity: 3 } + Map (array_index(regexp_split_to_array[" ", case_insensitive=false](#0{line}), 1), substr(#1, 2)) // { arity: 3 } Get l0 // { arity: 1 } Return // { arity: 5 } With Mutually Recursive @@ -158,38 +158,38 @@ Explained Query: Distinct project=[#0, #1] monotonic // { arity: 2 } Union // { arity: 2 } Project (#0, #2) // { arity: 2 } - Filter (#1 > 0) // { arity: 3 } - Map ((#1 - 1)) // { arity: 3 } + Filter (#1{counter} > 0) // { arity: 3 } + Map ((#1{counter} - 1)) // { arity: 3 } Get l3 // { arity: 2 } Project (#2, #3) // { arity: 2 } - Filter (#1 = 0) AND (#0 < 4100) // { arity: 4 } - Map ((#0 + 1), 20) // { arity: 4 } + Filter (#1{counter} = 0) AND (#0{press} < 4100) // { arity: 4 } + Map ((#0{press} + 1), 20) // { arity: 4 } Get l3 // { arity: 2 } Constant // { arity: 2 } - (1, 1) cte l4 = Union // { arity: 4 } Project (#2, #0, #3, #4) // { arity: 4 } - Filter (#1 = 0) // { arity: 5 } + Filter (#1{counter} = 0) // { arity: 5 } Map ("roadcaster", 1, "lo") // { arity: 5 } Get l3 // { arity: 2 } - Filter (#2 > 0) // { arity: 4 } + Filter (#2{round} > 0) // { arity: 4 } Get l12 // { arity: 4 } - Filter (#2 > 0) // { arity: 4 } + Filter (#2{round} > 0) // { arity: 4 } Get l26 // { arity: 4 } cte l5 = - ArrangeBy keys=[[#1]] // { arity: 4 } + ArrangeBy keys=[[#1{target}]] // { arity: 4 } Project (#0..=#3) // { arity: 4 } - Filter (#4 = "lo") AND (#1) IS NOT NULL // { arity: 5 } + Filter (#4{pulse} = "lo") AND (#1{target}) IS NOT NULL // { arity: 5 } Get l27 // { arity: 5 } cte l6 = Project (#0..=#3, #5) // { arity: 5 } - Map ((#3 + 1)) // { arity: 6 } - Join on=(#1 = #4) type=differential // { arity: 5 } + Map ((#3{round} + 1)) // { arity: 6 } + Join on=(#1{target} = #4{name}) type=differential // { arity: 5 } implementation - %0:l5[#1]Kef » %1:l2[#0]Kef + %0:l5[#1{target}]Kef » %1:l2[#0{name}]Kef Get l5 // { arity: 4 } - ArrangeBy keys=[[#0]] // { arity: 1 } + ArrangeBy keys=[[#0{name}]] // { arity: 1 } Project (#1) // { arity: 1 } Filter ("%" = substr(#0, 1, 1)) // { arity: 2 } Get l2 // { arity: 2 } @@ -200,11 +200,11 @@ Explained Query: cte l8 = Reduce group_by=[#0..=#3] aggregates=[count(*)] // { arity: 5 } Project (#0..=#3) // { arity: 4 } - Filter ((#6 < #1) OR ((#1 = #6) AND ((#7 < #2) OR ((#2 = #7) AND (#4 < #0))))) // { arity: 8 } - Join on=(#3 = #5) type=differential // { arity: 8 } + Filter ((#6{press} < #1{press}) OR ((#1{press} = #6{press}) AND ((#7{round} < #2{round}) OR ((#2{round} = #7{round}) AND (#4{source} < #0{source}))))) // { arity: 8 } + Join on=(#3{name} = #5{target}) type=differential // { arity: 8 } implementation - %1:l5[#1]Kef » %0:l7[#3]Kef - ArrangeBy keys=[[#3]] // { arity: 4 } + %1:l5[#1{target}]Kef » %0:l7[#3{name}]Kef + ArrangeBy keys=[[#3{name}]] // { arity: 4 } Get l7 // { arity: 4 } Get l5 // { arity: 4 } cte l9 = @@ -259,18 +259,18 @@ Explained Query: Get l7 // { arity: 4 } Get l9 // { arity: 4 } cte l13 = - Filter (#1) IS NOT NULL // { arity: 5 } + Filter (#1{target}) IS NOT NULL // { arity: 5 } Get l27 // { arity: 5 } cte l14 = Project (#0..=#3, #5) // { arity: 5 } - Map ((#3 + 1)) // { arity: 6 } - Join on=(#1 = #4) type=differential // { arity: 5 } + Map ((#3{round} + 1)) // { arity: 6 } + Join on=(#1{target} = #4{name}) type=differential // { arity: 5 } implementation - %1:l2[#0]Kef » %0:l13[#1]Kef - ArrangeBy keys=[[#1]] // { arity: 4 } + %1:l2[#0{name}]Kef » %0:l13[#1{target}]Kef + ArrangeBy keys=[[#1{target}]] // { arity: 4 } Project (#0..=#3) // { arity: 4 } Get l13 // { arity: 5 } - ArrangeBy keys=[[#0]] // { arity: 1 } + ArrangeBy keys=[[#0{name}]] // { arity: 1 } Project (#1) // { arity: 1 } Filter ("&" = substr(#0, 1, 1)) // { arity: 2 } Get l2 // { arity: 2 } @@ -279,18 +279,18 @@ Explained Query: Project (#1) // { arity: 1 } Get l14 // { arity: 5 } cte l16 = - ArrangeBy keys=[[#0]] // { arity: 1 } + ArrangeBy keys=[[#0{name}]] // { arity: 1 } Get l15 // { arity: 1 } cte l17 = Reduce group_by=[#0] aggregates=[count(*)] // { arity: 2 } Project (#0) // { arity: 1 } - Join on=(#0 = #1) type=differential // { arity: 2 } + Join on=(#0{name} = #1{link}) type=differential // { arity: 2 } implementation - %0:l16[#0]UK » %1:l1[#0]K + %0:l16[#0{name}]UK » %1:l1[#0{link}]K Get l16 // { arity: 1 } - ArrangeBy keys=[[#0]] // { arity: 1 } + ArrangeBy keys=[[#0{link}]] // { arity: 1 } Project (#1) // { arity: 1 } - Filter (#1) IS NOT NULL // { arity: 2 } + Filter (#1{link}) IS NOT NULL // { arity: 2 } Get l1 // { arity: 2 } cte l18 = Union // { arity: 2 } @@ -346,16 +346,16 @@ Explained Query: cte l22 = Reduce group_by=[#0..=#3] aggregates=[count(*)] // { arity: 5 } Project (#0..=#3) // { arity: 4 } - Filter (#7 = "hi") // { arity: 8 } + Filter (#7{pulse} = "hi") // { arity: 8 } TopK group_by=[#0, #1, #2, #3, #4] order_by=[#5 desc nulls_first, #6 desc nulls_first] limit=1 exp_group_size=1000 // { arity: 8 } Project (#0..=#4, #6..=#8) // { arity: 8 } - Filter ((#6 < #1) OR ((#1 = #6) AND ((#7 < #2) OR ((#2 = #7) AND (#4 <= #0))))) // { arity: 9 } - Join on=(#3 = #5) type=differential // { arity: 9 } + Filter ((#6{press} < #1{press}) OR ((#1{press} = #6{press}) AND ((#7{round} < #2{round}) OR ((#2{round} = #7{round}) AND (#4{source} <= #0{source}))))) // { arity: 9 } + Join on=(#3{name} = #5{target}) type=differential // { arity: 9 } implementation - %0:l21[#3]K » %1:l13[#1]K - ArrangeBy keys=[[#3]] // { arity: 4 } + %0:l21[#3{name}]K » %1:l13[#1{target}]K + ArrangeBy keys=[[#3{name}]] // { arity: 4 } Get l21 // { arity: 4 } - ArrangeBy keys=[[#1]] // { arity: 5 } + ArrangeBy keys=[[#1{target}]] // { arity: 5 } Get l13 // { arity: 5 } cte l23 = ArrangeBy keys=[[#0..=#3]] // { arity: 4 } @@ -410,16 +410,16 @@ Explained Query: Get l23 // { arity: 4 } cte l27 = Project (#0, #5, #1..=#3) // { arity: 5 } - Join on=(#0 = #4) type=differential // { arity: 6 } + Join on=(#0{name} = #4{name}) type=differential // { arity: 6 } implementation - %0:l4[#0]K » %1:l1[#0]K - ArrangeBy keys=[[#0]] // { arity: 4 } + %0:l4[#0{name}]K » %1:l1[#0{name}]K + ArrangeBy keys=[[#0{name}]] // { arity: 4 } Get l4 // { arity: 4 } - ArrangeBy keys=[[#0]] // { arity: 2 } - Filter (#0) IS NOT NULL // { arity: 2 } + ArrangeBy keys=[[#0{name}]] // { arity: 2 } + Filter (#0{name}) IS NOT NULL // { arity: 2 } Get l1 // { arity: 2 } Return // { arity: 5 } - Filter (#1 = "cn") AND (#4 = "hi") // { arity: 5 } + Filter (#1{target} = "cn") AND (#4{pulse} = "hi") // { arity: 5 } Get l27 // { arity: 5 } Source materialize.public.input diff --git a/test/sqllogictest/advent-of-code/2023/aoc_1222.slt b/test/sqllogictest/advent-of-code/2023/aoc_1222.slt index 77fa01707e9ef..00a45e4d82254 100644 --- a/test/sqllogictest/advent-of-code/2023/aoc_1222.slt +++ b/test/sqllogictest/advent-of-code/2023/aoc_1222.slt @@ -209,7 +209,7 @@ Explained Query: With cte l0 = Project (#1, #2) // { arity: 2 } - Map (array_index(regexp_split_to_array["\n", case_insensitive=false](#0{input}), integer_to_bigint(#1))) // { arity: 3 } + Map (array_index(regexp_split_to_array["\n", case_insensitive=false](#0{input}), integer_to_bigint(#1{r}))) // { arity: 3 } FlatMap generate_series(1, (regexp_split_to_array["\n", case_insensitive=false](#0{input}) array_length 1), 1) // { arity: 2 } ReadStorage materialize.public.input // { arity: 1 } cte l1 = @@ -220,22 +220,22 @@ Explained Query: Get l1 // { arity: 1 } cte l3 = Project (#0, #1, #3, #5) // { arity: 4 } - Join on=(#0 = #2 = #4) type=delta // { arity: 6 } + Join on=(#0{r} = #2{r} = #4{r}) type=delta // { arity: 6 } implementation - %0 » %1[#0]K » %2[#0]K - %1 » %0[#0]K » %2[#0]K - %2 » %0[#0]K » %1[#0]K - ArrangeBy keys=[[#0]] // { arity: 2 } + %0 » %1[#0{r}]K » %2[#0{r}]K + %1 » %0[#0{r}]K » %2[#0{r}]K + %2 » %0[#0{r}]K » %1[#0{r}]K + ArrangeBy keys=[[#0{r}]] // { arity: 2 } Project (#0, #2) // { arity: 2 } - FlatMap generate_series(text_to_integer(array_index(regexp_split_to_array[",", case_insensitive=false](array_index(regexp_split_to_array["~", case_insensitive=false](#1), 1)), 1)), text_to_integer(array_index(regexp_split_to_array[",", case_insensitive=false](array_index(regexp_split_to_array["~", case_insensitive=false](#1), 2)), 1)), 1) // { arity: 3 } + FlatMap generate_series(text_to_integer(array_index(regexp_split_to_array[",", case_insensitive=false](array_index(regexp_split_to_array["~", case_insensitive=false](#1{line}), 1)), 1)), text_to_integer(array_index(regexp_split_to_array[",", case_insensitive=false](array_index(regexp_split_to_array["~", case_insensitive=false](#1{line}), 2)), 1)), 1) // { arity: 3 } Get l0 // { arity: 2 } - ArrangeBy keys=[[#0]] // { arity: 2 } + ArrangeBy keys=[[#0{r}]] // { arity: 2 } Project (#0, #2) // { arity: 2 } - FlatMap generate_series(text_to_integer(array_index(regexp_split_to_array[",", case_insensitive=false](array_index(regexp_split_to_array["~", case_insensitive=false](#1), 1)), 2)), text_to_integer(array_index(regexp_split_to_array[",", case_insensitive=false](array_index(regexp_split_to_array["~", case_insensitive=false](#1), 2)), 2)), 1) // { arity: 3 } + FlatMap generate_series(text_to_integer(array_index(regexp_split_to_array[",", case_insensitive=false](array_index(regexp_split_to_array["~", case_insensitive=false](#1{line}), 1)), 2)), text_to_integer(array_index(regexp_split_to_array[",", case_insensitive=false](array_index(regexp_split_to_array["~", case_insensitive=false](#1{line}), 2)), 2)), 1) // { arity: 3 } Get l0 // { arity: 2 } - ArrangeBy keys=[[#0]] // { arity: 2 } + ArrangeBy keys=[[#0{r}]] // { arity: 2 } Project (#0, #2) // { arity: 2 } - FlatMap generate_series(text_to_integer(array_index(regexp_split_to_array[",", case_insensitive=false](array_index(regexp_split_to_array["~", case_insensitive=false](#1), 1)), 3)), text_to_integer(array_index(regexp_split_to_array[",", case_insensitive=false](array_index(regexp_split_to_array["~", case_insensitive=false](#1), 2)), 3)), 1) // { arity: 3 } + FlatMap generate_series(text_to_integer(array_index(regexp_split_to_array[",", case_insensitive=false](array_index(regexp_split_to_array["~", case_insensitive=false](#1{line}), 1)), 3)), text_to_integer(array_index(regexp_split_to_array[",", case_insensitive=false](array_index(regexp_split_to_array["~", case_insensitive=false](#1{line}), 2)), 3)), 1) // { arity: 3 } Get l0 // { arity: 2 } Return // { arity: 2 } With Mutually Recursive @@ -244,7 +244,7 @@ Explained Query: Project (#0) // { arity: 1 } Get l9 // { arity: 4 } cte l5 = - Reduce group_by=[#0] aggregates=[any((#0 = #1))] // { arity: 2 } + Reduce group_by=[#0] aggregates=[any((#0{r} = #1{right_col0_0}))] // { arity: 2 } CrossJoin type=differential // { arity: 2 } implementation %0:l4[×] » %1:l12[×] @@ -287,7 +287,7 @@ Explained Query: Negate // { arity: 4 } Get l16 // { arity: 4 } Project (#0..=#2, #6) // { arity: 4 } - Map (case when #5{any} then #3 else (#3 - 1) end) // { arity: 7 } + Map (case when #5{any} then #3{z} else (#3{z} - 1) end) // { arity: 7 } Join on=(#0 = #4) type=differential // { arity: 6 } implementation %0:l9[#0]K » %1[#0]K @@ -312,13 +312,13 @@ Explained Query: cte l10 = Distinct project=[#0, #1] // { arity: 2 } Project (#0, #4) // { arity: 2 } - Filter (#0 != #4) // { arity: 8 } - Join on=(#1 = #5 AND #2 = #6 AND #7 = (#3 + 1)) type=differential // { arity: 8 } + Filter (#0{r} != #4{r}) // { arity: 8 } + Join on=(#1{x} = #5{x} AND #2{y} = #6{y} AND #7{z} = (#3{z} + 1)) type=differential // { arity: 8 } implementation - %0:l9[#1, #2, (#3 + 1)]KKK » %1:l9[#1..=#3]KKK - ArrangeBy keys=[[#1, #2, (#3 + 1)]] // { arity: 4 } + %0:l9[#1{x}, #2{y}, (#3{z} + 1)]KKK » %1:l9[#1{x}..=#3{z}]KKK + ArrangeBy keys=[[#1{x}, #2{y}, (#3{z} + 1)]] // { arity: 4 } Get l9 // { arity: 4 } - ArrangeBy keys=[[#1..=#3]] // { arity: 4 } + ArrangeBy keys=[[#1{x}..=#3{z}]] // { arity: 4 } Get l9 // { arity: 4 } cte l11 = Project (#1) // { arity: 1 } @@ -327,7 +327,7 @@ Explained Query: Distinct project=[#0] // { arity: 1 } Union // { arity: 1 } Project (#0) // { arity: 1 } - Filter (#3 = 1) // { arity: 4 } + Filter (#3{z} = 1) // { arity: 4 } Get l9 // { arity: 4 } Get l11 // { arity: 1 } cte l13 = @@ -342,7 +342,7 @@ Explained Query: ArrangeBy keys=[[#0]] // { arity: 1 } Get l11 // { arity: 1 } cte l15 = - Reduce aggregates=[count(distinct #0)] // { arity: 1 } + Reduce aggregates=[count(distinct #0{r})] // { arity: 1 } Project (#0) // { arity: 1 } Join on=(#0 = #1) type=differential // { arity: 2 } implementation @@ -379,26 +379,26 @@ Explained Query: cte l17 = Reduce group_by=[#0, #1] aggregates=[count(*)] // { arity: 3 } Project (#0, #3) // { arity: 2 } - Join on=(#1 = #2) type=differential // { arity: 4 } + Join on=(#1{r2} = #2{r1}) type=differential // { arity: 4 } implementation - %0:l22[#1]K » %1:l10[#0]K - ArrangeBy keys=[[#1]] // { arity: 2 } + %0:l22[#1{r2}]K » %1:l10[#0{r1}]K + ArrangeBy keys=[[#1{r2}]] // { arity: 2 } Get l22 // { arity: 2 } - ArrangeBy keys=[[#0]] // { arity: 2 } + ArrangeBy keys=[[#0{r1}]] // { arity: 2 } Get l10 // { arity: 2 } cte l18 = Distinct project=[#0] // { arity: 1 } Project (#1) // { arity: 1 } Get l17 // { arity: 3 } cte l19 = - ArrangeBy keys=[[#0]] // { arity: 1 } + ArrangeBy keys=[[#0{r2}]] // { arity: 1 } Get l18 // { arity: 1 } cte l20 = Reduce group_by=[#0] aggregates=[count(*)] // { arity: 2 } Project (#0) // { arity: 1 } - Join on=(#0 = #1) type=differential // { arity: 2 } + Join on=(#0{r2} = #1{r2}) type=differential // { arity: 2 } implementation - %0:l19[#0]UK » %1:l14[#0]K + %0:l19[#0{r2}]UK » %1:l14[#0{r2}]K Get l19 // { arity: 1 } Get l14 // { arity: 1 } cte l21 = @@ -432,7 +432,7 @@ Explained Query: Project (#0, #1) // { arity: 2 } Join on=(#1 = #3 AND #2{count} = #4{count}) type=differential // { arity: 5 } implementation - %0:l17[#1, #2]KK » %1[#0, #1]KK + %0:l17[#1, #2{?column?}]KK » %1[#0, #1]KK ArrangeBy keys=[[#1, #2{count}]] // { arity: 3 } Get l17 // { arity: 3 } ArrangeBy keys=[[#0, #1{count}]] // { arity: 2 } diff --git a/test/sqllogictest/advent-of-code/2023/aoc_1223.slt b/test/sqllogictest/advent-of-code/2023/aoc_1223.slt index 47abf3a64aafd..35fe598f32011 100644 --- a/test/sqllogictest/advent-of-code/2023/aoc_1223.slt +++ b/test/sqllogictest/advent-of-code/2023/aoc_1223.slt @@ -295,10 +295,10 @@ Explained Query: With cte l0 = Project (#0, #2) // { arity: 2 } - Filter ("#" != substr(#1, #2, 1)) // { arity: 3 } - FlatMap generate_series(1, char_length(#1), 1) // { arity: 3 } + Filter ("#" != substr(#1{line}, #2{c}, 1)) // { arity: 3 } + FlatMap generate_series(1, char_length(#1{line}), 1) // { arity: 3 } Project (#1, #2) // { arity: 2 } - Map (array_index(regexp_split_to_array["\n", case_insensitive=false](#0{input}), integer_to_bigint(#1))) // { arity: 3 } + Map (array_index(regexp_split_to_array["\n", case_insensitive=false](#0{input}), integer_to_bigint(#1{r}))) // { arity: 3 } FlatMap generate_series(1, (regexp_split_to_array["\n", case_insensitive=false](#0{input}) array_length 1), 1) // { arity: 2 } ReadStorage materialize.public.input // { arity: 1 } cte l1 = @@ -314,7 +314,7 @@ Explained Query: Distinct project=[#0..=#2] // { arity: 3 } Union // { arity: 3 } Project (#0, #1, #4) // { arity: 3 } - Map ((#0 + 1)) // { arity: 5 } + Map ((#0{r} + 1)) // { arity: 5 } Join on=(#0 = #2 AND #1 = #3) type=differential // { arity: 4 } implementation %1[#0, #1]UKKA » %0:l2[#0, #1]KK @@ -322,14 +322,14 @@ Explained Query: ArrangeBy keys=[[#0, #1]] // { arity: 2 } Distinct project=[#0, #1] // { arity: 2 } Project (#0, #1) // { arity: 2 } - Join on=(#1 = #3 AND #2 = (#0 + 1)) type=differential // { arity: 4 } + Join on=(#1{c} = #3{right_col1_13} AND #2{right_col0_12} = (#0{r} + 1)) type=differential // { arity: 4 } implementation - %0:l1[(#0 + 1), #1]KK » %1:l2[#0, #1]KK - ArrangeBy keys=[[(#0 + 1), #1]] // { arity: 2 } + %0:l1[(#0{r} + 1), #1{c}]KK » %1:l2[#0{right_col0_12}, #1{right_col1_13}]KK + ArrangeBy keys=[[(#0{r} + 1), #1{c}]] // { arity: 2 } Get l1 // { arity: 2 } Get l2 // { arity: 2 } Project (#0, #1, #4) // { arity: 3 } - Map ((#0 - 1)) // { arity: 5 } + Map ((#0{r} - 1)) // { arity: 5 } Join on=(#0 = #2 AND #1 = #3) type=differential // { arity: 4 } implementation %1[#0, #1]UKKA » %0:l2[#0, #1]KK @@ -337,14 +337,14 @@ Explained Query: ArrangeBy keys=[[#0, #1]] // { arity: 2 } Distinct project=[#0, #1] // { arity: 2 } Project (#0, #1) // { arity: 2 } - Join on=(#1 = #3 AND #2 = (#0 - 1)) type=differential // { arity: 4 } + Join on=(#1{c} = #3{right_col1_16} AND #2{right_col0_15} = (#0{r} - 1)) type=differential // { arity: 4 } implementation - %0:l1[(#0 - 1), #1]KK » %1:l2[#0, #1]KK - ArrangeBy keys=[[(#0 - 1), #1]] // { arity: 2 } + %0:l1[(#0{r} - 1), #1{c}]KK » %1:l2[#0{right_col0_15}, #1{right_col1_16}]KK + ArrangeBy keys=[[(#0{r} - 1), #1{c}]] // { arity: 2 } Get l1 // { arity: 2 } Get l2 // { arity: 2 } Project (#0, #1, #0, #4) // { arity: 4 } - Map ((#1 + 1)) // { arity: 5 } + Map ((#1{c} + 1)) // { arity: 5 } Join on=(#0 = #2 AND #1 = #3) type=differential // { arity: 4 } implementation %1[#0, #1]UKKA » %0:l2[#0, #1]KK @@ -352,14 +352,14 @@ Explained Query: ArrangeBy keys=[[#0, #1]] // { arity: 2 } Distinct project=[#0, #1] // { arity: 2 } Project (#0, #1) // { arity: 2 } - Join on=(#0 = #2 AND #3 = (#1 + 1)) type=differential // { arity: 4 } + Join on=(#0{r} = #2{right_col0_18} AND #3{right_col1_19} = (#1{c} + 1)) type=differential // { arity: 4 } implementation - %0:l1[#0, (#1 + 1)]KK » %1:l2[#0, #1]KK - ArrangeBy keys=[[#0, (#1 + 1)]] // { arity: 2 } + %0:l1[#0{r}, (#1{c} + 1)]KK » %1:l2[#0{right_col0_18}, #1{right_col1_19}]KK + ArrangeBy keys=[[#0{r}, (#1{c} + 1)]] // { arity: 2 } Get l1 // { arity: 2 } Get l2 // { arity: 2 } Project (#0, #1, #0, #4) // { arity: 4 } - Map ((#1 - 1)) // { arity: 5 } + Map ((#1{c} - 1)) // { arity: 5 } Join on=(#0 = #2 AND #1 = #3) type=differential // { arity: 4 } implementation %1[#0, #1]UKKA » %0:l2[#0, #1]KK @@ -367,10 +367,10 @@ Explained Query: ArrangeBy keys=[[#0, #1]] // { arity: 2 } Distinct project=[#0, #1] // { arity: 2 } Project (#0, #1) // { arity: 2 } - Join on=(#0 = #2 AND #3 = (#1 - 1)) type=differential // { arity: 4 } + Join on=(#0{r} = #2{right_col0_21} AND #3{right_col1_22} = (#1{c} - 1)) type=differential // { arity: 4 } implementation - %0:l1[#0, (#1 - 1)]KK » %1:l2[#0, #1]KK - ArrangeBy keys=[[#0, (#1 - 1)]] // { arity: 2 } + %0:l1[#0{r}, (#1{c} - 1)]KK » %1:l2[#0{right_col0_21}, #1{right_col1_22}]KK + ArrangeBy keys=[[#0{r}, (#1{c} - 1)]] // { arity: 2 } Get l1 // { arity: 2 } Get l2 // { arity: 2 } cte l4 = @@ -384,7 +384,7 @@ Explained Query: Negate // { arity: 2 } Distinct project=[#0, #1] // { arity: 2 } Project (#0, #1) // { arity: 2 } - Filter (#0 = #2) AND (#1 = #3) // { arity: 4 } + Filter (#0{r} = #2{right_col0_36}) AND (#1{c} = #3{right_col1_37}) // { arity: 4 } FlatMap wrap2(1, 2, 12, 20, 130, 126, 141, 140) // { arity: 4 } Get l4 // { arity: 2 } Get l4 // { arity: 2 } @@ -392,7 +392,7 @@ Explained Query: Distinct project=[#0, #1] // { arity: 2 } Get l5 // { arity: 2 } cte l7 = - Filter ((#2 < #0) OR ((#0 = #2) AND (#3 < #1))) // { arity: 4 } + Filter ((#2{r} < #0{r}) OR ((#0{r} = #2{r}) AND (#3{c} < #1{c}))) // { arity: 4 } CrossJoin type=differential // { arity: 4 } implementation %0:l6[×] » %1:l4[×] @@ -417,12 +417,12 @@ Explained Query: Negate // { arity: 2 } Distinct project=[#0, #1] // { arity: 2 } Project (#0, #1) // { arity: 2 } - Filter (#0 = #2) AND (#1 = #3) // { arity: 4 } + Filter (#0{r} = #2{right_col0_33}) AND (#1{c} = #3{right_col1_34}) // { arity: 4 } FlatMap wrap2(1, 2, 12, 20, 130, 126, 141, 140) // { arity: 4 } Get l8 // { arity: 2 } Get l8 // { arity: 2 } cte l10 = - ArrangeBy keys=[[#0, #1]] // { arity: 4 } + ArrangeBy keys=[[#0{r1}, #1{c1}]] // { arity: 4 } Get l3 // { arity: 4 } cte l11 = ArrangeBy keys=[[#0, #1]] // { arity: 2 } @@ -431,11 +431,11 @@ Explained Query: With Mutually Recursive cte l12 = Project (#0..=#4, #7, #8) // { arity: 7 } - Filter ((#0 != #7) OR (#1 != #8)) // { arity: 9 } - Join on=(#3 = #5 AND #4 = #6) type=differential // { arity: 9 } + Filter ((#0{r1} != #7{r2}) OR (#1{c1} != #8{c2})) // { arity: 9 } + Join on=(#3{r2} = #5{r1} AND #4{c2} = #6{c1}) type=differential // { arity: 9 } implementation - %0:l14[#3, #4]KK » %1:l10[#0, #1]KK - ArrangeBy keys=[[#3, #4]] // { arity: 5 } + %0:l14[#3{r2}, #4{c2}]KK » %1:l10[#0{r1}, #1{c1}]KK + ArrangeBy keys=[[#3{r2}, #4{c2}]] // { arity: 5 } Get l14 // { arity: 5 } Get l10 // { arity: 4 } cte l13 = @@ -444,7 +444,7 @@ Explained Query: Get l12 // { arity: 7 } cte l14 = Project (#0, #1, #4{min}, #2, #3) // { arity: 5 } - Reduce group_by=[#0, #1, #3, #4] aggregates=[min(#2)] // { arity: 5 } + Reduce group_by=[#0, #1, #3, #4] aggregates=[min(#2{d})] // { arity: 5 } Union // { arity: 5 } Project (#0, #1, #6, #2, #3) // { arity: 5 } Map (1) // { arity: 7 } @@ -454,7 +454,7 @@ Explained Query: Get l10 // { arity: 4 } Get l11 // { arity: 2 } Project (#0, #1, #9, #5, #6) // { arity: 5 } - Map ((#2 + 1)) // { arity: 10 } + Map ((#2{d} + 1)) // { arity: 10 } Join on=(#3 = #7 AND #4 = #8) type=differential // { arity: 9 } implementation %0:l12[#3, #4]KK » %1[#0, #1]KK @@ -473,20 +473,20 @@ Explained Query: Get l13 // { arity: 2 } cte l15 = Project (#0, #1, #3{max}, #2) // { arity: 4 } - Reduce group_by=[#0, #1, #3] aggregates=[max(#2)] // { arity: 4 } + Reduce group_by=[#0, #1, #3] aggregates=[max(#2{d})] // { arity: 4 } Union // { arity: 4 } Project (#7, #8, #15, #16) // { arity: 4 } - Filter (1 != ((#3 >> #14) % 2)) // { arity: 17 } - Map (bigint_to_integer(#13{count}), (#2 + #6{min}), (#3 + (1 << #14))) // { arity: 17 } - Join on=(#0 = #4 AND #1 = #5 AND #7 = #9 = #11 AND #8 = #10 = #12) type=delta // { arity: 14 } + Filter (1 != ((#3{v} >> #14) % 2)) // { arity: 17 } + Map (bigint_to_integer(#13{count}), (#2{d} + #6{min}), (#3{v} + (1 << #14{id}))) // { arity: 17 } + Join on=(#0{r} = #4{r1} AND #1{c} = #5{c1} AND #7 = #9 = #11 AND #8 = #10 = #12) type=delta // { arity: 14 } implementation - %0:l15 » %1:l14[#0, #1]KK » %3[#0, #1]UKK » %2:l5[#0, #1]KK - %1:l14 » %3[#0, #1]UKK » %0:l15[#0, #1]KK » %2:l5[#0, #1]KK - %2:l5 » %3[#0, #1]UKK » %1:l14[#3, #4]KK » %0:l15[#0, #1]KK - %3 » %1:l14[#3, #4]KK » %0:l15[#0, #1]KK » %2:l5[#0, #1]KK - ArrangeBy keys=[[#0, #1]] // { arity: 4 } + %0:l15 » %1:l14[#0{r1}, #1{c1}]KK » %3[#0, #1]UKK » %2:l5[#0, #1]KK + %1:l14 » %3[#0, #1]UKK » %0:l15[#0{r}, #1{c}]KK » %2:l5[#0, #1]KK + %2:l5 » %3[#0, #1]UKK » %1:l14[#3, #4]KK » %0:l15[#0{r}, #1{c}]KK + %3 » %1:l14[#3, #4]KK » %0:l15[#0{r}, #1{c}]KK » %2:l5[#0, #1]KK + ArrangeBy keys=[[#0{r}, #1{c}]] // { arity: 4 } Get l15 // { arity: 4 } - ArrangeBy keys=[[#0, #1], [#3, #4]] // { arity: 5 } + ArrangeBy keys=[[#0{r1}, #1{c1}], [#3, #4]] // { arity: 5 } Get l14 // { arity: 5 } ArrangeBy keys=[[#0, #1]] // { arity: 2 } Get l5 // { arity: 2 } diff --git a/test/sqllogictest/advent-of-code/2023/aoc_1224.slt b/test/sqllogictest/advent-of-code/2023/aoc_1224.slt index 8beb7670dfeac..e5caee13752b9 100644 --- a/test/sqllogictest/advent-of-code/2023/aoc_1224.slt +++ b/test/sqllogictest/advent-of-code/2023/aoc_1224.slt @@ -120,16 +120,16 @@ SELECT x, y, ox, oy, COUNT(*) FROM coincidence_xz GROUP BY x, y, ox, oy HAVING C Explained Query: With cte l0 = - ArrangeBy keys=[[#5]] // { arity: 6 } + ArrangeBy keys=[[#5{oy}]] // { arity: 6 } Project (#0..=#2, #6, #8, #7) // { arity: 6 } - Map ((#3 - -117), integer_to_numeric(#5), (#4 - #7)) // { arity: 9 } + Map ((#3{dx} - -117), integer_to_numeric(#5{oz}), (#4{dz} - #7)) // { arity: 9 } CrossJoin type=differential // { arity: 6 } implementation %0[×]if » %1[×]if ArrangeBy keys=[[]] // { arity: 5 } Project (#1, #3..=#6) // { arity: 5 } - Filter (#1 < 10) // { arity: 7 } - Map (regexp_split_to_array[" ", case_insensitive=false](array_index(regexp_split_to_array["\n", case_insensitive=false](#0{input}), integer_to_bigint(#1))), text_to_numeric(btrim(array_index(#2, 1), ",")), text_to_numeric(btrim(array_index(#2, 3), ",")), text_to_numeric(btrim(array_index(#2, 5), ",")), text_to_numeric(btrim(array_index(#2, 7), ","))) // { arity: 7 } + Filter (#1{r} < 10) // { arity: 7 } + Map (regexp_split_to_array[" ", case_insensitive=false](array_index(regexp_split_to_array["\n", case_insensitive=false](#0{input}), integer_to_bigint(#1{r}))), text_to_numeric(btrim(array_index(#2, 1), ",")), text_to_numeric(btrim(array_index(#2, 3), ",")), text_to_numeric(btrim(array_index(#2, 5), ",")), text_to_numeric(btrim(array_index(#2, 7), ","))) // { arity: 7 } FlatMap generate_series(1, (regexp_split_to_array["\n", case_insensitive=false](#0{input}) array_length 1), 1) // { arity: 2 } ReadStorage materialize.public.input // { arity: 1 } ArrangeBy keys=[[]] // { arity: 1 } @@ -160,12 +160,12 @@ Explained Query: Project (#0, #1, #4, #2, #3{count}) // { arity: 5 } Filter (#3{count} > 1) // { arity: 5 } Map (-117) // { arity: 5 } - Reduce group_by=[(#0 + ((#2 * (((#5 - #0) * #8) - ((#6 - #1) * #7))) / ((#2 * #8) - (#3 * #7)))), (#1 + ((#3 * (((#5 - #0) * #8) - ((#6 - #1) * #7))) / ((#2 * #8) - (#3 * #7)))), #4] aggregates=[count(*)] // { arity: 4 } + Reduce group_by=[(#0{x} + ((#2{dx} * (((#5{x} - #0{x}) * #8{dy}) - ((#6{y} - #1{y}) * #7{dx}))) / ((#2{dx} * #8{dy}) - (#3{dy} * #7{dx})))), (#1{y} + ((#3{dy} * (((#5{x} - #0{x}) * #8{dy}) - ((#6{y} - #1{y}) * #7{dx}))) / ((#2{dx} * #8{dy}) - (#3{dy} * #7{dx})))), #4] aggregates=[count(*)] // { arity: 4 } Project (#1..=#5, #7..=#10) // { arity: 9 } - Filter (#0 < #6) AND ((#3 * #10) != (#4 * #9)) // { arity: 12 } - Join on=(#5 = #11) type=differential // { arity: 12 } + Filter (#0{r} < #6{r}) AND ((#3{dx} * #10{dy}) != (#4{dy} * #9{dx})) // { arity: 12 } + Join on=(#5{oy} = #11{oy}) type=differential // { arity: 12 } implementation - %0:l0[#5]K » %1:l0[#5]K + %0:l0[#5{oy}]K » %1:l0[#5{oy}]K Get l0 // { arity: 6 } Get l0 // { arity: 6 } diff --git a/test/sqllogictest/advent-of-code/2023/aoc_1225.slt b/test/sqllogictest/advent-of-code/2023/aoc_1225.slt index 9ca3c0ef13e85..6f7dbdf01731d 100644 --- a/test/sqllogictest/advent-of-code/2023/aoc_1225.slt +++ b/test/sqllogictest/advent-of-code/2023/aoc_1225.slt @@ -132,14 +132,14 @@ Explained Query: With cte l0 = Project (#3, #4) // { arity: 2 } - Map (regexp_split_to_array[" ", case_insensitive=false](#0), btrim(array_index(#2, 1), ":"), btrim(array_index(#2, integer_to_bigint(#1)), ",")) // { arity: 5 } - FlatMap generate_series(2, (regexp_split_to_array[" ", case_insensitive=false](#0) array_length 1), 1) // { arity: 2 } + Map (regexp_split_to_array[" ", case_insensitive=false](#0{line}), btrim(array_index(#2, 1), ":"), btrim(array_index(#2, integer_to_bigint(#1{x})), ",")) // { arity: 5 } + FlatMap generate_series(2, (regexp_split_to_array[" ", case_insensitive=false](#0{line}) array_length 1), 1) // { arity: 2 } Project (#2) // { arity: 1 } - Map (array_index(regexp_split_to_array["\n", case_insensitive=false](#0{input}), integer_to_bigint(#1))) // { arity: 3 } + Map (array_index(regexp_split_to_array["\n", case_insensitive=false](#0{input}), integer_to_bigint(#1{r}))) // { arity: 3 } FlatMap generate_series(1, (regexp_split_to_array["\n", case_insensitive=false](#0{input}) array_length 1), 1) // { arity: 2 } ReadStorage materialize.public.input // { arity: 1 } cte l1 = - Map (case when (#0 < "n") then 1 else -1 end) // { arity: 2 } + Map (case when (#0{src} < "n") then 1 else -1 end) // { arity: 2 } Union // { arity: 1 } Project (#0) // { arity: 1 } Get l0 // { arity: 2 } @@ -151,7 +151,7 @@ Explained Query: Project (#1{sum}) // { arity: 1 } Get l7 // { arity: 2 } cte l3 = - Reduce aggregates=[sum(#0), count(#0)] // { arity: 2 } + Reduce aggregates=[sum(#0{val}), count(#0{val})] // { arity: 2 } Get l2 // { arity: 1 } cte l4 = Project (#2) // { arity: 1 } @@ -166,7 +166,7 @@ Explained Query: Constant // { arity: 0 } - () cte l5 = - Reduce aggregates=[sum((#0 * #0)), sum(#0), count(#0)] // { arity: 3 } + Reduce aggregates=[sum((#0{val} * #0{val})), sum(#0{val}), count(#0{val})] // { arity: 3 } Get l2 // { arity: 1 } cte l6 = Project (#3) // { arity: 1 } @@ -187,23 +187,23 @@ Explained Query: Get l1 // { arity: 2 } Negate // { arity: 2 } Get l8 // { arity: 2 } - Reduce group_by=[#0] aggregates=[sum(((#1 - #2) / #3))] // { arity: 2 } + Reduce group_by=[#0] aggregates=[sum(((#1{val} - #2) / #3))] // { arity: 2 } Project (#0, #3..=#5) // { arity: 4 } - Join on=(#1 = #2) type=delta // { arity: 6 } + Join on=(#1{dst} = #2{src}) type=delta // { arity: 6 } implementation - %0 » %2[×]U » %3[×]U » %1:l7[#0]K - %1:l7 » %2[×]U » %3[×]U » %0[#1]K - %2 » %3[×]U » %0[×] » %1:l7[#0]K - %3 » %2[×]U » %0[×] » %1:l7[#0]K - ArrangeBy keys=[[], [#1]] // { arity: 2 } + %0 » %2[×]U » %3[×]U » %1:l7[#0{src}]K + %1:l7 » %2[×]U » %3[×]U » %0[#1{dst}]K + %2 » %3[×]U » %0[×] » %1:l7[#0{src}]K + %3 » %2[×]U » %0[×] » %1:l7[#0{src}]K + ArrangeBy keys=[[], [#1{dst}]] // { arity: 2 } Union // { arity: 2 } - Filter (#1) IS NOT NULL // { arity: 2 } + Filter (#1{dst}) IS NOT NULL // { arity: 2 } Get l0 // { arity: 2 } Project (#1, #0) // { arity: 2 } - Filter (#0) IS NOT NULL // { arity: 2 } + Filter (#0{dst}) IS NOT NULL // { arity: 2 } Get l0 // { arity: 2 } - ArrangeBy keys=[[#0]] // { arity: 2 } - Filter (#0) IS NOT NULL // { arity: 2 } + ArrangeBy keys=[[#0{src}]] // { arity: 2 } + Filter (#0{src}) IS NOT NULL // { arity: 2 } Get l7 // { arity: 2 } ArrangeBy keys=[[]] // { arity: 1 } Union // { arity: 1 } diff --git a/test/sqllogictest/aggregates.slt b/test/sqllogictest/aggregates.slt index 5638a5a7e76b4..1ad81edf6133a 100644 --- a/test/sqllogictest/aggregates.slt +++ b/test/sqllogictest/aggregates.slt @@ -709,8 +709,8 @@ query T multiline EXPLAIN RAW PLAN FOR SELECT stddev(x), sum(x) FROM t_variance; ---- Project (#4, #3) - Map (sqrtf64(case when (((#0 - ((#1 * #1) / bigint_to_double(case when (#2 = integer_to_bigint(0)) then null else #2 end))) / bigint_to_double(case when ((#2 - integer_to_bigint(1)) = integer_to_bigint(0)) then null else (#2 - integer_to_bigint(1)) end))) IS NULL then null else greatest(((#0 - ((#1 * #1) / bigint_to_double(case when (#2 = integer_to_bigint(0)) then null else #2 end))) / bigint_to_double(case when ((#2 - integer_to_bigint(1)) = integer_to_bigint(0)) then null else (#2 - integer_to_bigint(1)) end)), integer_to_double(0)) end)) - Reduce aggregates=[sum((#0 * #0)), sum(#0), count(#0), sum(#0)] + Map (sqrtf64(case when (((#0{?column?} - ((#1{?column?} * #1{?column?}) / bigint_to_double(case when (#2{?column?} = integer_to_bigint(0)) then null else #2{?column?} end))) / bigint_to_double(case when ((#2{?column?} - integer_to_bigint(1)) = integer_to_bigint(0)) then null else (#2{?column?} - integer_to_bigint(1)) end))) IS NULL then null else greatest(((#0{?column?} - ((#1{?column?} * #1{?column?}) / bigint_to_double(case when (#2{?column?} = integer_to_bigint(0)) then null else #2{?column?} end))) / bigint_to_double(case when ((#2{?column?} - integer_to_bigint(1)) = integer_to_bigint(0)) then null else (#2{?column?} - integer_to_bigint(1)) end)), integer_to_double(0)) end)) + Reduce aggregates=[sum((#0{x} * #0{x})), sum(#0{x}), count(#0{x}), sum(#0{x})] Get materialize.public.t_variance Target cluster: quickstart diff --git a/test/sqllogictest/attributes/mir_arity.slt b/test/sqllogictest/attributes/mir_arity.slt index 45c5ba0ee30a3..b336af76ad0b0 100644 --- a/test/sqllogictest/attributes/mir_arity.slt +++ b/test/sqllogictest/attributes/mir_arity.slt @@ -121,14 +121,14 @@ SELECT u.g as g, w.g as h FROM u, u as w WHERE u.g = w.g Explained Query: With cte l0 = - ArrangeBy keys=[[#0]] // { arity: 1 } + ArrangeBy keys=[[#0{g}]] // { arity: 1 } Project (#2) // { arity: 1 } Filter (#0{c}) IS NOT NULL // { arity: 3 } Map ((#0{c} + 1)) // { arity: 3 } ReadIndex on=u u_d_idx=[*** full scan ***] // { arity: 2 } Return // { arity: 2 } Project (#0, #0) // { arity: 2 } - Join on=(#0 = #1) type=differential // { arity: 2 } + Join on=(#0{g} = #1{g}) type=differential // { arity: 2 } Get l0 // { arity: 1 } Get l0 // { arity: 1 } diff --git a/test/sqllogictest/autogenerated/all_parts_essential.slt b/test/sqllogictest/autogenerated/all_parts_essential.slt index 5ce347b953b59..a068211b94921 100644 --- a/test/sqllogictest/autogenerated/all_parts_essential.slt +++ b/test/sqllogictest/autogenerated/all_parts_essential.slt @@ -199,7 +199,7 @@ Explained Query: Filter ((#4{l_quantity} = 24) OR ((#3{l_linenumber} = 6) AND (#4{l_quantity} <= 4) AND (#4{l_quantity} >= 3))) // { arity: 25 } Join on=(#0{l_orderkey} = #16{o_orderkey}) type=differential // { arity: 25 } implementation - %0:lineitem[#0]KAeif » %1:orders[#0]KAeif + %0:lineitem[#0{l_orderkey}]KAeif » %1:orders[#0{o_orderkey}]KAeif ArrangeBy keys=[[#0{l_orderkey}]] // { arity: 16 } ReadIndex on=lineitem fk_lineitem_orderkey=[differential join] // { arity: 16 } ArrangeBy keys=[[#0{o_orderkey}]] // { arity: 9 } @@ -246,9 +246,9 @@ Explained Query: Filter (#11{l_commitdate} > #20{o_orderdate}) AND (#10{l_shipdate} >= #20{o_orderdate}) AND (#30{c_acctbal} >= #19{o_totalprice}) // { arity: 33 } Join on=(#0{l_orderkey} = #16{o_orderkey} AND #17{o_custkey} = #25{c_custkey}) type=delta // { arity: 33 } implementation - %0:lineitem » %1:orders[#0]KA » %2:customer[#0]KA - %1:orders » %0:lineitem[#0]KA » %2:customer[#0]KA - %2:customer » %1:orders[#1]KA » %0:lineitem[#0]KA + %0:lineitem » %1:orders[#0{o_orderkey}]KA » %2:customer[#0{c_custkey}]KA + %1:orders » %0:lineitem[#0{l_orderkey}]KA » %2:customer[#0{c_custkey}]KA + %2:customer » %1:orders[#1{o_custkey}]KA » %0:lineitem[#0{l_orderkey}]KA ArrangeBy keys=[[#0{l_orderkey}]] // { arity: 16 } ReadIndex on=lineitem fk_lineitem_orderkey=[delta join 1st input (full scan)] // { arity: 16 } ArrangeBy keys=[[#0{o_orderkey}], [#1{o_custkey}]] // { arity: 9 } @@ -312,9 +312,9 @@ Explained Query: Filter (#10{l_shipdate} <= 1995-11-14) AND (#30{c_acctbal} <= 12907776) AND (#10{l_shipdate} >= 1995-04-19) AND (#30{c_acctbal} >= #5{l_extendedprice}) // { arity: 33 } Join on=(#0{l_orderkey} = #16{o_orderkey} AND #17{o_custkey} = #25{c_custkey}) type=delta // { arity: 33 } implementation - %0:lineitem » %1:orders[#0]KA » %2:customer[#0]KAif - %1:orders » %0:lineitem[#0]KAiif » %2:customer[#0]KAif - %2:customer » %1:orders[#1]KA » %0:lineitem[#0]KAiif + %0:lineitem » %1:orders[#0{o_orderkey}]KA » %2:customer[#0{c_custkey}]KAif + %1:orders » %0:lineitem[#0{l_orderkey}]KAiif » %2:customer[#0{c_custkey}]KAif + %2:customer » %1:orders[#1{o_custkey}]KA » %0:lineitem[#0{l_orderkey}]KAiif ArrangeBy keys=[[#0{l_orderkey}]] // { arity: 16 } ReadIndex on=lineitem fk_lineitem_orderkey=[delta join 1st input (full scan)] // { arity: 16 } ArrangeBy keys=[[#0{o_orderkey}], [#1{o_custkey}]] // { arity: 9 } @@ -386,9 +386,9 @@ Explained Query: Filter (#13{c_acctbal} < #6{o_totalprice}) AND (#13{c_acctbal} <= #3{l_extendedprice}) // { arity: 16 } Join on=(#4{l_receiptdate} = #7{o_orderdate} AND #5{o_custkey} = #8{c_custkey}) type=delta // { arity: 16 } implementation - %0:lineitem » %1:orders[#2]K » %2:customer[#0]KA - %1:orders » %2:customer[#0]KA » %0:lineitem[#4]Kf - %2:customer » %1:orders[#0]KA » %0:lineitem[#4]Kf + %0:lineitem » %1:orders[#2{o_orderdate}]K » %2:customer[#0{c_custkey}]KA + %1:orders » %2:customer[#0{c_custkey}]KA » %0:lineitem[#4{l_receiptdate}]Kf + %2:customer » %1:orders[#0{o_custkey}]KA » %0:lineitem[#4{l_receiptdate}]Kf ArrangeBy keys=[[#4{l_receiptdate}]] // { arity: 5 } Project (#2{l_suppkey}..=#5{l_extendedprice}, #12{l_receiptdate}) // { arity: 5 } Filter (#3{l_linenumber} != 1) AND (#3{l_linenumber} != 2) AND (#3{l_linenumber} != 6) // { arity: 16 } @@ -436,7 +436,7 @@ Explained Query: Project (#0{l_orderkey}..=#4{o_orderkey}) // { arity: 5 } Join on=(#2{l_commitdate} = #5{o_orderdate}) type=differential // { arity: 6 } implementation - %0:lineitem[#2]K » %1:orders[#1]K + %0:lineitem[#2{l_commitdate}]K » %1:orders[#1{o_orderdate}]K ArrangeBy keys=[[#2{l_commitdate}]] // { arity: 4 } Project (#0{l_orderkey}, #4{l_quantity}, #11{l_commitdate}, #12{l_receiptdate}) // { arity: 4 } ReadIndex on=lineitem pk_lineitem_orderkey_linenumber=[*** full scan ***] // { arity: 16 } @@ -456,7 +456,7 @@ Explained Query: Project (#0{l_quantity}) // { arity: 1 } Join on=(#1{l_commitdate} = #2{l_commitdate}) type=differential // { arity: 3 } implementation - %1[#0]UKA » %0:l1[#1]Kif + %1[#0]UKA » %0:l1[#1{l_commitdate}]Kif ArrangeBy keys=[[#1{l_commitdate}]] // { arity: 2 } Get l1 // { arity: 2 } ArrangeBy keys=[[#0{l_commitdate}]] // { arity: 1 } @@ -508,9 +508,9 @@ Explained Query: Filter (#12{c_acctbal} <= #5{o_totalprice}) AND ((#1{l_quantity} = 7) OR (#1{l_quantity} = 33) OR ((#1{l_quantity} = 17) AND (#13{c_comment} <= "x") AND (#13{c_comment} >= "s"))) // { arity: 14 } Join on=(#0{l_orderkey} = #2{o_orderkey}) type=delta // { arity: 14 } implementation - %0:lineitem » %1:orders[#0]KA » %2:customer[×] - %1:orders » %0:lineitem[#0]KAef » %2:customer[×] - %2:customer » %0:lineitem[×]ef » %1:orders[#0]KA + %0:lineitem » %1:orders[#0{o_orderkey}]KA » %2:customer[×] + %1:orders » %0:lineitem[#0{l_orderkey}]KAef » %2:customer[×] + %2:customer » %0:lineitem[×]ef » %1:orders[#0{o_orderkey}]KA ArrangeBy keys=[[], [#0{l_orderkey}]] // { arity: 2 } Project (#0{l_orderkey}, #4{l_quantity}) // { arity: 2 } Filter ((#4{l_quantity} = 7) OR (#4{l_quantity} = 17) OR (#4{l_quantity} = 33)) // { arity: 16 } @@ -567,9 +567,9 @@ Explained Query: Filter (#4{l_quantity} <= 30) AND (#12{l_receiptdate} <= 1998-11-27) AND (#12{l_receiptdate} <= 1992-11-22) AND (#4{l_quantity} >= 1) AND (#12{l_receiptdate} >= 1992-06-21) AND (#12{l_receiptdate} >= 1992-07-13) // { arity: 33 } Join on=(#0{l_orderkey} = #16{o_orderkey} AND #17{o_custkey} = #25{c_custkey}) type=delta // { arity: 33 } implementation - %0:lineitem » %1:orders[#0]KA » %2:customer[#0]KA - %1:orders » %0:lineitem[#0]KAiiiiiif » %2:customer[#0]KA - %2:customer » %1:orders[#1]KA » %0:lineitem[#0]KAiiiiiif + %0:lineitem » %1:orders[#0{o_orderkey}]KA » %2:customer[#0{c_custkey}]KA + %1:orders » %0:lineitem[#0{l_orderkey}]KAiiiiiif » %2:customer[#0{c_custkey}]KA + %2:customer » %1:orders[#1{o_custkey}]KA » %0:lineitem[#0{l_orderkey}]KAiiiiiif ArrangeBy keys=[[#0{l_orderkey}]] // { arity: 16 } ReadIndex on=lineitem fk_lineitem_orderkey=[delta join 1st input (full scan)] // { arity: 16 } ArrangeBy keys=[[#0{o_orderkey}], [#1{o_custkey}]] // { arity: 9 } @@ -626,9 +626,9 @@ Explained Query: Filter (#1{l_shipdate} < #5{o_orderdate}) AND (#11{c_acctbal} > #4{o_totalprice}) AND (#11{c_acctbal} >= #0{l_extendedprice}) // { arity: 14 } Join on=(#3{o_custkey} = #6{c_custkey}) type=delta // { arity: 14 } implementation - %0:lineitem » %1:orders[×] » %2:customer[#0]KA - %1:orders » %2:customer[#0]KA » %0:lineitem[×]f - %2:customer » %1:orders[#1]KA » %0:lineitem[×]f + %0:lineitem » %1:orders[×] » %2:customer[#0{c_custkey}]KA + %1:orders » %2:customer[#0{c_custkey}]KA » %0:lineitem[×]f + %2:customer » %1:orders[#1{o_custkey}]KA » %0:lineitem[×]f ArrangeBy keys=[[]] // { arity: 2 } Project (#5{l_extendedprice}, #10{l_shipdate}) // { arity: 2 } Filter (#3{l_linenumber} != 4) // { arity: 16 } @@ -695,9 +695,9 @@ Explained Query: Filter (#0{l_orderkey} <= 280) AND (#0{l_orderkey} <= 289) AND (#0{l_orderkey} >= 62) AND (#0{l_orderkey} >= 117) AND (#10{l_shipdate} > #20{o_orderdate}) // { arity: 33 } Join on=(#0{l_orderkey} = #16{o_orderkey} AND #17{o_custkey} = #25{c_custkey}) type=delta // { arity: 33 } implementation - %0:lineitem » %1:orders[#0]KAiiiif » %2:customer[#0]KA - %1:orders » %0:lineitem[#0]KAiiiif » %2:customer[#0]KA - %2:customer » %1:orders[#1]KAiiiif » %0:lineitem[#0]KAiiiif + %0:lineitem » %1:orders[#0{o_orderkey}]KAiiiif » %2:customer[#0{c_custkey}]KA + %1:orders » %0:lineitem[#0{l_orderkey}]KAiiiif » %2:customer[#0{c_custkey}]KA + %2:customer » %1:orders[#1{o_custkey}]KAiiiif » %0:lineitem[#0{l_orderkey}]KAiiiif ArrangeBy keys=[[#0{l_orderkey}]] // { arity: 16 } ReadIndex on=lineitem fk_lineitem_orderkey=[delta join 1st input (full scan)] // { arity: 16 } ArrangeBy keys=[[#0{o_orderkey}], [#1{o_custkey}]] // { arity: 9 } @@ -749,9 +749,9 @@ Explained Query: Filter (#0{l_orderkey} >= 53) AND (#1{l_extendedprice} < #5{o_totalprice}) AND (#12{c_acctbal} < #5{o_totalprice}) // { arity: 13 } Join on=(#0{l_orderkey} = #2{o_orderkey}) type=delta // { arity: 13 } implementation - %0:lineitem » %1:orders[#0]KAif » %2:customer[×] - %1:orders » %0:lineitem[#0]KAiif » %2:customer[×] - %2:customer » %0:lineitem[×]iif » %1:orders[#0]KAif + %0:lineitem » %1:orders[#0{o_orderkey}]KAif » %2:customer[×] + %1:orders » %0:lineitem[#0{l_orderkey}]KAiif » %2:customer[×] + %2:customer » %0:lineitem[×]iif » %1:orders[#0{o_orderkey}]KAif ArrangeBy keys=[[], [#0{l_orderkey}]] // { arity: 2 } Project (#0{l_orderkey}, #5{l_extendedprice}) // { arity: 2 } Filter (#10{l_shipdate} <= 1994-03-17) AND (#0{l_orderkey} >= 53) // { arity: 16 } diff --git a/test/sqllogictest/cardinality.slt b/test/sqllogictest/cardinality.slt index c4a0fb0fc8aa9..8a793de23bee0 100644 --- a/test/sqllogictest/cardinality.slt +++ b/test/sqllogictest/cardinality.slt @@ -71,7 +71,7 @@ Explained Query: Project (#0{x}, #1{y}, #0{x}, #3{y}) Join on=(#0{x} = #2{x}) type=differential implementation - %0:l0[#0]KA|4| » %1:l0[#0]KA|4| + %0:l0[#0{x}]KA|4| » %1:l0[#0{x}]KA|4| Get l0 Get l0 @@ -92,7 +92,7 @@ Explained Query: Project (#0{x}, #1{y}, #0{x}, #3{y}) Join on=(#0{x} = #2{x}) type=differential implementation - %0:t[#0]KA|4| » %1:t2[#0]KA|10000| + %0:t[#0{x}]KA|4| » %1:t2[#0{x}]KA|10000| ArrangeBy keys=[[#0{x}]] ReadIndex on=t t_x=[differential join] ArrangeBy keys=[[#0{x}]] @@ -162,7 +162,7 @@ Explained Query: With Mutually Recursive cte l0 = Project (#1, #3{person2id}) - Join on=(#0 = #2{person1id}) type=differential + Join on=(#0{src} = #2{person1id}) type=differential ArrangeBy keys=[[#0{person2id}]] Get l3 ArrangeBy keys=[[#0{person1id}]] @@ -179,11 +179,11 @@ Explained Query: Join on=(#0{person2id} = #1{person2id}) type=differential ArrangeBy keys=[[#0{person2id}]] Project (#0{person2id}) - Filter #1 + Filter #1{dir} Get l1 ArrangeBy keys=[[#0{person2id}]] Project (#0{person2id}) - Filter NOT(#1) + Filter NOT(#1{dir}) Get l1 cte l3 = Distinct project=[#0{person2id}, #1] @@ -260,7 +260,7 @@ Explained Query: With Mutually Recursive cte l0 = Project (#1, #3{person2id}) - Join on=(#0 = #2{person1id}) type=differential + Join on=(#0{src} = #2{person1id}) type=differential ArrangeBy keys=[[#0{person2id}]] Get l3 ArrangeBy keys=[[#0{person1id}]] @@ -277,11 +277,11 @@ Explained Query: Join on=(#0{person2id} = #1{person2id}) type=differential ArrangeBy keys=[[#0{person2id}]] Project (#0{person2id}) - Filter #1 + Filter #1{dir} Get l1 ArrangeBy keys=[[#0{person2id}]] Project (#0{person2id}) - Filter NOT(#1) + Filter NOT(#1{dir}) Get l1 cte l3 = Distinct project=[#0{person2id}, #1] @@ -436,16 +436,16 @@ Explained Query: Project (#0{x}, #1{y}, #0{x}, #3{y}, #0{x}, #5{y}, #0{x}, #7{y}, #0{x}, #9{y}, #0{x}, #11{y}, #0{x}, #13{y}, #0{x}, #15{y}, #0{x}, #17{y}, #0{x}, #19{y}) Join on=(#0{x} = #2{x} = #4{x} = #6{x} = #8{x} = #10{x} = #12{x} = #14{x} = #16{x} = #18{x}) type=delta implementation - %0:t » %1:t2[#0]KA|10000| » %2:t3[#0]K|169| » %9:t10[#0]K|260| » %8:t9[#0]K|273| » %5:t6[#0]K|299| » %6:t7[#0]K|299| » %7:t8[#0]K|299| » %4:t5[#0]K|494| » %3:t4[#0]K|611| - %1:t2 » %0:t[#0]KA|4| » %2:t3[#0]K|169| » %9:t10[#0]K|260| » %8:t9[#0]K|273| » %5:t6[#0]K|299| » %6:t7[#0]K|299| » %7:t8[#0]K|299| » %4:t5[#0]K|494| » %3:t4[#0]K|611| - %2:t3 » %0:t[#0]KA|4| » %1:t2[#0]KA|10000| » %9:t10[#0]K|260| » %8:t9[#0]K|273| » %5:t6[#0]K|299| » %6:t7[#0]K|299| » %7:t8[#0]K|299| » %4:t5[#0]K|494| » %3:t4[#0]K|611| - %3:t4 » %0:t[#0]KA|4| » %1:t2[#0]KA|10000| » %2:t3[#0]K|169| » %9:t10[#0]K|260| » %8:t9[#0]K|273| » %5:t6[#0]K|299| » %6:t7[#0]K|299| » %7:t8[#0]K|299| » %4:t5[#0]K|494| - %4:t5 » %0:t[#0]KA|4| » %1:t2[#0]KA|10000| » %2:t3[#0]K|169| » %9:t10[#0]K|260| » %8:t9[#0]K|273| » %5:t6[#0]K|299| » %6:t7[#0]K|299| » %7:t8[#0]K|299| » %3:t4[#0]K|611| - %5:t6 » %0:t[#0]KA|4| » %1:t2[#0]KA|10000| » %2:t3[#0]K|169| » %9:t10[#0]K|260| » %8:t9[#0]K|273| » %6:t7[#0]K|299| » %7:t8[#0]K|299| » %4:t5[#0]K|494| » %3:t4[#0]K|611| - %6:t7 » %0:t[#0]KA|4| » %1:t2[#0]KA|10000| » %2:t3[#0]K|169| » %9:t10[#0]K|260| » %8:t9[#0]K|273| » %5:t6[#0]K|299| » %7:t8[#0]K|299| » %4:t5[#0]K|494| » %3:t4[#0]K|611| - %7:t8 » %0:t[#0]KA|4| » %1:t2[#0]KA|10000| » %2:t3[#0]K|169| » %9:t10[#0]K|260| » %8:t9[#0]K|273| » %5:t6[#0]K|299| » %6:t7[#0]K|299| » %4:t5[#0]K|494| » %3:t4[#0]K|611| - %8:t9 » %0:t[#0]KA|4| » %1:t2[#0]KA|10000| » %2:t3[#0]K|169| » %9:t10[#0]K|260| » %5:t6[#0]K|299| » %6:t7[#0]K|299| » %7:t8[#0]K|299| » %4:t5[#0]K|494| » %3:t4[#0]K|611| - %9:t10 » %0:t[#0]KA|4| » %1:t2[#0]KA|10000| » %2:t3[#0]K|169| » %8:t9[#0]K|273| » %5:t6[#0]K|299| » %6:t7[#0]K|299| » %7:t8[#0]K|299| » %4:t5[#0]K|494| » %3:t4[#0]K|611| + %0:t » %1:t2[#0{x}]KA|10000| » %2:t3[#0{x}]K|169| » %9:t10[#0{x}]K|260| » %8:t9[#0{x}]K|273| » %5:t6[#0{x}]K|299| » %6:t7[#0{x}]K|299| » %7:t8[#0{x}]K|299| » %4:t5[#0{x}]K|494| » %3:t4[#0{x}]K|611| + %1:t2 » %0:t[#0{x}]KA|4| » %2:t3[#0{x}]K|169| » %9:t10[#0{x}]K|260| » %8:t9[#0{x}]K|273| » %5:t6[#0{x}]K|299| » %6:t7[#0{x}]K|299| » %7:t8[#0{x}]K|299| » %4:t5[#0{x}]K|494| » %3:t4[#0{x}]K|611| + %2:t3 » %0:t[#0{x}]KA|4| » %1:t2[#0{x}]KA|10000| » %9:t10[#0{x}]K|260| » %8:t9[#0{x}]K|273| » %5:t6[#0{x}]K|299| » %6:t7[#0{x}]K|299| » %7:t8[#0{x}]K|299| » %4:t5[#0{x}]K|494| » %3:t4[#0{x}]K|611| + %3:t4 » %0:t[#0{x}]KA|4| » %1:t2[#0{x}]KA|10000| » %2:t3[#0{x}]K|169| » %9:t10[#0{x}]K|260| » %8:t9[#0{x}]K|273| » %5:t6[#0{x}]K|299| » %6:t7[#0{x}]K|299| » %7:t8[#0{x}]K|299| » %4:t5[#0{x}]K|494| + %4:t5 » %0:t[#0{x}]KA|4| » %1:t2[#0{x}]KA|10000| » %2:t3[#0{x}]K|169| » %9:t10[#0{x}]K|260| » %8:t9[#0{x}]K|273| » %5:t6[#0{x}]K|299| » %6:t7[#0{x}]K|299| » %7:t8[#0{x}]K|299| » %3:t4[#0{x}]K|611| + %5:t6 » %0:t[#0{x}]KA|4| » %1:t2[#0{x}]KA|10000| » %2:t3[#0{x}]K|169| » %9:t10[#0{x}]K|260| » %8:t9[#0{x}]K|273| » %6:t7[#0{x}]K|299| » %7:t8[#0{x}]K|299| » %4:t5[#0{x}]K|494| » %3:t4[#0{x}]K|611| + %6:t7 » %0:t[#0{x}]KA|4| » %1:t2[#0{x}]KA|10000| » %2:t3[#0{x}]K|169| » %9:t10[#0{x}]K|260| » %8:t9[#0{x}]K|273| » %5:t6[#0{x}]K|299| » %7:t8[#0{x}]K|299| » %4:t5[#0{x}]K|494| » %3:t4[#0{x}]K|611| + %7:t8 » %0:t[#0{x}]KA|4| » %1:t2[#0{x}]KA|10000| » %2:t3[#0{x}]K|169| » %9:t10[#0{x}]K|260| » %8:t9[#0{x}]K|273| » %5:t6[#0{x}]K|299| » %6:t7[#0{x}]K|299| » %4:t5[#0{x}]K|494| » %3:t4[#0{x}]K|611| + %8:t9 » %0:t[#0{x}]KA|4| » %1:t2[#0{x}]KA|10000| » %2:t3[#0{x}]K|169| » %9:t10[#0{x}]K|260| » %5:t6[#0{x}]K|299| » %6:t7[#0{x}]K|299| » %7:t8[#0{x}]K|299| » %4:t5[#0{x}]K|494| » %3:t4[#0{x}]K|611| + %9:t10 » %0:t[#0{x}]KA|4| » %1:t2[#0{x}]KA|10000| » %2:t3[#0{x}]K|169| » %8:t9[#0{x}]K|273| » %5:t6[#0{x}]K|299| » %6:t7[#0{x}]K|299| » %7:t8[#0{x}]K|299| » %4:t5[#0{x}]K|494| » %3:t4[#0{x}]K|611| ArrangeBy keys=[[#0{x}]] ReadIndex on=t t_x=[delta join 1st input (full scan)] ArrangeBy keys=[[#0{x}]] @@ -501,8 +501,8 @@ Explained Query: - (1) cte l1 = Project (#1) // { cardinality: "" } - Filter (#0 < 7) // { cardinality: "" } - Map ((#0 + 1)) // { cardinality: "" } + Filter (#0{x} < 7) // { cardinality: "" } + Map ((#0{x} + 1)) // { cardinality: "" } Get l0 // { cardinality: "" } Return // { cardinality: "" } Get l0 // { cardinality: "" } diff --git a/test/sqllogictest/chbench.slt b/test/sqllogictest/chbench.slt index 4d340091a1a52..75173946a7428 100644 --- a/test/sqllogictest/chbench.slt +++ b/test/sqllogictest/chbench.slt @@ -318,12 +318,12 @@ Explained Query: Filter (#10{s_quantity}) IS NOT NULL // { arity: 32 } Join on=(#0{i_id} = #8{s_i_id} = #30{s_i_id} AND #2{su_suppkey} = #25{s_su_suppkey} AND #5{su_nationkey} = #26{n_nationkey} AND #10{s_quantity} = #31{min_s_quantity} AND #28{n_regionkey} = #29{r_regionkey}) type=delta // { arity: 32 } implementation - %0:item » %5[#0]UKA » %2:stock[#0]KA » %1:supplier[#0]UK » %3:nation[#0]UK » %4:l0[#0]UKlf - %1:supplier » %3:nation[#0]UK » %4:l0[#0]UKlf » %2:stock[#17]KA » %5[#0]UKA » %0:item[#0]UKlf - %2:stock » %5[#0]UKA » %0:item[#0]UKlf » %1:supplier[#0]UK » %3:nation[#0]UK » %4:l0[#0]UKlf - %3:nation » %4:l0[#0]UKlf » %1:supplier[#3]KA » %2:stock[#17]KA » %5[#0]UKA » %0:item[#0]UKlf - %4:l0 » %3:nation[#2]KA » %1:supplier[#3]KA » %2:stock[#17]KA » %5[#0]UKA » %0:item[#0]UKlf - %5 » %0:item[#0]UKlf » %2:stock[#0]KA » %1:supplier[#0]UK » %3:nation[#0]UK » %4:l0[#0]UKlf + %0:item » %5[#0]UKA » %2:stock[#0{s_i_id}]KA » %1:supplier[#0{su_suppkey}]UK » %3:nation[#0{n_nationkey}]UK » %4:l0[#0{r_regionkey}]UKlf + %1:supplier » %3:nation[#0{n_nationkey}]UK » %4:l0[#0{r_regionkey}]UKlf » %2:stock[#17{s_su_suppkey}]KA » %5[#0]UKA » %0:item[#0{i_id}]UKlf + %2:stock » %5[#0]UKA » %0:item[#0{i_id}]UKlf » %1:supplier[#0{su_suppkey}]UK » %3:nation[#0{n_nationkey}]UK » %4:l0[#0{r_regionkey}]UKlf + %3:nation » %4:l0[#0{r_regionkey}]UKlf » %1:supplier[#3{su_nationkey}]KA » %2:stock[#17{s_su_suppkey}]KA » %5[#0]UKA » %0:item[#0{i_id}]UKlf + %4:l0 » %3:nation[#2{n_regionkey}]KA » %1:supplier[#3{su_nationkey}]KA » %2:stock[#17{s_su_suppkey}]KA » %5[#0]UKA » %0:item[#0{i_id}]UKlf + %5 » %0:item[#0{i_id}]UKlf » %2:stock[#0{s_i_id}]KA » %1:supplier[#0{su_suppkey}]UK » %3:nation[#0{n_nationkey}]UK » %4:l0[#0{r_regionkey}]UKlf ArrangeBy keys=[[#0{i_id}]] // { arity: 2 } Project (#0{i_id}, #2{i_name}) // { arity: 2 } Filter like["%b"](padchar(#4{i_data})) // { arity: 5 } @@ -342,10 +342,10 @@ Explained Query: Project (#0{s_i_id}, #2{s_quantity}) // { arity: 2 } Join on=(#17{s_su_suppkey} = #18{su_suppkey} AND #19{su_nationkey} = #20{n_nationkey} AND #21{n_regionkey} = #22{r_regionkey}) type=delta // { arity: 23 } implementation - %0:stock » %1:supplier[#0]UK » %2:nation[#0]UK » %3:l0[#0]UKlf - %1:supplier » %2:nation[#0]UK » %3:l0[#0]UKlf » %0:stock[#17]KA - %2:nation » %3:l0[#0]UKlf » %1:supplier[#1]KA » %0:stock[#17]KA - %3:l0 » %2:nation[#1]KA » %1:supplier[#1]KA » %0:stock[#17]KA + %0:stock » %1:supplier[#0{su_suppkey}]UK » %2:nation[#0{n_nationkey}]UK » %3:l0[#0{r_regionkey}]UKlf + %1:supplier » %2:nation[#0{n_nationkey}]UK » %3:l0[#0{r_regionkey}]UKlf » %0:stock[#17{s_su_suppkey}]KA + %2:nation » %3:l0[#0{r_regionkey}]UKlf » %1:supplier[#1{su_nationkey}]KA » %0:stock[#17{s_su_suppkey}]KA + %3:l0 » %2:nation[#1{n_regionkey}]KA » %1:supplier[#1{su_nationkey}]KA » %0:stock[#17{s_su_suppkey}]KA ArrangeBy keys=[[#17{s_su_suppkey}]] // { arity: 18 } ReadIndex on=stock fk_stock_supplier=[delta join 1st input (full scan)] // { arity: 18 } ArrangeBy keys=[[#0{su_suppkey}], [#1{su_nationkey}]] // { arity: 2 } @@ -397,10 +397,10 @@ Explained Query: Project (#1{c_d_id}..=#3{no_o_id}, #10{o_entry_d}, #19{ol_amount}) // { arity: 5 } Join on=(#0{c_id} = #9{o_c_id} AND #1{c_d_id} = #4{no_d_id} = #7{o_d_id} = #12{ol_d_id} AND #2{c_w_id} = #5{no_w_id} = #8{o_w_id} = #13{ol_w_id} AND #3{no_o_id} = #6{o_id} = #11{ol_o_id}) type=delta // { arity: 21 } implementation - %0:customer » %2:order[#2, #1, #3]KKKAif » %1:neworder[#0..=#2]UKKK » %3:orderline[#2, #1, #0]KKKA - %1:neworder » %2:order[#0..=#2]UKKKif » %0:customer[#0..=#2]UKKKlf » %3:orderline[#2, #1, #0]KKKA - %2:order » %0:customer[#0..=#2]UKKKlf » %1:neworder[#0..=#2]UKKK » %3:orderline[#2, #1, #0]KKKA - %3:orderline » %2:order[#0..=#2]UKKKif » %0:customer[#0..=#2]UKKKlf » %1:neworder[#0..=#2]UKKK + %0:customer » %2:order[#2{o_w_id}, #1{o_d_id}, #3{o_c_id}]KKKAif » %1:neworder[#0{no_o_id}..=#2{no_w_id}]UKKK » %3:orderline[#2{ol_w_id}, #1{ol_d_id}, #0{ol_o_id}]KKKA + %1:neworder » %2:order[#0{o_id}..=#2{o_w_id}]UKKKif » %0:customer[#0{c_id}..=#2{c_w_id}]UKKKlf » %3:orderline[#2{ol_w_id}, #1{ol_d_id}, #0{ol_o_id}]KKKA + %2:order » %0:customer[#0{c_id}..=#2{c_w_id}]UKKKlf » %1:neworder[#0{no_o_id}..=#2{no_w_id}]UKKK » %3:orderline[#2{ol_w_id}, #1{ol_d_id}, #0{ol_o_id}]KKKA + %3:orderline » %2:order[#0{o_id}..=#2{o_w_id}]UKKKif » %0:customer[#0{c_id}..=#2{c_w_id}]UKKKlf » %1:neworder[#0{no_o_id}..=#2{no_w_id}]UKKK ArrangeBy keys=[[#0{c_id}..=#2{c_w_id}]] // { arity: 3 } Project (#0{c_id}..=#2{c_w_id}) // { arity: 3 } Filter like["A%"](padchar(#9{c_state})) // { arity: 22 } @@ -465,7 +465,7 @@ Explained Query: Filter (#10{ol_delivery_d} >= #3{o_entry_d}) // { arity: 14 } Join on=(#0{o_id} = #4{ol_o_id} AND #1{o_d_id} = #5{ol_d_id} AND #2{o_w_id} = #6{ol_w_id}) type=differential // { arity: 14 } implementation - %0:l0[#2, #1, #0]UKKKiif » %1:orderline[#2, #1, #0]KKKAiif + %0:l0[#2{o_w_id}, #1{o_d_id}, #0{o_id}]UKKKiif » %1:orderline[#2{ol_w_id}, #1{ol_d_id}, #0{ol_o_id}]KKKAiif ArrangeBy keys=[[#2{o_w_id}, #1{o_d_id}, #0{o_id}]] // { arity: 4 } Project (#0{o_id}..=#3{o_entry_d}) // { arity: 4 } Get l0 // { arity: 5 } @@ -510,13 +510,13 @@ Explained Query: Project (#16{ol_amount}, #24{n_name}) // { arity: 2 } Join on=(#0{c_id} = #7{o_c_id} AND #1{c_d_id} = #5{o_d_id} = #9{ol_d_id} AND #2{c_w_id} = #6{o_w_id} = #10{ol_w_id} = #19{s_w_id} AND #3{c_n_nationkey} = #22{su_nationkey} = #23{n_nationkey} AND #4{o_id} = #8{ol_o_id} AND #12{ol_i_id} = #18{s_i_id} AND #20{s_su_suppkey} = #21{su_suppkey} AND #25{n_regionkey} = #26{r_regionkey}) type=delta // { arity: 27 } implementation - %0:customer » %5:nation[#0]UK » %6:region[#0]UKef » %1:order[#2, #1, #3]KKKAif » %2:orderline[#2, #1, #0]KKKA » %3:stock[#0, #1]UKK » %4:supplier[#0, #1]UKK - %1:order » %0:customer[#0..=#2]UKKK » %5:nation[#0]UK » %6:region[#0]UKef » %2:orderline[#2, #1, #0]KKKA » %3:stock[#0, #1]UKK » %4:supplier[#0, #1]UKK - %2:orderline » %1:order[#0..=#2]UKKKif » %0:customer[#0..=#2]UKKK » %3:stock[#0, #1]UKK » %4:supplier[#0, #1]UKK » %5:nation[#0]UK » %6:region[#0]UKef - %3:stock » %4:supplier[#0]UK » %5:nation[#0]UK » %6:region[#0]UKef » %0:customer[#3]KA » %1:order[#2, #1, #3]KKKAif » %2:orderline[#2, #1, #0]KKKA - %4:supplier » %5:nation[#0]UK » %6:region[#0]UKef » %0:customer[#3]KA » %1:order[#2, #1, #3]KKKAif » %2:orderline[#2, #1, #0]KKKA » %3:stock[#0..=#2]UKKK - %5:nation » %6:region[#0]UKef » %0:customer[#3]KA » %1:order[#2, #1, #3]KKKAif » %2:orderline[#2, #1, #0]KKKA » %3:stock[#0, #1]UKK » %4:supplier[#0, #1]UKK - %6:region » %5:nation[#2]KA » %0:customer[#3]KA » %1:order[#2, #1, #3]KKKAif » %2:orderline[#2, #1, #0]KKKA » %3:stock[#0, #1]UKK » %4:supplier[#0, #1]UKK + %0:customer » %5:nation[#0{n_nationkey}]UK » %6:region[#0{r_regionkey}]UKef » %1:order[#2{o_w_id}, #1{o_d_id}, #3{o_c_id}]KKKAif » %2:orderline[#2{ol_w_id}, #1{ol_d_id}, #0{ol_o_id}]KKKA » %3:stock[#0{s_i_id}, #1{s_w_id}]UKK » %4:supplier[#0{su_suppkey}, #1{su_nationkey}]UKK + %1:order » %0:customer[#0{c_id}..=#2{c_w_id}]UKKK » %5:nation[#0{n_nationkey}]UK » %6:region[#0{r_regionkey}]UKef » %2:orderline[#2{ol_w_id}, #1{ol_d_id}, #0{ol_o_id}]KKKA » %3:stock[#0{s_i_id}, #1{s_w_id}]UKK » %4:supplier[#0{su_suppkey}, #1{su_nationkey}]UKK + %2:orderline » %1:order[#0{o_id}..=#2{o_w_id}]UKKKif » %0:customer[#0{c_id}..=#2{c_w_id}]UKKK » %3:stock[#0{s_i_id}, #1{s_w_id}]UKK » %4:supplier[#0{su_suppkey}, #1{su_nationkey}]UKK » %5:nation[#0{n_nationkey}]UK » %6:region[#0{r_regionkey}]UKef + %3:stock » %4:supplier[#0{su_suppkey}]UK » %5:nation[#0{n_nationkey}]UK » %6:region[#0{r_regionkey}]UKef » %0:customer[#3{c_n_nationkey}]KA » %1:order[#2{o_w_id}, #1{o_d_id}, #3{o_c_id}]KKKAif » %2:orderline[#2{ol_w_id}, #1{ol_d_id}, #0{ol_o_id}]KKKA + %4:supplier » %5:nation[#0{n_nationkey}]UK » %6:region[#0{r_regionkey}]UKef » %0:customer[#3{c_n_nationkey}]KA » %1:order[#2{o_w_id}, #1{o_d_id}, #3{o_c_id}]KKKAif » %2:orderline[#2{ol_w_id}, #1{ol_d_id}, #0{ol_o_id}]KKKA » %3:stock[#0{s_i_id}..=#2{s_su_suppkey}]UKKK + %5:nation » %6:region[#0{r_regionkey}]UKef » %0:customer[#3{c_n_nationkey}]KA » %1:order[#2{o_w_id}, #1{o_d_id}, #3{o_c_id}]KKKAif » %2:orderline[#2{ol_w_id}, #1{ol_d_id}, #0{ol_o_id}]KKKA » %3:stock[#0{s_i_id}, #1{s_w_id}]UKK » %4:supplier[#0{su_suppkey}, #1{su_nationkey}]UKK + %6:region » %5:nation[#2{n_regionkey}]KA » %0:customer[#3{c_n_nationkey}]KA » %1:order[#2{o_w_id}, #1{o_d_id}, #3{o_c_id}]KKKAif » %2:orderline[#2{ol_w_id}, #1{ol_d_id}, #0{ol_o_id}]KKKA » %3:stock[#0{s_i_id}, #1{s_w_id}]UKK » %4:supplier[#0{su_suppkey}, #1{su_nationkey}]UKK ArrangeBy keys=[[#0{c_id}..=#2{c_w_id}], [#3{c_n_nationkey}]] // { arity: 4 } Project (#0{c_id}..=#2{c_w_id}, #21{c_n_nationkey}) // { arity: 4 } Filter (#21{c_n_nationkey}) IS NOT NULL // { arity: 22 } @@ -635,13 +635,13 @@ Explained Query: Map (date_to_timestamp(#11{ol_delivery_d})) // { arity: 30 } Join on=(#0{su_suppkey} = #4{s_su_suppkey} AND #1{su_nationkey} = #25{n_nationkey} AND #2{s_i_id} = #9{ol_i_id} AND #3{s_w_id} = #10{ol_supply_w_id} AND #5{ol_o_id} = #15{o_id} AND #6{ol_d_id} = #16{o_d_id} = #21{c_d_id} AND #7{ol_w_id} = #17{o_w_id} = #22{c_w_id} AND #18{o_c_id} = #20{c_id} AND #24{c_n_nationkey} = #27{n_nationkey}) type=delta // { arity: 29 } implementation - %0:supplier » %5:l0[#0]UKef » %1:stock[#2]KA » %2:orderline[#5, #4]KKAiif » %3:order[#0..=#2]UKKK » %4:customer[#0..=#2]UKKK » %6:l0[#0]UKef - %1:stock » %0:supplier[#0]UK » %5:l0[#0]UKef » %2:orderline[#5, #4]KKAiif » %3:order[#0..=#2]UKKK » %4:customer[#0..=#2]UKKK » %6:l0[#0]UKef - %2:orderline » %3:order[#0..=#2]UKKK » %4:customer[#0..=#2]UKKK » %1:stock[#0, #1]UKK » %6:l0[#0]UKef » %0:supplier[#0]UK » %5:l0[#0]UKef - %3:order » %4:customer[#0..=#2]UKKK » %6:l0[#0]UKef » %2:orderline[#2, #1, #0]KKKAiif » %1:stock[#0, #1]UKK » %0:supplier[#0]UK » %5:l0[#0]UKef - %4:customer » %6:l0[#0]UKef » %3:order[#2, #1, #3]KKKA » %2:orderline[#2, #1, #0]KKKAiif » %1:stock[#0, #1]UKK » %0:supplier[#0]UK » %5:l0[#0]UKef - %5:l0 » %0:supplier[#1]KA » %1:stock[#2]KA » %2:orderline[#5, #4]KKAiif » %3:order[#0..=#2]UKKK » %4:customer[#0..=#2]UKKK » %6:l0[#0]UKef - %6:l0 » %4:customer[#4]KA » %3:order[#2, #1, #3]KKKA » %2:orderline[#2, #1, #0]KKKAiif » %1:stock[#0, #1]UKK » %0:supplier[#0]UK » %5:l0[#0]UKef + %0:supplier » %5:l0[#0{n_nationkey}]UKef » %1:stock[#2{s_su_suppkey}]KA » %2:orderline[#5{ol_supply_w_id}, #4{ol_i_id}]KKAiif » %3:order[#0{o_id}..=#2{o_w_id}]UKKK » %4:customer[#0{c_id}..=#2{c_w_id}]UKKK » %6:l0[#0{n_nationkey}]UKef + %1:stock » %0:supplier[#0{su_suppkey}]UK » %5:l0[#0{n_nationkey}]UKef » %2:orderline[#5{ol_supply_w_id}, #4{ol_i_id}]KKAiif » %3:order[#0{o_id}..=#2{o_w_id}]UKKK » %4:customer[#0{c_id}..=#2{c_w_id}]UKKK » %6:l0[#0{n_nationkey}]UKef + %2:orderline » %3:order[#0{o_id}..=#2{o_w_id}]UKKK » %4:customer[#0{c_id}..=#2{c_w_id}]UKKK » %1:stock[#0{s_i_id}, #1{s_w_id}]UKK » %6:l0[#0{n_nationkey}]UKef » %0:supplier[#0{su_suppkey}]UK » %5:l0[#0{n_nationkey}]UKef + %3:order » %4:customer[#0{c_id}..=#2{c_w_id}]UKKK » %6:l0[#0{n_nationkey}]UKef » %2:orderline[#2{ol_w_id}, #1{ol_d_id}, #0{ol_o_id}]KKKAiif » %1:stock[#0{s_i_id}, #1{s_w_id}]UKK » %0:supplier[#0{su_suppkey}]UK » %5:l0[#0{n_nationkey}]UKef + %4:customer » %6:l0[#0{n_nationkey}]UKef » %3:order[#2{o_w_id}, #1{o_d_id}, #3{o_c_id}]KKKA » %2:orderline[#2{ol_w_id}, #1{ol_d_id}, #0{ol_o_id}]KKKAiif » %1:stock[#0{s_i_id}, #1{s_w_id}]UKK » %0:supplier[#0{su_suppkey}]UK » %5:l0[#0{n_nationkey}]UKef + %5:l0 » %0:supplier[#1{su_nationkey}]KA » %1:stock[#2{s_su_suppkey}]KA » %2:orderline[#5{ol_supply_w_id}, #4{ol_i_id}]KKAiif » %3:order[#0{o_id}..=#2{o_w_id}]UKKK » %4:customer[#0{c_id}..=#2{c_w_id}]UKKK » %6:l0[#0{n_nationkey}]UKef + %6:l0 » %4:customer[#4{c_n_nationkey}]KA » %3:order[#2{o_w_id}, #1{o_d_id}, #3{o_c_id}]KKKA » %2:orderline[#2{ol_w_id}, #1{ol_d_id}, #0{ol_o_id}]KKKAiif » %1:stock[#0{s_i_id}, #1{s_w_id}]UKK » %0:supplier[#0{su_suppkey}]UK » %5:l0[#0{n_nationkey}]UKef ArrangeBy keys=[[#0{su_suppkey}], [#1{su_nationkey}]] // { arity: 2 } Project (#0{su_suppkey}, #3{su_nationkey}) // { arity: 2 } ReadIndex on=supplier fk_supplier_nationkey=[*** full scan ***] // { arity: 7 } @@ -711,15 +711,15 @@ Explained Query: Filter (#0{i_id} < 1000) // { arity: 30 } Join on=(#0{i_id} = #3{s_i_id} = #10{ol_i_id} AND #1{su_suppkey} = #5{s_su_suppkey} AND #2{su_nationkey} = #27{n_nationkey} AND #4{s_w_id} = #11{ol_supply_w_id} AND #6{ol_o_id} = #16{o_id} AND #7{ol_d_id} = #17{o_d_id} = #22{c_d_id} AND #8{ol_w_id} = #18{o_w_id} = #23{c_w_id} AND #19{o_c_id} = #21{c_id} AND #24{c_n_nationkey} = #25{n_nationkey} AND #26{n_regionkey} = #29{r_regionkey}) type=delta // { arity: 30 } implementation - %0:item » %2:stock[#0]KAif » %1:supplier[#0]UK » %7:nation[#0]UK » %3:orderline[#5, #4]KKAif » %4:order[#0..=#2]UKKKiif » %5:customer[#0..=#2]UKKK » %6:nation[#0]UK » %8:region[#0]UKef - %1:supplier » %7:nation[#0]UK » %2:stock[#2]KAif » %0:item[#0]UKlif » %3:orderline[#5, #4]KKAif » %4:order[#0..=#2]UKKKiif » %5:customer[#0..=#2]UKKK » %6:nation[#0]UK » %8:region[#0]UKef - %2:stock » %0:item[#0]UKlif » %1:supplier[#0]UK » %7:nation[#0]UK » %3:orderline[#5, #4]KKAif » %4:order[#0..=#2]UKKKiif » %5:customer[#0..=#2]UKKK » %6:nation[#0]UK » %8:region[#0]UKef - %3:orderline » %4:order[#0..=#2]UKKKiif » %5:customer[#0..=#2]UKKK » %2:stock[#0, #1]UKKif » %0:item[#0]UKlif » %1:supplier[#0]UK » %6:nation[#0]UK » %8:region[#0]UKef » %7:nation[#0]UK - %4:order » %5:customer[#0..=#2]UKKK » %6:nation[#0]UK » %8:region[#0]UKef » %3:orderline[#2, #1, #0]KKKAif » %2:stock[#0, #1]UKKif » %0:item[#0]UKlif » %1:supplier[#0]UK » %7:nation[#0]UK - %5:customer » %6:nation[#0]UK » %8:region[#0]UKef » %4:order[#2, #1, #3]KKKAiif » %3:orderline[#2, #1, #0]KKKAif » %2:stock[#0, #1]UKKif » %0:item[#0]UKlif » %1:supplier[#0]UK » %7:nation[#0]UK - %6:nation » %8:region[#0]UKef » %5:customer[#3]KA » %4:order[#2, #1, #3]KKKAiif » %3:orderline[#2, #1, #0]KKKAif » %2:stock[#0, #1]UKKif » %0:item[#0]UKlif » %1:supplier[#0]UK » %7:nation[#0]UK - %7:nation » %1:supplier[#1]KA » %2:stock[#2]KAif » %0:item[#0]UKlif » %3:orderline[#5, #4]KKAif » %4:order[#0..=#2]UKKKiif » %5:customer[#0..=#2]UKKK » %6:nation[#0]UK » %8:region[#0]UKef - %8:region » %6:nation[#1]KA » %5:customer[#3]KA » %4:order[#2, #1, #3]KKKAiif » %3:orderline[#2, #1, #0]KKKAif » %2:stock[#0, #1]UKKif » %0:item[#0]UKlif » %1:supplier[#0]UK » %7:nation[#0]UK + %0:item » %2:stock[#0{s_i_id}]KAif » %1:supplier[#0{su_suppkey}]UK » %7:nation[#0{n_nationkey}]UK » %3:orderline[#5{ol_supply_w_id}, #4{ol_i_id}]KKAif » %4:order[#0{o_id}..=#2{o_w_id}]UKKKiif » %5:customer[#0{c_id}..=#2{c_w_id}]UKKK » %6:nation[#0{n_nationkey}]UK » %8:region[#0{r_regionkey}]UKef + %1:supplier » %7:nation[#0{n_nationkey}]UK » %2:stock[#2{s_su_suppkey}]KAif » %0:item[#0{i_id}]UKlif » %3:orderline[#5{ol_supply_w_id}, #4{ol_i_id}]KKAif » %4:order[#0{o_id}..=#2{o_w_id}]UKKKiif » %5:customer[#0{c_id}..=#2{c_w_id}]UKKK » %6:nation[#0{n_nationkey}]UK » %8:region[#0{r_regionkey}]UKef + %2:stock » %0:item[#0{i_id}]UKlif » %1:supplier[#0{su_suppkey}]UK » %7:nation[#0{n_nationkey}]UK » %3:orderline[#5{ol_supply_w_id}, #4{ol_i_id}]KKAif » %4:order[#0{o_id}..=#2{o_w_id}]UKKKiif » %5:customer[#0{c_id}..=#2{c_w_id}]UKKK » %6:nation[#0{n_nationkey}]UK » %8:region[#0{r_regionkey}]UKef + %3:orderline » %4:order[#0{o_id}..=#2{o_w_id}]UKKKiif » %5:customer[#0{c_id}..=#2{c_w_id}]UKKK » %2:stock[#0{s_i_id}, #1{s_w_id}]UKKif » %0:item[#0{i_id}]UKlif » %1:supplier[#0{su_suppkey}]UK » %6:nation[#0{n_nationkey}]UK » %8:region[#0{r_regionkey}]UKef » %7:nation[#0{n_nationkey}]UK + %4:order » %5:customer[#0{c_id}..=#2{c_w_id}]UKKK » %6:nation[#0{n_nationkey}]UK » %8:region[#0{r_regionkey}]UKef » %3:orderline[#2{ol_w_id}, #1{ol_d_id}, #0{ol_o_id}]KKKAif » %2:stock[#0{s_i_id}, #1{s_w_id}]UKKif » %0:item[#0{i_id}]UKlif » %1:supplier[#0{su_suppkey}]UK » %7:nation[#0{n_nationkey}]UK + %5:customer » %6:nation[#0{n_nationkey}]UK » %8:region[#0{r_regionkey}]UKef » %4:order[#2{o_w_id}, #1{o_d_id}, #3{o_c_id}]KKKAiif » %3:orderline[#2{ol_w_id}, #1{ol_d_id}, #0{ol_o_id}]KKKAif » %2:stock[#0{s_i_id}, #1{s_w_id}]UKKif » %0:item[#0{i_id}]UKlif » %1:supplier[#0{su_suppkey}]UK » %7:nation[#0{n_nationkey}]UK + %6:nation » %8:region[#0{r_regionkey}]UKef » %5:customer[#3{c_n_nationkey}]KA » %4:order[#2{o_w_id}, #1{o_d_id}, #3{o_c_id}]KKKAiif » %3:orderline[#2{ol_w_id}, #1{ol_d_id}, #0{ol_o_id}]KKKAif » %2:stock[#0{s_i_id}, #1{s_w_id}]UKKif » %0:item[#0{i_id}]UKlif » %1:supplier[#0{su_suppkey}]UK » %7:nation[#0{n_nationkey}]UK + %7:nation » %1:supplier[#1{su_nationkey}]KA » %2:stock[#2{s_su_suppkey}]KAif » %0:item[#0{i_id}]UKlif » %3:orderline[#5{ol_supply_w_id}, #4{ol_i_id}]KKAif » %4:order[#0{o_id}..=#2{o_w_id}]UKKKiif » %5:customer[#0{c_id}..=#2{c_w_id}]UKKK » %6:nation[#0{n_nationkey}]UK » %8:region[#0{r_regionkey}]UKef + %8:region » %6:nation[#1{n_regionkey}]KA » %5:customer[#3{c_n_nationkey}]KA » %4:order[#2{o_w_id}, #1{o_d_id}, #3{o_c_id}]KKKAiif » %3:orderline[#2{ol_w_id}, #1{ol_d_id}, #0{ol_o_id}]KKKAif » %2:stock[#0{s_i_id}, #1{s_w_id}]UKKif » %0:item[#0{i_id}]UKlif » %1:supplier[#0{su_suppkey}]UK » %7:nation[#0{n_nationkey}]UK ArrangeBy keys=[[#0{i_id}]] // { arity: 1 } Project (#0{i_id}) // { arity: 1 } Filter (#0{i_id} < 1000) AND like["%b"](padchar(#4{i_data})) // { arity: 5 } @@ -796,12 +796,12 @@ Explained Query: Project (#14{ol_amount}, #19{o_entry_d}, #21{n_name}) // { arity: 3 } Join on=(#0{i_id} = #1{s_i_id} = #10{ol_i_id} AND #2{s_w_id} = #11{ol_supply_w_id} AND #3{s_su_suppkey} = #4{su_suppkey} AND #5{su_nationkey} = #20{n_nationkey} AND #6{ol_o_id} = #16{o_id} AND #7{ol_d_id} = #17{o_d_id} AND #8{ol_w_id} = #18{o_w_id}) type=delta // { arity: 22 } implementation - %0:item » %1:stock[#0]KA » %2:supplier[#0]UK » %5:nation[#0]UK » %3:orderline[#5, #4]KKA » %4:order[#0..=#2]UKKK - %1:stock » %0:item[#0]UKlf » %2:supplier[#0]UK » %5:nation[#0]UK » %3:orderline[#5, #4]KKA » %4:order[#0..=#2]UKKK - %2:supplier » %5:nation[#0]UK » %1:stock[#2]KA » %0:item[#0]UKlf » %3:orderline[#5, #4]KKA » %4:order[#0..=#2]UKKK - %3:orderline » %4:order[#0..=#2]UKKK » %1:stock[#0, #1]UKK » %0:item[#0]UKlf » %2:supplier[#0]UK » %5:nation[#0]UK - %4:order » %3:orderline[#2, #1, #0]KKKA » %1:stock[#0, #1]UKK » %0:item[#0]UKlf » %2:supplier[#0]UK » %5:nation[#0]UK - %5:nation » %2:supplier[#1]KA » %1:stock[#2]KA » %0:item[#0]UKlf » %3:orderline[#5, #4]KKA » %4:order[#0..=#2]UKKK + %0:item » %1:stock[#0{s_i_id}]KA » %2:supplier[#0{su_suppkey}]UK » %5:nation[#0{n_nationkey}]UK » %3:orderline[#5{ol_supply_w_id}, #4{ol_i_id}]KKA » %4:order[#0{o_id}..=#2{o_w_id}]UKKK + %1:stock » %0:item[#0{i_id}]UKlf » %2:supplier[#0{su_suppkey}]UK » %5:nation[#0{n_nationkey}]UK » %3:orderline[#5{ol_supply_w_id}, #4{ol_i_id}]KKA » %4:order[#0{o_id}..=#2{o_w_id}]UKKK + %2:supplier » %5:nation[#0{n_nationkey}]UK » %1:stock[#2{s_su_suppkey}]KA » %0:item[#0{i_id}]UKlf » %3:orderline[#5{ol_supply_w_id}, #4{ol_i_id}]KKA » %4:order[#0{o_id}..=#2{o_w_id}]UKKK + %3:orderline » %4:order[#0{o_id}..=#2{o_w_id}]UKKK » %1:stock[#0{s_i_id}, #1{s_w_id}]UKK » %0:item[#0{i_id}]UKlf » %2:supplier[#0{su_suppkey}]UK » %5:nation[#0{n_nationkey}]UK + %4:order » %3:orderline[#2{ol_w_id}, #1{ol_d_id}, #0{ol_o_id}]KKKA » %1:stock[#0{s_i_id}, #1{s_w_id}]UKK » %0:item[#0{i_id}]UKlf » %2:supplier[#0{su_suppkey}]UK » %5:nation[#0{n_nationkey}]UK + %5:nation » %2:supplier[#1{su_nationkey}]KA » %1:stock[#2{s_su_suppkey}]KA » %0:item[#0{i_id}]UKlf » %3:orderline[#5{ol_supply_w_id}, #4{ol_i_id}]KKA » %4:order[#0{o_id}..=#2{o_w_id}]UKKK ArrangeBy keys=[[#0{i_id}]] // { arity: 1 } Project (#0{i_id}) // { arity: 1 } Filter like["%BB"](padchar(#4{i_data})) // { arity: 5 } @@ -862,10 +862,10 @@ Explained Query: Filter (#11{o_entry_d} <= #18{ol_delivery_d}) // { arity: 24 } Join on=(#0{c_id} = #10{o_c_id} AND #1{c_d_id} = #8{o_d_id} = #13{ol_d_id} AND #2{c_w_id} = #9{o_w_id} = #14{ol_w_id} AND #6{c_n_nationkey} = #22{n_nationkey} AND #7{o_id} = #12{ol_o_id}) type=delta // { arity: 24 } implementation - %0:customer » %3:nation[#0]UK » %1:order[#2, #1, #3]KKKAif » %2:orderline[#2, #1, #0]KKKA - %1:order » %0:customer[#0..=#2]UKKK » %3:nation[#0]UK » %2:orderline[#2, #1, #0]KKKA - %2:orderline » %1:order[#0..=#2]UKKKif » %0:customer[#0..=#2]UKKK » %3:nation[#0]UK - %3:nation » %0:customer[#6]KA » %1:order[#2, #1, #3]KKKAif » %2:orderline[#2, #1, #0]KKKA + %0:customer » %3:nation[#0{n_nationkey}]UK » %1:order[#2{o_w_id}, #1{o_d_id}, #3{o_c_id}]KKKAif » %2:orderline[#2{ol_w_id}, #1{ol_d_id}, #0{ol_o_id}]KKKA + %1:order » %0:customer[#0{c_id}..=#2{c_w_id}]UKKK » %3:nation[#0{n_nationkey}]UK » %2:orderline[#2{ol_w_id}, #1{ol_d_id}, #0{ol_o_id}]KKKA + %2:orderline » %1:order[#0{o_id}..=#2{o_w_id}]UKKKif » %0:customer[#0{c_id}..=#2{c_w_id}]UKKK » %3:nation[#0{n_nationkey}]UK + %3:nation » %0:customer[#6{c_n_nationkey}]KA » %1:order[#2{o_w_id}, #1{o_d_id}, #3{o_c_id}]KKKAif » %2:orderline[#2{ol_w_id}, #1{ol_d_id}, #0{ol_o_id}]KKKA ArrangeBy keys=[[#0{c_id}..=#2{c_w_id}], [#6{c_n_nationkey}]] // { arity: 7 } Project (#0{c_id}..=#2{c_w_id}, #5{c_last}, #8{c_city}, #11{c_phone}, #21{c_n_nationkey}) // { arity: 7 } Filter (#21{c_n_nationkey}) IS NOT NULL // { arity: 22 } @@ -915,9 +915,9 @@ Explained Query: Project (#0{s_i_id}, #14{s_order_cnt}) // { arity: 2 } Join on=(#17{s_su_suppkey} = #18{su_suppkey} AND #19{su_nationkey} = #20{n_nationkey}) type=delta // { arity: 21 } implementation - %0:stock » %1:supplier[#0]UK » %2:nation[#0]UKef - %1:supplier » %2:nation[#0]UKef » %0:stock[#17]KA - %2:nation » %1:supplier[#1]KA » %0:stock[#17]KA + %0:stock » %1:supplier[#0{su_suppkey}]UK » %2:nation[#0{n_nationkey}]UKef + %1:supplier » %2:nation[#0{n_nationkey}]UKef » %0:stock[#17{s_su_suppkey}]KA + %2:nation » %1:supplier[#1{su_nationkey}]KA » %0:stock[#17{s_su_suppkey}]KA ArrangeBy keys=[[#17{s_su_suppkey}]] // { arity: 18 } ReadIndex on=stock fk_stock_supplier=[delta join 1st input (full scan)] // { arity: 18 } ArrangeBy keys=[[#0{su_suppkey}], [#1{su_nationkey}]] // { arity: 2 } @@ -974,7 +974,7 @@ Explained Query: Filter (date_to_timestamp(#12{ol_delivery_d}) < 2020-01-01 00:00:00) AND (#3{o_entry_d} <= #12{ol_delivery_d}) // { arity: 16 } Join on=(#0{o_id} = #6{ol_o_id} AND #1{o_d_id} = #7{ol_d_id} AND #2{o_w_id} = #8{ol_w_id}) type=differential // { arity: 16 } implementation - %0:order[#2, #1, #0]UKKK » %1:orderline[#2, #1, #0]KKKAif + %0:order[#2{o_w_id}, #1{o_d_id}, #0{o_id}]UKKK » %1:orderline[#2{ol_w_id}, #1{ol_d_id}, #0{ol_o_id}]KKKAif ArrangeBy keys=[[#2{o_w_id}, #1{o_d_id}, #0{o_id}]] // { arity: 6 } Project (#0{o_id}..=#2{o_w_id}, #4{o_entry_d}..=#6{o_ol_cnt}) // { arity: 6 } ReadIndex on=order fk_order_customer=[*** full scan ***] // { arity: 8 } @@ -1013,7 +1013,7 @@ Explained Query: Filter (#8{o_carrier_id} > 8) // { arity: 11 } Join on=(#0{c_id} = #6{o_c_id} AND #1{c_d_id} = #4{o_d_id} AND #2{c_w_id} = #5{o_w_id}) type=differential // { arity: 11 } implementation - %0:customer[#2, #1, #0]UKKK » %1:order[#2, #1, #3]KKKAif + %0:customer[#2{c_w_id}, #1{c_d_id}, #0{c_id}]UKKK » %1:order[#2{o_w_id}, #1{o_d_id}, #3{o_c_id}]KKKAif ArrangeBy keys=[[#2{c_w_id}, #1{c_d_id}, #0{c_id}]] // { arity: 3 } Project (#0{c_id}..=#2{c_w_id}) // { arity: 3 } ReadIndex on=customer fk_customer_district=[*** full scan ***] // { arity: 22 } @@ -1063,7 +1063,7 @@ Explained Query: Map (date_to_timestamp(#6{ol_delivery_d})) // { arity: 13 } Join on=(#4{ol_i_id} = #10{i_id}) type=differential // { arity: 12 } implementation - %1:item[#0]UK » %0:orderline[#4]KAiif + %1:item[#0{i_id}]UK » %0:orderline[#4{ol_i_id}]KAiif ArrangeBy keys=[[#4{ol_i_id}]] // { arity: 10 } ReadIndex on=orderline fk_orderline_item=[differential join] // { arity: 10 } ArrangeBy keys=[[#0{i_id}]] // { arity: 2 } @@ -1132,7 +1132,7 @@ Explained Query: Filter (date_to_timestamp(#6{ol_delivery_d}) >= 2007-01-02 00:00:00) // { arity: 13 } Join on=(#4{ol_i_id} = #10{s_i_id} AND #5{ol_supply_w_id} = #11{s_w_id}) type=differential // { arity: 13 } implementation - %1:stock[#1, #0]UKK » %0:orderline[#5, #4]KKAif + %1:stock[#1{s_w_id}, #0{s_i_id}]UKK » %0:orderline[#5{ol_supply_w_id}, #4{ol_i_id}]KKAif ArrangeBy keys=[[#5{ol_supply_w_id}, #4{ol_i_id}]] // { arity: 10 } ReadIndex on=orderline fk_orderline_stock=[differential join] // { arity: 10 } ArrangeBy keys=[[#1{s_w_id}, #0{s_i_id}]] // { arity: 3 } @@ -1143,8 +1143,8 @@ Explained Query: Join on=(#0{su_suppkey} = #4{s_su_suppkey} AND #5{sum_ol_amount} = #6{max_sum_ol_amount}) type=delta // { arity: 7 } implementation %0:supplier » %1:l0[#0]UKA » %2[#0]UK - %1:l0 » %0:supplier[#0]UK » %2[#0]UK - %2 » %1:l0[#1]K » %0:supplier[#0]UK + %1:l0 » %0:supplier[#0{su_suppkey}]UK » %2[#0]UK + %2 » %1:l0[#1{total_revenue}]K » %0:supplier[#0{su_suppkey}]UK ArrangeBy keys=[[#0{su_suppkey}]] // { arity: 4 } Project (#0{su_suppkey}..=#2{su_address}, #4{su_phone}) // { arity: 4 } ReadIndex on=supplier fk_supplier_nationkey=[*** full scan ***] // { arity: 7 } @@ -1190,7 +1190,7 @@ Explained Query: Project (#17{s_su_suppkey}, #19{i_name}..=#21{i_data}) // { arity: 4 } Join on=(#0{s_i_id} = #18{i_id}) type=differential // { arity: 22 } implementation - %1:item[#0]UKf » %0:stock[#0]KAf + %1:item[#0{i_id}]UKf » %0:stock[#0{s_i_id}]KAf ArrangeBy keys=[[#0{s_i_id}]] // { arity: 18 } ReadIndex on=stock fk_stock_item=[differential join] // { arity: 18 } ArrangeBy keys=[[#0{i_id}]] // { arity: 4 } @@ -1262,14 +1262,14 @@ Explained Query: Filter (integer_to_numeric(#7{ol_quantity}) < (bigint_to_numeric(#11{sum_ol_quantity}) / bigint_to_numeric(case when (#12{count_ol_quantity} = 0) then null else #12{count_ol_quantity} end))) // { arity: 13 } Join on=(#4{ol_i_id} = #10{i_id}) type=differential // { arity: 13 } implementation - %1[#0]UKA » %0:l0[#4]KA + %1[#0{i_id}]UKA » %0:l0[#4{ol_i_id}]KA Get l0 // { arity: 10 } ArrangeBy keys=[[#0{i_id}]] // { arity: 3 } Reduce group_by=[#0{i_id}] aggregates=[sum(#1{ol_quantity}), count(#1{ol_quantity})] // { arity: 3 } Project (#0{i_id}, #8{ol_quantity}) // { arity: 2 } Join on=(#0{i_id} = #5{ol_i_id}) type=differential // { arity: 11 } implementation - %0:item[#0]UKlf » %1:l0[#4]KAlf + %0:item[#0{i_id}]UKlf » %1:l0[#4{ol_i_id}]KAlf ArrangeBy keys=[[#0{i_id}]] // { arity: 1 } Project (#0{i_id}) // { arity: 1 } Filter like["%b"](padchar(#4{i_data})) // { arity: 5 } @@ -1321,9 +1321,9 @@ Explained Query: Project (#0{c_id}..=#4{o_id}, #8{o_entry_d}, #9{o_ol_cnt}, #18{ol_amount}) // { arity: 8 } Join on=(#0{c_id} = #7{o_c_id} AND #1{c_d_id} = #5{o_d_id} = #11{ol_d_id} AND #2{c_w_id} = #6{o_w_id} = #12{ol_w_id} AND #4{o_id} = #10{ol_o_id}) type=delta // { arity: 20 } implementation - %0:customer » %1:order[#2, #1, #3]KKKA » %2:orderline[#2, #1, #0]KKKA - %1:order » %0:customer[#0..=#2]UKKK » %2:orderline[#2, #1, #0]KKKA - %2:orderline » %1:order[#0..=#2]UKKK » %0:customer[#0..=#2]UKKK + %0:customer » %1:order[#2{o_w_id}, #1{o_d_id}, #3{o_c_id}]KKKA » %2:orderline[#2{ol_w_id}, #1{ol_d_id}, #0{ol_o_id}]KKKA + %1:order » %0:customer[#0{c_id}..=#2{c_w_id}]UKKK » %2:orderline[#2{ol_w_id}, #1{ol_d_id}, #0{ol_o_id}]KKKA + %2:orderline » %1:order[#0{o_id}..=#2{o_w_id}]UKKK » %0:customer[#0{c_id}..=#2{c_w_id}]UKKK ArrangeBy keys=[[#0{c_id}..=#2{c_w_id}]] // { arity: 4 } Project (#0{c_id}..=#2{c_w_id}, #5{c_last}) // { arity: 4 } ReadIndex on=customer fk_customer_district=[*** full scan ***] // { arity: 22 } @@ -1380,7 +1380,7 @@ Explained Query: Map ((#2{ol_w_id} = 1), (#2{ol_w_id} = 2), (#2{ol_w_id} = 3), (#2{ol_w_id} = 4), (#2{ol_w_id} = 5), padchar(#11{i_data})) // { arity: 18 } Join on=(#4{ol_i_id} = #10{i_id}) type=differential // { arity: 12 } implementation - %1:item[#0]UKliif » %0:orderline[#4]KAeliiiif + %1:item[#0{i_id}]UKliif » %0:orderline[#4{ol_i_id}]KAeliiiif ArrangeBy keys=[[#4{ol_i_id}]] // { arity: 10 } ReadIndex on=orderline fk_orderline_item=[differential join] // { arity: 10 } ArrangeBy keys=[[#0{i_id}]] // { arity: 2 } @@ -1440,7 +1440,7 @@ Explained Query: Project (#0{su_suppkey}..=#2{su_address}) // { arity: 3 } Join on=(#3{su_nationkey} = #7{n_nationkey}) type=differential // { arity: 8 } implementation - %1:nation[#0]UKef » %0:supplier[#3]KAef + %1:nation[#0{n_nationkey}]UKef » %0:supplier[#3{su_nationkey}]KAef ArrangeBy keys=[[#3{su_nationkey}]] // { arity: 7 } ReadIndex on=supplier fk_supplier_nationkey=[differential join] // { arity: 7 } ArrangeBy keys=[[#0{n_nationkey}]] // { arity: 1 } @@ -1463,10 +1463,10 @@ Explained Query: Filter (date_to_timestamp(#10{ol_delivery_d}) > 2010-05-23 12:00:00) // { arity: 15 } Join on=(#0{su_suppkey} = ((#1{s_i_id} * #2{s_w_id}) % 10000) AND #1{s_i_id} = #8{ol_i_id} = #14{i_id}) type=delta // { arity: 15 } implementation - %0:l0 » %1:stock[((#0 * #1) % 10000)]K » %3:item[#0]UKlf » %2:orderline[#4]KAif - %1:stock » %3:item[#0]UKlf » %0:l0[#0]UK » %2:orderline[#4]KAif - %2:orderline » %3:item[#0]UKlf » %1:stock[#0]KA » %0:l0[#0]UK - %3:item » %2:orderline[#4]KAif » %1:stock[#0]KA » %0:l0[#0]UK + %0:l0 » %1:stock[((#0 * #1) % 10000)]K » %3:item[#0]UKlf » %2:orderline[#4{ol_i_id}]KAif + %1:stock » %3:item[#0]UKlf » %0:l0[#0]UK » %2:orderline[#4{ol_i_id}]KAif + %2:orderline » %3:item[#0]UKlf » %1:stock[#0{s_i_id}]KA » %0:l0[#0]UK + %3:item » %2:orderline[#4{ol_i_id}]KAif » %1:stock[#0{s_i_id}]KA » %0:l0[#0]UK ArrangeBy keys=[[#0{su_suppkey}]] // { arity: 1 } Project (#0{su_suppkey}) // { arity: 1 } Get l0 // { arity: 3 } @@ -1528,11 +1528,11 @@ Explained Query: Filter (#9{ol_delivery_d} > #16{o_entry_d}) // { arity: 21 } Join on=(#0{su_suppkey} = #19{s_su_suppkey} AND #2{su_nationkey} = #20{n_nationkey} AND #3{ol_o_id} = #13{o_id} AND #4{ol_d_id} = #14{o_d_id} AND #5{ol_w_id} = #15{o_w_id} = #18{s_w_id} AND #7{ol_i_id} = #17{s_i_id}) type=delta // { arity: 21 } implementation - %0:supplier » %4:nation[#0]UKef » %3:stock[#2]KA » %1:orderline[#4]KA » %2:order[#0..=#2]UKKK - %1:orderline » %2:order[#0..=#2]UKKK » %3:stock[#0, #1]UKK » %0:supplier[#0]UK » %4:nation[#0]UKef - %2:order » %1:orderline[#2, #1, #0]KKKA » %3:stock[#0, #1]UKK » %0:supplier[#0]UK » %4:nation[#0]UKef - %3:stock » %0:supplier[#0]UK » %4:nation[#0]UKef » %1:orderline[#4]KA » %2:order[#0..=#2]UKKK - %4:nation » %0:supplier[#2]KA » %3:stock[#2]KA » %1:orderline[#4]KA » %2:order[#0..=#2]UKKK + %0:supplier » %4:nation[#0{n_nationkey}]UKef » %3:stock[#2{s_su_suppkey}]KA » %1:orderline[#4{ol_i_id}]KA » %2:order[#0{o_id}..=#2{o_w_id}]UKKK + %1:orderline » %2:order[#0{o_id}..=#2{o_w_id}]UKKK » %3:stock[#0{s_i_id}, #1{s_w_id}]UKK » %0:supplier[#0{su_suppkey}]UK » %4:nation[#0{n_nationkey}]UKef + %2:order » %1:orderline[#2{ol_w_id}, #1{ol_d_id}, #0{ol_o_id}]KKKA » %3:stock[#0{s_i_id}, #1{s_w_id}]UKK » %0:supplier[#0{su_suppkey}]UK » %4:nation[#0{n_nationkey}]UKef + %3:stock » %0:supplier[#0{su_suppkey}]UK » %4:nation[#0{n_nationkey}]UKef » %1:orderline[#4{ol_i_id}]KA » %2:order[#0{o_id}..=#2{o_w_id}]UKKK + %4:nation » %0:supplier[#2{su_nationkey}]KA » %3:stock[#2{s_su_suppkey}]KA » %1:orderline[#4{ol_i_id}]KA » %2:order[#0{o_id}..=#2{o_w_id}]UKKK ArrangeBy keys=[[#0{su_suppkey}], [#2{su_nationkey}]] // { arity: 3 } Project (#0{su_suppkey}, #1{su_name}, #3{su_nationkey}) // { arity: 3 } ReadIndex on=supplier fk_supplier_nationkey=[*** full scan ***] // { arity: 7 } @@ -1568,7 +1568,7 @@ Explained Query: Filter (#10{ol_delivery_d} > #3{ol_delivery_d}) // { arity: 14 } Join on=(#0{ol_o_id} = #4{ol_o_id} AND #1{ol_d_id} = #5{ol_d_id} AND #2{ol_w_id} = #6{ol_w_id}) type=differential // { arity: 14 } implementation - %0:l1[#2, #1, #0]KKK » %1:orderline[#2, #1, #0]KKKA + %0:l1[#2{ol_w_id}, #1{ol_d_id}, #0{ol_o_id}]KKK » %1:orderline[#2{ol_w_id}, #1{ol_d_id}, #0{ol_o_id}]KKKA ArrangeBy keys=[[#2{ol_w_id}, #1{ol_d_id}, #0{ol_o_id}]] // { arity: 4 } Get l1 // { arity: 4 } ArrangeBy keys=[[#2{ol_w_id}, #1{ol_d_id}, #0{ol_o_id}]] // { arity: 10 } diff --git a/test/sqllogictest/cluster_features.slt b/test/sqllogictest/cluster_features.slt index 0bd1af7d4a429..e50d846359fbd 100644 --- a/test/sqllogictest/cluster_features.slt +++ b/test/sqllogictest/cluster_features.slt @@ -102,9 +102,9 @@ materialize.public.mv1: Project (#1{y}, #3{y}, #3{y}) Join on=(#0{x} = #2{x} AND #3{y} = #4{y}) type=delta implementation - %0:t1 » %1:t2[#0]K » %2:t3[#0]K - %1:t2 » %0:t1[#0]K » %2:t3[#0]K - %2:t3 » %1:t2[#1]K » %0:t1[#0]K + %0:t1 » %1:t2[#0{x}]K » %2:t3[#0{y}]K + %1:t2 » %0:t1[#0{x}]K » %2:t3[#0{y}]K + %2:t3 » %1:t2[#1{y}]K » %0:t1[#0{x}]K ArrangeBy keys=[[#0{x}]] Filter (#0{x}) IS NOT NULL ReadStorage materialize.public.t1 @@ -136,7 +136,7 @@ materialize.public.mv2: Project (#1{y}, #3{y}, #3{y}) Join on=(#0{x} = #2{x} AND #3{y} = #4{y}) type=differential implementation - %0:t1[#0]K » %1:t2[#0]K » %2:t3[#0]K + %0:t1[#0{x}]K » %1:t2[#0{x}]K » %2:t3[#0{y}]K ArrangeBy keys=[[#0{x}]] Filter (#0{x}) IS NOT NULL ReadStorage materialize.public.t1 @@ -168,9 +168,9 @@ materialize.public.mv1: Project (#1{y}, #3{y}, #3{y}) Join on=(#0{x} = #2{x} AND #3{y} = #4{y}) type=delta implementation - %0:t1 » %1:t2[#0]K » %2:t3[#0]K - %1:t2 » %0:t1[#0]K » %2:t3[#0]K - %2:t3 » %1:t2[#1]K » %0:t1[#0]K + %0:t1 » %1:t2[#0{x}]K » %2:t3[#0{y}]K + %1:t2 » %0:t1[#0{x}]K » %2:t3[#0{y}]K + %2:t3 » %1:t2[#1{y}]K » %0:t1[#0{x}]K ArrangeBy keys=[[#0{x}]] Filter (#0{x}) IS NOT NULL ReadStorage materialize.public.t1 @@ -203,7 +203,7 @@ materialize.public.mv1: Project (#1{y}, #3{y}, #3{y}) Join on=(#0{x} = #2{x} AND #3{y} = #4{y}) type=differential implementation - %0:t1[#0]K » %1:t2[#0]K » %2:t3[#0]K + %0:t1[#0{x}]K » %1:t2[#0{x}]K » %2:t3[#0{y}]K ArrangeBy keys=[[#0{x}]] Filter (#0{x}) IS NOT NULL ReadStorage materialize.public.t1 @@ -245,7 +245,7 @@ materialize.public.mv1: Project (#1{y}, #3{y}, #3{y}) Join on=(#0{x} = #2{x} AND #3{y} = #4{y}) type=differential implementation - %0:t1[#0]K » %1:t2[#0]K » %2:t3[#0]K + %0:t1[#0{x}]K » %1:t2[#0{x}]K » %2:t3[#0{y}]K ArrangeBy keys=[[#0{x}]] Filter (#0{x}) IS NOT NULL ReadStorage materialize.public.t1 @@ -303,9 +303,9 @@ materialize.public.v: Project (#1{y}, #3{y}, #3{y}) Join on=(#0{x} = #2{x} AND #3{y} = #4{y}) type=delta implementation - %0:t1 » %1:t2[#0]K » %2:t3[#0]K - %1:t2 » %0:t1[#0]K » %2:t3[#0]K - %2:t3 » %1:t2[#1]K » %0:t1[#0]K + %0:t1 » %1:t2[#0{x}]K » %2:t3[#0{y}]K + %1:t2 » %0:t1[#0{x}]K » %2:t3[#0{y}]K + %2:t3 » %1:t2[#1{y}]K » %0:t1[#0{x}]K ArrangeBy keys=[[#0{x}]] Filter (#0{x}) IS NOT NULL ReadStorage materialize.public.t1 @@ -341,7 +341,7 @@ materialize.public.v: Project (#1{y}, #3{y}, #3{y}) Join on=(#0{x} = #2{x} AND #3{y} = #4{y}) type=differential implementation - %0:t1[#0]K » %1:t2[#0]K » %2:t3[#0]K + %0:t1[#0{x}]K » %1:t2[#0{x}]K » %2:t3[#0{y}]K ArrangeBy keys=[[#0{x}]] Filter (#0{x}) IS NOT NULL ReadStorage materialize.public.t1 @@ -377,9 +377,9 @@ materialize.public.v: Project (#1{y}, #3{y}, #3{y}) Join on=(#0{x} = #2{x} AND #3{y} = #4{y}) type=delta implementation - %0:t1 » %1:t2[#0]K » %2:t3[#0]K - %1:t2 » %0:t1[#0]K » %2:t3[#0]K - %2:t3 » %1:t2[#1]K » %0:t1[#0]K + %0:t1 » %1:t2[#0{x}]K » %2:t3[#0{y}]K + %1:t2 » %0:t1[#0{x}]K » %2:t3[#0{y}]K + %2:t3 » %1:t2[#1{y}]K » %0:t1[#0{x}]K ArrangeBy keys=[[#0{x}]] Filter (#0{x}) IS NOT NULL ReadStorage materialize.public.t1 @@ -416,7 +416,7 @@ materialize.public.v: Project (#1{y}, #3{y}, #3{y}) Join on=(#0{x} = #2{x} AND #3{y} = #4{y}) type=differential implementation - %0:t1[#0]K » %1:t2[#0]K » %2:t3[#0]K + %0:t1[#0{x}]K » %1:t2[#0{x}]K » %2:t3[#0{y}]K ArrangeBy keys=[[#0{x}]] Filter (#0{x}) IS NOT NULL ReadStorage materialize.public.t1 @@ -458,7 +458,7 @@ materialize.public.v: Project (#1{y}, #3{y}, #3{y}) Join on=(#0{x} = #2{x} AND #3{y} = #4{y}) type=differential implementation - %0:t1[#0]K » %1:t2[#0]K » %2:t3[#0]K + %0:t1[#0{x}]K » %1:t2[#0{x}]K » %2:t3[#0{y}]K ArrangeBy keys=[[#0{x}]] Filter (#0{x}) IS NOT NULL ReadStorage materialize.public.t1 diff --git a/test/sqllogictest/cte_lowering.slt b/test/sqllogictest/cte_lowering.slt index 5df2dc2582c6e..20c2a1e725f6f 100644 --- a/test/sqllogictest/cte_lowering.slt +++ b/test/sqllogictest/cte_lowering.slt @@ -32,10 +32,10 @@ WITH t AS (SELECT * FROM y WHERE a < 3) Project (#0) With cte [l0 as t] = - Filter (#0 < 3) + Filter (#0{a} < 3) Get materialize.public.y Return - InnerJoin (#0 = #1) + InnerJoin (#0{a} = #1{a}) Get l0 Get l0 @@ -51,10 +51,10 @@ WITH t AS (SELECT * FROM y WHERE a < 3) ---- With cte [l0 as t] = - Filter (#0 < 3) + Filter (#0{a} < 3) Get materialize.public.y Return - Filter (select(Get l0) < #0) + Filter (select(Get l0) < #0{a}) Get materialize.public.y Target cluster: quickstart @@ -69,14 +69,14 @@ WITH t AS (SELECT * FROM y WHERE a < 3) ---- With cte l0 = - Filter (#0 < 3) // { arity: 1 } + Filter (#0{a} < 3) // { arity: 1 } CrossJoin // { arity: 1 } Constant // { arity: 0 } - () Get materialize.public.y // { arity: 1 } Return // { arity: 1 } Project (#0) // { arity: 1 } - Filter (#0 = #1) // { arity: 2 } + Filter (#0{a} = #1{a}) // { arity: 2 } Project (#0, #1) // { arity: 2 } CrossJoin // { arity: 2 } Get l0 // { arity: 1 } @@ -104,8 +104,8 @@ With Distinct project=[#0] // { arity: 1 } Get l0 // { arity: 1 } cte l2 = - Reduce group_by=[#0] aggregates=[max(#1)] // { arity: 2 } - Filter (#1 < #0) // { arity: 2 } + Reduce group_by=[#0] aggregates=[max(#1{a})] // { arity: 2 } + Filter (#1{a} < #0{a}) // { arity: 2 } CrossJoin // { arity: 2 } Get l1 // { arity: 1 } Get materialize.public.y // { arity: 1 } @@ -163,8 +163,8 @@ With Distinct project=[#0] // { arity: 1 } Get l0 // { arity: 1 } cte l2 = - Reduce group_by=[#0] aggregates=[max(#1)] // { arity: 2 } - Filter (#1 < #0) // { arity: 2 } + Reduce group_by=[#0] aggregates=[max(#1{a})] // { arity: 2 } + Filter (#1{a} < #0{a}) // { arity: 2 } CrossJoin // { arity: 2 } Get l1 // { arity: 1 } Get materialize.public.y // { arity: 1 } @@ -254,8 +254,8 @@ With Distinct project=[#0] // { arity: 1 } Get l0 // { arity: 1 } cte l2 = - Reduce group_by=[#0] aggregates=[max(#1)] // { arity: 2 } - Filter (#1 < #0) // { arity: 2 } + Reduce group_by=[#0] aggregates=[max(#1{a})] // { arity: 2 } + Filter (#1{a} < #0{a}) // { arity: 2 } CrossJoin // { arity: 2 } Get l1 // { arity: 1 } Get materialize.public.y // { arity: 1 } @@ -278,7 +278,7 @@ Return // { arity: 3 } Project (#0, #2, #3) // { arity: 3 } Join on=(#0 = #1) // { arity: 4 } Get l0 // { arity: 1 } - Filter (#1 = #2) // { arity: 3 } + Filter (#1{m} = #2{m}) // { arity: 3 } Project (#0, #1, #3) // { arity: 3 } Join on=(#0 = #2) // { arity: 4 } Get l3 // { arity: 2 } @@ -325,8 +325,8 @@ With Distinct project=[#0] // { arity: 1 } Get l0 // { arity: 1 } cte l2 = - Reduce group_by=[#0] aggregates=[max(#1)] // { arity: 2 } - Filter (#1 < #0) // { arity: 2 } + Reduce group_by=[#0] aggregates=[max(#1{a})] // { arity: 2 } + Filter (#1{a} < #0{a}) // { arity: 2 } CrossJoin // { arity: 2 } Get l1 // { arity: 1 } Get materialize.public.y // { arity: 1 } @@ -436,8 +436,8 @@ With Distinct project=[#0] // { arity: 1 } Get l0 // { arity: 1 } cte l2 = - Reduce group_by=[#0] aggregates=[max(#1)] // { arity: 2 } - Filter (#1 < #0) // { arity: 2 } + Reduce group_by=[#0] aggregates=[max(#1{a})] // { arity: 2 } + Filter (#1{a} < #0{a}) // { arity: 2 } CrossJoin // { arity: 2 } Get l1 // { arity: 1 } Get materialize.public.y // { arity: 1 } @@ -487,7 +487,7 @@ Return // { arity: 3 } Join on=(#1 = #2) // { arity: 4 } Get l3 // { arity: 2 } Project (#0, #2) // { arity: 2 } - Map (#0) // { arity: 3 } + Map (#0{a}) // { arity: 3 } Project (#0, #1) // { arity: 2 } Filter (#2 > 0) // { arity: 3 } Project (#0, #1, #3) // { arity: 3 } @@ -543,7 +543,7 @@ Project (#1) cte [l4 as d] = Get l3 Return - Reduce aggregates=[max(#0)] + Reduce aggregates=[max(#0{d})] Get l4 Return Filter (select(Get l5) > 1) @@ -554,14 +554,14 @@ Project (#1) cte [l3 as e] = Get l1 cte [l7 as subquery-7] = - Reduce aggregates=[max(#0)] + Reduce aggregates=[max(#0{x})] Get l2 cte [l6 as subquery-6] = With cte [l4 as f] = Get l3 Return - Reduce aggregates=[min(#0)] + Reduce aggregates=[min(#0{f})] Get l4 Return Filter (select(Get l6) < select(Get l7)) diff --git a/test/sqllogictest/distinct_arrangements.slt b/test/sqllogictest/distinct_arrangements.slt index 0849af6778fc7..1c3c0798d987e 100644 --- a/test/sqllogictest/distinct_arrangements.slt +++ b/test/sqllogictest/distinct_arrangements.slt @@ -866,8 +866,8 @@ Arrange ReduceMinsMaxes ArrangeAccumulable [val: empty] ArrangeAccumulable [val: empty] ArrangeAccumulable [val: empty] -ArrangeBy[[CallBinary { func: ModInt64, expr1: Column(0), expr2: Literal(Ok(Row{[Int64(2)]}), ColumnType { scalar_type: Int64, nullable: false }) }]] -ArrangeBy[[CallUnary { func: CastInt32ToInt64(CastInt32ToInt64), expr: Column(0) }]] +ArrangeBy[[CallBinary(ModInt64, Column(0), Literal(Ok(Row{[Int64(2)]}), ColumnType { scalar_type: Int64, nullable: false }))]] +ArrangeBy[[CallUnary(CastInt32ToInt64(CastInt32ToInt64), Column(0))]] ArrangeBy[[Column(0)]] ArrangeBy[[Column(0)]] ArrangeBy[[Column(0)]] @@ -952,8 +952,8 @@ SELECT mz_unsafe.mz_sleep(4) query T SELECT mdo.name FROM mz_introspection.mz_arrangement_sharing mash JOIN mz_introspection.mz_dataflow_operators mdo ON mash.operator_id = mdo.id ORDER BY mdo.name; ---- -ArrangeBy[[CallUnary { func: CastStringToVarChar(CastStringToVarChar { length: None, fail_on_len: false }), expr: Column(1) }, CallUnary { func: CastInt64ToString(CastInt64ToString), expr: Column(0) }]] -ArrangeBy[[CallUnary { func: CastStringToVarChar(CastStringToVarChar { length: None, fail_on_len: false }), expr: Column(1) }, CallUnary { func: CastInt64ToString(CastInt64ToString), expr: Column(0) }]]-errors +ArrangeBy[[CallUnary(CastStringToVarChar(CastStringToVarChar { length: None, fail_on_len: false }), Column(1)), CallUnary(CastInt64ToString(CastInt64ToString), Column(0))]] +ArrangeBy[[CallUnary(CastStringToVarChar(CastStringToVarChar { length: None, fail_on_len: false }), Column(1)), CallUnary(CastInt64ToString(CastInt64ToString), Column(0))]]-errors ArrangeBy[[Column(0), Column(1)]] ArrangeBy[[Column(0), Column(1)]]-errors @@ -984,13 +984,13 @@ Arrange␠export␠iterative 2 Arrange␠export␠iterative␠err 2 Arrange␠recursive␠err 3 ArrangeAccumulable␠[val:␠empty] 10 -ArrangeBy[[CallBinary␠{␠func:␠JsonbGetStringStringify,␠expr1:␠Column(1),␠expr2:␠Literal(Ok(Row{[String("id")]}),␠ColumnType␠{␠scalar_type:␠String,␠nullable:␠false␠})␠}]] 2 -ArrangeBy[[CallBinary␠{␠func:␠JsonbGetStringStringify,␠expr1:␠Column(2),␠expr2:␠Literal(Ok(Row{[String("id")]}),␠ColumnType␠{␠scalar_type:␠String,␠nullable:␠false␠})␠}]] 1 -ArrangeBy[[CallVariadic␠{␠func:␠Coalesce,␠exprs:␠[Column(2),␠Column(3)]␠}]] 2 -ArrangeBy[[Column(0),␠CallUnary␠{␠func:␠CastInt32ToNumeric(CastInt32ToNumeric(None)),␠expr:␠Column(1)␠}]] 1 -ArrangeBy[[Column(0),␠CallUnary␠{␠func:␠CastUint64ToNumeric(CastUint64ToNumeric(None)),␠expr:␠Column(2)␠}]] 1 -ArrangeBy[[Column(0),␠CallUnary␠{␠func:␠Lower(Lower),␠expr:␠Column(1)␠}]] 1 -ArrangeBy[[Column(0),␠CallUnary␠{␠func:␠Lower(Lower),␠expr:␠Column(2)␠}]] 1 +ArrangeBy[[CallBinary(JsonbGetStringStringify,␠Column(1),␠Literal(Ok(Row{[String("id")]}),␠ColumnType␠{␠scalar_type:␠String,␠nullable:␠false␠}))]] 2 +ArrangeBy[[CallBinary(JsonbGetStringStringify,␠Column(2),␠Literal(Ok(Row{[String("id")]}),␠ColumnType␠{␠scalar_type:␠String,␠nullable:␠false␠}))]] 1 +ArrangeBy[[CallVariadic(Coalesce,␠[Column(2),␠Column(3)])]] 2 +ArrangeBy[[Column(0),␠CallUnary(CastInt32ToNumeric(CastInt32ToNumeric(None)),␠Column(1))]] 1 +ArrangeBy[[Column(0),␠CallUnary(CastUint64ToNumeric(CastUint64ToNumeric(None)),␠Column(2))]] 1 +ArrangeBy[[Column(0),␠CallUnary(Lower(Lower),␠Column(1))]] 1 +ArrangeBy[[Column(0),␠CallUnary(Lower(Lower),␠Column(2))]] 1 ArrangeBy[[Column(0),␠Column(1),␠Column(2),␠Column(3),␠Column(4),␠Column(5),␠Column(6),␠Column(7),␠Column(8),␠Column(9),␠Column(10),␠Column(11),␠Column(12),␠Column(13),␠Column(14),␠Column(15),␠Column(16),␠Column(17),␠Column(18),␠Column(19),␠Column(20),␠Column(21),␠Column(22),␠Column(23),␠Column(24),␠Column(25),␠Column(26),␠Column(27)]] 2 ArrangeBy[[Column(0),␠Column(1),␠Column(2),␠Column(3),␠Column(4),␠Column(5),␠Column(6),␠Column(7),␠Column(8),␠Column(9),␠Column(10),␠Column(11),␠Column(12),␠Column(13)]] 1 ArrangeBy[[Column(0),␠Column(1),␠Column(2),␠Column(3),␠Column(4),␠Column(5),␠Column(6),␠Column(7),␠Column(8),␠Column(9),␠Column(10),␠Column(11),␠Column(12),␠Column(13)]]-errors 1 diff --git a/test/sqllogictest/explain/decorrelated_plan_as_json.slt b/test/sqllogictest/explain/decorrelated_plan_as_json.slt index c34791f734e5d..986821c2d496b 100644 --- a/test/sqllogictest/explain/decorrelated_plan_as_json.slt +++ b/test/sqllogictest/explain/decorrelated_plan_as_json.slt @@ -434,7 +434,10 @@ SELECT 1, a + b as c FROM mv WHERE a > 0 and b < 0 and a + b > 0 "CallBinary": { "func": "Gt", "expr1": { - "Column": 0 + "Column": [ + 0, + "a" + ] }, "expr2": { "Literal": [ @@ -457,7 +460,10 @@ SELECT 1, a + b as c FROM mv WHERE a > 0 and b < 0 and a + b > 0 "CallBinary": { "func": "Lt", "expr1": { - "Column": 1 + "Column": [ + 1, + "b" + ] }, "expr2": { "Literal": [ @@ -486,10 +492,16 @@ SELECT 1, a + b as c FROM mv WHERE a > 0 and b < 0 and a + b > 0 "CallBinary": { "func": "AddInt32", "expr1": { - "Column": 0 + "Column": [ + 0, + "a" + ] }, "expr2": { - "Column": 1 + "Column": [ + 1, + "b" + ] } } }, @@ -560,10 +572,16 @@ SELECT 1, a + b as c FROM mv WHERE a > 0 and b < 0 and a + b > 0 "CallBinary": { "func": "AddInt32", "expr1": { - "Column": 0 + "Column": [ + 0, + "a" + ] }, "expr2": { - "Column": 1 + "Column": [ + 1, + "b" + ] } } } @@ -682,10 +700,16 @@ SELECT generate_series(a, b) from t "func": "GenerateSeriesInt32", "exprs": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] }, { - "Column": 1 + "Column": [ + 1, + "b" + ] }, { "Literal": [ @@ -803,7 +827,10 @@ SELECT a FROM t EXCEPT SELECT b FROM mv }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -870,7 +897,10 @@ SELECT a FROM t EXCEPT SELECT b FROM mv }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -1200,14 +1230,20 @@ SELECT abs(min(a) - max(a)) FROM t { "func": "MinInt32", "expr": { - "Column": 0 + "Column": [ + 0, + "a" + ] }, "distinct": false }, { "func": "MaxInt32", "expr": { - "Column": 0 + "Column": [ + 0, + "a" + ] }, "distinct": false } @@ -1408,10 +1444,16 @@ SELECT abs(min(a) - max(a)) FROM t "CallBinary": { "func": "SubInt32", "expr1": { - "Column": 0 + "Column": [ + 0, + "?column?" + ] }, "expr2": { - "Column": 1 + "Column": [ + 1, + "?column?" + ] } } } @@ -1541,7 +1583,10 @@ SELECT abs(min(a) - max(a)) FROM t GROUP BY b }, "scalars": [ { - "Column": 1 + "Column": [ + 1, + "b" + ] } ] } @@ -1555,21 +1600,30 @@ SELECT abs(min(a) - max(a)) FROM t GROUP BY b }, "group_key": [ { - "Column": 2 + "Column": [ + 2, + null + ] } ], "aggregates": [ { "func": "MinInt32", "expr": { - "Column": 0 + "Column": [ + 0, + "a" + ] }, "distinct": false }, { "func": "MaxInt32", "expr": { - "Column": 0 + "Column": [ + 0, + "a" + ] }, "distinct": false } @@ -1619,10 +1673,16 @@ SELECT abs(min(a) - max(a)) FROM t GROUP BY b "CallBinary": { "func": "SubInt32", "expr1": { - "Column": 1 + "Column": [ + 1, + "?column?" + ] }, "expr2": { - "Column": 2 + "Column": [ + 2, + "?column?" + ] } } } @@ -1796,7 +1856,10 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -1896,10 +1959,16 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC "CallBinary": { "func": "Lt", "expr1": { - "Column": 0 + "Column": [ + 0, + "a" + ] }, "expr2": { - "Column": 1 + "Column": [ + 1, + "a" + ] } } } @@ -1908,7 +1977,10 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -2004,7 +2076,10 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -2040,7 +2115,10 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -2076,10 +2154,16 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC "equivalences": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] }, { - "Column": 1 + "Column": [ + 1, + null + ] } ] ], @@ -2130,10 +2214,16 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC "equivalences": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] }, { - "Column": 2 + "Column": [ + 2, + null + ] } ] ], @@ -2153,7 +2243,10 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC }, "predicates": [ { - "Column": 2 + "Column": [ + 2, + null + ] } ] } @@ -2192,7 +2285,10 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC }, "group_key": [ { - "Column": 1 + "Column": [ + 1, + null + ] } ], "aggregates": [], @@ -2292,10 +2388,16 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC "CallBinary": { "func": "Gt", "expr1": { - "Column": 0 + "Column": [ + 0, + "b" + ] }, "expr2": { - "Column": 2 + "Column": [ + 2, + "b" + ] } } } @@ -2304,7 +2406,10 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -2400,7 +2505,10 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -2436,7 +2544,10 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -2472,10 +2583,16 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC "equivalences": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] }, { - "Column": 1 + "Column": [ + 1, + null + ] } ] ], @@ -2526,10 +2643,16 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC "equivalences": [ [ { - "Column": 1 + "Column": [ + 1, + null + ] }, { - "Column": 2 + "Column": [ + 2, + null + ] } ] ], @@ -2549,7 +2672,10 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC }, "predicates": [ { - "Column": 2 + "Column": [ + 2, + null + ] } ] } @@ -2694,10 +2820,16 @@ SELECT (SELECT v.a FROM v WHERE v.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHERE m }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] }, { - "Column": 1 + "Column": [ + 1, + null + ] } ], "aggregates": [], @@ -2738,7 +2870,10 @@ SELECT (SELECT v.a FROM v WHERE v.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHERE m }, "group_key": [ { - "Column": 1 + "Column": [ + 1, + null + ] } ], "aggregates": [], @@ -2846,10 +2981,16 @@ SELECT (SELECT v.a FROM v WHERE v.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHERE m "CallBinary": { "func": "Eq", "expr1": { - "Column": 2 + "Column": [ + 2, + "b" + ] }, "expr2": { - "Column": 0 + "Column": [ + 0, + "b" + ] } } } @@ -2950,7 +3091,10 @@ SELECT (SELECT v.a FROM v WHERE v.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHERE m }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [ @@ -2983,7 +3127,10 @@ SELECT (SELECT v.a FROM v WHERE v.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHERE m "CallBinary": { "func": "Gt", "expr1": { - "Column": 1 + "Column": [ + 1, + null + ] }, "expr2": { "Literal": [ @@ -3092,7 +3239,10 @@ SELECT (SELECT v.a FROM v WHERE v.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHERE m }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -3128,7 +3278,10 @@ SELECT (SELECT v.a FROM v WHERE v.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHERE m }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -3164,10 +3317,16 @@ SELECT (SELECT v.a FROM v WHERE v.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHERE m "equivalences": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] }, { - "Column": 1 + "Column": [ + 1, + null + ] } ] ], @@ -3218,10 +3377,16 @@ SELECT (SELECT v.a FROM v WHERE v.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHERE m "equivalences": [ [ { - "Column": 1 + "Column": [ + 1, + null + ] }, { - "Column": 2 + "Column": [ + 2, + null + ] } ] ], @@ -3267,10 +3432,16 @@ SELECT (SELECT v.a FROM v WHERE v.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHERE m }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] }, { - "Column": 1 + "Column": [ + 1, + null + ] } ], "aggregates": [], @@ -3311,7 +3482,10 @@ SELECT (SELECT v.a FROM v WHERE v.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHERE m }, "group_key": [ { - "Column": 1 + "Column": [ + 1, + null + ] } ], "aggregates": [], @@ -3419,10 +3593,16 @@ SELECT (SELECT v.a FROM v WHERE v.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHERE m "CallBinary": { "func": "Eq", "expr1": { - "Column": 2 + "Column": [ + 2, + "b" + ] }, "expr2": { - "Column": 0 + "Column": [ + 0, + "b" + ] } } } @@ -3523,7 +3703,10 @@ SELECT (SELECT v.a FROM v WHERE v.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHERE m }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [ @@ -3556,7 +3739,10 @@ SELECT (SELECT v.a FROM v WHERE v.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHERE m "CallBinary": { "func": "Gt", "expr1": { - "Column": 1 + "Column": [ + 1, + null + ] }, "expr2": { "Literal": [ @@ -3665,7 +3851,10 @@ SELECT (SELECT v.a FROM v WHERE v.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHERE m }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -3701,7 +3890,10 @@ SELECT (SELECT v.a FROM v WHERE v.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHERE m }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -3737,10 +3929,16 @@ SELECT (SELECT v.a FROM v WHERE v.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHERE m "equivalences": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] }, { - "Column": 1 + "Column": [ + 1, + null + ] } ] ], @@ -3791,10 +3989,16 @@ SELECT (SELECT v.a FROM v WHERE v.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHERE m "equivalences": [ [ { - "Column": 1 + "Column": [ + 1, + null + ] }, { - "Column": 2 + "Column": [ + 2, + null + ] } ] ], @@ -3816,24 +4020,42 @@ SELECT (SELECT v.a FROM v WHERE v.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHERE m "equivalences": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] }, { - "Column": 2 + "Column": [ + 2, + null + ] }, { - "Column": 5 + "Column": [ + 5, + null + ] } ], [ { - "Column": 1 + "Column": [ + 1, + null + ] }, { - "Column": 3 + "Column": [ + 3, + null + ] }, { - "Column": 6 + "Column": [ + 6, + null + ] } ] ], @@ -3844,10 +4066,16 @@ SELECT (SELECT v.a FROM v WHERE v.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHERE m }, "scalars": [ { - "Column": 4 + "Column": [ + 4, + null + ] }, { - "Column": 7 + "Column": [ + 7, + null + ] } ] } @@ -4731,10 +4959,16 @@ WHERE t1.b = t2.b AND t2.b = t3.b "CallBinary": { "func": "Eq", "expr1": { - "Column": 1 + "Column": [ + 1, + "b" + ] }, "expr2": { - "Column": 3 + "Column": [ + 3, + "b" + ] } } }, @@ -4742,10 +4976,16 @@ WHERE t1.b = t2.b AND t2.b = t3.b "CallBinary": { "func": "Eq", "expr1": { - "Column": 3 + "Column": [ + 3, + "b" + ] }, "expr2": { - "Column": 5 + "Column": [ + 5, + "b" + ] } } } @@ -4965,10 +5205,16 @@ INNER JOIN t as t3 ON t2.b = t3.b "CallBinary": { "func": "Eq", "expr1": { - "Column": 1 + "Column": [ + 1, + "b" + ] }, "expr2": { - "Column": 3 + "Column": [ + 3, + "b" + ] } } } @@ -5138,10 +5384,16 @@ INNER JOIN t as t3 ON t2.b = t3.b "CallBinary": { "func": "Eq", "expr1": { - "Column": 3 + "Column": [ + 3, + "b" + ] }, "expr2": { - "Column": 5 + "Column": [ + 5, + "b" + ] } } } @@ -5401,10 +5653,16 @@ RIGHT JOIN t as t3 ON t2.b = t3.b "CallBinary": { "func": "Eq", "expr1": { - "Column": 1 + "Column": [ + 1, + "b" + ] }, "expr2": { - "Column": 3 + "Column": [ + 3, + "b" + ] } } } @@ -5454,7 +5712,10 @@ RIGHT JOIN t as t3 ON t2.b = t3.b }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -5510,7 +5771,10 @@ RIGHT JOIN t as t3 ON t2.b = t3.b "IsNull": null }, "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] } } } @@ -5544,10 +5808,16 @@ RIGHT JOIN t as t3 ON t2.b = t3.b "equivalences": [ [ { - "Column": 1 + "Column": [ + 1, + "b" + ] }, { - "Column": 2 + "Column": [ + 2, + null + ] } ] ], @@ -5790,10 +6060,16 @@ RIGHT JOIN t as t3 ON t2.b = t3.b "CallBinary": { "func": "Eq", "expr1": { - "Column": 3 + "Column": [ + 3, + "b" + ] }, "expr2": { - "Column": 5 + "Column": [ + 5, + "b" + ] } } } @@ -5851,7 +6127,10 @@ RIGHT JOIN t as t3 ON t2.b = t3.b }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -5909,7 +6188,10 @@ RIGHT JOIN t as t3 ON t2.b = t3.b "IsNull": null }, "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] } } } @@ -5943,10 +6225,16 @@ RIGHT JOIN t as t3 ON t2.b = t3.b "equivalences": [ [ { - "Column": 1 + "Column": [ + 1, + "b" + ] }, { - "Column": 2 + "Column": [ + 2, + null + ] } ] ], @@ -6230,10 +6518,16 @@ WITH x AS (SELECT t.a * t.b as v from t) SELECT a.v + b.v FROM x as a, x as b "CallBinary": { "func": "MulInt32", "expr1": { - "Column": 0 + "Column": [ + 0, + "a" + ] }, "expr2": { - "Column": 1 + "Column": [ + 1, + "b" + ] } } } @@ -6356,10 +6650,16 @@ WITH x AS (SELECT t.a * t.b as v from t) SELECT a.v + b.v FROM x as a, x as b "CallBinary": { "func": "AddInt32", "expr1": { - "Column": 0 + "Column": [ + 0, + "v" + ] }, "expr2": { - "Column": 1 + "Column": [ + 1, + "v" + ] } } } @@ -6507,7 +6807,10 @@ FROM }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -6603,7 +6906,10 @@ FROM }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [ @@ -6613,10 +6919,16 @@ FROM "CallBinary": { "func": "MulInt32", "expr1": { - "Column": 0 + "Column": [ + 0, + "a" + ] }, "expr2": { - "Column": 1 + "Column": [ + 1, + "a" + ] } } }, @@ -6696,7 +7008,10 @@ FROM }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -6732,7 +7047,10 @@ FROM }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -6768,10 +7086,16 @@ FROM "equivalences": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] }, { - "Column": 1 + "Column": [ + 1, + null + ] } ] ], @@ -6846,10 +7170,16 @@ FROM "CallBinary": { "func": "NotEq", "expr1": { - "Column": 1 + "Column": [ + 1, + "m" + ] }, "expr2": { - "Column": 0 + "Column": [ + 0, + "a" + ] } } } @@ -6862,10 +7192,16 @@ FROM "equivalences": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] }, { - "Column": 2 + "Column": [ + 2, + null + ] } ] ], @@ -6915,7 +7251,10 @@ FROM }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -7015,7 +7354,10 @@ FROM }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [ @@ -7025,10 +7367,16 @@ FROM "CallBinary": { "func": "MulInt32", "expr1": { - "Column": 0 + "Column": [ + 0, + "a" + ] }, "expr2": { - "Column": 1 + "Column": [ + 1, + "a" + ] } } }, @@ -7108,7 +7456,10 @@ FROM }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -7144,7 +7495,10 @@ FROM }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -7180,10 +7534,16 @@ FROM "equivalences": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] }, { - "Column": 1 + "Column": [ + 1, + null + ] } ] ], @@ -7262,10 +7622,16 @@ FROM "CallBinary": { "func": "NotEq", "expr1": { - "Column": 1 + "Column": [ + 1, + "m" + ] }, "expr2": { - "Column": 0 + "Column": [ + 0, + "a" + ] } } }, @@ -7284,7 +7650,10 @@ FROM "IsNull": null }, "expr": { - "Column": 1 + "Column": [ + 1, + "m" + ] } } } @@ -7296,7 +7665,10 @@ FROM "IsNull": null }, "expr": { - "Column": 0 + "Column": [ + 0, + "a" + ] } } } @@ -7315,10 +7687,16 @@ FROM "equivalences": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] }, { - "Column": 3 + "Column": [ + 3, + null + ] } ] ], @@ -7465,7 +7843,10 @@ FROM }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -7561,7 +7942,10 @@ FROM }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [ @@ -7571,10 +7955,16 @@ FROM "CallBinary": { "func": "MulInt32", "expr1": { - "Column": 0 + "Column": [ + 0, + "a" + ] }, "expr2": { - "Column": 1 + "Column": [ + 1, + "a" + ] } } }, @@ -7654,7 +8044,10 @@ FROM }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -7690,7 +8083,10 @@ FROM }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -7726,10 +8122,16 @@ FROM "equivalences": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] }, { - "Column": 1 + "Column": [ + 1, + null + ] } ] ], @@ -7806,10 +8208,16 @@ FROM }, "group_key": [ { - "Column": 1 + "Column": [ + 1, + null + ] }, { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -7910,10 +8318,16 @@ FROM }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] }, { - "Column": 1 + "Column": [ + 1, + null + ] } ], "aggregates": [ @@ -7923,10 +8337,16 @@ FROM "CallBinary": { "func": "MulInt32", "expr1": { - "Column": 1 + "Column": [ + 1, + "a" + ] }, "expr2": { - "Column": 2 + "Column": [ + 2, + "a" + ] } } }, @@ -8016,10 +8436,16 @@ FROM }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] }, { - "Column": 1 + "Column": [ + 1, + null + ] } ], "aggregates": [], @@ -8060,10 +8486,16 @@ FROM }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] }, { - "Column": 1 + "Column": [ + 1, + null + ] } ], "aggregates": [], @@ -8104,18 +8536,30 @@ FROM "equivalences": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] }, { - "Column": 2 + "Column": [ + 2, + null + ] } ], [ { - "Column": 1 + "Column": [ + 1, + null + ] }, { - "Column": 3 + "Column": [ + 3, + null + ] } ] ], @@ -8199,10 +8643,16 @@ FROM "CallBinary": { "func": "Eq", "expr1": { - "Column": 1 + "Column": [ + 1, + "a" + ] }, "expr2": { - "Column": 0 + "Column": [ + 0, + "m" + ] } } }, @@ -8210,7 +8660,10 @@ FROM "CallBinary": { "func": "Gt", "expr1": { - "Column": 2 + "Column": [ + 2, + "m" + ] }, "expr2": { "Literal": [ @@ -8242,18 +8695,30 @@ FROM "equivalences": [ [ { - "Column": 1 + "Column": [ + 1, + null + ] }, { - "Column": 2 + "Column": [ + 2, + null + ] } ], [ { - "Column": 0 + "Column": [ + 0, + null + ] }, { - "Column": 3 + "Column": [ + 3, + null + ] } ] ], @@ -8274,10 +8739,16 @@ FROM "CallBinary": { "func": "NotEq", "expr1": { - "Column": 0 + "Column": [ + 0, + "a" + ] }, "expr2": { - "Column": 0 + "Column": [ + 0, + "a" + ] } } } @@ -8290,10 +8761,16 @@ FROM "equivalences": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] }, { - "Column": 2 + "Column": [ + 2, + null + ] } ] ], diff --git a/test/sqllogictest/explain/decorrelated_plan_as_text.slt b/test/sqllogictest/explain/decorrelated_plan_as_text.slt index 624ee2ab01298..f189bb2be9830 100644 --- a/test/sqllogictest/explain/decorrelated_plan_as_text.slt +++ b/test/sqllogictest/explain/decorrelated_plan_as_text.slt @@ -82,8 +82,8 @@ EXPLAIN DECORRELATED PLAN AS TEXT FOR SELECT 1, a + b as c FROM mv WHERE a > 0 and b < 0 and a + b > 0 ---- Project (#2, #3) - Map (1, (#0 + #1)) - Filter (((#0 > 0) AND (#1 < 0)) AND ((#0 + #1) > 0)) + Map (1, (#0{a} + #1{b})) + Filter (((#0{a} > 0) AND (#1{b} < 0)) AND ((#0{a} + #1{b}) > 0)) CrossJoin Constant - () @@ -99,7 +99,7 @@ EXPLAIN DECORRELATED PLAN AS TEXT FOR SELECT generate_series(a, b) from t ---- Project (#2) - FlatMap generate_series(#0, #1, 1) + FlatMap generate_series(#0{a}, #1{b}, 1) CrossJoin Constant - () @@ -179,14 +179,14 @@ SELECT abs(min(a) - max(a)) FROM t ---- With cte l0 = - Reduce aggregates=[min(#0), max(#0)] + Reduce aggregates=[min(#0{a}), max(#0{a})] CrossJoin Constant - () Get materialize.public.t Return Project (#2) - Map (abs((#0 - #1))) + Map (abs((#0{?column?} - #1{?column?}))) Union Get l0 CrossJoin @@ -214,10 +214,10 @@ EXPLAIN DECORRELATED PLAN AS TEXT FOR SELECT abs(min(a) - max(a)) FROM t GROUP BY b ---- Project (#3) - Map (abs((#1 - #2))) - Reduce group_by=[#2] aggregates=[min(#0), max(#0)] + Map (abs((#1{?column?} - #2{?column?}))) + Reduce group_by=[#2] aggregates=[min(#0{a}), max(#0{a})] Project (#0..=#2) - Map (#1) + Map (#1{b}) CrossJoin Constant - () @@ -245,7 +245,7 @@ With cte l2 = Map (true) Distinct project=[#0] - Filter (#0 < #1) + Filter (#0{a} < #1{a}) CrossJoin Get l1 Get materialize.public.mv @@ -275,7 +275,7 @@ With cte l5 = Map (true) Distinct project=[#0] - Filter (#0 > #2) + Filter (#0{b} > #2{b}) CrossJoin Get l4 Get materialize.public.mv @@ -324,7 +324,7 @@ With cte l3 = Project (#0, #1) TopK group_by=[#0] limit=1 - Filter (#2 = #0) + Filter (#2{b} = #0{b}) CrossJoin Get l2 Get materialize.public.v @@ -345,7 +345,7 @@ With cte l7 = Project (#0, #1) TopK group_by=[#0] limit=1 - Filter (#2 = #0) + Filter (#2{b} = #0{b}) CrossJoin Get l6 Get materialize.public.mv @@ -454,7 +454,7 @@ FROM WHERE t1.b = t2.b AND t2.b = t3.b ---- Project (#0, #2) - Filter ((#1 = #3) AND (#3 = #5)) + Filter ((#1{b} = #3{b}) AND (#3{b} = #5{b})) Project (#0..=#5) CrossJoin Project (#0..=#3) @@ -485,10 +485,10 @@ INNER JOIN t as t2 ON t1.b = t2.b INNER JOIN t as t3 ON t2.b = t3.b ---- Project (#0, #2) - Filter (#3 = #5) + Filter (#3{b} = #5{b}) Project (#0..=#5) CrossJoin - Filter (#1 = #3) + Filter (#1{b} = #3{b}) Project (#0..=#3) CrossJoin CrossJoin @@ -523,7 +523,7 @@ With - () Get materialize.public.t cte l1 = - Filter (#1 = #3) + Filter (#1{b} = #3{b}) Project (#0..=#3) CrossJoin Get l0 @@ -537,7 +537,7 @@ With - () Get materialize.public.t cte l3 = - Filter (#3 = #5) + Filter (#3{b} = #5{b}) Project (#0..=#5) CrossJoin Union @@ -545,8 +545,8 @@ With Union Negate Project (#0, #1) - Join on=(#1 = #2) - Filter (#1) IS NOT NULL + Join on=(#1{b} = #2) + Filter (#1{b}) IS NOT NULL Get l0 Distinct project=[#0] Project (#1) @@ -562,8 +562,8 @@ Return Union Negate Project (#0, #1) - Join on=(#1 = #2) - Filter (#1) IS NOT NULL + Join on=(#1{b} = #2) + Filter (#1{b}) IS NOT NULL Get l2 Distinct project=[#0] Project (#3) @@ -583,7 +583,7 @@ WITH x AS (SELECT t.a * t.b as v from t) SELECT a.v + b.v FROM x as a, x as b With cte l0 = Project (#2) - Map ((#0 * #1)) + Map ((#0{a} * #1{b})) CrossJoin Constant - () @@ -591,7 +591,7 @@ With Return Project (#2) Project (#0..=#2) - Map ((#0 + #1)) + Map ((#0{v} + #1{v})) Project (#0, #1) CrossJoin Get l0 @@ -634,7 +634,7 @@ With Distinct project=[#0] Get l0 cte l2 = - Reduce group_by=[#0] aggregates=[max((#0 * #1))] + Reduce group_by=[#0] aggregates=[max((#0{a} * #1{a}))] CrossJoin Get l1 Get materialize.public.t @@ -642,7 +642,7 @@ With Project (#0, #1, #3) Join on=(#0 = #2) Get l0 - Filter (#1 != #0) + Filter (#1{m} != #0{a}) Union Get l2 CrossJoin @@ -661,7 +661,7 @@ With Distinct project=[#0] Get l3 cte l5 = - Reduce group_by=[#0] aggregates=[max((#0 * #1))] + Reduce group_by=[#0] aggregates=[max((#0{a} * #1{a}))] CrossJoin Get l4 Get materialize.public.t @@ -669,7 +669,7 @@ Return Project (#0..=#2, #4) Join on=(#0 = #3) Get l3 - Filter ((#1 != #0) OR ((#1) IS NOT NULL AND (#0) IS NULL)) + Filter ((#1{m} != #0{a}) OR ((#1{m}) IS NOT NULL AND (#0{a}) IS NULL)) Union Get l5 CrossJoin @@ -726,7 +726,7 @@ With Distinct project=[#0] Get l0 cte l2 = - Reduce group_by=[#0] aggregates=[max((#0 * #1))] + Reduce group_by=[#0] aggregates=[max((#0{a} * #1{a}))] CrossJoin Get l1 Get materialize.public.t @@ -749,7 +749,7 @@ With Distinct project=[#1, #0] Get l3 cte l5 = - Reduce group_by=[#0, #1] aggregates=[max((#1 * #2))] + Reduce group_by=[#0, #1] aggregates=[max((#1{a} * #2{a}))] CrossJoin Get l4 Get materialize.public.t @@ -757,11 +757,11 @@ Return Project (#0, #1, #3, #4) Join on=(#0 = #2) Get l0 - Filter (#0 != #0) + Filter (#0{a} != #0{a}) Project (#0, #1, #4) Join on=(#1 = #2 AND #0 = #3) Get l3 - Filter ((#1 = #0) AND (#2 > 5)) + Filter ((#1{a} = #0{m}) AND (#2{m} > 5)) Union Get l5 CrossJoin diff --git a/test/sqllogictest/explain/enable_eager_delta_joins.slt b/test/sqllogictest/explain/enable_eager_delta_joins.slt index ed856c6ee6ff7..f10b52aa52867 100644 --- a/test/sqllogictest/explain/enable_eager_delta_joins.slt +++ b/test/sqllogictest/explain/enable_eager_delta_joins.slt @@ -62,7 +62,7 @@ materialize.public.mv: Project (#1{y}, #3{y}, #3{y}) Join on=(#0{x} = #2{x} AND #3{y} = #4{y}) type=differential implementation - %0:t1[#0]K » %1:t2[#0]K » %2:t3[#0]K + %0:t1[#0{x}]K » %1:t2[#0{x}]K » %2:t3[#0{y}]K ArrangeBy keys=[[#0{x}]] Filter (#0{x}) IS NOT NULL ReadStorage materialize.public.t1 @@ -94,7 +94,7 @@ materialize.public.mv: Project (#1{y}, #3{y}, #3{y}) Join on=(#0{x} = #2{x} AND #3{y} = #4{y}) type=differential implementation - %0:t1[#0]K » %1:t2[#0]K » %2:t3[#0]K + %0:t1[#0{x}]K » %1:t2[#0{x}]K » %2:t3[#0{y}]K ArrangeBy keys=[[#0{x}]] Filter (#0{x}) IS NOT NULL ReadStorage materialize.public.t1 @@ -126,9 +126,9 @@ materialize.public.mv: Project (#1{y}, #3{y}, #3{y}) Join on=(#0{x} = #2{x} AND #3{y} = #4{y}) type=delta implementation - %0:t1 » %1:t2[#0]K » %2:t3[#0]K - %1:t2 » %0:t1[#0]K » %2:t3[#0]K - %2:t3 » %1:t2[#1]K » %0:t1[#0]K + %0:t1 » %1:t2[#0{x}]K » %2:t3[#0{y}]K + %1:t2 » %0:t1[#0{x}]K » %2:t3[#0{y}]K + %2:t3 » %1:t2[#1{y}]K » %0:t1[#0{x}]K ArrangeBy keys=[[#0{x}]] Filter (#0{x}) IS NOT NULL ReadStorage materialize.public.t1 @@ -183,7 +183,7 @@ materialize.public.v: Project (#1{y}, #3{y}, #3{y}) Join on=(#0{x} = #2{x} AND #3{y} = #4{y}) type=differential implementation - %0:t1[#0]K » %1:t2[#0]K » %2:t3[#0]K + %0:t1[#0{x}]K » %1:t2[#0{x}]K » %2:t3[#0{y}]K ArrangeBy keys=[[#0{x}]] Filter (#0{x}) IS NOT NULL ReadStorage materialize.public.t1 @@ -219,7 +219,7 @@ materialize.public.v: Project (#1{y}, #3{y}, #3{y}) Join on=(#0{x} = #2{x} AND #3{y} = #4{y}) type=differential implementation - %0:t1[#0]K » %1:t2[#0]K » %2:t3[#0]K + %0:t1[#0{x}]K » %1:t2[#0{x}]K » %2:t3[#0{y}]K ArrangeBy keys=[[#0{x}]] Filter (#0{x}) IS NOT NULL ReadStorage materialize.public.t1 @@ -255,9 +255,9 @@ materialize.public.v: Project (#1{y}, #3{y}, #3{y}) Join on=(#0{x} = #2{x} AND #3{y} = #4{y}) type=delta implementation - %0:t1 » %1:t2[#0]K » %2:t3[#0]K - %1:t2 » %0:t1[#0]K » %2:t3[#0]K - %2:t3 » %1:t2[#1]K » %0:t1[#0]K + %0:t1 » %1:t2[#0{x}]K » %2:t3[#0{y}]K + %1:t2 » %0:t1[#0{x}]K » %2:t3[#0{y}]K + %2:t3 » %1:t2[#1{y}]K » %0:t1[#0{x}]K ArrangeBy keys=[[#0{x}]] Filter (#0{x}) IS NOT NULL ReadStorage materialize.public.t1 diff --git a/test/sqllogictest/explain/locally_optimized_plan.slt b/test/sqllogictest/explain/locally_optimized_plan.slt index 4fc5aec67f39c..8dc86e7661a05 100644 --- a/test/sqllogictest/explain/locally_optimized_plan.slt +++ b/test/sqllogictest/explain/locally_optimized_plan.slt @@ -39,10 +39,10 @@ VIEW v; ---- With cte l0 = - Join on=(#2 = integer_to_bigint(#0)) - Filter (#1 = 100) AND (#0) IS NOT NULL + Join on=(#2{id} = integer_to_bigint(#0{id})) + Filter (#1{balance} = 100) AND (#0{id}) IS NOT NULL Get materialize.public.accounts - Filter (#0) IS NOT NULL + Filter (#0{id}) IS NOT NULL Get materialize.public.account_details cte l1 = Filter (#1 = 100) @@ -71,10 +71,10 @@ REPLAN VIEW v; ---- With cte l0 = - Join on=(#2 = integer_to_bigint(#0)) - Filter (#1 = 100) AND (#0) IS NOT NULL + Join on=(#2{id} = integer_to_bigint(#0{id})) + Filter (#1{balance} = 100) AND (#0{id}) IS NOT NULL Get materialize.public.accounts - Filter (#0) IS NOT NULL + Filter (#0{id}) IS NOT NULL Get materialize.public.account_details cte l1 = Filter (#1 = 100) @@ -104,10 +104,10 @@ REPLAN VIEW v; ---- With cte l0 = - Join on=(#2 = integer_to_bigint(#0)) - Filter (#0) IS NOT NULL + Join on=(#2{id} = integer_to_bigint(#0{id})) + Filter (#0{id}) IS NOT NULL Get materialize.public.accounts - Filter (#0) IS NOT NULL + Filter (#0{id}) IS NOT NULL Get materialize.public.account_details Return Project (#0, #1, #3) @@ -116,14 +116,14 @@ Return Union Project (#0, #1) Negate - Join on=(#2 = integer_to_bigint(#0)) - Filter (#1 = 100) AND (#0) IS NOT NULL + Join on=(#2 = integer_to_bigint(#0{id})) + Filter (#1{balance} = 100) AND (#0{id}) IS NOT NULL Get materialize.public.accounts Distinct project=[#2] Get l0 - Filter (#1 = 100) + Filter (#1{balance} = 100) Get materialize.public.accounts - Filter (#1 = 100) + Filter (#1{balance} = 100) Get l0 EOF @@ -152,10 +152,10 @@ VIEW v; ---- With cte l0 = - Join on=(#2 = integer_to_bigint(#0)) - Filter (#0) IS NOT NULL + Join on=(#2{id} = integer_to_bigint(#0{id})) + Filter (#0{id}) IS NOT NULL Get materialize.public.accounts - Filter (#0) IS NOT NULL + Filter (#0{id}) IS NOT NULL Get materialize.public.account_details Return Project (#0, #1, #3) @@ -164,14 +164,14 @@ Return Union Project (#0, #1) Negate - Join on=(#2 = integer_to_bigint(#0)) - Filter (#1 = 100) AND (#0) IS NOT NULL + Join on=(#2 = integer_to_bigint(#0{id})) + Filter (#1{balance} = 100) AND (#0{id}) IS NOT NULL Get materialize.public.accounts Distinct project=[#2] Get l0 - Filter (#1 = 100) + Filter (#1{balance} = 100) Get materialize.public.accounts - Filter (#1 = 100) + Filter (#1{balance} = 100) Get l0 EOF @@ -183,10 +183,10 @@ REPLAN VIEW v; ---- With cte l0 = - Join on=(#2 = integer_to_bigint(#0)) - Filter (#1 = 100) AND (#0) IS NOT NULL + Join on=(#2{id} = integer_to_bigint(#0{id})) + Filter (#1{balance} = 100) AND (#0{id}) IS NOT NULL Get materialize.public.accounts - Filter (#0) IS NOT NULL + Filter (#0{id}) IS NOT NULL Get materialize.public.account_details cte l1 = Filter (#1 = 100) diff --git a/test/sqllogictest/explain/materialized_view.slt b/test/sqllogictest/explain/materialized_view.slt index ebae5f3fbe5ba..70650bd77aa2b 100644 --- a/test/sqllogictest/explain/materialized_view.slt +++ b/test/sqllogictest/explain/materialized_view.slt @@ -62,7 +62,7 @@ materialize.public.mv: raw=true Source materialize.public.accounts - filter=((#1 = 100)) + filter=((#1{balance} = 100)) Target cluster: quickstart @@ -97,12 +97,12 @@ materialize.public.mv: linear_stage[0] closure project=(#1, #0) - lookup={ relation=0, key=[#1] } + lookup={ relation=0, key=[#1{balance}] } stream={ key=[#0], thinning=() } source={ relation=1, key=[#0] } Get::PassArrangements materialize.public.accounts raw=false - arrangements[0]={ key=[#1], permutation={#0: #1, #1: #0}, thinning=(#0) } + arrangements[0]={ key=[#1{balance}], permutation={#0: #1, #1: #0}, thinning=(#0) } types=[integer?, integer?] ArrangeBy raw=true @@ -146,12 +146,12 @@ materialize.public.mv: linear_stage[0] closure project=(#1, #0) - lookup={ relation=0, key=[#1] } + lookup={ relation=0, key=[#1{balance}] } stream={ key=[#0], thinning=() } source={ relation=1, key=[#0] } Get::PassArrangements materialize.public.accounts raw=false - arrangements[0]={ key=[#1], permutation={#0: #1, #1: #0}, thinning=(#0) } + arrangements[0]={ key=[#1{balance}], permutation={#0: #1, #1: #0}, thinning=(#0) } types=[integer?, integer?] ArrangeBy raw=true @@ -196,12 +196,12 @@ materialize.public.mv: linear_stage[0] closure project=(#1, #0) - lookup={ relation=0, key=[#1] } + lookup={ relation=0, key=[#1{balance}] } stream={ key=[#0], thinning=() } source={ relation=1, key=[#0] } Get::PassArrangements materialize.public.accounts raw=false - arrangements[0]={ key=[#1], permutation={#0: #1, #1: #0}, thinning=(#0) } + arrangements[0]={ key=[#1{balance}], permutation={#0: #1, #1: #0}, thinning=(#0) } types=[integer?, integer?] ArrangeBy raw=true diff --git a/test/sqllogictest/explain/optimized_plan_as_json.slt b/test/sqllogictest/explain/optimized_plan_as_json.slt index feb886f8ecd05..4f9c6d7b45c08 100644 --- a/test/sqllogictest/explain/optimized_plan_as_json.slt +++ b/test/sqllogictest/explain/optimized_plan_as_json.slt @@ -161,10 +161,16 @@ SELECT 1, a + b as c FROM t WHERE a > 0 and b < 0 and a + b > 0 "CallBinary": { "func": "AddInt32", "expr1": { - "Column": 0 + "Column": [ + 0, + "a" + ] }, "expr2": { - "Column": 1 + "Column": [ + 1, + "b" + ] } } }, @@ -192,7 +198,10 @@ SELECT 1, a + b as c FROM t WHERE a > 0 and b < 0 and a + b > 0 "CallBinary": { "func": "Gt", "expr1": { - "Column": 0 + "Column": [ + 0, + "a" + ] }, "expr2": { "Literal": [ @@ -218,7 +227,10 @@ SELECT 1, a + b as c FROM t WHERE a > 0 and b < 0 and a + b > 0 "CallBinary": { "func": "Lt", "expr1": { - "Column": 1 + "Column": [ + 1, + "b" + ] }, "expr2": { "Literal": [ @@ -244,7 +256,10 @@ SELECT 1, a + b as c FROM t WHERE a > 0 and b < 0 and a + b > 0 "CallBinary": { "func": "Gt", "expr1": { - "Column": 2 + "Column": [ + 2, + null + ] }, "expr2": { "Literal": [ @@ -323,10 +338,16 @@ SELECT 1, a + b as c FROM mv WHERE a > 0 and b < 0 and a + b > 0 "CallBinary": { "func": "AddInt32", "expr1": { - "Column": 0 + "Column": [ + 0, + "a" + ] }, "expr2": { - "Column": 1 + "Column": [ + 1, + "b" + ] } } }, @@ -354,7 +375,10 @@ SELECT 1, a + b as c FROM mv WHERE a > 0 and b < 0 and a + b > 0 "CallBinary": { "func": "Lt", "expr1": { - "Column": 1 + "Column": [ + 1, + "b" + ] }, "expr2": { "Literal": [ @@ -377,7 +401,10 @@ SELECT 1, a + b as c FROM mv WHERE a > 0 and b < 0 and a + b > 0 "CallBinary": { "func": "Gt", "expr1": { - "Column": 0 + "Column": [ + 0, + "a" + ] }, "expr2": { "Literal": [ @@ -400,7 +427,10 @@ SELECT 1, a + b as c FROM mv WHERE a > 0 and b < 0 and a + b > 0 "CallBinary": { "func": "Gt", "expr1": { - "Column": 2 + "Column": [ + 2, + null + ] }, "expr2": { "Literal": [ @@ -444,7 +474,10 @@ SELECT 1, a + b as c FROM mv WHERE a > 0 and b < 0 and a + b > 0 "CallBinary": { "func": "Gt", "expr1": { - "Column": 0 + "Column": [ + 0, + "a" + ] }, "expr2": { "Literal": [ @@ -470,7 +503,10 @@ SELECT 1, a + b as c FROM mv WHERE a > 0 and b < 0 and a + b > 0 "CallBinary": { "func": "Lt", "expr1": { - "Column": 1 + "Column": [ + 1, + "b" + ] }, "expr2": { "Literal": [ @@ -499,10 +535,16 @@ SELECT 1, a + b as c FROM mv WHERE a > 0 and b < 0 and a + b > 0 "CallBinary": { "func": "AddInt32", "expr1": { - "Column": 0 + "Column": [ + 0, + "a" + ] }, "expr2": { - "Column": 1 + "Column": [ + 1, + "b" + ] } } }, @@ -584,10 +626,16 @@ SELECT generate_series(a, b) from t "func": "GenerateSeriesInt32", "exprs": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] }, { - "Column": 1 + "Column": [ + 1, + "b" + ] }, { "Literal": [ @@ -675,7 +723,10 @@ SELECT a FROM t EXCEPT SELECT b FROM mv }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -720,7 +771,10 @@ SELECT a FROM t EXCEPT SELECT b FROM mv }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -1031,14 +1085,20 @@ SELECT abs(min(a) - max(a)) FROM t { "func": "MinInt32", "expr": { - "Column": 0 + "Column": [ + 0, + "a" + ] }, "distinct": false }, { "func": "MaxInt32", "expr": { - "Column": 0 + "Column": [ + 0, + "a" + ] }, "distinct": false } @@ -1182,10 +1242,16 @@ SELECT abs(min(a) - max(a)) FROM t "CallBinary": { "func": "SubInt32", "expr1": { - "Column": 0 + "Column": [ + 0, + "?column?" + ] }, "expr2": { - "Column": 1 + "Column": [ + 1, + "?column?" + ] } } } @@ -1256,21 +1322,30 @@ SELECT abs(min(a) - max(a)) FROM t GROUP BY b }, "group_key": [ { - "Column": 1 + "Column": [ + 1, + null + ] } ], "aggregates": [ { "func": "MinInt32", "expr": { - "Column": 0 + "Column": [ + 0, + "a" + ] }, "distinct": false }, { "func": "MaxInt32", "expr": { - "Column": 0 + "Column": [ + 0, + "a" + ] }, "distinct": false } @@ -1289,10 +1364,16 @@ SELECT abs(min(a) - max(a)) FROM t GROUP BY b "CallBinary": { "func": "SubInt32", "expr1": { - "Column": 1 + "Column": [ + 1, + "?column?" + ] }, "expr2": { - "Column": 2 + "Column": [ + 2, + "?column?" + ] } } } @@ -1366,7 +1447,10 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC "keys": [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ] ] @@ -1428,7 +1512,10 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -1535,10 +1622,16 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC "CallBinary": { "func": "Lt", "expr1": { - "Column": 0 + "Column": [ + 0, + "a" + ] }, "expr2": { - "Column": 1 + "Column": [ + 1, + "a" + ] } } } @@ -1552,7 +1645,10 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -1563,7 +1659,10 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC "keys": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] } ] ] @@ -1573,10 +1672,16 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC "equivalences": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] }, { - "Column": 2 + "Column": [ + 2, + null + ] } ] ], @@ -1586,7 +1691,10 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC 1, [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], { @@ -1612,7 +1720,10 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC 0, [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], { @@ -1675,7 +1786,10 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC "keys": [ [ { - "Column": 1 + "Column": [ + 1, + null + ] } ] ] @@ -1726,7 +1840,10 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -1833,10 +1950,16 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC "CallBinary": { "func": "Gt", "expr1": { - "Column": 0 + "Column": [ + 0, + "b" + ] }, "expr2": { - "Column": 1 + "Column": [ + 1, + "b" + ] } } } @@ -1850,7 +1973,10 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -1861,7 +1987,10 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC "keys": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] } ] ] @@ -1871,10 +2000,16 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC "equivalences": [ [ { - "Column": 1 + "Column": [ + 1, + null + ] }, { - "Column": 2 + "Column": [ + 2, + null + ] } ] ], @@ -1884,7 +2019,10 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC 1, [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], { @@ -1910,7 +2048,10 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC 0, [ { - "Column": 1 + "Column": [ + 1, + null + ] } ], { @@ -2032,7 +2173,10 @@ SELECT (SELECT iv.a FROM iv WHERE iv.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHER }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -2069,7 +2213,10 @@ SELECT (SELECT iv.a FROM iv WHERE iv.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHER "keys": [ [ { - "Column": 0 + "Column": [ + 0, + "b" + ] } ] ] @@ -2154,7 +2301,10 @@ SELECT (SELECT iv.a FROM iv WHERE iv.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHER "IsNull": null }, "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] } } } @@ -2166,7 +2316,10 @@ SELECT (SELECT iv.a FROM iv WHERE iv.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHER "keys": [ [ { - "Column": 1 + "Column": [ + 1, + "b" + ] } ] ] @@ -2176,10 +2329,16 @@ SELECT (SELECT iv.a FROM iv WHERE iv.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHER "equivalences": [ [ { - "Column": 0 + "Column": [ + 0, + "b" + ] }, { - "Column": 2 + "Column": [ + 2, + "b" + ] } ] ], @@ -2189,7 +2348,10 @@ SELECT (SELECT iv.a FROM iv WHERE iv.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHER 0, [ { - "Column": 0 + "Column": [ + 0, + "b" + ] } ], { @@ -2215,7 +2377,10 @@ SELECT (SELECT iv.a FROM iv WHERE iv.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHER 1, [ { - "Column": 1 + "Column": [ + 1, + "b" + ] } ], { @@ -2342,7 +2507,10 @@ SELECT (SELECT iv.a FROM iv WHERE iv.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHER "IsNull": null }, "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] } } } @@ -2354,7 +2522,10 @@ SELECT (SELECT iv.a FROM iv WHERE iv.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHER "keys": [ [ { - "Column": 1 + "Column": [ + 1, + "b" + ] } ] ] @@ -2364,10 +2535,16 @@ SELECT (SELECT iv.a FROM iv WHERE iv.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHER "equivalences": [ [ { - "Column": 0 + "Column": [ + 0, + "b" + ] }, { - "Column": 2 + "Column": [ + 2, + "b" + ] } ] ], @@ -2377,7 +2554,10 @@ SELECT (SELECT iv.a FROM iv WHERE iv.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHER 0, [ { - "Column": 0 + "Column": [ + 0, + "b" + ] } ], { @@ -2403,7 +2583,10 @@ SELECT (SELECT iv.a FROM iv WHERE iv.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHER 1, [ { - "Column": 1 + "Column": [ + 1, + "b" + ] } ], { @@ -2487,7 +2670,10 @@ SELECT (SELECT iv.a FROM iv WHERE iv.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHER "keys": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] } ] ] @@ -2613,7 +2799,10 @@ SELECT (SELECT iv.a FROM iv WHERE iv.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHER "keys": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] } ] ] @@ -2739,7 +2928,10 @@ SELECT (SELECT iv.a FROM iv WHERE iv.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHER "keys": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] } ] ] @@ -2749,13 +2941,22 @@ SELECT (SELECT iv.a FROM iv WHERE iv.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHER "equivalences": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] }, { - "Column": 1 + "Column": [ + 1, + null + ] }, { - "Column": 3 + "Column": [ + 3, + null + ] } ] ], @@ -2766,7 +2967,10 @@ SELECT (SELECT iv.a FROM iv WHERE iv.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHER 1, [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], { @@ -2791,7 +2995,10 @@ SELECT (SELECT iv.a FROM iv WHERE iv.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHER 2, [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], { @@ -2818,7 +3025,10 @@ SELECT (SELECT iv.a FROM iv WHERE iv.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHER 2, [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], { @@ -2843,7 +3053,10 @@ SELECT (SELECT iv.a FROM iv WHERE iv.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHER 0, [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], { @@ -2870,7 +3083,10 @@ SELECT (SELECT iv.a FROM iv WHERE iv.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHER 1, [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], { @@ -2895,7 +3111,10 @@ SELECT (SELECT iv.a FROM iv WHERE iv.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHER 0, [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], { @@ -2960,7 +3179,10 @@ SELECT (SELECT iv.a FROM iv WHERE iv.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHER "IsNull": null }, "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] } } } @@ -3040,7 +3262,10 @@ RIGHT JOIN t as t3 ON t2.b = t3.b "IsNull": null }, "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] } } } @@ -3078,7 +3303,10 @@ RIGHT JOIN t as t3 ON t2.b = t3.b "keys": [ [ { - "Column": 1 + "Column": [ + 1, + "b" + ] } ] ] @@ -3120,7 +3348,10 @@ RIGHT JOIN t as t3 ON t2.b = t3.b "keys": [ [ { - "Column": 0 + "Column": [ + 0, + "b" + ] } ] ] @@ -3197,13 +3428,22 @@ RIGHT JOIN t as t3 ON t2.b = t3.b "equivalences": [ [ { - "Column": 1 + "Column": [ + 1, + "b" + ] }, { - "Column": 3 + "Column": [ + 3, + "b" + ] }, { - "Column": 4 + "Column": [ + 4, + "b" + ] } ] ], @@ -3214,7 +3454,10 @@ RIGHT JOIN t as t3 ON t2.b = t3.b 1, [ { - "Column": 1 + "Column": [ + 1, + "b" + ] } ], { @@ -3239,7 +3482,10 @@ RIGHT JOIN t as t3 ON t2.b = t3.b 2, [ { - "Column": 0 + "Column": [ + 0, + "b" + ] } ], { @@ -3266,7 +3512,10 @@ RIGHT JOIN t as t3 ON t2.b = t3.b 0, [ { - "Column": 1 + "Column": [ + 1, + "b" + ] } ], { @@ -3291,7 +3540,10 @@ RIGHT JOIN t as t3 ON t2.b = t3.b 2, [ { - "Column": 0 + "Column": [ + 0, + "b" + ] } ], { @@ -3318,7 +3570,10 @@ RIGHT JOIN t as t3 ON t2.b = t3.b 0, [ { - "Column": 1 + "Column": [ + 1, + "b" + ] } ], { @@ -3343,7 +3598,10 @@ RIGHT JOIN t as t3 ON t2.b = t3.b 1, [ { - "Column": 1 + "Column": [ + 1, + "b" + ] } ], { @@ -3444,7 +3702,10 @@ RIGHT JOIN t as t3 ON t2.b = t3.b }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -3455,7 +3716,10 @@ RIGHT JOIN t as t3 ON t2.b = t3.b "keys": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] } ] ] @@ -3465,10 +3729,16 @@ RIGHT JOIN t as t3 ON t2.b = t3.b "equivalences": [ [ { - "Column": 0 + "Column": [ + 0, + "b" + ] }, { - "Column": 1 + "Column": [ + 1, + null + ] } ] ], @@ -3478,7 +3748,10 @@ RIGHT JOIN t as t3 ON t2.b = t3.b 1, [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], { @@ -3504,7 +3777,10 @@ RIGHT JOIN t as t3 ON t2.b = t3.b 0, [ { - "Column": 0 + "Column": [ + 0, + "b" + ] } ], { @@ -3804,7 +4080,10 @@ FROM "keys": [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ] ] @@ -3840,7 +4119,10 @@ FROM }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -3924,7 +4206,10 @@ FROM }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [ @@ -3934,10 +4219,16 @@ FROM "CallBinary": { "func": "MulInt32", "expr1": { - "Column": 0 + "Column": [ + 0, + "a" + ] }, "expr2": { - "Column": 1 + "Column": [ + 1, + "a" + ] } } }, @@ -3951,7 +4242,10 @@ FROM "keys": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] } ] ] @@ -3961,10 +4255,16 @@ FROM "equivalences": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] }, { - "Column": 2 + "Column": [ + 2, + null + ] } ] ], @@ -3974,7 +4274,10 @@ FROM 1, [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], { @@ -4000,7 +4303,10 @@ FROM 0, [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], { @@ -4031,10 +4337,16 @@ FROM "CallBinary": { "func": "NotEq", "expr1": { - "Column": 0 + "Column": [ + 0, + null + ] }, "expr2": { - "Column": 3 + "Column": [ + 3, + "m" + ] } } } @@ -4085,7 +4397,10 @@ FROM "keys": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] } ] ] @@ -4136,7 +4451,10 @@ FROM }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [], @@ -4220,7 +4538,10 @@ FROM }, "group_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "aggregates": [ @@ -4230,10 +4551,16 @@ FROM "CallBinary": { "func": "MulInt32", "expr1": { - "Column": 0 + "Column": [ + 0, + "a" + ] }, "expr2": { - "Column": 1 + "Column": [ + 1, + "a" + ] } } }, @@ -4247,7 +4574,10 @@ FROM "keys": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] } ] ] @@ -4257,10 +4587,16 @@ FROM "equivalences": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] }, { - "Column": 3 + "Column": [ + 3, + null + ] } ] ], @@ -4270,7 +4606,10 @@ FROM 1, [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], { @@ -4296,7 +4635,10 @@ FROM 0, [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], { @@ -4327,10 +4669,16 @@ FROM "CallBinary": { "func": "NotEq", "expr1": { - "Column": 0 + "Column": [ + 0, + null + ] }, "expr2": { - "Column": 4 + "Column": [ + 4, + "m" + ] } } } @@ -4575,7 +4923,10 @@ WHERE t1.b = t2.b AND t2.b = t3.b "IsNull": null }, "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] } } } @@ -4613,7 +4964,10 @@ WHERE t1.b = t2.b AND t2.b = t3.b "keys": [ [ { - "Column": 1 + "Column": [ + 1, + "b" + ] } ] ] @@ -4699,7 +5053,10 @@ WHERE t1.b = t2.b AND t2.b = t3.b "keys": [ [ { - "Column": 0 + "Column": [ + 0, + "b" + ] } ] ] @@ -4709,13 +5066,22 @@ WHERE t1.b = t2.b AND t2.b = t3.b "equivalences": [ [ { - "Column": 1 + "Column": [ + 1, + "b" + ] }, { - "Column": 3 + "Column": [ + 3, + "b" + ] }, { - "Column": 4 + "Column": [ + 4, + "b" + ] } ] ], @@ -4726,7 +5092,10 @@ WHERE t1.b = t2.b AND t2.b = t3.b 1, [ { - "Column": 1 + "Column": [ + 1, + "b" + ] } ], { @@ -4751,7 +5120,10 @@ WHERE t1.b = t2.b AND t2.b = t3.b 2, [ { - "Column": 0 + "Column": [ + 0, + "b" + ] } ], { @@ -4778,7 +5150,10 @@ WHERE t1.b = t2.b AND t2.b = t3.b 0, [ { - "Column": 1 + "Column": [ + 1, + "b" + ] } ], { @@ -4803,7 +5178,10 @@ WHERE t1.b = t2.b AND t2.b = t3.b 2, [ { - "Column": 0 + "Column": [ + 0, + "b" + ] } ], { @@ -4830,7 +5208,10 @@ WHERE t1.b = t2.b AND t2.b = t3.b 0, [ { - "Column": 1 + "Column": [ + 1, + "b" + ] } ], { @@ -4855,7 +5236,10 @@ WHERE t1.b = t2.b AND t2.b = t3.b 1, [ { - "Column": 1 + "Column": [ + 1, + "b" + ] } ], { @@ -4965,7 +5349,10 @@ WHERE a = c and d = e and b = f "keys": [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ] ] @@ -5018,12 +5405,18 @@ WHERE a = c and d = e and b = f "keys": [ [ { - "Column": 0 + "Column": [ + 0, + "c" + ] } ], [ { - "Column": 1 + "Column": [ + 1, + "d" + ] } ] ] @@ -5068,7 +5461,10 @@ WHERE a = c and d = e and b = f "keys": [ [ { - "Column": 0 + "Column": [ + 0, + "e" + ] } ] ] @@ -5078,26 +5474,44 @@ WHERE a = c and d = e and b = f "equivalences": [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] }, { - "Column": 2 + "Column": [ + 2, + "c" + ] } ], [ { - "Column": 1 + "Column": [ + 1, + "b" + ] }, { - "Column": 5 + "Column": [ + 5, + "f" + ] } ], [ { - "Column": 3 + "Column": [ + 3, + "d" + ] }, { - "Column": 4 + "Column": [ + 4, + "e" + ] } ] ], @@ -5108,7 +5522,10 @@ WHERE a = c and d = e and b = f 1, [ { - "Column": 0 + "Column": [ + 0, + "c" + ] } ], { @@ -5133,7 +5550,10 @@ WHERE a = c and d = e and b = f 2, [ { - "Column": 0 + "Column": [ + 0, + "e" + ] } ], { @@ -5160,7 +5580,10 @@ WHERE a = c and d = e and b = f 0, [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], { @@ -5185,7 +5608,10 @@ WHERE a = c and d = e and b = f 2, [ { - "Column": 0 + "Column": [ + 0, + "e" + ] } ], { @@ -5212,7 +5638,10 @@ WHERE a = c and d = e and b = f 1, [ { - "Column": 1 + "Column": [ + 1, + "d" + ] } ], { @@ -5237,7 +5666,10 @@ WHERE a = c and d = e and b = f 0, [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], { @@ -5275,7 +5707,10 @@ WHERE a = c and d = e and b = f "IsNull": null }, "expr": { - "Column": 0 + "Column": [ + 0, + "a" + ] } } } @@ -5292,7 +5727,10 @@ WHERE a = c and d = e and b = f "IsNull": null }, "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] } } } @@ -5309,7 +5747,10 @@ WHERE a = c and d = e and b = f "IsNull": null }, "expr": { - "Column": 3 + "Column": [ + 3, + "d" + ] } } } @@ -5396,7 +5837,10 @@ WHERE b = c and d = e "keys": [ [ { - "Column": 1 + "Column": [ + 1, + "b" + ] } ] ] @@ -5449,12 +5893,18 @@ WHERE b = c and d = e "keys": [ [ { - "Column": 0 + "Column": [ + 0, + "c" + ] } ], [ { - "Column": 1 + "Column": [ + 1, + "d" + ] } ] ] @@ -5499,7 +5949,10 @@ WHERE b = c and d = e "keys": [ [ { - "Column": 0 + "Column": [ + 0, + "e" + ] } ] ] @@ -5509,18 +5962,30 @@ WHERE b = c and d = e "equivalences": [ [ { - "Column": 1 + "Column": [ + 1, + "b" + ] }, { - "Column": 2 + "Column": [ + 2, + "c" + ] } ], [ { - "Column": 3 + "Column": [ + 3, + "d" + ] }, { - "Column": 4 + "Column": [ + 4, + "e" + ] } ] ], @@ -5531,7 +5996,10 @@ WHERE b = c and d = e 1, [ { - "Column": 0 + "Column": [ + 0, + "c" + ] } ], { @@ -5556,7 +6024,10 @@ WHERE b = c and d = e 2, [ { - "Column": 0 + "Column": [ + 0, + "e" + ] } ], { @@ -5583,7 +6054,10 @@ WHERE b = c and d = e 0, [ { - "Column": 1 + "Column": [ + 1, + "b" + ] } ], { @@ -5608,7 +6082,10 @@ WHERE b = c and d = e 2, [ { - "Column": 0 + "Column": [ + 0, + "e" + ] } ], { @@ -5635,7 +6112,10 @@ WHERE b = c and d = e 1, [ { - "Column": 1 + "Column": [ + 1, + "d" + ] } ], { @@ -5660,7 +6140,10 @@ WHERE b = c and d = e 0, [ { - "Column": 1 + "Column": [ + 1, + "b" + ] } ], { @@ -5698,7 +6181,10 @@ WHERE b = c and d = e "IsNull": null }, "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] } } } @@ -5715,7 +6201,10 @@ WHERE b = c and d = e "IsNull": null }, "expr": { - "Column": 3 + "Column": [ + 3, + "d" + ] } } } @@ -5799,7 +6288,10 @@ SELECT s FROM t2 WHERE s ~ 'a.*'; } }, "expr": { - "Column": 0 + "Column": [ + 0, + "s" + ] } } } @@ -5833,7 +6325,10 @@ SELECT s FROM t2 WHERE s ~ 'a.*'; } }, "expr": { - "Column": 0 + "Column": [ + 0, + "s" + ] } } } diff --git a/test/sqllogictest/explain/optimized_plan_as_text.slt b/test/sqllogictest/explain/optimized_plan_as_text.slt index ae50378b34bf4..8c80fcfa96f4d 100644 --- a/test/sqllogictest/explain/optimized_plan_as_text.slt +++ b/test/sqllogictest/explain/optimized_plan_as_text.slt @@ -544,7 +544,7 @@ Explained Query: ReadIndex on=t t_a_idx=[*** full scan ***] Return Project (#2) - Map ((#0 + #1)) + Map ((#0{v} + #1{v})) CrossJoin type=differential Get l0 Get l0 @@ -807,9 +807,9 @@ Explained Query: Filter (#0{a}) IS NOT NULL AND (#1{b}) IS NOT NULL AND (#3{d}) IS NOT NULL Join on=(#0{a} = #2{c} AND #1{b} = #5{f} AND #3{d} = #4{e}) type=delta implementation - %0:t » %1:u[#0]KA » %2:v[#0]KA - %1:u » %0:t[#0]KA » %2:v[#0]KA - %2:v » %1:u[#1]KA » %0:t[#0]KA + %0:t » %1:u[#0{c}]KA » %2:v[#0{e}]KA + %1:u » %0:t[#0{a}]KA » %2:v[#0{e}]KA + %2:v » %1:u[#1{d}]KA » %0:t[#0{a}]KA ArrangeBy keys=[[#0{a}]] ReadIndex on=t t_a_idx=[delta join 1st input (full scan)] ArrangeBy keys=[[#0{c}], [#1{d}]] @@ -877,9 +877,9 @@ Explained Query: Filter (#1{b}) IS NOT NULL AND (#3{d}) IS NOT NULL Join on=(#1{b} = #2{c} AND #3{d} = #4{e}) type=delta implementation - %0:t » %1:u[#0]KA » %2:v[#0]KA - %1:u » %0:t[#1]KA » %2:v[#0]KA - %2:v » %1:u[#1]KA » %0:t[#1]KA + %0:t » %1:u[#0{c}]KA » %2:v[#0{e}]KA + %1:u » %0:t[#1{b}]KA » %2:v[#0{e}]KA + %2:v » %1:u[#1{d}]KA » %0:t[#1{b}]KA ArrangeBy keys=[[#1{b}]] ReadIndex on=t t_b_idx=[delta join 1st input (full scan)] ArrangeBy keys=[[#0{c}], [#1{d}]] @@ -909,9 +909,9 @@ Explained Query: Filter (#0{a}) IS NOT NULL AND (#1{b}) IS NOT NULL Join on=(#0{a} = #2{c} AND #1{b} = #4{e}) type=delta implementation - %0:t » %1:u[#0]KA » %2:v[#0]KA - %1:u » %0:t[#0]KA » %2:v[#0]KA - %2:v » %0:t[#1]KA » %1:u[#0]KA + %0:t » %1:u[#0{c}]KA » %2:v[#0{e}]KA + %1:u » %0:t[#0{a}]KA » %2:v[#0{e}]KA + %2:v » %0:t[#1{b}]KA » %1:u[#0{c}]KA ArrangeBy keys=[[#0{a}], [#1{b}]] ReadIndex on=t t_a_idx=[delta join 1st input (full scan)] t_b_idx=[delta join lookup] ArrangeBy keys=[[#0{c}]] @@ -1752,7 +1752,7 @@ SELECT a+b FROM t4; ---- Explained Query: Project (#3) - Map ((#0 + #1)) + Map ((#0{a} + #1{b})) ReadStorage materialize.public.t4 Source materialize.public.t4 diff --git a/test/sqllogictest/explain/physical_plan_aggregates.slt b/test/sqllogictest/explain/physical_plan_aggregates.slt index ddde423c774a2..11babd8c698b0 100644 --- a/test/sqllogictest/explain/physical_plan_aggregates.slt +++ b/test/sqllogictest/explain/physical_plan_aggregates.slt @@ -24,10 +24,10 @@ EXPLAIN PHYSICAL PLAN AS TEXT FOR SELECT a, array_agg(b) FROM t GROUP BY a; ---- Explained Query: Reduce::Basic - aggr=(0, array_agg[order_by=[]](row(array[#1]))) + aggr=(0, array_agg[order_by=[]](row(array[#1{b}]))) val_plan project=(#2) - map=(row(array[#1])) + map=(row(array[#1{b}])) key_plan project=(#0) Get::Collection materialize.public.t @@ -50,20 +50,20 @@ Explained Query: stream={ key=[#0], thinning=(#1) } source={ relation=0, key=[#0] } Reduce::Basic - aggr=(0, array_agg[order_by=[]](row(array[#1]))) + aggr=(0, array_agg[order_by=[]](row(array[#1{b}]))) val_plan project=(#2) - map=(row(array[#1])) + map=(row(array[#1{b}])) key_plan project=(#0) Get::Collection materialize.public.t project=(#0, #1) raw=true Reduce::Basic - aggr=(0, array_agg[order_by=[]](row(array[#1]))) + aggr=(0, array_agg[order_by=[]](row(array[#1{c}]))) val_plan project=(#2) - map=(row(array[#1])) + map=(row(array[#1{c}])) key_plan project=(#0) Get::Collection materialize.public.t @@ -84,20 +84,20 @@ Explained Query: stream={ key=[#0], thinning=(#1) } source={ relation=0, key=[#0] } Reduce::Basic - aggr=(0, array_agg[order_by=[]](row(array[#1]))) + aggr=(0, array_agg[order_by=[]](row(array[#1{b}]))) val_plan project=(#2) - map=(row(array[#1])) + map=(row(array[#1{b}])) key_plan project=(#0) Get::Collection materialize.public.t project=(#0, #1) raw=true Reduce::Basic - aggr=(0, string_agg[order_by=[]](row(row(#1, ",")))) + aggr=(0, string_agg[order_by=[]](row(row(#1{c}, ",")))) val_plan project=(#2) - map=(row(row(#1, ","))) + map=(row(row(#1{c}, ","))) key_plan project=(#0) Get::Collection materialize.public.t @@ -118,20 +118,20 @@ Explained Query: stream={ key=[#0], thinning=(#1) } source={ relation=0, key=[#0] } Reduce::Basic - aggr=(0, array_agg[order_by=[]](row(array[#1]))) + aggr=(0, array_agg[order_by=[]](row(array[#1{b}]))) val_plan project=(#2) - map=(row(array[#1])) + map=(row(array[#1{b}])) key_plan project=(#0) Get::Collection materialize.public.t project=(#0, #1) raw=true Reduce::Basic - aggr=(0, string_agg[order_by=[#0 desc nulls_first]](row(row(#2, ","), #1))) + aggr=(0, string_agg[order_by=[#0 desc nulls_first]](row(row(#2{c}, ","), #1{b}))) val_plan project=(#3) - map=(row(row(#2, ","), #1)) + map=(row(row(#2{c}, ","), #1{b})) key_plan project=(#0) Get::PassArrangements materialize.public.t @@ -172,10 +172,10 @@ Explained Query: project=(#0, #2) raw=true Reduce::Basic - aggr=(0, array_agg[order_by=[]](row(array[#1]))) + aggr=(0, array_agg[order_by=[]](row(array[#1{b}]))) val_plan project=(#2) - map=(row(array[#1])) + map=(row(array[#1{b}])) key_plan project=(#0) Get::Collection l0 @@ -183,7 +183,7 @@ Explained Query: raw=true Source materialize.public.t - filter=((#2 != "x")) + filter=((#2{c} != "x")) Target cluster: quickstart @@ -208,7 +208,7 @@ Explained Query: delta_stage[0] closure project=(#0, #1) - filter=((#2 > 1)) + filter=((#2{?column?} > 1)) lookup={ relation=1, key=[#0] } stream={ key=[#0], thinning=(#1) } source={ relation=0, key=[#0] } @@ -225,7 +225,7 @@ Explained Query: stream={ key=[#0], thinning=() } initial_closure project=(#0) - filter=((#1 > 1)) + filter=((#1{?column?} > 1)) source={ relation=1, key=[#0] } plan_path[2] delta_stage[1] @@ -234,7 +234,7 @@ Explained Query: delta_stage[0] closure project=(#0, #1) - filter=((#2 > 1)) + filter=((#2{?column?} > 1)) lookup={ relation=1, key=[#0] } stream={ key=[#0], thinning=(#1) } source={ relation=2, key=[#0] } @@ -259,10 +259,10 @@ Explained Query: project=(#0) raw=true Reduce::Basic - aggr=(0, array_agg[order_by=[]](row(array[#1]))) + aggr=(0, array_agg[order_by=[]](row(array[#1{b}]))) val_plan project=(#2) - map=(row(array[#1])) + map=(row(array[#1{b}])) key_plan project=(#0) Get::PassArrangements l0 @@ -313,19 +313,19 @@ Explained Query: stream={ key=[#0], thinning=(#1) } source={ relation=0, key=[#0] } Reduce::Basic - aggr=(0, array_agg[order_by=[#0 asc nulls_last]](row(array[#1], #1))) + aggr=(0, array_agg[order_by=[#0 asc nulls_last]](row(array[#1{b}], #1{b}))) val_plan project=(#2) - map=(row(array[#1], #1)) + map=(row(array[#1{b}], #1{b})) key_plan project=(#0) Get::PassArrangements l0 raw=true Reduce::Basic - aggr=(0, array_agg[order_by=[#0 desc nulls_first]](row(array[#1], #1))) + aggr=(0, array_agg[order_by=[#0 desc nulls_first]](row(array[#1{b}], #1{b}))) val_plan project=(#2) - map=(row(array[#1], #1)) + map=(row(array[#1{b}], #1{b})) key_plan project=(#0) Get::PassArrangements l0 @@ -388,19 +388,19 @@ Explained Query: project=() raw=true Reduce::Basic - aggr=(0, array_agg[order_by=[#0 asc nulls_last]](row(array[#0], #0))) + aggr=(0, array_agg[order_by=[#0 asc nulls_last]](row(array[#0{b}], #0{b}))) val_plan project=(#1) - map=(row(array[#0], #0)) + map=(row(array[#0{b}], #0{b})) key_plan project=() Get::PassArrangements l0 raw=true Reduce::Basic - aggr=(0, array_agg[order_by=[#0 desc nulls_first]](row(array[#0], #0))) + aggr=(0, array_agg[order_by=[#0 desc nulls_first]](row(array[#0{b}], #0{b}))) val_plan project=(#1) - map=(row(array[#0], #0)) + map=(row(array[#0{b}], #0{b})) key_plan project=() Get::PassArrangements l0 @@ -408,7 +408,7 @@ Explained Query: Return Mfp project=(#0, #1, #3) - map=((#2 > 0)) + map=((#2{?column?} > 0)) Union Get::Collection l1 project=(#1, #2, #0) @@ -444,28 +444,28 @@ Explained Query: project=(#0, #1, #1) input_key=#0 Reduce::Basic - aggr=(0, array_agg[order_by=[]](row(array[#1]))) + aggr=(0, array_agg[order_by=[]](row(array[#1{c}]))) val_plan project=(#2) - map=(row(array[#1])) + map=(row(array[#1{c}])) key_plan project=(#0) Join::Linear linear_stage[0] closure project=(#1, #0) - lookup={ relation=1, key=[#0] } - stream={ key=[#1], thinning=(#0) } - source={ relation=0, key=[#1] } + lookup={ relation=1, key=[#0{c}] } + stream={ key=[#1{c}], thinning=(#0) } + source={ relation=0, key=[#1{c}] } ArrangeBy raw=true - arrangements[0]={ key=[#1], permutation={#0: #1, #1: #0}, thinning=(#0) } + arrangements[0]={ key=[#1{c}], permutation={#0: #1, #1: #0}, thinning=(#0) } types=[integer, text] Get::PassArrangements l0 raw=true ArrangeBy raw=true - arrangements[0]={ key=[#0], permutation=id, thinning=() } + arrangements[0]={ key=[#0{c}], permutation=id, thinning=() } types=[text] Get::Collection l0 project=(#1) @@ -473,7 +473,7 @@ Explained Query: Source materialize.public.t project=(#0, #2) - filter=((#2) IS NOT NULL) + filter=((#2{c}) IS NOT NULL) Target cluster: quickstart @@ -521,7 +521,7 @@ Explained Query: stream={ key=[], thinning=(#0) } source={ relation=2, key=[] } Reduce::Accumulable - simple_aggrs[0]=(0, 0, sum(#0)) + simple_aggrs[0]=(0, 0, sum(#0{a})) val_plan=id key_plan project=() @@ -529,19 +529,19 @@ Explained Query: project=(#0) raw=true Reduce::Basic - aggr=(0, jsonb_agg[order_by=[]](row(jsonbable_to_jsonb(#0)))) + aggr=(0, jsonb_agg[order_by=[]](row(jsonbable_to_jsonb(#0{b})))) val_plan project=(#1) - map=(row(jsonbable_to_jsonb(#0))) + map=(row(jsonbable_to_jsonb(#0{b}))) key_plan project=() Get::PassArrangements l0 raw=true Reduce::Basic - aggr=(0, array_agg[order_by=[]](row(array[#0]))) + aggr=(0, array_agg[order_by=[]](row(array[#0{b}]))) val_plan project=(#1) - map=(row(array[#0])) + map=(row(array[#0{b}])) key_plan project=() Get::PassArrangements l0 @@ -583,24 +583,24 @@ Explained Query: linear_stage[0] closure project=(#0, #1) - ready_equivalences=#2 = #1 + ready_equivalences=#2{?column?} = #1{?column?} lookup={ relation=1, key=[#0] } stream={ key=[#0], thinning=(#1) } source={ relation=0, key=[#0] } Reduce::Basic - aggr=(0, array_agg[order_by=[#0 asc nulls_last]](row(array[#1], #1))) + aggr=(0, array_agg[order_by=[#0 asc nulls_last]](row(array[#1{b}], #1{b}))) val_plan project=(#2) - map=(row(array[#1], #1)) + map=(row(array[#1{b}], #1{b})) key_plan project=(#0) Get::PassArrangements l0 raw=true Reduce::Basic - aggr=(0, array_agg[order_by=[#0 desc nulls_first]](row(array[#1], #1))) + aggr=(0, array_agg[order_by=[#0 desc nulls_first]](row(array[#1{b}], #1{b}))) val_plan project=(#2) - map=(row(array[#1], #1)) + map=(row(array[#1{b}], #1{b})) key_plan project=(#0) Get::PassArrangements l0 @@ -631,19 +631,19 @@ Explained Query: stream={ key=[#0], thinning=(#1) } source={ relation=0, key=[#0] } Reduce::Basic - aggr=(0, array_agg[order_by=[]](row(array[digest(text_to_bytea(#1), "sha256")]))) + aggr=(0, array_agg[order_by=[]](row(array[digest(text_to_bytea(#1{b}), "sha256")]))) val_plan project=(#2) - map=(row(array[digest(text_to_bytea(#1), "sha256")])) + map=(row(array[digest(text_to_bytea(#1{b}), "sha256")])) key_plan project=(#0) Get::PassArrangements l0 raw=true Reduce::Basic - aggr=(0, array_agg[order_by=[]](row(array[#1]))) + aggr=(0, array_agg[order_by=[]](row(array[#1{b}]))) val_plan project=(#2) - map=(row(array[#1])) + map=(row(array[#1{b}])) key_plan project=(#0) Get::PassArrangements l0 @@ -672,19 +672,19 @@ Explained Query: stream={ key=[#0], thinning=(#1) } source={ relation=0, key=[#0] } Reduce::Basic - aggr=(0, array_agg[order_by=[]](row(array[#1]))) + aggr=(0, array_agg[order_by=[]](row(array[#1{b}]))) val_plan project=(#2) - map=(row(array[#1])) + map=(row(array[#1{b}])) key_plan project=(#0) Get::PassArrangements l0 raw=true Reduce::Basic - aggr=(0, array_agg[order_by=[]](row(array[case when (#0 = 1) then "ooo" else #1 end]))) + aggr=(0, array_agg[order_by=[]](row(array[case when (#0{a} = 1) then "ooo" else #1{b} end]))) val_plan project=(#2) - map=(row(array[case when (#0 = 1) then "ooo" else #1 end])) + map=(row(array[case when (#0{a} = 1) then "ooo" else #1{b} end])) key_plan project=(#0) Get::PassArrangements l0 @@ -706,18 +706,18 @@ Explained Query: map=(record_get[1](#0), record_get[0](#1), record_get[1](#1), record_get[0](#0)) input_key= Reduce::Basic - aggr=(0, dense_rank[order_by=[#0 asc nulls_last]](row(list[row(#0, #1)], #0)), fused_unnest_list=true) + aggr=(0, dense_rank[order_by=[#0 asc nulls_last]](row(list[row(#0, #1)], #0{a})), fused_unnest_list=true) val_plan project=(#2) - map=(row(list[row(#0, #1)], #0)) + map=(row(list[row(#0, #1)], #0{a})) key_plan project=() input_key=#0 Reduce::Basic - aggr=(0, array_agg[order_by=[]](row(array[#1]))) + aggr=(0, array_agg[order_by=[]](row(array[#1{b}]))) val_plan project=(#2) - map=(row(array[#1])) + map=(row(array[#1{b}])) key_plan project=(#0) Get::Collection materialize.public.t diff --git a/test/sqllogictest/explain/physical_plan_as_json.slt b/test/sqllogictest/explain/physical_plan_as_json.slt index 63d2d9a62e176..3b3bbea57ec6b 100644 --- a/test/sqllogictest/explain/physical_plan_as_json.slt +++ b/test/sqllogictest/explain/physical_plan_as_json.slt @@ -201,7 +201,10 @@ SELECT * FROM t [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], [ @@ -298,7 +301,10 @@ SELECT a + b, 1 FROM t [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], [ @@ -325,7 +331,10 @@ SELECT a + b, 1 FROM t "Arrangement": [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], null, @@ -335,10 +344,16 @@ SELECT a + b, 1 FROM t "CallBinary": { "func": "AddInt32", "expr1": { - "Column": 0 + "Column": [ + 0, + "a" + ] }, "expr2": { - "Column": 1 + "Column": [ + 1, + "b" + ] } } }, @@ -427,10 +442,16 @@ SELECT c + d, 1 FROM u "CallBinary": { "func": "AddInt32", "expr1": { - "Column": 0 + "Column": [ + 0, + "c" + ] }, "expr2": { - "Column": 1 + "Column": [ + 1, + "d" + ] } } }, @@ -495,7 +516,10 @@ SELECT * FROM ov [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], [ @@ -529,7 +553,10 @@ SELECT * FROM ov }, "input_key": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], "input_mfp": { @@ -625,7 +652,10 @@ SELECT a FROM t EXCEPT ALL SELECT b FROM mv [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], [ @@ -652,7 +682,10 @@ SELECT a FROM t EXCEPT ALL SELECT b FROM mv "Arrangement": [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], null, @@ -714,7 +747,10 @@ SELECT a FROM t EXCEPT ALL SELECT b FROM mv [ [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], [ @@ -747,7 +783,10 @@ SELECT a FROM t EXCEPT ALL SELECT b FROM mv "ensure_arrangement": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], [ @@ -811,7 +850,10 @@ SELECT * FROM ov [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], [ @@ -845,7 +887,10 @@ SELECT * FROM ov }, "input_key": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], "input_mfp": { @@ -947,7 +992,10 @@ WITH cte(x) as (SELECT a FROM t EXCEPT ALL SELECT b FROM mv) [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], [ @@ -974,7 +1022,10 @@ WITH cte(x) as (SELECT a FROM t EXCEPT ALL SELECT b FROM mv) "Arrangement": [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], null, @@ -1036,7 +1087,10 @@ WITH cte(x) as (SELECT a FROM t EXCEPT ALL SELECT b FROM mv) [ [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], [ @@ -1069,7 +1123,10 @@ WITH cte(x) as (SELECT a FROM t EXCEPT ALL SELECT b FROM mv) "ensure_arrangement": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], [ @@ -1100,7 +1157,10 @@ WITH cte(x) as (SELECT a FROM t EXCEPT ALL SELECT b FROM mv) [ [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], [ @@ -1120,7 +1180,10 @@ WITH cte(x) as (SELECT a FROM t EXCEPT ALL SELECT b FROM mv) "Arrangement": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], null, @@ -1130,7 +1193,10 @@ WITH cte(x) as (SELECT a FROM t EXCEPT ALL SELECT b FROM mv) "CallBinary": { "func": "AddInt32", "expr1": { - "Column": 0 + "Column": [ + 0, + "x" + ] }, "expr2": { "Literal": [ @@ -1175,7 +1241,10 @@ WITH cte(x) as (SELECT a FROM t EXCEPT ALL SELECT b FROM mv) [ [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], [ @@ -1195,7 +1264,10 @@ WITH cte(x) as (SELECT a FROM t EXCEPT ALL SELECT b FROM mv) "Arrangement": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], null, @@ -1205,7 +1277,10 @@ WITH cte(x) as (SELECT a FROM t EXCEPT ALL SELECT b FROM mv) "CallBinary": { "func": "SubInt32", "expr1": { - "Column": 0 + "Column": [ + 0, + "x" + ] }, "expr2": { "Literal": [ @@ -1312,7 +1387,10 @@ SELECT x * 5 FROM cte WHERE x = 5 [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], [ @@ -1370,7 +1448,10 @@ SELECT x * 5 FROM cte WHERE x = 5 [ [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], [ @@ -1404,7 +1485,10 @@ SELECT x * 5 FROM cte WHERE x = 5 "source_relation": 1, "source_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "initial_closure": null, @@ -1413,13 +1497,19 @@ SELECT x * 5 FROM cte WHERE x = 5 "lookup_relation": 0, "stream_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "stream_thinning": [], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], "closure": { @@ -1488,7 +1578,10 @@ SELECT x * 5 FROM cte WHERE x = 5 [ [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], [ @@ -1521,7 +1614,10 @@ SELECT x * 5 FROM cte WHERE x = 5 "ensure_arrangement": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], [ @@ -1562,7 +1658,10 @@ SELECT x * 5 FROM cte WHERE x = 5 "input_key_val": [ [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], null @@ -1586,7 +1685,10 @@ SELECT x * 5 FROM cte WHERE x = 5 "CallBinary": { "func": "Eq", "expr1": { - "Column": 1 + "Column": [ + 1, + "x" + ] }, "expr2": { "Literal": [ @@ -1646,7 +1748,10 @@ SELECT generate_series(a, b) from t [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], [ @@ -1676,10 +1781,16 @@ SELECT generate_series(a, b) from t "func": "GenerateSeriesInt32", "exprs": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] }, { - "Column": 1 + "Column": [ + 1, + "b" + ] }, { "Literal": [ @@ -1708,7 +1819,10 @@ SELECT generate_series(a, b) from t }, "input_key": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ] } @@ -1748,7 +1862,10 @@ SELECT DISTINCT a, b FROM t [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], [ @@ -1799,7 +1916,10 @@ SELECT DISTINCT a, b FROM t "plan": "Distinct", "input_key": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], "mfp_after": { @@ -1853,7 +1973,10 @@ GROUP BY a [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], [ @@ -1909,14 +2032,20 @@ GROUP BY a { "func": "SumInt32", "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] }, "distinct": false }, { "func": "Count", "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] }, "distinct": true } @@ -1928,7 +2057,10 @@ GROUP BY a { "func": "SumInt32", "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] }, "distinct": false } @@ -1941,7 +2073,10 @@ GROUP BY a { "func": "Count", "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] }, "distinct": true } @@ -1951,7 +2086,10 @@ GROUP BY a }, "input_key": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], "mfp_after": { @@ -2009,7 +2147,10 @@ FROM t [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], [ @@ -2036,7 +2177,10 @@ FROM t "Arrangement": [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], null, @@ -2080,14 +2224,20 @@ FROM t { "func": "SumInt32", "expr": { - "Column": 0 + "Column": [ + 0, + "b" + ] }, "distinct": false }, { "func": "Count", "expr": { - "Column": 0 + "Column": [ + 0, + "b" + ] }, "distinct": true } @@ -2099,7 +2249,10 @@ FROM t { "func": "SumInt32", "expr": { - "Column": 0 + "Column": [ + 0, + "b" + ] }, "distinct": false } @@ -2112,7 +2265,10 @@ FROM t { "func": "Count", "expr": { - "Column": 0 + "Column": [ + 0, + "b" + ] }, "distinct": true } @@ -2352,7 +2508,10 @@ SELECT * FROM hierarchical_group_by [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], [ @@ -2419,7 +2578,10 @@ SELECT * FROM hierarchical_group_by }, "input_key": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], "mfp_after": { @@ -2474,7 +2636,10 @@ MATERIALIZED VIEW hierarchical_global_mv [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], [ @@ -2501,7 +2666,10 @@ MATERIALIZED VIEW hierarchical_global_mv "Arrangement": [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], null, @@ -2799,7 +2967,10 @@ SELECT * FROM hierarchical_global [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], [ @@ -2826,7 +2997,10 @@ SELECT * FROM hierarchical_global "Arrangement": [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], null, @@ -3121,7 +3295,10 @@ GROUP BY a [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], [ @@ -3192,7 +3369,10 @@ GROUP BY a "CastInt32ToString": null }, "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] } } }, @@ -3287,7 +3467,10 @@ GROUP BY a "CastInt32ToString": null }, "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] } } }, @@ -3341,7 +3524,10 @@ GROUP BY a }, "input_key": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], "mfp_after": { @@ -3375,7 +3561,10 @@ GROUP BY a [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], [ @@ -3446,7 +3635,10 @@ GROUP BY a "CastInt32ToString": null }, "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] } } }, @@ -3541,7 +3733,10 @@ GROUP BY a "CastInt32ToString": null }, "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] } } }, @@ -3595,7 +3790,10 @@ GROUP BY a }, "input_key": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], "mfp_after": { @@ -3616,7 +3814,10 @@ GROUP BY a "source_relation": 0, "source_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "initial_closure": null, @@ -3625,7 +3826,10 @@ GROUP BY a "lookup_relation": 1, "stream_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "stream_thinning": [ @@ -3633,7 +3837,10 @@ GROUP BY a ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "closure": { @@ -3697,7 +3904,10 @@ FROM t [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], [ @@ -3724,7 +3934,10 @@ FROM t "Arrangement": [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], null, @@ -3813,7 +4026,10 @@ FROM t "CastInt32ToString": null }, "expr": { - "Column": 0 + "Column": [ + 0, + "b" + ] } } }, @@ -3908,7 +4124,10 @@ FROM t "CastInt32ToString": null }, "expr": { - "Column": 0 + "Column": [ + 0, + "b" + ] } } }, @@ -4034,7 +4253,10 @@ FROM t "CastInt32ToString": null }, "expr": { - "Column": 0 + "Column": [ + 0, + "b" + ] } } }, @@ -4129,7 +4351,10 @@ FROM t "CastInt32ToString": null }, "expr": { - "Column": 0 + "Column": [ + 0, + "b" + ] } } }, @@ -4406,7 +4631,10 @@ MATERIALIZED VIEW collated_group_by_mv [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], [ @@ -4481,7 +4709,10 @@ MATERIALIZED VIEW collated_group_by_mv }, "input_key": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], "mfp_after": { @@ -4516,7 +4747,10 @@ MATERIALIZED VIEW collated_group_by_mv [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], [ @@ -4572,14 +4806,20 @@ MATERIALIZED VIEW collated_group_by_mv { "func": "Count", "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] }, "distinct": true }, { "func": "SumInt32", "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] }, "distinct": false } @@ -4591,7 +4831,10 @@ MATERIALIZED VIEW collated_group_by_mv { "func": "SumInt32", "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] }, "distinct": false } @@ -4604,7 +4847,10 @@ MATERIALIZED VIEW collated_group_by_mv { "func": "Count", "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] }, "distinct": true } @@ -4614,7 +4860,10 @@ MATERIALIZED VIEW collated_group_by_mv }, "input_key": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], "mfp_after": { @@ -4649,7 +4898,10 @@ MATERIALIZED VIEW collated_group_by_mv [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], [ @@ -4720,7 +4972,10 @@ MATERIALIZED VIEW collated_group_by_mv "CastInt32ToString": null }, "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] } } }, @@ -4815,7 +5070,10 @@ MATERIALIZED VIEW collated_group_by_mv "CastInt32ToString": null }, "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] } } }, @@ -4869,7 +5127,10 @@ MATERIALIZED VIEW collated_group_by_mv }, "input_key": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], "mfp_after": { @@ -4903,7 +5164,10 @@ MATERIALIZED VIEW collated_group_by_mv [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], [ @@ -4974,7 +5238,10 @@ MATERIALIZED VIEW collated_group_by_mv "CastInt32ToString": null }, "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] } } }, @@ -5069,7 +5336,10 @@ MATERIALIZED VIEW collated_group_by_mv "CastInt32ToString": null }, "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] } } }, @@ -5123,7 +5393,10 @@ MATERIALIZED VIEW collated_group_by_mv }, "input_key": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], "mfp_after": { @@ -5146,7 +5419,10 @@ MATERIALIZED VIEW collated_group_by_mv "source_relation": 0, "source_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "initial_closure": { @@ -5169,7 +5445,10 @@ MATERIALIZED VIEW collated_group_by_mv "lookup_relation": 1, "stream_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "stream_thinning": [ @@ -5178,7 +5457,10 @@ MATERIALIZED VIEW collated_group_by_mv ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "closure": { @@ -5203,7 +5485,10 @@ MATERIALIZED VIEW collated_group_by_mv "lookup_relation": 2, "stream_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "stream_thinning": [ @@ -5214,7 +5499,10 @@ MATERIALIZED VIEW collated_group_by_mv ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "closure": { @@ -5240,7 +5528,10 @@ MATERIALIZED VIEW collated_group_by_mv "lookup_relation": 3, "stream_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "stream_thinning": [ @@ -5252,7 +5543,10 @@ MATERIALIZED VIEW collated_group_by_mv ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "closure": { @@ -5282,7 +5576,10 @@ MATERIALIZED VIEW collated_group_by_mv "source_relation": 1, "source_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "initial_closure": { @@ -5305,7 +5602,10 @@ MATERIALIZED VIEW collated_group_by_mv "lookup_relation": 0, "stream_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "stream_thinning": [ @@ -5314,7 +5614,10 @@ MATERIALIZED VIEW collated_group_by_mv ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "closure": { @@ -5340,7 +5643,10 @@ MATERIALIZED VIEW collated_group_by_mv "lookup_relation": 2, "stream_key": [ { - "Column": 3 + "Column": [ + 3, + null + ] } ], "stream_thinning": [ @@ -5352,7 +5658,10 @@ MATERIALIZED VIEW collated_group_by_mv ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "closure": { @@ -5379,7 +5688,10 @@ MATERIALIZED VIEW collated_group_by_mv "lookup_relation": 3, "stream_key": [ { - "Column": 3 + "Column": [ + 3, + null + ] } ], "stream_thinning": [ @@ -5392,7 +5704,10 @@ MATERIALIZED VIEW collated_group_by_mv ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "closure": { @@ -5422,7 +5737,10 @@ MATERIALIZED VIEW collated_group_by_mv "source_relation": 2, "source_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "initial_closure": { @@ -5444,7 +5762,10 @@ MATERIALIZED VIEW collated_group_by_mv "lookup_relation": 0, "stream_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "stream_thinning": [ @@ -5452,7 +5773,10 @@ MATERIALIZED VIEW collated_group_by_mv ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "closure": { @@ -5477,7 +5801,10 @@ MATERIALIZED VIEW collated_group_by_mv "lookup_relation": 1, "stream_key": [ { - "Column": 3 + "Column": [ + 3, + null + ] } ], "stream_thinning": [ @@ -5488,7 +5815,10 @@ MATERIALIZED VIEW collated_group_by_mv ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "closure": { @@ -5515,7 +5845,10 @@ MATERIALIZED VIEW collated_group_by_mv "lookup_relation": 3, "stream_key": [ { - "Column": 5 + "Column": [ + 5, + null + ] } ], "stream_thinning": [ @@ -5528,7 +5861,10 @@ MATERIALIZED VIEW collated_group_by_mv ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "closure": { @@ -5558,7 +5894,10 @@ MATERIALIZED VIEW collated_group_by_mv "source_relation": 3, "source_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "initial_closure": { @@ -5580,7 +5919,10 @@ MATERIALIZED VIEW collated_group_by_mv "lookup_relation": 0, "stream_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "stream_thinning": [ @@ -5588,7 +5930,10 @@ MATERIALIZED VIEW collated_group_by_mv ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "closure": { @@ -5613,7 +5958,10 @@ MATERIALIZED VIEW collated_group_by_mv "lookup_relation": 1, "stream_key": [ { - "Column": 3 + "Column": [ + 3, + null + ] } ], "stream_thinning": [ @@ -5624,7 +5972,10 @@ MATERIALIZED VIEW collated_group_by_mv ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "closure": { @@ -5651,7 +6002,10 @@ MATERIALIZED VIEW collated_group_by_mv "lookup_relation": 2, "stream_key": [ { - "Column": 5 + "Column": [ + 5, + null + ] } ], "stream_thinning": [ @@ -5664,7 +6018,10 @@ MATERIALIZED VIEW collated_group_by_mv ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "closure": { @@ -5735,7 +6092,10 @@ SELECT * FROM collated_group_by [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], [ @@ -5802,7 +6162,10 @@ SELECT * FROM collated_group_by }, "input_key": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], "mfp_after": { @@ -5837,7 +6200,10 @@ SELECT * FROM collated_group_by [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], [ @@ -5893,14 +6259,20 @@ SELECT * FROM collated_group_by { "func": "Count", "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] }, "distinct": true }, { "func": "SumInt32", "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] }, "distinct": false } @@ -5912,7 +6284,10 @@ SELECT * FROM collated_group_by { "func": "SumInt32", "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] }, "distinct": false } @@ -5925,7 +6300,10 @@ SELECT * FROM collated_group_by { "func": "Count", "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] }, "distinct": true } @@ -5935,7 +6313,10 @@ SELECT * FROM collated_group_by }, "input_key": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], "mfp_after": { @@ -5970,7 +6351,10 @@ SELECT * FROM collated_group_by [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], [ @@ -6041,7 +6425,10 @@ SELECT * FROM collated_group_by "CastInt32ToString": null }, "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] } } }, @@ -6136,7 +6523,10 @@ SELECT * FROM collated_group_by "CastInt32ToString": null }, "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] } } }, @@ -6190,7 +6580,10 @@ SELECT * FROM collated_group_by }, "input_key": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], "mfp_after": { @@ -6224,7 +6617,10 @@ SELECT * FROM collated_group_by [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], [ @@ -6295,7 +6691,10 @@ SELECT * FROM collated_group_by "CastInt32ToString": null }, "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] } } }, @@ -6390,7 +6789,10 @@ SELECT * FROM collated_group_by "CastInt32ToString": null }, "expr": { - "Column": 1 + "Column": [ + 1, + "b" + ] } } }, @@ -6444,7 +6846,10 @@ SELECT * FROM collated_group_by }, "input_key": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], "mfp_after": { @@ -6467,7 +6872,10 @@ SELECT * FROM collated_group_by "source_relation": 0, "source_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "initial_closure": { @@ -6490,7 +6898,10 @@ SELECT * FROM collated_group_by "lookup_relation": 1, "stream_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "stream_thinning": [ @@ -6499,7 +6910,10 @@ SELECT * FROM collated_group_by ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "closure": { @@ -6524,7 +6938,10 @@ SELECT * FROM collated_group_by "lookup_relation": 2, "stream_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "stream_thinning": [ @@ -6535,7 +6952,10 @@ SELECT * FROM collated_group_by ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "closure": { @@ -6561,7 +6981,10 @@ SELECT * FROM collated_group_by "lookup_relation": 3, "stream_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "stream_thinning": [ @@ -6573,7 +6996,10 @@ SELECT * FROM collated_group_by ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "closure": { @@ -6603,7 +7029,10 @@ SELECT * FROM collated_group_by "source_relation": 1, "source_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "initial_closure": { @@ -6626,7 +7055,10 @@ SELECT * FROM collated_group_by "lookup_relation": 0, "stream_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "stream_thinning": [ @@ -6635,7 +7067,10 @@ SELECT * FROM collated_group_by ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "closure": { @@ -6661,7 +7096,10 @@ SELECT * FROM collated_group_by "lookup_relation": 2, "stream_key": [ { - "Column": 3 + "Column": [ + 3, + null + ] } ], "stream_thinning": [ @@ -6673,7 +7111,10 @@ SELECT * FROM collated_group_by ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "closure": { @@ -6700,7 +7141,10 @@ SELECT * FROM collated_group_by "lookup_relation": 3, "stream_key": [ { - "Column": 3 + "Column": [ + 3, + null + ] } ], "stream_thinning": [ @@ -6713,7 +7157,10 @@ SELECT * FROM collated_group_by ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "closure": { @@ -6743,7 +7190,10 @@ SELECT * FROM collated_group_by "source_relation": 2, "source_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "initial_closure": { @@ -6765,7 +7215,10 @@ SELECT * FROM collated_group_by "lookup_relation": 0, "stream_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "stream_thinning": [ @@ -6773,7 +7226,10 @@ SELECT * FROM collated_group_by ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "closure": { @@ -6798,7 +7254,10 @@ SELECT * FROM collated_group_by "lookup_relation": 1, "stream_key": [ { - "Column": 3 + "Column": [ + 3, + null + ] } ], "stream_thinning": [ @@ -6809,7 +7268,10 @@ SELECT * FROM collated_group_by ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "closure": { @@ -6836,7 +7298,10 @@ SELECT * FROM collated_group_by "lookup_relation": 3, "stream_key": [ { - "Column": 5 + "Column": [ + 5, + null + ] } ], "stream_thinning": [ @@ -6849,7 +7314,10 @@ SELECT * FROM collated_group_by ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "closure": { @@ -6879,7 +7347,10 @@ SELECT * FROM collated_group_by "source_relation": 3, "source_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "initial_closure": { @@ -6901,7 +7372,10 @@ SELECT * FROM collated_group_by "lookup_relation": 0, "stream_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "stream_thinning": [ @@ -6909,7 +7383,10 @@ SELECT * FROM collated_group_by ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "closure": { @@ -6934,7 +7411,10 @@ SELECT * FROM collated_group_by "lookup_relation": 1, "stream_key": [ { - "Column": 3 + "Column": [ + 3, + null + ] } ], "stream_thinning": [ @@ -6945,7 +7425,10 @@ SELECT * FROM collated_group_by ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "closure": { @@ -6972,7 +7455,10 @@ SELECT * FROM collated_group_by "lookup_relation": 2, "stream_key": [ { - "Column": 5 + "Column": [ + 5, + null + ] } ], "stream_thinning": [ @@ -6985,7 +7471,10 @@ SELECT * FROM collated_group_by ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + null + ] } ], "closure": { @@ -7052,7 +7541,10 @@ MATERIALIZED VIEW collated_global_mv [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], [ @@ -7079,7 +7571,10 @@ MATERIALIZED VIEW collated_global_mv "Arrangement": [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], null, @@ -7230,14 +7725,20 @@ MATERIALIZED VIEW collated_global_mv { "func": "Count", "expr": { - "Column": 0 + "Column": [ + 0, + "b" + ] }, "distinct": true }, { "func": "SumInt32", "expr": { - "Column": 0 + "Column": [ + 0, + "b" + ] }, "distinct": false } @@ -7249,7 +7750,10 @@ MATERIALIZED VIEW collated_global_mv { "func": "SumInt32", "expr": { - "Column": 0 + "Column": [ + 0, + "b" + ] }, "distinct": false } @@ -7262,7 +7766,10 @@ MATERIALIZED VIEW collated_global_mv { "func": "Count", "expr": { - "Column": 0 + "Column": [ + 0, + "b" + ] }, "distinct": true } @@ -7345,7 +7852,10 @@ MATERIALIZED VIEW collated_global_mv "CastInt32ToString": null }, "expr": { - "Column": 0 + "Column": [ + 0, + "b" + ] } } }, @@ -7440,7 +7950,10 @@ MATERIALIZED VIEW collated_global_mv "CastInt32ToString": null }, "expr": { - "Column": 0 + "Column": [ + 0, + "b" + ] } } }, @@ -7566,7 +8079,10 @@ MATERIALIZED VIEW collated_global_mv "CastInt32ToString": null }, "expr": { - "Column": 0 + "Column": [ + 0, + "b" + ] } } }, @@ -7661,7 +8177,10 @@ MATERIALIZED VIEW collated_global_mv "CastInt32ToString": null }, "expr": { - "Column": 0 + "Column": [ + 0, + "b" + ] } } }, @@ -8394,7 +8913,10 @@ SELECT * FROM collated_global [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], [ @@ -8421,7 +8943,10 @@ SELECT * FROM collated_global "Arrangement": [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], null, @@ -8564,14 +9089,20 @@ SELECT * FROM collated_global { "func": "Count", "expr": { - "Column": 0 + "Column": [ + 0, + "b" + ] }, "distinct": true }, { "func": "SumInt32", "expr": { - "Column": 0 + "Column": [ + 0, + "b" + ] }, "distinct": false } @@ -8583,7 +9114,10 @@ SELECT * FROM collated_global { "func": "SumInt32", "expr": { - "Column": 0 + "Column": [ + 0, + "b" + ] }, "distinct": false } @@ -8596,7 +9130,10 @@ SELECT * FROM collated_global { "func": "Count", "expr": { - "Column": 0 + "Column": [ + 0, + "b" + ] }, "distinct": true } @@ -8679,7 +9216,10 @@ SELECT * FROM collated_global "CastInt32ToString": null }, "expr": { - "Column": 0 + "Column": [ + 0, + "b" + ] } } }, @@ -8774,7 +9314,10 @@ SELECT * FROM collated_global "CastInt32ToString": null }, "expr": { - "Column": 0 + "Column": [ + 0, + "b" + ] } } }, @@ -8900,7 +9443,10 @@ SELECT * FROM collated_global "CastInt32ToString": null }, "expr": { - "Column": 0 + "Column": [ + 0, + "b" + ] } } }, @@ -8995,7 +9541,10 @@ SELECT * FROM collated_global "CastInt32ToString": null }, "expr": { - "Column": 0 + "Column": [ + 0, + "b" + ] } } }, @@ -9730,7 +10279,10 @@ WHERE a = c AND d = e AND b + d > 42 [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], [ @@ -9795,7 +10347,10 @@ WHERE a = c AND d = e AND b + d > 42 [ [ { - "Column": 0 + "Column": [ + 0, + "c" + ] } ], [ @@ -9809,7 +10364,10 @@ WHERE a = c AND d = e AND b + d > 42 [ [ { - "Column": 1 + "Column": [ + 1, + "d" + ] } ], [ @@ -9882,7 +10440,10 @@ WHERE a = c AND d = e AND b + d > 42 [ [ { - "Column": 0 + "Column": [ + 0, + "e" + ] } ], [ @@ -9918,7 +10479,10 @@ WHERE a = c AND d = e AND b + d > 42 "source_relation": 0, "source_key": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], "initial_closure": { @@ -9940,7 +10504,10 @@ WHERE a = c AND d = e AND b + d > 42 "lookup_relation": 1, "stream_key": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], "stream_thinning": [ @@ -9948,7 +10515,10 @@ WHERE a = c AND d = e AND b + d > 42 ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + "c" + ] } ], "closure": { @@ -9960,10 +10530,16 @@ WHERE a = c AND d = e AND b + d > 42 "CallBinary": { "func": "AddInt32", "expr1": { - "Column": 1 + "Column": [ + 1, + "b" + ] }, "expr2": { - "Column": 2 + "Column": [ + 2, + "d" + ] } } }, @@ -9971,10 +10547,16 @@ WHERE a = c AND d = e AND b + d > 42 "CallBinary": { "func": "AddInt32", "expr1": { - "Column": 0 + "Column": [ + 0, + "a" + ] }, "expr2": { - "Column": 2 + "Column": [ + 2, + "d" + ] } } } @@ -9986,7 +10568,10 @@ WHERE a = c AND d = e AND b + d > 42 "CallBinary": { "func": "Gt", "expr1": { - "Column": 3 + "Column": [ + 3, + null + ] }, "expr2": { "Literal": [ @@ -10022,7 +10607,10 @@ WHERE a = c AND d = e AND b + d > 42 "lookup_relation": 2, "stream_key": [ { - "Column": 0 + "Column": [ + 0, + "d" + ] } ], "stream_thinning": [ @@ -10031,7 +10619,10 @@ WHERE a = c AND d = e AND b + d > 42 ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + "e" + ] } ], "closure": { @@ -10070,7 +10661,10 @@ WHERE a = c AND d = e AND b + d > 42 "source_relation": 1, "source_key": [ { - "Column": 0 + "Column": [ + 0, + "c" + ] } ], "initial_closure": { @@ -10092,7 +10686,10 @@ WHERE a = c AND d = e AND b + d > 42 "lookup_relation": 0, "stream_key": [ { - "Column": 0 + "Column": [ + 0, + "c" + ] } ], "stream_thinning": [ @@ -10100,7 +10697,10 @@ WHERE a = c AND d = e AND b + d > 42 ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], "closure": { @@ -10112,10 +10712,16 @@ WHERE a = c AND d = e AND b + d > 42 "CallBinary": { "func": "AddInt32", "expr1": { - "Column": 2 + "Column": [ + 2, + "b" + ] }, "expr2": { - "Column": 1 + "Column": [ + 1, + "d" + ] } } }, @@ -10123,10 +10729,16 @@ WHERE a = c AND d = e AND b + d > 42 "CallBinary": { "func": "AddInt32", "expr1": { - "Column": 0 + "Column": [ + 0, + "a" + ] }, "expr2": { - "Column": 1 + "Column": [ + 1, + "d" + ] } } } @@ -10138,7 +10750,10 @@ WHERE a = c AND d = e AND b + d > 42 "CallBinary": { "func": "Gt", "expr1": { - "Column": 3 + "Column": [ + 3, + null + ] }, "expr2": { "Literal": [ @@ -10174,7 +10789,10 @@ WHERE a = c AND d = e AND b + d > 42 "lookup_relation": 2, "stream_key": [ { - "Column": 0 + "Column": [ + 0, + "d" + ] } ], "stream_thinning": [ @@ -10183,7 +10801,10 @@ WHERE a = c AND d = e AND b + d > 42 ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + "e" + ] } ], "closure": { @@ -10222,7 +10843,10 @@ WHERE a = c AND d = e AND b + d > 42 "source_relation": 2, "source_key": [ { - "Column": 0 + "Column": [ + 0, + "e" + ] } ], "initial_closure": { @@ -10243,13 +10867,19 @@ WHERE a = c AND d = e AND b + d > 42 "lookup_relation": 1, "stream_key": [ { - "Column": 0 + "Column": [ + 0, + "e" + ] } ], "stream_thinning": [], "lookup_key": [ { - "Column": 1 + "Column": [ + 1, + "d" + ] } ], "closure": { @@ -10271,7 +10901,10 @@ WHERE a = c AND d = e AND b + d > 42 "lookup_relation": 0, "stream_key": [ { - "Column": 0 + "Column": [ + 0, + "c" + ] } ], "stream_thinning": [ @@ -10279,7 +10912,10 @@ WHERE a = c AND d = e AND b + d > 42 ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], "closure": { @@ -10291,10 +10927,16 @@ WHERE a = c AND d = e AND b + d > 42 "CallBinary": { "func": "AddInt32", "expr1": { - "Column": 2 + "Column": [ + 2, + "b" + ] }, "expr2": { - "Column": 1 + "Column": [ + 1, + "d" + ] } } }, @@ -10302,10 +10944,16 @@ WHERE a = c AND d = e AND b + d > 42 "CallBinary": { "func": "AddInt32", "expr1": { - "Column": 0 + "Column": [ + 0, + "a" + ] }, "expr2": { - "Column": 1 + "Column": [ + 1, + "d" + ] } } } @@ -10317,7 +10965,10 @@ WHERE a = c AND d = e AND b + d > 42 "CallBinary": { "func": "Gt", "expr1": { - "Column": 3 + "Column": [ + 3, + null + ] }, "expr2": { "Literal": [ @@ -10394,7 +11045,10 @@ WHERE a = c AND d = e AND b + d > 42 "IsNull": null }, "expr": { - "Column": 0 + "Column": [ + 0, + "c" + ] } } } @@ -10414,7 +11068,10 @@ WHERE a = c AND d = e AND b + d > 42 "IsNull": null }, "expr": { - "Column": 1 + "Column": [ + 1, + "d" + ] } } } @@ -10449,7 +11106,10 @@ WHERE a = c AND d = e AND b + d > 42 "IsNull": null }, "expr": { - "Column": 0 + "Column": [ + 0, + "e" + ] } } } @@ -10509,7 +11169,10 @@ WHERE a = c AND d = e AND f = a [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], [ @@ -10551,7 +11214,10 @@ WHERE a = c AND d = e AND f = a [ [ { - "Column": 0 + "Column": [ + 0, + "c" + ] } ], [ @@ -10565,7 +11231,10 @@ WHERE a = c AND d = e AND f = a [ [ { - "Column": 1 + "Column": [ + 1, + "d" + ] } ], [ @@ -10607,7 +11276,10 @@ WHERE a = c AND d = e AND f = a [ [ { - "Column": 0 + "Column": [ + 0, + "e" + ] } ], [ @@ -10642,7 +11314,10 @@ WHERE a = c AND d = e AND f = a "source_relation": 0, "source_key": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], "initial_closure": { @@ -10664,7 +11339,10 @@ WHERE a = c AND d = e AND f = a "IsNull": null }, "expr": { - "Column": 0 + "Column": [ + 0, + "a" + ] } } } @@ -10685,7 +11363,10 @@ WHERE a = c AND d = e AND f = a "lookup_relation": 1, "stream_key": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], "stream_thinning": [ @@ -10693,7 +11374,10 @@ WHERE a = c AND d = e AND f = a ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + "c" + ] } ], "closure": { @@ -10715,7 +11399,10 @@ WHERE a = c AND d = e AND f = a "IsNull": null }, "expr": { - "Column": 2 + "Column": [ + 2, + "d" + ] } } } @@ -10737,7 +11424,10 @@ WHERE a = c AND d = e AND f = a "lookup_relation": 2, "stream_key": [ { - "Column": 2 + "Column": [ + 2, + "d" + ] } ], "stream_thinning": [ @@ -10746,17 +11436,26 @@ WHERE a = c AND d = e AND f = a ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + "e" + ] } ], "closure": { "ready_equivalences": [ [ { - "Column": 3 + "Column": [ + 3, + "f" + ] }, { - "Column": 1 + "Column": [ + 1, + "a" + ] } ] ], @@ -10798,7 +11497,10 @@ WHERE a = c AND d = e AND f = a "source_relation": 1, "source_key": [ { - "Column": 0 + "Column": [ + 0, + "c" + ] } ], "initial_closure": { @@ -10820,7 +11522,10 @@ WHERE a = c AND d = e AND f = a "IsNull": null }, "expr": { - "Column": 1 + "Column": [ + 1, + "d" + ] } } } @@ -10841,7 +11546,10 @@ WHERE a = c AND d = e AND f = a "lookup_relation": 0, "stream_key": [ { - "Column": 0 + "Column": [ + 0, + "c" + ] } ], "stream_thinning": [ @@ -10849,7 +11557,10 @@ WHERE a = c AND d = e AND f = a ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], "closure": { @@ -10871,7 +11582,10 @@ WHERE a = c AND d = e AND f = a "IsNull": null }, "expr": { - "Column": 0 + "Column": [ + 0, + "a" + ] } } } @@ -10894,7 +11608,10 @@ WHERE a = c AND d = e AND f = a "lookup_relation": 2, "stream_key": [ { - "Column": 3 + "Column": [ + 3, + "d" + ] } ], "stream_thinning": [ @@ -10904,17 +11621,26 @@ WHERE a = c AND d = e AND f = a ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + "e" + ] } ], "closure": { "ready_equivalences": [ [ { - "Column": 4 + "Column": [ + 4, + "f" + ] }, { - "Column": 3 + "Column": [ + 3, + "c" + ] } ] ], @@ -10956,7 +11682,10 @@ WHERE a = c AND d = e AND f = a "source_relation": 2, "source_key": [ { - "Column": 0 + "Column": [ + 0, + "e" + ] } ], "initial_closure": { @@ -10978,7 +11707,10 @@ WHERE a = c AND d = e AND f = a "lookup_relation": 0, "stream_key": [ { - "Column": 1 + "Column": [ + 1, + "f" + ] } ], "stream_thinning": [ @@ -10986,7 +11718,10 @@ WHERE a = c AND d = e AND f = a ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], "closure": { @@ -11008,7 +11743,10 @@ WHERE a = c AND d = e AND f = a "IsNull": null }, "expr": { - "Column": 0 + "Column": [ + 0, + "a" + ] } } } @@ -11031,7 +11769,10 @@ WHERE a = c AND d = e AND f = a "lookup_relation": 1, "stream_key": [ { - "Column": 2 + "Column": [ + 2, + "e" + ] } ], "stream_thinning": [ @@ -11041,17 +11782,26 @@ WHERE a = c AND d = e AND f = a ], "lookup_key": [ { - "Column": 1 + "Column": [ + 1, + "d" + ] } ], "closure": { "ready_equivalences": [ [ { - "Column": 3 + "Column": [ + 3, + "f" + ] }, { - "Column": 4 + "Column": [ + 4, + "c" + ] } ] ], @@ -11072,7 +11822,10 @@ WHERE a = c AND d = e AND f = a "IsNull": null }, "expr": { - "Column": 0 + "Column": [ + 0, + "d" + ] } } } @@ -11153,7 +11906,10 @@ WHERE a = c and a = e [ [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], [ @@ -11195,7 +11951,10 @@ WHERE a = c and a = e [ [ { - "Column": 0 + "Column": [ + 0, + "c" + ] } ], [ @@ -11237,7 +11996,10 @@ WHERE a = c and a = e [ [ { - "Column": 0 + "Column": [ + 0, + "e" + ] } ], [ @@ -11272,7 +12034,10 @@ WHERE a = c and a = e "source_relation": 0, "source_key": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], "initial_closure": { @@ -11294,7 +12059,10 @@ WHERE a = c and a = e "IsNull": null }, "expr": { - "Column": 0 + "Column": [ + 0, + "a" + ] } } } @@ -11315,7 +12083,10 @@ WHERE a = c and a = e "lookup_relation": 1, "stream_key": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], "stream_thinning": [ @@ -11323,7 +12094,10 @@ WHERE a = c and a = e ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + "c" + ] } ], "closure": { @@ -11346,7 +12120,10 @@ WHERE a = c and a = e "lookup_relation": 2, "stream_key": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], "stream_thinning": [ @@ -11355,7 +12132,10 @@ WHERE a = c and a = e ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + "e" + ] } ], "closure": { @@ -11399,7 +12179,10 @@ WHERE a = c and a = e "source_relation": 1, "source_key": [ { - "Column": 0 + "Column": [ + 0, + "c" + ] } ], "initial_closure": { @@ -11421,7 +12204,10 @@ WHERE a = c and a = e "lookup_relation": 0, "stream_key": [ { - "Column": 0 + "Column": [ + 0, + "c" + ] } ], "stream_thinning": [ @@ -11429,7 +12215,10 @@ WHERE a = c and a = e ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], "closure": { @@ -11451,7 +12240,10 @@ WHERE a = c and a = e "IsNull": null }, "expr": { - "Column": 0 + "Column": [ + 0, + "a" + ] } } } @@ -11474,7 +12266,10 @@ WHERE a = c and a = e "lookup_relation": 2, "stream_key": [ { - "Column": 2 + "Column": [ + 2, + "c" + ] } ], "stream_thinning": [ @@ -11484,7 +12279,10 @@ WHERE a = c and a = e ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + "e" + ] } ], "closure": { @@ -11528,7 +12326,10 @@ WHERE a = c and a = e "source_relation": 2, "source_key": [ { - "Column": 0 + "Column": [ + 0, + "e" + ] } ], "initial_closure": { @@ -11550,7 +12351,10 @@ WHERE a = c and a = e "lookup_relation": 0, "stream_key": [ { - "Column": 0 + "Column": [ + 0, + "e" + ] } ], "stream_thinning": [ @@ -11558,7 +12362,10 @@ WHERE a = c and a = e ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + "a" + ] } ], "closure": { @@ -11580,7 +12387,10 @@ WHERE a = c and a = e "IsNull": null }, "expr": { - "Column": 0 + "Column": [ + 0, + "a" + ] } } } @@ -11603,7 +12413,10 @@ WHERE a = c and a = e "lookup_relation": 1, "stream_key": [ { - "Column": 2 + "Column": [ + 2, + "e" + ] } ], "stream_thinning": [ @@ -11613,7 +12426,10 @@ WHERE a = c and a = e ], "lookup_key": [ { - "Column": 0 + "Column": [ + 0, + "c" + ] } ], "closure": { diff --git a/test/sqllogictest/explain/physical_plan_as_text.slt b/test/sqllogictest/explain/physical_plan_as_text.slt index 4ee9d1d1e647e..de07fceeffdd7 100644 --- a/test/sqllogictest/explain/physical_plan_as_text.slt +++ b/test/sqllogictest/explain/physical_plan_as_text.slt @@ -154,7 +154,7 @@ SELECT * FROM t Explained Query: Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -187,10 +187,10 @@ SELECT a + b, 1 FROM t Explained Query: Get::Arrangement materialize.public.t project=(#2, #3) - map=((#0 + #1), 1) - key=#0 + map=((#0{a} + #1{b}), 1) + key=#0{a} raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -211,7 +211,7 @@ Explained Query: Source materialize.public.u project=(#2, #3) - map=((#0 + #1), 1) + map=((#0{c} + #1{d}), 1) Target cluster: quickstart @@ -225,7 +225,7 @@ INDEX ov_a_idx materialize.public.ov_a_idx: ArrangeBy raw=true - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Get::PassArrangements materialize.public.ov raw=true @@ -233,11 +233,11 @@ materialize.public.ov_a_idx: materialize.public.ov: TopK::Basic order_by=[#1 asc nulls_last, #0 desc nulls_first] limit=5 ArrangeBy - input_key=[#0] + input_key=[#0{a}] raw=true Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -255,11 +255,11 @@ SELECT * FROM (SELECT * FROM t ORDER BY b asc, a desc LIMIT 5) Explained Query: TopK::MonotonicTopK order_by=[#1 asc nulls_last, #0 desc nulls_first] limit=5 must_consolidate ArrangeBy - input_key=[#0] + input_key=[#0{a}] raw=true Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -283,9 +283,9 @@ Explained Query: Union consolidate_output=true Get::Arrangement materialize.public.t project=(#0) - key=#0 + key=#0{a} raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Negate Get::Collection materialize.public.mv @@ -318,9 +318,9 @@ Explained Query: Union consolidate_output=true Get::Arrangement materialize.public.t project=(#0) - key=#0 + key=#0{a} raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Negate Get::Collection materialize.public.mv @@ -329,14 +329,14 @@ Explained Query: Union Get::Arrangement l0 project=(#1) - map=((#0 + 1)) + map=((#0{x} + 1)) key=#0 raw=false arrangements[0]={ key=[#0], permutation=id, thinning=() } types=[integer?] Get::Arrangement l0 project=(#1) - map=((#0 - 1)) + map=((#0{x} - 1)) key=#0 raw=false arrangements[0]={ key=[#0], permutation=id, thinning=() } @@ -373,12 +373,12 @@ Explained Query: linear_stage[0] closure project=(#0) - lookup={ relation=0, key=[#0] } + lookup={ relation=0, key=[#0{a}] } stream={ key=[#0], thinning=() } source={ relation=1, key=[#0] } Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] ArrangeBy raw=true @@ -392,7 +392,7 @@ Explained Query: Source materialize.public.mv project=(#1) - filter=((#1 = 5)) + filter=((#1{x} = 5)) Used Indexes: - materialize.public.t_a_idx (lookup) @@ -407,13 +407,13 @@ EXPLAIN PHYSICAL PLAN AS TEXT FOR SELECT generate_series(a, b) from t ---- Explained Query: - FlatMap generate_series(#0, #1, 1) + FlatMap generate_series(#0{a}, #1{b}, 1) mfp_after project=(#2) - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -433,10 +433,10 @@ Explained Query: val_plan project=() key_plan=id - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -458,16 +458,16 @@ GROUP BY a ---- Explained Query: Reduce::Accumulable - simple_aggrs[0]=(0, 0, sum(#1)) - distinct_aggrs[0]=(1, 1, count(distinct #1)) + simple_aggrs[0]=(0, 0, sum(#1{b})) + distinct_aggrs[0]=(1, 1, count(distinct #1{b})) val_plan project=(#1, #1) key_plan project=(#0) - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -489,17 +489,17 @@ Explained Query: With cte l0 = Reduce::Accumulable - simple_aggrs[0]=(0, 0, sum(#0)) - distinct_aggrs[0]=(1, 1, count(distinct #0)) + simple_aggrs[0]=(0, 0, sum(#0{b})) + distinct_aggrs[0]=(1, 1, count(distinct #0{b})) val_plan project=(#0, #0) key_plan project=() Get::Arrangement materialize.public.t project=(#1) - key=#0 + key=#0{a} raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Return Union @@ -543,10 +543,10 @@ materialize.public.hierarchical_group_by_mv: project=(#1, #1) key_plan project=(#0) - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -571,10 +571,10 @@ Explained Query: project=(#1, #1) key_plan project=(#0) - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -602,9 +602,9 @@ materialize.public.hierarchical_global_mv: project=() Get::Arrangement materialize.public.t project=(#1) - key=#0 + key=#0{a} raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Return Union @@ -653,9 +653,9 @@ Explained Query: project=() Get::Arrangement materialize.public.t project=(#1) - key=#0 + key=#0{a} raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Return Union @@ -702,28 +702,28 @@ Explained Query: stream={ key=[#0], thinning=(#1) } source={ relation=0, key=[#0] } Reduce::Basic - aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#1) || "1"), ",")))) + aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#1{b}) || "1"), ",")))) val_plan project=(#2) - map=(row(row((integer_to_text(#1) || "1"), ","))) + map=(row(row((integer_to_text(#1{b}) || "1"), ","))) key_plan project=(#0) - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Reduce::Basic - aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#1) || "2"), ",")))) + aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#1{b}) || "2"), ",")))) val_plan project=(#2) - map=(row(row((integer_to_text(#1) || "2"), ","))) + map=(row(row((integer_to_text(#1{b}) || "2"), ","))) key_plan project=(#0) - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -746,9 +746,9 @@ Explained Query: cte l0 = Get::Arrangement materialize.public.t project=(#1) - key=#0 + key=#0{a} raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] cte l1 = Join::Linear @@ -757,19 +757,19 @@ Explained Query: stream={ key=[], thinning=(#0) } source={ relation=0, key=[] } Reduce::Basic - aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#0) || "1"), ",")))) + aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#0{b}) || "1"), ",")))) val_plan project=(#1) - map=(row(row((integer_to_text(#0) || "1"), ","))) + map=(row(row((integer_to_text(#0{b}) || "1"), ","))) key_plan project=() Get::PassArrangements l0 raw=true Reduce::Basic - aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#0) || "2"), ",")))) + aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#0{b}) || "2"), ",")))) val_plan project=(#1) - map=(row(row((integer_to_text(#0) || "2"), ","))) + map=(row(row((integer_to_text(#0{b}) || "2"), ","))) key_plan project=() Get::PassArrangements l0 @@ -875,46 +875,46 @@ materialize.public.collated_group_by_mv: project=(#1, #1) key_plan project=(#0) - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Reduce::Accumulable - simple_aggrs[0]=(1, 1, sum(#1)) - distinct_aggrs[0]=(0, 0, count(distinct #1)) + simple_aggrs[0]=(1, 1, sum(#1{b})) + distinct_aggrs[0]=(0, 0, count(distinct #1{b})) val_plan project=(#1, #1) key_plan project=(#0) - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Reduce::Basic - aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#1) || "1"), ",")))) + aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#1{b}) || "1"), ",")))) val_plan project=(#2) - map=(row(row((integer_to_text(#1) || "1"), ","))) + map=(row(row((integer_to_text(#1{b}) || "1"), ","))) key_plan project=(#0) - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Reduce::Basic - aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#1) || "2"), ",")))) + aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#1{b}) || "2"), ",")))) val_plan project=(#2) - map=(row(row((integer_to_text(#1) || "2"), ","))) + map=(row(row((integer_to_text(#1{b}) || "2"), ","))) key_plan project=(#0) - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -1004,46 +1004,46 @@ Explained Query: project=(#1, #1) key_plan project=(#0) - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Reduce::Accumulable - simple_aggrs[0]=(1, 1, sum(#1)) - distinct_aggrs[0]=(0, 0, count(distinct #1)) + simple_aggrs[0]=(1, 1, sum(#1{b})) + distinct_aggrs[0]=(0, 0, count(distinct #1{b})) val_plan project=(#1, #1) key_plan project=(#0) - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Reduce::Basic - aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#1) || "1"), ",")))) + aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#1{b}) || "1"), ",")))) val_plan project=(#2) - map=(row(row((integer_to_text(#1) || "1"), ","))) + map=(row(row((integer_to_text(#1{b}) || "1"), ","))) key_plan project=(#0) - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Reduce::Basic - aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#1) || "2"), ",")))) + aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#1{b}) || "2"), ",")))) val_plan project=(#2) - map=(row(row((integer_to_text(#1) || "2"), ","))) + map=(row(row((integer_to_text(#1{b}) || "2"), ","))) key_plan project=(#0) - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -1063,9 +1063,9 @@ materialize.public.collated_global_mv: cte l0 = Get::Arrangement materialize.public.t project=(#1) - key=#0 + key=#0{a} raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] cte l1 = Join::Delta @@ -1136,8 +1136,8 @@ materialize.public.collated_global_mv: Get::PassArrangements l0 raw=true Reduce::Accumulable - simple_aggrs[0]=(1, 1, sum(#0)) - distinct_aggrs[0]=(0, 0, count(distinct #0)) + simple_aggrs[0]=(1, 1, sum(#0{b})) + distinct_aggrs[0]=(0, 0, count(distinct #0{b})) val_plan project=(#0, #0) key_plan @@ -1145,19 +1145,19 @@ materialize.public.collated_global_mv: Get::PassArrangements l0 raw=true Reduce::Basic - aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#0) || "1"), ",")))) + aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#0{b}) || "1"), ",")))) val_plan project=(#1) - map=(row(row((integer_to_text(#0) || "1"), ","))) + map=(row(row((integer_to_text(#0{b}) || "1"), ","))) key_plan project=() Get::PassArrangements l0 raw=true Reduce::Basic - aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#0) || "2"), ",")))) + aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#0{b}) || "2"), ",")))) val_plan project=(#1) - map=(row(row((integer_to_text(#0) || "2"), ","))) + map=(row(row((integer_to_text(#0{b}) || "2"), ","))) key_plan project=() Get::PassArrangements l0 @@ -1195,9 +1195,9 @@ Explained Query: cte l0 = Get::Arrangement materialize.public.t project=(#1) - key=#0 + key=#0{a} raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] cte l1 = Join::Delta @@ -1269,8 +1269,8 @@ Explained Query: Get::PassArrangements l0 raw=true Reduce::Accumulable - simple_aggrs[0]=(1, 1, sum(#0)) - distinct_aggrs[0]=(0, 0, count(distinct #0)) + simple_aggrs[0]=(1, 1, sum(#0{b})) + distinct_aggrs[0]=(0, 0, count(distinct #0{b})) val_plan project=(#0, #0) key_plan @@ -1278,19 +1278,19 @@ Explained Query: Get::PassArrangements l0 raw=true Reduce::Basic - aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#0) || "1"), ",")))) + aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#0{b}) || "1"), ",")))) val_plan project=(#1) - map=(row(row((integer_to_text(#0) || "1"), ","))) + map=(row(row((integer_to_text(#0{b}) || "1"), ","))) key_plan project=() Get::PassArrangements l0 raw=true Reduce::Basic - aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#0) || "2"), ",")))) + aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#0{b}) || "2"), ",")))) val_plan project=(#1) - map=(row(row((integer_to_text(#0) || "2"), ","))) + map=(row(row((integer_to_text(#0{b}) || "2"), ","))) key_plan project=() Get::PassArrangements l0 @@ -1328,7 +1328,7 @@ INDEX t_a_idx materialize.public.t_a_idx: ArrangeBy raw=true - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Get::PassArrangements materialize.public.t raw=true @@ -1347,7 +1347,7 @@ INDEX ov_a_idx; materialize.public.ov_a_idx: ArrangeBy raw=true - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Get::PassArrangements materialize.public.ov raw=true @@ -1355,11 +1355,11 @@ materialize.public.ov_a_idx: materialize.public.ov: TopK::Basic order_by=[#1 asc nulls_last, #0 desc nulls_first] limit=5 ArrangeBy - input_key=[#0] + input_key=[#0{a}] raw=true Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -1376,14 +1376,14 @@ INDEX ov_b_idx; ---- materialize.public.ov_b_idx: ArrangeBy - input_key=[#0] + input_key=[#0{a}] raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } - arrangements[1]={ key=[#1], permutation={#0: #1, #1: #0}, thinning=(#0) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } + arrangements[1]={ key=[#1{b}], permutation={#0: #1, #1: #0}, thinning=(#0) } types=[integer?, integer?] Get::PassArrangements materialize.public.ov raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -1409,32 +1409,32 @@ Explained Query: delta_stage[1] closure project=(#1, #2) - lookup={ relation=2, key=[#0] } - stream={ key=[#0], thinning=(#1, #2) } + lookup={ relation=2, key=[#0{e}] } + stream={ key=[#0{d}], thinning=(#1, #2) } delta_stage[0] closure project=(#2..=#4) filter=((#3 > 42)) - map=((#1 + #2), (#0 + #2)) - lookup={ relation=1, key=[#0] } - stream={ key=[#0], thinning=(#1) } - source={ relation=0, key=[#0] } + map=((#1{b} + #2{d}), (#0{a} + #2{d})) + lookup={ relation=1, key=[#0{c}] } + stream={ key=[#0{a}], thinning=(#1) } + source={ relation=0, key=[#0{a}] } plan_path[1] final_closure project=(#0, #1, #1) delta_stage[1] closure project=(#1, #2) - lookup={ relation=2, key=[#0] } - stream={ key=[#0], thinning=(#1, #2) } + lookup={ relation=2, key=[#0{e}] } + stream={ key=[#0{d}], thinning=(#1, #2) } delta_stage[0] closure project=(#1, #3, #4) filter=((#3 > 42)) - map=((#2 + #1), (#0 + #1)) - lookup={ relation=0, key=[#0] } - stream={ key=[#0], thinning=(#1) } - source={ relation=1, key=[#0] } + map=((#2{b} + #1{d}), (#0{a} + #1{d})) + lookup={ relation=0, key=[#0{a}] } + stream={ key=[#0{c}], thinning=(#1) } + source={ relation=1, key=[#0{c}] } plan_path[2] final_closure project=(#0, #1, #1) @@ -1442,38 +1442,38 @@ Explained Query: closure project=(#3, #4) filter=((#3 > 42)) - map=((#2 + #1), (#0 + #1)) - lookup={ relation=0, key=[#0] } - stream={ key=[#0], thinning=(#1) } + map=((#2{b} + #1{d}), (#0{a} + #1{d})) + lookup={ relation=0, key=[#0{a}] } + stream={ key=[#0{c}], thinning=(#1) } delta_stage[0] closure project=(#1, #0) - lookup={ relation=1, key=[#1] } - stream={ key=[#0], thinning=() } - source={ relation=2, key=[#0] } + lookup={ relation=1, key=[#1{d}] } + stream={ key=[#0{e}], thinning=() } + source={ relation=2, key=[#0{e}] } Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] ArrangeBy raw=true - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } - arrangements[1]={ key=[#1], permutation={#0: #1, #1: #0}, thinning=(#0) } + arrangements[0]={ key=[#0{c}], permutation=id, thinning=(#1) } + arrangements[1]={ key=[#1{d}], permutation={#0: #1, #1: #0}, thinning=(#0) } types=[integer, integer] Get::Collection materialize.public.u raw=true ArrangeBy raw=true - arrangements[0]={ key=[#0], permutation=id, thinning=() } + arrangements[0]={ key=[#0{e}], permutation=id, thinning=() } types=[integer] Get::Collection materialize.public.v raw=true Source materialize.public.u - filter=((#0) IS NOT NULL AND (#1) IS NOT NULL) + filter=((#0{c}) IS NOT NULL AND (#1{d}) IS NOT NULL) Source materialize.public.v project=(#0) - filter=((#0) IS NOT NULL) + filter=((#0{e}) IS NOT NULL) Used Indexes: - materialize.public.t_a_idx (delta join 1st input (full scan)) @@ -1508,64 +1508,64 @@ Explained Query: delta_stage[1] closure project=(#1, #2, #0) - ready_equivalences=#3 = #1 - lookup={ relation=2, key=[#0] } - stream={ key=[#2], thinning=(#0, #1) } + ready_equivalences=#3{f} = #1{a} + lookup={ relation=2, key=[#0{e}] } + stream={ key=[#2{d}], thinning=(#0, #1) } delta_stage[0] closure - filter=((#2) IS NOT NULL) - lookup={ relation=1, key=[#0] } - stream={ key=[#0], thinning=(#1) } + filter=((#2{d}) IS NOT NULL) + lookup={ relation=1, key=[#0{c}] } + stream={ key=[#0{a}], thinning=(#1) } initial_closure - filter=((#0) IS NOT NULL) - source={ relation=0, key=[#0] } + filter=((#0{a}) IS NOT NULL) + source={ relation=0, key=[#0{a}] } plan_path[1] final_closure project=(#0, #1, #0, #2, #2, #0) delta_stage[1] closure project=(#1, #2, #0) - ready_equivalences=#4 = #3 - lookup={ relation=2, key=[#0] } - stream={ key=[#3], thinning=(#0..=#2) } + ready_equivalences=#4{f} = #3{c} + lookup={ relation=2, key=[#0{e}] } + stream={ key=[#3{d}], thinning=(#0..=#2) } delta_stage[0] closure project=(#0, #2, #0, #1) - filter=((#0) IS NOT NULL) - lookup={ relation=0, key=[#0] } - stream={ key=[#0], thinning=(#1) } + filter=((#0{a}) IS NOT NULL) + lookup={ relation=0, key=[#0{a}] } + stream={ key=[#0{c}], thinning=(#1) } initial_closure - filter=((#1) IS NOT NULL) - source={ relation=1, key=[#0] } + filter=((#1{d}) IS NOT NULL) + source={ relation=1, key=[#0{c}] } plan_path[2] final_closure project=(#0, #1, #0, #2, #2, #0) delta_stage[1] closure project=(#1, #2, #0) - filter=((#0) IS NOT NULL) - ready_equivalences=#3 = #4 - lookup={ relation=1, key=[#1] } - stream={ key=[#2], thinning=(#0, #1, #3) } + filter=((#0{d}) IS NOT NULL) + ready_equivalences=#3{f} = #4{c} + lookup={ relation=1, key=[#1{d}] } + stream={ key=[#2{e}], thinning=(#0, #1, #3) } delta_stage[0] closure project=(#0, #2, #1, #0) - filter=((#0) IS NOT NULL) - lookup={ relation=0, key=[#0] } - stream={ key=[#1], thinning=(#0) } - source={ relation=2, key=[#0] } + filter=((#0{a}) IS NOT NULL) + lookup={ relation=0, key=[#0{a}] } + stream={ key=[#1{f}], thinning=(#0) } + source={ relation=2, key=[#0{e}] } Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Get::PassArrangements materialize.public.u raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } - arrangements[1]={ key=[#1], permutation={#0: #1, #1: #0}, thinning=(#0) } + arrangements[0]={ key=[#0{c}], permutation=id, thinning=(#1) } + arrangements[1]={ key=[#1{d}], permutation={#0: #1, #1: #0}, thinning=(#0) } types=[integer?, integer?] Get::PassArrangements materialize.public.v raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{e}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -1591,55 +1591,55 @@ Explained Query: final_closure project=(#0, #1, #0, #2, #0, #3) delta_stage[1] - lookup={ relation=2, key=[#0] } - stream={ key=[#0], thinning=(#1, #2) } + lookup={ relation=2, key=[#0{e}] } + stream={ key=[#0{a}], thinning=(#1, #2) } delta_stage[0] - lookup={ relation=1, key=[#0] } - stream={ key=[#0], thinning=(#1) } + lookup={ relation=1, key=[#0{c}] } + stream={ key=[#0{a}], thinning=(#1) } initial_closure - filter=((#0) IS NOT NULL) - source={ relation=0, key=[#0] } + filter=((#0{a}) IS NOT NULL) + source={ relation=0, key=[#0{a}] } plan_path[1] final_closure project=(#0, #1, #0, #2, #0, #3) delta_stage[1] closure project=(#1..=#4) - lookup={ relation=2, key=[#0] } - stream={ key=[#2], thinning=(#0, #1, #3) } + lookup={ relation=2, key=[#0{e}] } + stream={ key=[#2{c}], thinning=(#0, #1, #3) } delta_stage[0] closure project=(#0, #2, #0, #1) - filter=((#0) IS NOT NULL) - lookup={ relation=0, key=[#0] } - stream={ key=[#0], thinning=(#1) } - source={ relation=1, key=[#0] } + filter=((#0{a}) IS NOT NULL) + lookup={ relation=0, key=[#0{a}] } + stream={ key=[#0{c}], thinning=(#1) } + source={ relation=1, key=[#0{c}] } plan_path[2] final_closure project=(#0, #1, #0, #2, #0, #3) delta_stage[1] closure project=(#1, #2, #4, #3) - lookup={ relation=1, key=[#0] } - stream={ key=[#2], thinning=(#0, #1, #3) } + lookup={ relation=1, key=[#0{c}] } + stream={ key=[#2{e}], thinning=(#0, #1, #3) } delta_stage[0] closure project=(#0, #2, #0, #1) - filter=((#0) IS NOT NULL) - lookup={ relation=0, key=[#0] } - stream={ key=[#0], thinning=(#1) } - source={ relation=2, key=[#0] } + filter=((#0{a}) IS NOT NULL) + lookup={ relation=0, key=[#0{a}] } + stream={ key=[#0{e}], thinning=(#1) } + source={ relation=2, key=[#0{e}] } Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Get::PassArrangements materialize.public.u raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{c}], permutation=id, thinning=(#1) } types=[integer?, integer?] Get::PassArrangements materialize.public.v raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{e}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -1726,16 +1726,16 @@ Explained Query: map=(record_get[0](#0)) input_key= Reduce::Basic - aggr=(0, lead[ignore_nulls=true, order_by=[]](row(row(row(#0, #1), row(#1, 3, -5)))), fused_unnest_list=true) + aggr=(0, lead[ignore_nulls=true, order_by=[]](row(row(row(#0, #1), row(#1{b}, 3, -5)))), fused_unnest_list=true) val_plan project=(#2) - map=(row(row(row(#0, #1), row(#1, 3, -5)))) + map=(row(row(row(#0, #1), row(#1{b}, 3, -5)))) key_plan project=() - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -1756,16 +1756,16 @@ Explained Query: map=(record_get[0](#2)) input_key=#0, #1 Reduce::Basic - aggr=(0, lag[ignore_nulls=true, order_by=[#0 asc nulls_last, #1 asc nulls_last]](row(row(row(#0, #1), row(#1, 3, -5)), (#1 + 8), (#0 - 7))), fused_unnest_list=true) + aggr=(0, lag[ignore_nulls=true, order_by=[#0 asc nulls_last, #1 asc nulls_last]](row(row(row(#0, #1), row(#1{b}, 3, -5)), (#1{b} + 8), (#0{a} - 7))), fused_unnest_list=true) val_plan project=(#2) - map=(row(row(row(#0, #1), row(#1, 3, -5)), (#1 + 8), (#0 - 7))) + map=(row(row(row(#0, #1), row(#1{b}, 3, -5)), (#1{b} + 8), (#0{a} - 7))) key_plan project=(#1, #0) - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -1796,12 +1796,12 @@ Explained Query: linear_stage[0] closure project=(#0) - lookup={ relation=0, key=[#0] } + lookup={ relation=0, key=[#0{a}] } stream={ key=[#0], thinning=() } source={ relation=1, key=[#0] } Get::PassArrangements materialize.public.t // { node_id: LirId(1) } raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] ArrangeBy // { node_id: LirId(3) } raw=true @@ -1815,7 +1815,7 @@ Explained Query: Source materialize.public.mv project=(#1) - filter=((#1 = 5)) + filter=((#1{x} = 5)) Used Indexes: - materialize.public.t_a_idx (lookup) @@ -1841,18 +1841,18 @@ Explained Query: With cte l0 = Reduce::Basic - aggrs[0]=(0, string_agg[order_by=[]](row(row((integer_to_text(#0) || "1"), ",")))) - aggrs[1]=(1, string_agg[order_by=[]](row(row((integer_to_text(#0) || "2"), ",")))) + aggrs[0]=(0, string_agg[order_by=[]](row(row((integer_to_text(#0{b}) || "1"), ",")))) + aggrs[1]=(1, string_agg[order_by=[]](row(row((integer_to_text(#0{b}) || "2"), ",")))) val_plan project=(#2, #3) - map=(integer_to_text(#0), row(row((#1 || "1"), ",")), row(row((#1 || "2"), ","))) + map=(integer_to_text(#0{b}), row(row((#1 || "1"), ",")), row(row((#1 || "2"), ","))) key_plan project=() Get::Arrangement materialize.public.t project=(#1) - key=#0 + key=#0{a} raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Return Union diff --git a/test/sqllogictest/explain/physical_plan_as_text_redacted.slt b/test/sqllogictest/explain/physical_plan_as_text_redacted.slt index 64cbb694fa8ef..bc8839cc05e39 100644 --- a/test/sqllogictest/explain/physical_plan_as_text_redacted.slt +++ b/test/sqllogictest/explain/physical_plan_as_text_redacted.slt @@ -139,7 +139,7 @@ SELECT * FROM t Explained Query: Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -172,10 +172,10 @@ SELECT a + b, 1 FROM t Explained Query: Get::Arrangement materialize.public.t project=(#2, #3) - map=((#0 + #1), █) - key=#0 + map=((#0{a} + #1{b}), █) + key=#0{a} raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -196,7 +196,7 @@ Explained Query: Source materialize.public.u project=(#2, #3) - map=((#0 + #1), █) + map=((#0{c} + #1{d}), █) Target cluster: quickstart @@ -210,7 +210,7 @@ INDEX ov_a_idx materialize.public.ov_a_idx: ArrangeBy raw=true - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Get::PassArrangements materialize.public.ov raw=true @@ -218,11 +218,11 @@ materialize.public.ov_a_idx: materialize.public.ov: TopK::Basic order_by=[#1 asc nulls_last, #0 desc nulls_first] limit=█ ArrangeBy - input_key=[#0] + input_key=[#0{a}] raw=true Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -240,11 +240,11 @@ SELECT * FROM (SELECT * FROM t ORDER BY b asc, a desc LIMIT 5) Explained Query: TopK::MonotonicTopK order_by=[#1 asc nulls_last, #0 desc nulls_first] limit=█ must_consolidate ArrangeBy - input_key=[#0] + input_key=[#0{a}] raw=true Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -268,9 +268,9 @@ Explained Query: Union consolidate_output=true Get::Arrangement materialize.public.t project=(#0) - key=#0 + key=#0{a} raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Negate Get::Collection materialize.public.mv @@ -303,9 +303,9 @@ Explained Query: Union consolidate_output=true Get::Arrangement materialize.public.t project=(#0) - key=#0 + key=#0{a} raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Negate Get::Collection materialize.public.mv @@ -314,14 +314,14 @@ Explained Query: Union Get::Arrangement l0 project=(#1) - map=((#0 + █)) + map=((#0{x} + █)) key=#0 raw=false arrangements[0]={ key=[#0], permutation=id, thinning=() } types=[integer?] Get::Arrangement l0 project=(#1) - map=((#0 - █)) + map=((#0{x} - █)) key=#0 raw=false arrangements[0]={ key=[#0], permutation=id, thinning=() } @@ -358,12 +358,12 @@ Explained Query: linear_stage[0] closure project=(#0) - lookup={ relation=0, key=[#0] } + lookup={ relation=0, key=[#0{a}] } stream={ key=[#0], thinning=() } source={ relation=1, key=[#0] } Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] ArrangeBy raw=true @@ -377,7 +377,7 @@ Explained Query: Source materialize.public.mv project=(#1) - filter=((#1 = █)) + filter=((#1{x} = █)) Used Indexes: - materialize.public.t_a_idx (lookup) @@ -392,13 +392,13 @@ EXPLAIN PHYSICAL PLAN WITH(redacted) AS TEXT FOR SELECT generate_series(a, b) from t ---- Explained Query: - FlatMap generate_series(#0, #1, █) + FlatMap generate_series(#0{a}, #1{b}, █) mfp_after project=(#2) - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -418,10 +418,10 @@ Explained Query: val_plan project=() key_plan=id - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -443,16 +443,16 @@ GROUP BY a ---- Explained Query: Reduce::Accumulable - simple_aggrs[0]=(0, 0, sum(#1)) - distinct_aggrs[0]=(1, 1, count(distinct #1)) + simple_aggrs[0]=(0, 0, sum(#1{b})) + distinct_aggrs[0]=(1, 1, count(distinct #1{b})) val_plan project=(#1, #1) key_plan project=(#0) - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -474,17 +474,17 @@ Explained Query: With cte l0 = Reduce::Accumulable - simple_aggrs[0]=(0, 0, sum(#0)) - distinct_aggrs[0]=(1, 1, count(distinct #0)) + simple_aggrs[0]=(0, 0, sum(#0{b})) + distinct_aggrs[0]=(1, 1, count(distinct #0{b})) val_plan project=(#0, #0) key_plan project=() Get::Arrangement materialize.public.t project=(#1) - key=#0 + key=#0{a} raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Return Union @@ -528,10 +528,10 @@ materialize.public.hierarchical_group_by_mv: project=(#1, #1) key_plan project=(#0) - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -556,10 +556,10 @@ Explained Query: project=(#1, #1) key_plan project=(#0) - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -587,9 +587,9 @@ materialize.public.hierarchical_global_mv: project=() Get::Arrangement materialize.public.t project=(#1) - key=#0 + key=#0{a} raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Return Union @@ -638,9 +638,9 @@ Explained Query: project=() Get::Arrangement materialize.public.t project=(#1) - key=#0 + key=#0{a} raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Return Union @@ -687,28 +687,28 @@ Explained Query: stream={ key=[#0], thinning=(#1) } source={ relation=0, key=[#0] } Reduce::Basic - aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#1) || █), █)))) + aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#1{b}) || █), █)))) val_plan project=(#2) - map=(row(row((integer_to_text(#1) || █), █))) + map=(row(row((integer_to_text(#1{b}) || █), █))) key_plan project=(#0) - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Reduce::Basic - aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#1) || █), █)))) + aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#1{b}) || █), █)))) val_plan project=(#2) - map=(row(row((integer_to_text(#1) || █), █))) + map=(row(row((integer_to_text(#1{b}) || █), █))) key_plan project=(#0) - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -731,9 +731,9 @@ Explained Query: cte l0 = Get::Arrangement materialize.public.t project=(#1) - key=#0 + key=#0{a} raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] cte l1 = Join::Linear @@ -742,19 +742,19 @@ Explained Query: stream={ key=[], thinning=(#0) } source={ relation=0, key=[] } Reduce::Basic - aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#0) || █), █)))) + aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#0{b}) || █), █)))) val_plan project=(#1) - map=(row(row((integer_to_text(#0) || █), █))) + map=(row(row((integer_to_text(#0{b}) || █), █))) key_plan project=() Get::PassArrangements l0 raw=true Reduce::Basic - aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#0) || █), █)))) + aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#0{b}) || █), █)))) val_plan project=(#1) - map=(row(row((integer_to_text(#0) || █), █))) + map=(row(row((integer_to_text(#0{b}) || █), █))) key_plan project=() Get::PassArrangements l0 @@ -860,46 +860,46 @@ materialize.public.collated_group_by_mv: project=(#1, #1) key_plan project=(#0) - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Reduce::Accumulable - simple_aggrs[0]=(1, 1, sum(#1)) - distinct_aggrs[0]=(0, 0, count(distinct #1)) + simple_aggrs[0]=(1, 1, sum(#1{b})) + distinct_aggrs[0]=(0, 0, count(distinct #1{b})) val_plan project=(#1, #1) key_plan project=(#0) - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Reduce::Basic - aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#1) || █), █)))) + aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#1{b}) || █), █)))) val_plan project=(#2) - map=(row(row((integer_to_text(#1) || █), █))) + map=(row(row((integer_to_text(#1{b}) || █), █))) key_plan project=(#0) - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Reduce::Basic - aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#1) || █), █)))) + aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#1{b}) || █), █)))) val_plan project=(#2) - map=(row(row((integer_to_text(#1) || █), █))) + map=(row(row((integer_to_text(#1{b}) || █), █))) key_plan project=(#0) - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -989,46 +989,46 @@ Explained Query: project=(#1, #1) key_plan project=(#0) - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Reduce::Accumulable - simple_aggrs[0]=(1, 1, sum(#1)) - distinct_aggrs[0]=(0, 0, count(distinct #1)) + simple_aggrs[0]=(1, 1, sum(#1{b})) + distinct_aggrs[0]=(0, 0, count(distinct #1{b})) val_plan project=(#1, #1) key_plan project=(#0) - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Reduce::Basic - aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#1) || █), █)))) + aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#1{b}) || █), █)))) val_plan project=(#2) - map=(row(row((integer_to_text(#1) || █), █))) + map=(row(row((integer_to_text(#1{b}) || █), █))) key_plan project=(#0) - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Reduce::Basic - aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#1) || █), █)))) + aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#1{b}) || █), █)))) val_plan project=(#2) - map=(row(row((integer_to_text(#1) || █), █))) + map=(row(row((integer_to_text(#1{b}) || █), █))) key_plan project=(#0) - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -1048,9 +1048,9 @@ materialize.public.collated_global_mv: cte l0 = Get::Arrangement materialize.public.t project=(#1) - key=#0 + key=#0{a} raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] cte l1 = Join::Delta @@ -1121,8 +1121,8 @@ materialize.public.collated_global_mv: Get::PassArrangements l0 raw=true Reduce::Accumulable - simple_aggrs[0]=(1, 1, sum(#0)) - distinct_aggrs[0]=(0, 0, count(distinct #0)) + simple_aggrs[0]=(1, 1, sum(#0{b})) + distinct_aggrs[0]=(0, 0, count(distinct #0{b})) val_plan project=(#0, #0) key_plan @@ -1130,19 +1130,19 @@ materialize.public.collated_global_mv: Get::PassArrangements l0 raw=true Reduce::Basic - aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#0) || █), █)))) + aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#0{b}) || █), █)))) val_plan project=(#1) - map=(row(row((integer_to_text(#0) || █), █))) + map=(row(row((integer_to_text(#0{b}) || █), █))) key_plan project=() Get::PassArrangements l0 raw=true Reduce::Basic - aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#0) || █), █)))) + aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#0{b}) || █), █)))) val_plan project=(#1) - map=(row(row((integer_to_text(#0) || █), █))) + map=(row(row((integer_to_text(#0{b}) || █), █))) key_plan project=() Get::PassArrangements l0 @@ -1180,9 +1180,9 @@ Explained Query: cte l0 = Get::Arrangement materialize.public.t project=(#1) - key=#0 + key=#0{a} raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] cte l1 = Join::Delta @@ -1254,8 +1254,8 @@ Explained Query: Get::PassArrangements l0 raw=true Reduce::Accumulable - simple_aggrs[0]=(1, 1, sum(#0)) - distinct_aggrs[0]=(0, 0, count(distinct #0)) + simple_aggrs[0]=(1, 1, sum(#0{b})) + distinct_aggrs[0]=(0, 0, count(distinct #0{b})) val_plan project=(#0, #0) key_plan @@ -1263,19 +1263,19 @@ Explained Query: Get::PassArrangements l0 raw=true Reduce::Basic - aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#0) || █), █)))) + aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#0{b}) || █), █)))) val_plan project=(#1) - map=(row(row((integer_to_text(#0) || █), █))) + map=(row(row((integer_to_text(#0{b}) || █), █))) key_plan project=() Get::PassArrangements l0 raw=true Reduce::Basic - aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#0) || █), █)))) + aggr=(0, string_agg[order_by=[]](row(row((integer_to_text(#0{b}) || █), █)))) val_plan project=(#1) - map=(row(row((integer_to_text(#0) || █), █))) + map=(row(row((integer_to_text(#0{b}) || █), █))) key_plan project=() Get::PassArrangements l0 @@ -1313,7 +1313,7 @@ INDEX t_a_idx materialize.public.t_a_idx: ArrangeBy raw=true - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Get::PassArrangements materialize.public.t raw=true @@ -1332,7 +1332,7 @@ INDEX ov_a_idx; materialize.public.ov_a_idx: ArrangeBy raw=true - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Get::PassArrangements materialize.public.ov raw=true @@ -1340,11 +1340,11 @@ materialize.public.ov_a_idx: materialize.public.ov: TopK::Basic order_by=[#1 asc nulls_last, #0 desc nulls_first] limit=█ ArrangeBy - input_key=[#0] + input_key=[#0{a}] raw=true Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -1361,14 +1361,14 @@ INDEX ov_b_idx; ---- materialize.public.ov_b_idx: ArrangeBy - input_key=[#0] + input_key=[#0{a}] raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } - arrangements[1]={ key=[#1], permutation={#0: #1, #1: #0}, thinning=(#0) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } + arrangements[1]={ key=[#1{b}], permutation={#0: #1, #1: #0}, thinning=(#0) } types=[integer?, integer?] Get::PassArrangements materialize.public.ov raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -1394,32 +1394,32 @@ Explained Query: delta_stage[1] closure project=(#1, #2) - lookup={ relation=2, key=[#0] } - stream={ key=[#0], thinning=(#1, #2) } + lookup={ relation=2, key=[#0{e}] } + stream={ key=[#0{d}], thinning=(#1, #2) } delta_stage[0] closure project=(#2..=#4) filter=((#3 > 42)) - map=((#1 + #2), (#0 + #2)) - lookup={ relation=1, key=[#0] } - stream={ key=[#0], thinning=(#1) } - source={ relation=0, key=[#0] } + map=((#1{b} + #2{d}), (#0{a} + #2{d})) + lookup={ relation=1, key=[#0{c}] } + stream={ key=[#0{a}], thinning=(#1) } + source={ relation=0, key=[#0{a}] } plan_path[1] final_closure project=(#0, #1, #1) delta_stage[1] closure project=(#1, #2) - lookup={ relation=2, key=[#0] } - stream={ key=[#0], thinning=(#1, #2) } + lookup={ relation=2, key=[#0{e}] } + stream={ key=[#0{d}], thinning=(#1, #2) } delta_stage[0] closure project=(#1, #3, #4) filter=((#3 > 42)) - map=((#2 + #1), (#0 + #1)) - lookup={ relation=0, key=[#0] } - stream={ key=[#0], thinning=(#1) } - source={ relation=1, key=[#0] } + map=((#2{b} + #1{d}), (#0{a} + #1{d})) + lookup={ relation=0, key=[#0{a}] } + stream={ key=[#0{c}], thinning=(#1) } + source={ relation=1, key=[#0{c}] } plan_path[2] final_closure project=(#0, #1, #1) @@ -1427,38 +1427,38 @@ Explained Query: closure project=(#3, #4) filter=((#3 > 42)) - map=((#2 + #1), (#0 + #1)) - lookup={ relation=0, key=[#0] } - stream={ key=[#0], thinning=(#1) } + map=((#2{b} + #1{d}), (#0{a} + #1{d})) + lookup={ relation=0, key=[#0{a}] } + stream={ key=[#0{c}], thinning=(#1) } delta_stage[0] closure project=(#1, #0) - lookup={ relation=1, key=[#1] } - stream={ key=[#0], thinning=() } - source={ relation=2, key=[#0] } + lookup={ relation=1, key=[#1{d}] } + stream={ key=[#0{e}], thinning=() } + source={ relation=2, key=[#0{e}] } Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] ArrangeBy raw=true - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } - arrangements[1]={ key=[#1], permutation={#0: #1, #1: #0}, thinning=(#0) } + arrangements[0]={ key=[#0{c}], permutation=id, thinning=(#1) } + arrangements[1]={ key=[#1{d}], permutation={#0: #1, #1: #0}, thinning=(#0) } types=[integer, integer] Get::Collection materialize.public.u raw=true ArrangeBy raw=true - arrangements[0]={ key=[#0], permutation=id, thinning=() } + arrangements[0]={ key=[#0{e}], permutation=id, thinning=() } types=[integer] Get::Collection materialize.public.v raw=true Source materialize.public.u - filter=((#0) IS NOT NULL AND (#1) IS NOT NULL) + filter=((#0{c}) IS NOT NULL AND (#1{d}) IS NOT NULL) Source materialize.public.v project=(#0) - filter=((#0) IS NOT NULL) + filter=((#0{e}) IS NOT NULL) Used Indexes: - materialize.public.t_a_idx (delta join 1st input (full scan)) @@ -1493,64 +1493,64 @@ Explained Query: delta_stage[1] closure project=(#1, #2, #0) - ready_equivalences=#3 = #1 - lookup={ relation=2, key=[#0] } - stream={ key=[#2], thinning=(#0, #1) } + ready_equivalences=#3{f} = #1{a} + lookup={ relation=2, key=[#0{e}] } + stream={ key=[#2{d}], thinning=(#0, #1) } delta_stage[0] closure - filter=((#2) IS NOT NULL) - lookup={ relation=1, key=[#0] } - stream={ key=[#0], thinning=(#1) } + filter=((#2{d}) IS NOT NULL) + lookup={ relation=1, key=[#0{c}] } + stream={ key=[#0{a}], thinning=(#1) } initial_closure - filter=((#0) IS NOT NULL) - source={ relation=0, key=[#0] } + filter=((#0{a}) IS NOT NULL) + source={ relation=0, key=[#0{a}] } plan_path[1] final_closure project=(#0, #1, #0, #2, #2, #0) delta_stage[1] closure project=(#1, #2, #0) - ready_equivalences=#4 = #3 - lookup={ relation=2, key=[#0] } - stream={ key=[#3], thinning=(#0..=#2) } + ready_equivalences=#4{f} = #3{c} + lookup={ relation=2, key=[#0{e}] } + stream={ key=[#3{d}], thinning=(#0..=#2) } delta_stage[0] closure project=(#0, #2, #0, #1) - filter=((#0) IS NOT NULL) - lookup={ relation=0, key=[#0] } - stream={ key=[#0], thinning=(#1) } + filter=((#0{a}) IS NOT NULL) + lookup={ relation=0, key=[#0{a}] } + stream={ key=[#0{c}], thinning=(#1) } initial_closure - filter=((#1) IS NOT NULL) - source={ relation=1, key=[#0] } + filter=((#1{d}) IS NOT NULL) + source={ relation=1, key=[#0{c}] } plan_path[2] final_closure project=(#0, #1, #0, #2, #2, #0) delta_stage[1] closure project=(#1, #2, #0) - filter=((#0) IS NOT NULL) - ready_equivalences=#3 = #4 - lookup={ relation=1, key=[#1] } - stream={ key=[#2], thinning=(#0, #1, #3) } + filter=((#0{d}) IS NOT NULL) + ready_equivalences=#3{f} = #4{c} + lookup={ relation=1, key=[#1{d}] } + stream={ key=[#2{e}], thinning=(#0, #1, #3) } delta_stage[0] closure project=(#0, #2, #1, #0) - filter=((#0) IS NOT NULL) - lookup={ relation=0, key=[#0] } - stream={ key=[#1], thinning=(#0) } - source={ relation=2, key=[#0] } + filter=((#0{a}) IS NOT NULL) + lookup={ relation=0, key=[#0{a}] } + stream={ key=[#1{f}], thinning=(#0) } + source={ relation=2, key=[#0{e}] } Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Get::PassArrangements materialize.public.u raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } - arrangements[1]={ key=[#1], permutation={#0: #1, #1: #0}, thinning=(#0) } + arrangements[0]={ key=[#0{c}], permutation=id, thinning=(#1) } + arrangements[1]={ key=[#1{d}], permutation={#0: #1, #1: #0}, thinning=(#0) } types=[integer?, integer?] Get::PassArrangements materialize.public.v raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{e}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -1576,55 +1576,55 @@ Explained Query: final_closure project=(#0, #1, #0, #2, #0, #3) delta_stage[1] - lookup={ relation=2, key=[#0] } - stream={ key=[#0], thinning=(#1, #2) } + lookup={ relation=2, key=[#0{e}] } + stream={ key=[#0{a}], thinning=(#1, #2) } delta_stage[0] - lookup={ relation=1, key=[#0] } - stream={ key=[#0], thinning=(#1) } + lookup={ relation=1, key=[#0{c}] } + stream={ key=[#0{a}], thinning=(#1) } initial_closure - filter=((#0) IS NOT NULL) - source={ relation=0, key=[#0] } + filter=((#0{a}) IS NOT NULL) + source={ relation=0, key=[#0{a}] } plan_path[1] final_closure project=(#0, #1, #0, #2, #0, #3) delta_stage[1] closure project=(#1..=#4) - lookup={ relation=2, key=[#0] } - stream={ key=[#2], thinning=(#0, #1, #3) } + lookup={ relation=2, key=[#0{e}] } + stream={ key=[#2{c}], thinning=(#0, #1, #3) } delta_stage[0] closure project=(#0, #2, #0, #1) - filter=((#0) IS NOT NULL) - lookup={ relation=0, key=[#0] } - stream={ key=[#0], thinning=(#1) } - source={ relation=1, key=[#0] } + filter=((#0{a}) IS NOT NULL) + lookup={ relation=0, key=[#0{a}] } + stream={ key=[#0{c}], thinning=(#1) } + source={ relation=1, key=[#0{c}] } plan_path[2] final_closure project=(#0, #1, #0, #2, #0, #3) delta_stage[1] closure project=(#1, #2, #4, #3) - lookup={ relation=1, key=[#0] } - stream={ key=[#2], thinning=(#0, #1, #3) } + lookup={ relation=1, key=[#0{c}] } + stream={ key=[#2{e}], thinning=(#0, #1, #3) } delta_stage[0] closure project=(#0, #2, #0, #1) - filter=((#0) IS NOT NULL) - lookup={ relation=0, key=[#0] } - stream={ key=[#0], thinning=(#1) } - source={ relation=2, key=[#0] } + filter=((#0{a}) IS NOT NULL) + lookup={ relation=0, key=[#0{a}] } + stream={ key=[#0{e}], thinning=(#1) } + source={ relation=2, key=[#0{e}] } Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Get::PassArrangements materialize.public.u raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{c}], permutation=id, thinning=(#1) } types=[integer?, integer?] Get::PassArrangements materialize.public.v raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{e}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -1711,16 +1711,16 @@ Explained Query: map=(record_get[0](#0)) input_key= Reduce::Basic - aggr=(0, lead[ignore_nulls=true, order_by=[]](row(row(row(#0, #1), row(#1, █, █)))), fused_unnest_list=true) + aggr=(0, lead[ignore_nulls=true, order_by=[]](row(row(row(#0, #1), row(#1{b}, █, █)))), fused_unnest_list=true) val_plan project=(#2) - map=(row(row(row(#0, #1), row(#1, █, █)))) + map=(row(row(row(#0, #1), row(#1{b}, █, █)))) key_plan project=() - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -1741,16 +1741,16 @@ Explained Query: map=(record_get[0](#2)) input_key=#0, #1 Reduce::Basic - aggr=(0, lag[ignore_nulls=true, order_by=[#0 asc nulls_last, #1 asc nulls_last]](row(row(row(#0, #1), row(#1, █, █)), (#1 + █), (#0 - █))), fused_unnest_list=true) + aggr=(0, lag[ignore_nulls=true, order_by=[#0 asc nulls_last, #1 asc nulls_last]](row(row(row(#0, #1), row(#1{b}, █, █)), (#1{b} + █), (#0{a} - █))), fused_unnest_list=true) val_plan project=(#2) - map=(row(row(row(#0, #1), row(#1, █, █)), (#1 + █), (#0 - █))) + map=(row(row(row(#0, #1), row(#1{b}, █, █)), (#1{b} + █), (#0{a} - █))) key_plan project=(#1, #0) - input_key=#0 + input_key=#0{a} Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: diff --git a/test/sqllogictest/explain/plan_insights.slt b/test/sqllogictest/explain/plan_insights.slt index 8d8477df3e514..d156aea528207 100644 --- a/test/sqllogictest/explain/plan_insights.slt +++ b/test/sqllogictest/explain/plan_insights.slt @@ -166,7 +166,8 @@ EXPLAIN PLAN INSIGHTS AS JSON FOR SELECT * FROM t t1, t t2 { "scalar_type": "Bool", "nullable": false - } + }, + null ] }, "kind": "Inner" @@ -526,7 +527,8 @@ EXPLAIN PLAN INSIGHTS AS JSON FOR SELECT * FROM t t1, t t2 { "scalar_type": "Bool", "nullable": false - } + }, + null ] }, "kind": "Inner" @@ -862,7 +864,8 @@ EXPLAIN PLAN INSIGHTS AS JSON FOR SELECT count(*) FROM t { "scalar_type": "Bool", "nullable": false - } + }, + null ] }, "distinct": false @@ -1118,7 +1121,8 @@ EXPLAIN PLAN INSIGHTS AS JSON FOR CREATE VIEW V AS SELECT 1 { "scalar_type": "Int32", "nullable": false - } + }, + null ] } ] @@ -1181,7 +1185,8 @@ EXPLAIN PLAN INSIGHTS AS JSON FOR SELECT 'abc' { "scalar_type": "String", "nullable": false - } + }, + null ] } ] diff --git a/test/sqllogictest/explain/raw_plan_as_json.slt b/test/sqllogictest/explain/raw_plan_as_json.slt index 387cb72206f7c..d3aac7b3fca93 100644 --- a/test/sqllogictest/explain/raw_plan_as_json.slt +++ b/test/sqllogictest/explain/raw_plan_as_json.slt @@ -70,10 +70,13 @@ SELECT a + 1, b, 4 FROM mv WHERE a > 0 "CallBinary": { "func": "Gt", "expr1": { - "Column": { - "level": 0, - "column": 0 - } + "Column": [ + { + "level": 0, + "column": 0 + }, + "a" + ] }, "expr2": { "Literal": [ @@ -85,9 +88,11 @@ SELECT a + 1, b, 4 FROM mv WHERE a > 0 { "scalar_type": "Int32", "nullable": false - } + }, + null ] - } + }, + "name": null } } ] @@ -98,10 +103,13 @@ SELECT a + 1, b, 4 FROM mv WHERE a > 0 "CallBinary": { "func": "AddInt32", "expr1": { - "Column": { - "level": 0, - "column": 0 - } + "Column": [ + { + "level": 0, + "column": 0 + }, + "a" + ] }, "expr2": { "Literal": [ @@ -114,9 +122,11 @@ SELECT a + 1, b, 4 FROM mv WHERE a > 0 { "scalar_type": "Int32", "nullable": false - } + }, + null ] - } + }, + "name": null } }, { @@ -130,7 +140,8 @@ SELECT a + 1, b, 4 FROM mv WHERE a > 0 { "scalar_type": "Int32", "nullable": false - } + }, + null ] } ] @@ -165,7 +176,8 @@ SELECT * FROM generate_series(1, 7) { "scalar_type": "Int32", "nullable": false - } + }, + null ] }, { @@ -179,7 +191,8 @@ SELECT * FROM generate_series(1, 7) { "scalar_type": "Int32", "nullable": false - } + }, + null ] }, { @@ -193,7 +206,8 @@ SELECT * FROM generate_series(1, 7) { "scalar_type": "Int32", "nullable": false - } + }, + null ] } ] @@ -355,20 +369,26 @@ SELECT abs(min(a) - max(a)) FROM t { "func": "MinInt32", "expr": { - "Column": { - "level": 0, - "column": 0 - } + "Column": [ + { + "level": 0, + "column": 0 + }, + "a" + ] }, "distinct": false }, { "func": "MaxInt32", "expr": { - "Column": { - "level": 0, - "column": 0 - } + "Column": [ + { + "level": 0, + "column": 0 + }, + "a" + ] }, "distinct": false } @@ -386,19 +406,27 @@ SELECT abs(min(a) - max(a)) FROM t "CallBinary": { "func": "SubInt32", "expr1": { - "Column": { - "level": 0, - "column": 0 - } + "Column": [ + { + "level": 0, + "column": 0 + }, + "?column?" + ] }, "expr2": { - "Column": { - "level": 0, - "column": 1 - } - } + "Column": [ + { + "level": 0, + "column": 1 + }, + "?column?" + ] + }, + "name": null } - } + }, + "name": null } } ] @@ -448,10 +476,13 @@ SELECT abs(min(a) - max(a)) FROM t GROUP BY b }, "scalars": [ { - "Column": { - "level": 0, - "column": 1 - } + "Column": [ + { + "level": 0, + "column": 1 + }, + "b" + ] } ] } @@ -463,20 +494,26 @@ SELECT abs(min(a) - max(a)) FROM t GROUP BY b { "func": "MinInt32", "expr": { - "Column": { - "level": 0, - "column": 0 - } + "Column": [ + { + "level": 0, + "column": 0 + }, + "a" + ] }, "distinct": false }, { "func": "MaxInt32", "expr": { - "Column": { - "level": 0, - "column": 0 - } + "Column": [ + { + "level": 0, + "column": 0 + }, + "a" + ] }, "distinct": false } @@ -494,19 +531,27 @@ SELECT abs(min(a) - max(a)) FROM t GROUP BY b "CallBinary": { "func": "SubInt32", "expr1": { - "Column": { - "level": 0, - "column": 1 - } + "Column": [ + { + "level": 0, + "column": 1 + }, + "?column?" + ] }, "expr2": { - "Column": { - "level": 0, - "column": 2 - } - } + "Column": [ + { + "level": 0, + "column": 2 + }, + "?column?" + ] + }, + "name": null } - } + }, + "name": null } } ] @@ -557,17 +602,24 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC "CallBinary": { "func": "Gt", "expr1": { - "Column": { - "level": 1, - "column": 1 - } + "Column": [ + { + "level": 1, + "column": 1 + }, + "b" + ] }, "expr2": { - "Column": { - "level": 0, - "column": 1 - } - } + "Column": [ + { + "level": 0, + "column": 1 + }, + "b" + ] + }, + "name": null } } ] @@ -606,17 +658,24 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC "CallBinary": { "func": "Lt", "expr1": { - "Column": { - "level": 1, - "column": 0 - } + "Column": [ + { + "level": 1, + "column": 0 + }, + "a" + ] }, "expr2": { - "Column": { - "level": 0, - "column": 0 - } - } + "Column": [ + { + "level": 0, + "column": 0 + }, + "a" + ] + }, + "name": null } } ] @@ -652,32 +711,39 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC "func": "And", "exprs": [ { - "Exists": { - "Get": { - "id": { - "Local": 1 - }, - "typ": { - "column_types": [], - "keys": [] + "Exists": [ + { + "Get": { + "id": { + "Local": 1 + }, + "typ": { + "column_types": [], + "keys": [] + } } - } - } + }, + null + ] }, { - "Exists": { - "Get": { - "id": { - "Local": 2 - }, - "typ": { - "column_types": [], - "keys": [] + "Exists": [ + { + "Get": { + "id": { + "Local": 2 + }, + "typ": { + "column_types": [], + "keys": [] + } } - } - } + }, + null + ] } - ] + ], + "name": null } } ] @@ -733,17 +799,24 @@ SELECT (SELECT v.a FROM v WHERE v.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHERE m "CallBinary": { "func": "Eq", "expr1": { - "Column": { - "level": 0, - "column": 1 - } + "Column": [ + { + "level": 0, + "column": 1 + }, + "b" + ] }, "expr2": { - "Column": { - "level": 1, - "column": 1 - } - } + "Column": [ + { + "level": 1, + "column": 1 + }, + "b" + ] + }, + "name": null } } ] @@ -762,7 +835,8 @@ SELECT (SELECT v.a FROM v WHERE v.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHERE m { "scalar_type": "Int64", "nullable": false - } + }, + null ] }, "offset": 0, @@ -811,17 +885,24 @@ SELECT (SELECT v.a FROM v WHERE v.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHERE m "CallBinary": { "func": "Eq", "expr1": { - "Column": { - "level": 0, - "column": 1 - } + "Column": [ + { + "level": 0, + "column": 1 + }, + "b" + ] }, "expr2": { - "Column": { - "level": 1, - "column": 1 - } - } + "Column": [ + { + "level": 1, + "column": 1 + }, + "b" + ] + }, + "name": null } } ] @@ -840,7 +921,8 @@ SELECT (SELECT v.a FROM v WHERE v.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHERE m { "scalar_type": "Int64", "nullable": false - } + }, + null ] }, "offset": 0, @@ -878,30 +960,36 @@ SELECT (SELECT v.a FROM v WHERE v.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHERE m }, "scalars": [ { - "Select": { - "Get": { - "id": { - "Local": 1 - }, - "typ": { - "column_types": [], - "keys": [] + "Select": [ + { + "Get": { + "id": { + "Local": 1 + }, + "typ": { + "column_types": [], + "keys": [] + } } - } - } + }, + null + ] }, { - "Select": { - "Get": { - "id": { - "Local": 2 - }, - "typ": { - "column_types": [], - "keys": [] + "Select": [ + { + "Get": { + "id": { + "Local": 2 + }, + "typ": { + "column_types": [], + "keys": [] + } } - } - } + }, + null + ] } ] } @@ -981,7 +1069,8 @@ SELECT t1.a, t2.a FROM t as t1, t as t2 { "scalar_type": "Bool", "nullable": false - } + }, + null ] }, "kind": "Inner" @@ -1067,7 +1156,8 @@ WHERE t1.b = t2.b AND t2.b = t3.b { "scalar_type": "Bool", "nullable": false - } + }, + null ] }, "kind": "Inner" @@ -1105,7 +1195,8 @@ WHERE t1.b = t2.b AND t2.b = t3.b { "scalar_type": "Bool", "nullable": false - } + }, + null ] }, "kind": "Inner" @@ -1120,37 +1211,52 @@ WHERE t1.b = t2.b AND t2.b = t3.b "CallBinary": { "func": "Eq", "expr1": { - "Column": { - "level": 0, - "column": 1 - } + "Column": [ + { + "level": 0, + "column": 1 + }, + "b" + ] }, "expr2": { - "Column": { - "level": 0, - "column": 3 - } - } + "Column": [ + { + "level": 0, + "column": 3 + }, + "b" + ] + }, + "name": null } }, { "CallBinary": { "func": "Eq", "expr1": { - "Column": { - "level": 0, - "column": 3 - } + "Column": [ + { + "level": 0, + "column": 3 + }, + "b" + ] }, "expr2": { - "Column": { - "level": 0, - "column": 5 - } - } + "Column": [ + { + "level": 0, + "column": 5 + }, + "b" + ] + }, + "name": null } } - ] + ], + "name": null } } ] @@ -1200,7 +1306,8 @@ WITH A AS (SELECT 1 AS a), B as (SELECT a as b FROM A WHERE a > 0) SELECT * FROM { "scalar_type": "Int32", "nullable": false - } + }, + null ] } ] @@ -1233,10 +1340,13 @@ WITH A AS (SELECT 1 AS a), B as (SELECT a as b FROM A WHERE a > 0) SELECT * FROM "CallBinary": { "func": "Gt", "expr1": { - "Column": { - "level": 0, - "column": 0 - } + "Column": [ + { + "level": 0, + "column": 0 + }, + "a" + ] }, "expr2": { "Literal": [ @@ -1248,9 +1358,11 @@ WITH A AS (SELECT 1 AS a), B as (SELECT a as b FROM A WHERE a > 0) SELECT * FROM { "scalar_type": "Int32", "nullable": false - } + }, + null ] - } + }, + "name": null } } ] @@ -1300,7 +1412,8 @@ WITH A AS (SELECT 1 AS a), B as (SELECT a as b FROM A WHERE a > 0) SELECT * FROM { "scalar_type": "Bool", "nullable": false - } + }, + null ] }, "kind": "Inner" diff --git a/test/sqllogictest/explain/raw_plan_as_text.slt b/test/sqllogictest/explain/raw_plan_as_text.slt index 57d2de342c8ee..4419d8e3070e5 100644 --- a/test/sqllogictest/explain/raw_plan_as_text.slt +++ b/test/sqllogictest/explain/raw_plan_as_text.slt @@ -50,8 +50,8 @@ EXPLAIN RAW PLAN AS TEXT FOR SELECT a + 1, b, 4 FROM mv WHERE a > 0 ---- Project (#2, #1, #3) - Map ((#0 + 1), 4) - Filter (#0 > 0) + Map ((#0{a} + 1), 4) + Filter (#0{a} > 0) Get materialize.public.mv Target cluster: quickstart @@ -136,8 +136,8 @@ EXPLAIN RAW PLAN AS TEXT FOR SELECT abs(min(a) - max(a)) FROM t ---- Project (#2) - Map (abs((#0 - #1))) - Reduce aggregates=[min(#0), max(#0)] + Map (abs((#0{?column?} - #1{?column?}))) + Reduce aggregates=[min(#0{a}), max(#0{a})] Get materialize.public.t Target cluster: quickstart @@ -150,9 +150,9 @@ EXPLAIN RAW PLAN AS TEXT FOR SELECT abs(min(a) - max(a)) FROM t GROUP BY b ---- Project (#3) - Map (abs((#1 - #2))) - Reduce group_by=[#2] aggregates=[min(#0), max(#0)] - Map (#1) + Map (abs((#1{?column?} - #2{?column?}))) + Reduce group_by=[#2] aggregates=[min(#0{a}), max(#0{a})] + Map (#1{b}) Get materialize.public.t Target cluster: quickstart @@ -166,10 +166,10 @@ SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELEC ---- With cte [l2 as subquery-2] = - Filter (#^1 > #1) + Filter (#^1{b} > #1{b}) Get materialize.public.mv cte [l1 as subquery-1] = - Filter (#^0 < #0) + Filter (#^0{a} < #0{a}) Get materialize.public.mv Return Filter (exists(Get l1) AND exists(Get l2)) @@ -189,12 +189,12 @@ Project (#2, #3) cte [l2 as subquery-2] = Project (#0) TopK limit=1 - Filter (#1 = #^1) + Filter (#1{b} = #^1{b}) Get materialize.public.mv cte [l1 as subquery-1] = Project (#0) TopK limit=1 - Filter (#1 = #^1) + Filter (#1{b} = #^1{b}) Get materialize.public.v Return Map (select(Get l1), select(Get l2)) @@ -243,7 +243,7 @@ FROM WHERE t1.b = t2.b AND t2.b = t3.b ---- Project (#0, #2) - Filter ((#1 = #3) AND (#3 = #5)) + Filter ((#1{b} = #3{b}) AND (#3{b} = #5{b})) CrossJoin CrossJoin Get materialize.public.t @@ -263,8 +263,8 @@ INNER JOIN t as t2 ON t1.b = t2.b INNER JOIN t as t3 ON t2.b = t3.b ---- Project (#0, #2) - InnerJoin (#3 = #5) - InnerJoin (#1 = #3) + InnerJoin (#3{b} = #5{b}) + InnerJoin (#1{b} = #3{b}) Get materialize.public.t Get materialize.public.t Get materialize.public.t @@ -282,8 +282,8 @@ LEFT JOIN t as t2 ON t1.b = t2.b RIGHT JOIN t as t3 ON t2.b = t3.b ---- Project (#0, #2) - RightOuterJoin (#3 = #5) - LeftOuterJoin (#1 = #3) + RightOuterJoin (#3{b} = #5{b}) + LeftOuterJoin (#1{b} = #3{b}) Get materialize.public.t Get materialize.public.t Get materialize.public.t @@ -301,10 +301,10 @@ Project (#1) With cte [l0 as x] = Project (#2) - Map ((#0 * #1)) + Map ((#0{a} * #1{b})) Get materialize.public.t Return - Map ((#0 + 5)) + Map ((#0{v} + 5)) Get l0 Target cluster: quickstart @@ -322,7 +322,7 @@ With Constant - () cte [l1 as b] = - Filter (#0 > 0) + Filter (#0{a} > 0) Get l0 Return CrossJoin @@ -361,17 +361,17 @@ CrossJoin Get materialize.public.t With cte [l0 as r2] = - Reduce aggregates=[max((#^0 * #0))] + Reduce aggregates=[max((#^0{a} * #0{a}))] Get materialize.public.t Return - Filter (#0 != #^0) + Filter (#0{m} != #^0{a}) Get l0 With cte [l0 as r4] = - Reduce aggregates=[max((#^0 * #0))] + Reduce aggregates=[max((#^0{a} * #0{a}))] Get materialize.public.t Return - Filter ((#0 != #^0) OR ((#0) IS NOT NULL AND (#^0) IS NULL)) + Filter ((#0{m} != #^0{a}) OR ((#0{m}) IS NOT NULL AND (#^0{a}) IS NULL)) Get l0 Target cluster: quickstart @@ -409,18 +409,18 @@ CrossJoin Get materialize.public.t With cte [l0 as r4] = - Reduce aggregates=[max((#^0 * #0))] + Reduce aggregates=[max((#^0{a} * #0{a}))] Get materialize.public.t Return - Filter (#^0 != #^0) + Filter (#^0{a} != #^0{a}) CrossJoin Get l0 With cte [l1 as r2] = - Reduce aggregates=[max((#^^0 * #0))] + Reduce aggregates=[max((#^^0{a} * #0{a}))] Get materialize.public.t Return - Filter ((#^^0 = #^0) AND (#0 > 5)) + Filter ((#^^0{a} = #^0{m}) AND (#0{m} > 5)) Get l1 Target cluster: quickstart @@ -485,7 +485,7 @@ SELECT lag(b, 3) OVER () FROM t; ---- Project (#2) - Map (lag(row(#1, 3, null)) over (order by [])) + Map (lag(row(#1{b}, 3, null)) over (order by [])) Get materialize.public.t Target cluster: quickstart @@ -498,7 +498,7 @@ SELECT lag(b, 333) RESPECT NULLS OVER () FROM t; ---- Project (#2) - Map (lag(row(#1, 333, null)) over (order by [])) + Map (lag(row(#1{b}, 333, null)) over (order by [])) Get materialize.public.t Target cluster: quickstart @@ -511,7 +511,7 @@ SELECT lag(b, 333) IGNORE NULLS OVER () FROM t; ---- Project (#2) - Map (lag(row(#1, 333, null)) ignore nulls over (order by [])) + Map (lag(row(#1{b}, 333, null)) ignore nulls over (order by [])) Get materialize.public.t Target cluster: quickstart @@ -530,11 +530,11 @@ FROM ( ); ---- Project (#1) - Map (row_number() over (order by [#0 desc nulls_first])) + Map (row_number() over (order by [#0{r} desc nulls_first])) Project (#1) - Map (row_number() over (partition by [#0] order by [])) + Map (row_number() over (partition by [#0{l}] order by [])) Project (#2) - Map (lag(row(#1, 3, null)) over (partition by [(#1 % 2), (#0 % 3)] order by [#0 desc nulls_first, -(#1) asc nulls_last, ((2 * #1) + #0) asc nulls_first])) + Map (lag(row(#1{b}, 3, null)) over (partition by [(#1{b} % 2), (#0{a} % 3)] order by [#0{a} desc nulls_first, -(#1{b}) asc nulls_last, ((2 * #1{b}) + #0{a}) asc nulls_first])) Get materialize.public.t Target cluster: quickstart @@ -549,7 +549,7 @@ SELECT FROM t; ---- Project (#2) - Map (first_value(#1) over (partition by [(#1 % 6)] order by [(#1 + 33) asc nulls_last])) + Map (first_value(#1{b}) over (partition by [(#1{b} % 6)] order by [(#1{b} + 33) asc nulls_last])) Get materialize.public.t Target cluster: quickstart @@ -563,7 +563,7 @@ SELECT FROM t; ---- Project (#2) - Map (first_value(#1) over (partition by [(#1 % 6)] order by [(#1 + 33) asc nulls_last] rows between 2 preceding and current row)) + Map (first_value(#1{b}) over (partition by [(#1{b} % 6)] order by [(#1{b} + 33) asc nulls_last] rows between 2 preceding and current row)) Get materialize.public.t Target cluster: quickstart @@ -577,7 +577,7 @@ SELECT FROM t; ---- Project (#2) - Map (sum((#1 + 8)) over (partition by [(#1 % 6)] order by [(#1 + 33) desc nulls_first] rows between 2 preceding and 3 following)) + Map (sum((#1{b} + 8)) over (partition by [(#1{b} % 6)] order by [(#1{b} + 33) desc nulls_first] rows between 2 preceding and 3 following)) Get materialize.public.t Target cluster: quickstart @@ -684,8 +684,8 @@ EXPLAIN RAW PLAN AS TEXT FOR VIEW v; ---- Project (#0, #1, #3) - Filter (#1 = 100) - LeftOuterJoin (integer_to_bigint(#0) = #2) + Filter (#1{balance} = 100) + LeftOuterJoin (integer_to_bigint(#0{id}) = #2{id}) Get materialize.public.accounts Get materialize.public.account_details diff --git a/test/sqllogictest/freshmart.slt b/test/sqllogictest/freshmart.slt index 8064d869504a5..960bc53af8c54 100644 --- a/test/sqllogictest/freshmart.slt +++ b/test/sqllogictest/freshmart.slt @@ -220,7 +220,7 @@ Explained Query: cte l6 = Project (#0{product_id}..=#2{base_price}, #10..=#12) Map (case when (#5) IS NULL then null else #4 end, case when (#8) IS NULL then null else #7{min_promotion_discount} end) - Join on=(#0{product_id} = #3{product_id} = #6{product_id} = #9) type=delta + Join on=(#0{product_id} = #3{product_id} = #6{product_id} = #9{product_id}) type=delta ArrangeBy keys=[[#0{product_id}]] Project (#0{product_id}..=#2{base_price}) ReadIndex on=products idx_products_product_name=[*** full scan ***] @@ -246,7 +246,7 @@ Explained Query: Project (#0{product_id}) Get l3 Get l4 - ArrangeBy keys=[[#0]] + ArrangeBy keys=[[#0{product_id}]] Project (#2, #3) Filter (#2) IS NOT NULL Map (record_get[0](record_get[1](#1)), record_get[0](#1)) @@ -291,7 +291,7 @@ Explained Query: Get l6 Return Project (#0{product_id}, #13, #11{last_update_time}) - Map (case when (#8) IS NULL then null else #7 end, (((((#2{base_price} * case when (#3 <= 3) then 1.2 else case when ((#3 <= 10) AND (#3 >= 4)) then 1.1 else 0.9 end end) * coalesce((1 - (#5 / 100)), 1)) * case when (#12 <= 3) then 1.1 else case when ((#12 <= 10) AND (#12 >= 4)) then 1.05 else 1 end end) * case when (#2{base_price} > #4) then (1 + ((#2{base_price} - #4) / #4)) else (1 - ((#4 - #2{base_price}) / #4)) end) * case when ilike["%cheap%"](varchar_to_text(#1{product_name})) then 0.8 else 1 end)) + Map (case when (#8) IS NULL then null else #7 end, (((((#2{base_price} * case when (#3{popularity_rank} <= 3) then 1.2 else case when ((#3{popularity_rank} <= 10) AND (#3{popularity_rank} >= 4)) then 1.1 else 0.9 end end) * coalesce((1 - (#5{promotion_discount} / 100)), 1)) * case when (#12{stock_rank} <= 3) then 1.1 else case when ((#12 <= 10) AND (#12 >= 4)) then 1.05 else 1 end end) * case when (#2{base_price} > #4{avg_price}) then (1 + ((#2{base_price} - #4{avg_price}) / #4{avg_price})) else (1 - ((#4{avg_price} - #2{base_price}) / #4{avg_price})) end) * case when ilike["%cheap%"](varchar_to_text(#1{product_name})) then 0.8 else 1 end)) Join on=(#0{product_id} = #6{product_id} = #9{product_id} = #10{product_id}) type=delta ArrangeBy keys=[[#0{product_id}]] Get l6 @@ -712,7 +712,7 @@ Explained Query: Get l2 Project (#4{parent_id}, #1, #5) Map (integer_to_bigint(#2)) - Join on=(#0 = #3{category_id}) type=differential + Join on=(#0{category_id} = #3{category_id}) type=differential ArrangeBy keys=[[#0{category_id}]] Get l3 ArrangeBy keys=[[#0{category_id}]] @@ -741,7 +741,7 @@ Explained Query: Map (bigint_to_integer(#2{sum}), (#7{count} > 0)) Join on=(#0{category_id} = #3{category_id} = #6{category_id}) type=delta ArrangeBy keys=[[#0{category_id}]] - Reduce group_by=[#0{category_id}] aggregates=[sum(#1), sum(#2)] + Reduce group_by=[#0{category_id}] aggregates=[sum(#1{total}), sum(#2{item_count})] Project (#0{category_id}, #2, #3) Join on=(#0{category_id} = #1{category_id}) type=differential Get l5 diff --git a/test/sqllogictest/github-16036.slt b/test/sqllogictest/github-16036.slt index 2178b9c65b3c5..3ad8d144e1847 100644 --- a/test/sqllogictest/github-16036.slt +++ b/test/sqllogictest/github-16036.slt @@ -40,63 +40,63 @@ Explained Query: delta_stage[1] closure project=(#1..=#3) - lookup={ relation=2, key=[#1] } - stream={ key=[#1], thinning=(#0, #2) } + lookup={ relation=2, key=[#1{k2}] } + stream={ key=[#1{k2}], thinning=(#0, #2) } delta_stage[0] closure project=(#1..=#3) - lookup={ relation=1, key=[#1] } - stream={ key=[#1], thinning=(#0, #2) } + lookup={ relation=1, key=[#1{k1}] } + stream={ key=[#1{k1}], thinning=(#0, #2) } initial_closure project=(#1, #0, #2) - source={ relation=0, key=[#1] } + source={ relation=0, key=[#1{k1}] } plan_path[1] delta_stage[1] closure project=(#1..=#3) - lookup={ relation=2, key=[#1] } - stream={ key=[#1], thinning=(#0, #2) } + lookup={ relation=2, key=[#1{k2}] } + stream={ key=[#1{k2}], thinning=(#0, #2) } delta_stage[0] closure project=(#2, #3, #1) - lookup={ relation=0, key=[#1] } - stream={ key=[#1], thinning=(#0) } + lookup={ relation=0, key=[#1{k1}] } + stream={ key=[#1{k1}], thinning=(#0) } initial_closure project=(#1, #0) - source={ relation=1, key=[#1] } + source={ relation=1, key=[#1{k1}] } plan_path[2] delta_stage[1] closure project=(#1, #3, #2) - lookup={ relation=1, key=[#1] } - stream={ key=[#1], thinning=(#0, #2) } + lookup={ relation=1, key=[#1{k1}] } + stream={ key=[#1{k1}], thinning=(#0, #2) } delta_stage[0] closure project=(#2, #3, #1) - lookup={ relation=0, key=[#2] } - stream={ key=[#1], thinning=(#0) } + lookup={ relation=0, key=[#2{k2}] } + stream={ key=[#1{k2}], thinning=(#0) } initial_closure project=(#1, #0) - source={ relation=2, key=[#1] } + source={ relation=2, key=[#1{k2}] } ArrangeBy raw=true - arrangements[0]={ key=[#1], permutation={#0: #1, #1: #0}, thinning=(#0, #2) } - arrangements[1]={ key=[#2], permutation={#0: #1, #1: #2, #2: #0}, thinning=(#0, #1) } + arrangements[0]={ key=[#1{k1}], permutation={#0: #1, #1: #0}, thinning=(#0, #2) } + arrangements[1]={ key=[#2{k2}], permutation={#0: #1, #1: #2, #2: #0}, thinning=(#0, #1) } types=[text?, integer, integer] Get::Arrangement materialize.public.t1 project=(#1, #0, #2) - filter=((#0) IS NOT NULL AND (#2) IS NOT NULL) - key=#1 + filter=((#0{k1}) IS NOT NULL AND (#2{k2}) IS NOT NULL) + key=#1{k1} raw=false - arrangements[0]={ key=[#1], permutation={#0: #1, #1: #0}, thinning=(#0, #2) } + arrangements[0]={ key=[#1{k1}], permutation={#0: #1, #1: #0}, thinning=(#0, #2) } types=[text?, integer?, integer?] Get::PassArrangements materialize.public.t2 raw=false - arrangements[0]={ key=[#1], permutation={#0: #1, #1: #0}, thinning=(#0) } + arrangements[0]={ key=[#1{k1}], permutation={#0: #1, #1: #0}, thinning=(#0) } types=[text?, integer?] Get::PassArrangements materialize.public.t3 raw=false - arrangements[0]={ key=[#1], permutation={#0: #1, #1: #0}, thinning=(#0) } + arrangements[0]={ key=[#1{k2}], permutation={#0: #1, #1: #0}, thinning=(#0) } types=[text?, integer?] Used Indexes: diff --git a/test/sqllogictest/github-2746.slt b/test/sqllogictest/github-2746.slt index 330019e7d21e8..11e59a3b37d46 100644 --- a/test/sqllogictest/github-2746.slt +++ b/test/sqllogictest/github-2746.slt @@ -106,7 +106,7 @@ Explained Query: delta_stage[1] closure project=(#0) - filter=(((#2 = 1997-07-06) OR (date_to_timestamp(#1) = (#3 - 7 days)))) + filter=(((#2{l_receiptdate} = 1997-07-06) OR (date_to_timestamp(#1{l_commitdate}) = (#3{o_orderdate} - 7 days)))) lookup={ relation=2, key=[#0] } stream={ key=[#2], thinning=(#0, #1) } delta_stage[0] @@ -117,7 +117,7 @@ Explained Query: delta_stage[1] closure project=(#0) - filter=(((#3 = 1997-07-06) OR (date_to_timestamp(#2) = (#1 - 7 days)))) + filter=(((#3{l_receiptdate} = 1997-07-06) OR (date_to_timestamp(#2{l_commitdate}) = (#1{o_orderdate} - 7 days)))) lookup={ relation=0, key=[] } stream={ key=[], thinning=(#0, #1) } delta_stage[0] @@ -128,7 +128,7 @@ Explained Query: delta_stage[1] closure project=(#0) - filter=(((#3 = 1997-07-06) OR (date_to_timestamp(#2) = (#1 - 7 days)))) + filter=(((#3{l_receiptdate} = 1997-07-06) OR (date_to_timestamp(#2{l_commitdate}) = (#1{o_orderdate} - 7 days)))) lookup={ relation=0, key=[] } stream={ key=[], thinning=(#0, #1) } delta_stage[0] diff --git a/test/sqllogictest/github-2969.slt b/test/sqllogictest/github-2969.slt index 95cef3da12dad..7c2aca0816fe8 100644 --- a/test/sqllogictest/github-2969.slt +++ b/test/sqllogictest/github-2969.slt @@ -80,7 +80,7 @@ Explained Query: Project (#0{f4}..=#2{f6}) // { arity: 3 } Join on=(#1{f5} = #3{f5}) type=differential // { arity: 4 } implementation - %0:table_f4_f5_f6[#1]Kf » %1:table_f5_f6[#0]Kf + %0:table_f4_f5_f6[#1]Kf » %1:table_f5_f6[#0{f5}]Kf ArrangeBy keys=[[#1{f5}]] // { arity: 3 } Filter (#1{f5} = #2{f6}) // { arity: 3 } ReadStorage materialize.public.table_f4_f5_f6 // { arity: 3 } diff --git a/test/sqllogictest/github-5126.slt b/test/sqllogictest/github-5126.slt index 23b9ae2caebf6..4fd320b24ef0e 100644 --- a/test/sqllogictest/github-5126.slt +++ b/test/sqllogictest/github-5126.slt @@ -79,9 +79,9 @@ Return // { arity: 3 } Join on=(#1 = #3) // { arity: 7 } Get l0 // { arity: 3 } Project (#0, #3..=#5) // { arity: 4 } - Map ((#3 * 2)) // { arity: 6 } + Map ((#3{?column?} * 2)) // { arity: 6 } Project (#0..=#2, #7, #8) // { arity: 5 } - Map ((#0 * #1), #6) // { arity: 9 } + Map ((#0{f2} * #1{f2}), #6) // { arity: 9 } Join on=(#0 = #3 AND #1 = #4 AND #2 = #5) // { arity: 7 } Get l1 // { arity: 3 } Union // { arity: 4 } diff --git a/test/sqllogictest/github-6464.slt b/test/sqllogictest/github-6464.slt index 0bad480b5c613..b5411edfb6000 100644 --- a/test/sqllogictest/github-6464.slt +++ b/test/sqllogictest/github-6464.slt @@ -38,8 +38,8 @@ EXPLAIN RAW PLAN FOR ---- Finish order_by=[#1 asc nulls_last, #0 asc nulls_last] limit=2 output=[#0..=#2] TopK group_by=[#1] order_by=[#0 asc nulls_last] limit=1 exp_group_size=1000 - Reduce group_by=[#4, #5] aggregates=[max(#2)] exp_group_size=1000 - Map (#0, #1) + Reduce group_by=[#4, #5] aggregates=[max(#2{course_id})] exp_group_size=1000 + Map (#0{id}, #1{teacher_id}) Get materialize.public.sections Target cluster: quickstart diff --git a/test/sqllogictest/joins.slt b/test/sqllogictest/joins.slt index 1a0ef778a5464..113fc07b05405 100644 --- a/test/sqllogictest/joins.slt +++ b/test/sqllogictest/joins.slt @@ -127,9 +127,9 @@ Explained Query: Project (#0{la}, #2{lb}, #4{lb}) // { arity: 3 } Join on=(#1{la} = (#0{la} + 1) AND #3{la} = (#0{la} + #1{la})) type=delta // { arity: 5 } implementation - %0:l0 » %1:l1[#0]K » %2:l1[#0]K - %1:l1 » %0:l0[(#0 + 1)]K » %2:l1[#0]K - %2:l1 » %0:l0[×] » %1:l1[#0]K + %0:l0 » %1:l1[#0{la}]K » %2:l1[#0{la}]K + %1:l1 » %0:l0[(#0{la} + 1)]K » %2:l1[#0{la}]K + %2:l1 » %0:l0[×] » %1:l1[#0{la}]K ArrangeBy keys=[[], [(#0{la} + 1)]] // { arity: 1 } Project (#0{la}) // { arity: 1 } Get l0 // { arity: 2 } @@ -338,7 +338,7 @@ Explained Query: Project (#0{la}, #1{lb}, #3{rb}) // { arity: 3 } Join on=(#0{la} = #2{ra}) type=differential // { arity: 4 } implementation - %0:l0[#0]K » %1:r[#0]K + %0:l0[#0{la}]K » %1:r[#0{ra}]K Get l0 // { arity: 2 } ArrangeBy keys=[[#0{ra}]] // { arity: 2 } Filter (#0{ra}) IS NOT NULL // { arity: 2 } @@ -351,7 +351,7 @@ Explained Query: Project (#0{la}, #1{lb}) // { arity: 2 } Join on=(#0{la} = #2{la}) type=differential // { arity: 3 } implementation - %1[#0]UKA » %0:l0[#0]K + %1[#0]UKA » %0:l0[#0{la}]K Get l0 // { arity: 2 } ArrangeBy keys=[[#0{la}]] // { arity: 1 } Distinct project=[#0{la}] // { arity: 1 } @@ -383,7 +383,7 @@ Explained Query: Project (#0{la}, #1{lb}, #3{rb}) // { arity: 3 } Join on=(#0{la} = #2{ra}) type=differential // { arity: 4 } implementation - %0:l[#0]K » %1:l0[#0]K + %0:l[#0{la}]K » %1:l0[#0{ra}]K ArrangeBy keys=[[#0{la}]] // { arity: 2 } Filter (#0{la}) IS NOT NULL // { arity: 2 } ReadStorage materialize.public.l // { arity: 2 } @@ -397,7 +397,7 @@ Explained Query: Project (#0{ra}, #1{rb}) // { arity: 2 } Join on=(#0{ra} = #2{la}) type=differential // { arity: 3 } implementation - %1[#0]UKA » %0:l0[#0]K + %1[#0]UKA » %0:l0[#0{ra}]K Get l0 // { arity: 2 } ArrangeBy keys=[[#0{la}]] // { arity: 1 } Distinct project=[#0{la}] // { arity: 1 } @@ -433,7 +433,7 @@ Explained Query: Project (#0{la}, #1{lb}, #3{rb}) // { arity: 3 } Join on=(#0{la} = #2{ra}) type=differential // { arity: 4 } implementation - %0:l0[#0]K » %1:l1[#0]K + %0:l0[#0{la}]K » %1:l1[#0{ra}]K Get l0 // { arity: 2 } Get l1 // { arity: 2 } cte l3 = @@ -450,7 +450,7 @@ Explained Query: Project (#0{ra}, #1{rb}) // { arity: 2 } Join on=(#0{ra} = #2{la}) type=differential // { arity: 3 } implementation - %1:l3[#0]UKA » %0:l1[#0]K + %1:l3[#0]UKA » %0:l1[#0{ra}]K Get l1 // { arity: 2 } Get l3 // { arity: 1 } ReadStorage materialize.public.r // { arity: 2 } @@ -460,7 +460,7 @@ Explained Query: Project (#0{la}, #1{lb}) // { arity: 2 } Join on=(#0{la} = #2{la}) type=differential // { arity: 3 } implementation - %1:l3[#0]UKA » %0:l0[#0]K + %1:l3[#0]UKA » %0:l0[#0{la}]K Get l0 // { arity: 2 } Get l3 // { arity: 1 } ReadStorage materialize.public.l // { arity: 2 } @@ -491,7 +491,7 @@ EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) Explained Query: Join on=((#0{la} % 2) = (#2{ra} % 2)) type=differential // { arity: 4 } implementation - %0:l[(#0 % 2)]K » %1:r[(#0 % 2)]K + %0:l[(#0{la} % 2)]K » %1:r[(#0{ra} % 2)]K ArrangeBy keys=[[(#0{la} % 2)]] // { arity: 2 } Filter (#0{la}) IS NOT NULL // { arity: 2 } ReadStorage materialize.public.l // { arity: 2 } @@ -556,7 +556,7 @@ Explained Query: Project (#0{name}, #1{id}) // { arity: 2 } Join on=(#0{name} = #2{name}) type=differential // { arity: 3 } implementation - %0:t4362[#0]K » %1[#0]K + %0:t4362[#0{name}]K » %1[#0]K ArrangeBy keys=[[#0{name}]] // { arity: 2 } ReadStorage materialize.public.t4362 // { arity: 2 } ArrangeBy keys=[[#0{name}]] // { arity: 1 } @@ -594,7 +594,7 @@ query T multiline EXPLAIN RAW PLAN FOR SELECT la, l.lb, big_l.lb FROM l JOIN big_l USING (la) ---- Project (#0, #1, #3) - InnerJoin (integer_to_bigint(#0) = #2) + InnerJoin (integer_to_bigint(#0{la}) = #2{la}) Get materialize.public.l Get materialize.public.big_l @@ -628,7 +628,7 @@ Explained Query: Project (#1{lb}, #3{rb}) // { arity: 2 } Join on=(#0{la} = #2{ra}) type=differential // { arity: 4 } implementation - %0:l3[#0]K » %1:r3[#0]K + %0:l3[#0{la}]K » %1:r3[#0{ra}]K ArrangeBy keys=[[#0{la}]] // { arity: 2 } Filter (#0{la}) IS NOT NULL // { arity: 2 } ReadStorage materialize.public.l3 // { arity: 2 } @@ -658,7 +658,7 @@ Explained Query: Project (#1{lb}, #3{rb}) // { arity: 2 } Join on=(#0{la} = #2{ra}) type=differential // { arity: 4 } implementation - %0:l3[#0]K » %1:r3[#0]K + %0:l3[#0{la}]K » %1:r3[#0{ra}]K ArrangeBy keys=[[#0{la}]] // { arity: 2 } ReadStorage materialize.public.l3 // { arity: 2 } ArrangeBy keys=[[#0{ra}]] // { arity: 2 } @@ -685,7 +685,7 @@ Explained Query: Project (#1{lb}, #3{rb}) // { arity: 2 } Join on=(#0{la} = #2{ra}) type=differential // { arity: 4 } implementation - %0:l3[#0]K » %1:r3[#0]K + %0:l3[#0{la}]K » %1:r3[#0{ra}]K ArrangeBy keys=[[#0{la}]] // { arity: 2 } ReadStorage materialize.public.l3 // { arity: 2 } ArrangeBy keys=[[#0{ra}]] // { arity: 2 } diff --git a/test/sqllogictest/jsonb.slt b/test/sqllogictest/jsonb.slt index 3fa7e15146627..29877de2909c6 100644 --- a/test/sqllogictest/jsonb.slt +++ b/test/sqllogictest/jsonb.slt @@ -2158,7 +2158,7 @@ FROM t3; ---- Explained Query: Project (#3) - Map (case when (#0 = 1) then jsonbable_to_jsonb(integer_to_numeric(#0)) else case when (#0 = 2) then jsonbable_to_jsonb(#1) else case when (#0 = 3) then jsonbable_to_jsonb(#2) else jsonbable_to_jsonb(integer_to_numeric((#0 + #0))) end end end) + Map (case when (#0{x} = 1) then jsonbable_to_jsonb(integer_to_numeric(#0{x})) else case when (#0{x} = 2) then jsonbable_to_jsonb(#1{y}) else case when (#0{x} = 3) then jsonbable_to_jsonb(#2{z}) else jsonbable_to_jsonb(integer_to_numeric((#0{x} + #0{x}))) end end end) ReadStorage materialize.public.t3 Source materialize.public.t3 @@ -2181,7 +2181,7 @@ FROM t3; ---- Explained Query: Project (#3) - Map (jsonbable_to_jsonb(integer_to_numeric(case when (#0 = 1) then (1 * #0) else case when (#0 = 2) then (2 * #0) else case when (#0 = 3) then (3 * #0) else (#0 + #0) end end end))) + Map (jsonbable_to_jsonb(integer_to_numeric(case when (#0{x} = 1) then (1 * #0{x}) else case when (#0{x} = 2) then (2 * #0{x}) else case when (#0{x} = 3) then (3 * #0{x}) else (#0{x} + #0{x}) end end end))) ReadStorage materialize.public.t3 Source materialize.public.t3 diff --git a/test/sqllogictest/ldbc_bi.slt b/test/sqllogictest/ldbc_bi.slt index ae987ef141b37..54d970a0ff65f 100644 --- a/test/sqllogictest/ldbc_bi.slt +++ b/test/sqllogictest/ldbc_bi.slt @@ -449,7 +449,7 @@ Explained Query: ReadIndex on=message message_messageid=[*** full scan ***] // { arity: 13 } Return // { arity: 7 } Project (#0..=#2, #4{count}, #7, #5{sum}, #8) // { arity: 7 } - Map ((#5{sum} / bigint_to_numeric(case when (#6{count} = 0) then null else #6{count} end)), (bigint_to_numeric(#4{count}) / #3)) // { arity: 9 } + Map ((#5{sum} / bigint_to_numeric(case when (#6{count} = 0) then null else #6{count} end)), (bigint_to_numeric(#4{count}) / #3{cnt})) // { arity: 9 } Reduce group_by=[#1..=#4] aggregates=[count(*), sum(integer_to_bigint(#0{length})), count(integer_to_bigint(#0{length}))] // { arity: 7 } CrossJoin type=differential // { arity: 5 } implementation @@ -523,7 +523,7 @@ Explained Query: Project (#5{id}, #6{name}) // { arity: 2 } Join on=(#0{id} = #8{typetagclassid}) type=differential // { arity: 9 } implementation - %0:tagclass[#0]KAe » %1:tag[#3]KAe + %0:tagclass[#0{id}]KAe » %1:tag[#3{typetagclassid}]KAe ArrangeBy keys=[[#0{id}]] // { arity: 5 } ReadIndex on=materialize.public.tagclass tagclass_name=[lookup value=("ChristianBishop")] // { arity: 5 } ArrangeBy keys=[[#3{typetagclassid}]] // { arity: 4 } @@ -535,7 +535,7 @@ Explained Query: Project (#1{name}, #3{count}, #4{count}) // { arity: 3 } Join on=(#0{id} = #2{id}) type=differential // { arity: 5 } implementation - %1[#0]UKA » %0:l1[#0]K + %1[#0]UKA » %0:l1[#0{id}]K ArrangeBy keys=[[#0{id}]] // { arity: 2 } Get l1 // { arity: 2 } ArrangeBy keys=[[#0{id}]] // { arity: 3 } @@ -544,9 +544,9 @@ Explained Query: Filter (#4{creationdate} < 2010-12-25 00:00:00 UTC) AND (#4{creationdate} >= 2010-06-08 00:00:00 UTC) // { arity: 17 } Join on=(#0{id} = #3{tagid} AND #2{messageid} = #5{messageid}) type=delta // { arity: 17 } implementation - %0:l1 » %1:message_hastag_tag[#2]KA » %2:message[#1]KAiif - %1:message_hastag_tag » %2:message[#1]KAiif » %0:l1[#0]K - %2:message » %1:message_hastag_tag[#1]KA » %0:l1[#0]K + %0:l1 » %1:message_hastag_tag[#2{tagid}]KA » %2:message[#1{messageid}]KAiif + %1:message_hastag_tag » %2:message[#1{messageid}]KAiif » %0:l1[#0{id}]K + %2:message » %1:message_hastag_tag[#1{messageid}]KA » %0:l1[#0{id}]K ArrangeBy keys=[[#0{id}]] // { arity: 1 } Project (#0{id}) // { arity: 1 } Get l1 // { arity: 2 } @@ -556,7 +556,7 @@ Explained Query: ReadIndex on=message message_messageid=[delta join lookup] // { arity: 13 } Return // { arity: 4 } Project (#0{name}, #3..=#5) // { arity: 4 } - Map (coalesce(#1{count}, 0), coalesce(#2{count}, 0), abs((#3 - #4))) // { arity: 6 } + Map (coalesce(#1{count}, 0), coalesce(#2{count}, 0), abs((#3{?column?} - #4{?column?}))) // { arity: 6 } Union // { arity: 3 } Map (null, null) // { arity: 3 } Union // { arity: 1 } @@ -621,12 +621,12 @@ Explained Query: Filter (#33{name} = "China") AND (#16{moderatorpersonid}) IS NOT NULL AND (#31{partofcountryid}) IS NOT NULL // { arity: 37 } Join on=(#1{messageid} = #36{messageid} AND #10{containerforumid} = #14{id} AND #16{moderatorpersonid} = #18{id} AND #25{locationcityid} = #28{id} AND #31{partofcountryid} = #32{id}) type=delta // { arity: 37 } implementation - %0:message » %5[#0]UKA » %1:forum[#1]KA » %2:person[#1]KA » %3:city[#0]KA » %4:country[#0]KAef - %1:forum » %0:message[#10]KA » %5[#0]UKA » %2:person[#1]KA » %3:city[#0]KA » %4:country[#0]KAef - %2:person » %1:forum[#3]KA » %0:message[#10]KA » %5[#0]UKA » %3:city[#0]KA » %4:country[#0]KAef - %3:city » %4:country[#0]KAef » %2:person[#8]KA » %1:forum[#3]KA » %0:message[#10]KA » %5[#0]UKA - %4:country » %3:city[#3]KA » %2:person[#8]KA » %1:forum[#3]KA » %0:message[#10]KA » %5[#0]UKA - %5 » %0:message[#1]KA » %1:forum[#1]KA » %2:person[#1]KA » %3:city[#0]KA » %4:country[#0]KAef + %0:message » %5[#0]UKA » %1:forum[#1{id}]KA » %2:person[#1{id}]KA » %3:city[#0{id}]KA » %4:country[#0{id}]KAef + %1:forum » %0:message[#10{containerforumid}]KA » %5[#0]UKA » %2:person[#1{id}]KA » %3:city[#0{id}]KA » %4:country[#0{id}]KAef + %2:person » %1:forum[#3{moderatorpersonid}]KA » %0:message[#10{containerforumid}]KA » %5[#0]UKA » %3:city[#0{id}]KA » %4:country[#0{id}]KAef + %3:city » %4:country[#0{id}]KAef » %2:person[#8{locationcityid}]KA » %1:forum[#3{moderatorpersonid}]KA » %0:message[#10{containerforumid}]KA » %5[#0]UKA + %4:country » %3:city[#3{partofcountryid}]KA » %2:person[#8{locationcityid}]KA » %1:forum[#3{moderatorpersonid}]KA » %0:message[#10{containerforumid}]KA » %5[#0]UKA + %5 » %0:message[#1{messageid}]KA » %1:forum[#1{id}]KA » %2:person[#1{id}]KA » %3:city[#0{id}]KA » %4:country[#0{id}]KAef ArrangeBy keys=[[#1{messageid}], [#10{containerforumid}]] // { arity: 13 } ReadIndex on=message message_messageid=[delta join 1st input (full scan)] message_containerforumid=[delta join lookup] // { arity: 13 } ArrangeBy keys=[[#1{id}], [#3{moderatorpersonid}]] // { arity: 4 } @@ -642,9 +642,9 @@ Explained Query: Project (#10{messageid}) // { arity: 1 } Join on=(#0{id} = #8{typetagclassid} AND #5{id} = #11{tagid}) type=delta // { arity: 12 } implementation - %0:tagclass » %1:tag[#3]KA » %2:message_hastag_tag[#2]KA - %1:tag » %0:tagclass[#0]KAe » %2:message_hastag_tag[#2]KA - %2:message_hastag_tag » %1:tag[#0]KA » %0:tagclass[#0]KAe + %0:tagclass » %1:tag[#3{typetagclassid}]KA » %2:message_hastag_tag[#2{tagid}]KA + %1:tag » %0:tagclass[#0{id}]KAe » %2:message_hastag_tag[#2{tagid}]KA + %2:message_hastag_tag » %1:tag[#0{id}]KA » %0:tagclass[#0{id}]KAe ArrangeBy keys=[[#0{id}]] // { arity: 5 } ReadIndex on=materialize.public.tagclass tagclass_name=[lookup value=("Philosopher")] // { arity: 5 } ArrangeBy keys=[[#0{id}], [#3{typetagclassid}]] // { arity: 4 } @@ -753,7 +753,7 @@ Explained Query: Project (#0{creationdate}..=#3{lastname}) // { arity: 4 } Join on=(#1{id} = #11{personid}) type=differential // { arity: 12 } implementation - %1[#0]UKA » %0:person[#1]KA + %1[#0]UKA » %0:person[#1{id}]KA ArrangeBy keys=[[#1{id}]] // { arity: 11 } ReadIndex on=person person_id=[differential join] // { arity: 11 } ArrangeBy keys=[[#0{personid}]] // { arity: 1 } @@ -761,7 +761,7 @@ Explained Query: Project (#3{personid}) // { arity: 1 } Join on=(#0{id} = #2{forumid}) type=differential // { arity: 4 } implementation - %1:forum_hasmember_person[#1]KA » %0:l0[#0]K + %1:forum_hasmember_person[#1{forumid}]KA » %0:l0[#0{id}]K ArrangeBy keys=[[#0{id}]] // { arity: 1 } Get l0 // { arity: 1 } ArrangeBy keys=[[#1{forumid}]] // { arity: 3 } @@ -773,9 +773,9 @@ Explained Query: Project (#0{creationdate}..=#3{lastname}, #5{messageid}) // { arity: 5 } Join on=(#1{id} = #13{creatorpersonid} AND #14{containerforumid} = #17{id}) type=delta // { arity: 18 } implementation - %0:l2 » %1:message[#9]KA » %2[#0]UKA - %1:message » %2[#0]UKA » %0:l2[#1]K - %2 » %1:message[#10]KA » %0:l2[#1]K + %0:l2 » %1:message[#9{creatorpersonid}]KA » %2[#0]UKA + %1:message » %2[#0]UKA » %0:l2[#1{id}]K + %2 » %1:message[#10{containerforumid}]KA » %0:l2[#1{id}]K Get l2 // { arity: 4 } ArrangeBy keys=[[#9{creatorpersonid}], [#10{containerforumid}]] // { arity: 13 } ReadIndex on=message message_containerforumid=[delta join lookup] message_creatorpersonid=[delta join lookup] // { arity: 13 } @@ -791,7 +791,7 @@ Explained Query: Project (#0{creationdate}..=#3{lastname}) // { arity: 4 } Join on=(#1{id} = #4{id}) type=differential // { arity: 5 } implementation - %1[#0]UKA » %0:l2[#1]K + %1[#0]UKA » %0:l2[#1{id}]K Get l2 // { arity: 4 } ArrangeBy keys=[[#0{id}]] // { arity: 1 } Distinct project=[#0{id}] // { arity: 1 } @@ -850,9 +850,9 @@ Explained Query: Project (#1{name}, #5{messageid}, #16{creatorpersonid}) // { arity: 3 } Join on=(#0{id} = #6{tagid} AND #5{messageid} = #8{messageid}) type=delta // { arity: 20 } implementation - %0:tag » %1:message_hastag_tag[#2]KA » %2:message[#1]KA - %1:message_hastag_tag » %0:tag[#0]KA » %2:message[#1]KA - %2:message » %1:message_hastag_tag[#1]KA » %0:tag[#0]KA + %0:tag » %1:message_hastag_tag[#2{tagid}]KA » %2:message[#1{messageid}]KA + %1:message_hastag_tag » %0:tag[#0{id}]KA » %2:message[#1{messageid}]KA + %2:message » %1:message_hastag_tag[#1{messageid}]KA » %0:tag[#0{id}]KA ArrangeBy keys=[[#0{id}]] // { arity: 4 } ReadIndex on=tag tag_id=[delta join 1st input (full scan)] // { arity: 4 } ArrangeBy keys=[[#1{messageid}], [#2{tagid}]] // { arity: 3 } @@ -977,9 +977,9 @@ Explained Query: Project (#6{messageid}, #17{creatorpersonid}) // { arity: 2 } Join on=(#0{id} = #7{tagid} AND #6{messageid} = #9{messageid}) type=delta // { arity: 21 } implementation - %0:tag » %1:message_hastag_tag[#2]KA » %2:message[#1]KA - %1:message_hastag_tag » %0:tag[#0]KAe » %2:message[#1]KA - %2:message » %1:message_hastag_tag[#1]KA » %0:tag[#0]KAe + %0:tag » %1:message_hastag_tag[#2{tagid}]KA » %2:message[#1{messageid}]KA + %1:message_hastag_tag » %0:tag[#0{id}]KAe » %2:message[#1{messageid}]KA + %2:message » %1:message_hastag_tag[#1{messageid}]KA » %0:tag[#0{id}]KAe ArrangeBy keys=[[#0{id}]] // { arity: 5 } ReadIndex on=materialize.public.tag tag_name=[lookup value=("Bob_Geldof")] // { arity: 5 } ArrangeBy keys=[[#1{messageid}], [#2{tagid}]] // { arity: 3 } @@ -993,7 +993,7 @@ Explained Query: Project (#0{messageid}, #1{creatorpersonid}, #3{personid}) // { arity: 3 } Join on=(#0{messageid} = #4{messageid}) type=differential // { arity: 5 } implementation - %1:person_likes_message[#2]KA » %0:l1[#0]K + %1:person_likes_message[#2{messageid}]KA » %0:l1[#0{messageid}]K Get l1 // { arity: 2 } ArrangeBy keys=[[#2{messageid}]] // { arity: 3 } ReadIndex on=person_likes_message person_likes_message_messageid=[differential join] // { arity: 3 } @@ -1006,7 +1006,7 @@ Explained Query: Project (#1{creatorpersonid}) // { arity: 1 } Join on=(#0{messageid} = #2{messageid}) type=differential // { arity: 3 } implementation - %1[#0]UKA » %0:l1[#0]K + %1[#0]UKA » %0:l1[#0{messageid}]K Get l1 // { arity: 2 } ArrangeBy keys=[[#0{messageid}]] // { arity: 1 } Distinct project=[#0{messageid}] // { arity: 1 } @@ -1020,7 +1020,7 @@ Explained Query: Project (#0{creatorpersonid}, #3{popularityscore}) // { arity: 2 } Join on=(#1{personid} = #2{person2id}) type=differential // { arity: 4 } implementation - %1:popularityscoreq06[#0]UKA » %0:l3[#1]K + %1:popularityscoreq06[#0]UKA » %0:l3[#1{person2id}]K ArrangeBy keys=[[#1{personid}]] // { arity: 2 } Filter (#1{personid}) IS NOT NULL // { arity: 2 } Get l3 // { arity: 2 } @@ -1083,9 +1083,9 @@ Explained Query: Project (#6{messageid}, #17{creatorpersonid}) // { arity: 2 } Join on=(#0{id} = #7{tagid} AND #6{messageid} = #9{messageid}) type=delta // { arity: 21 } implementation - %0:tag » %1:message_hastag_tag[#2]KA » %2:message[#1]KA - %1:message_hastag_tag » %0:tag[#0]KAe » %2:message[#1]KA - %2:message » %1:message_hastag_tag[#1]KA » %0:tag[#0]KAe + %0:tag » %1:message_hastag_tag[#2{tagid}]KA » %2:message[#1{messageid}]KA + %1:message_hastag_tag » %0:tag[#0{id}]KAe » %2:message[#1{messageid}]KA + %2:message » %1:message_hastag_tag[#1{messageid}]KA » %0:tag[#0{id}]KAe ArrangeBy keys=[[#0{id}]] // { arity: 5 } ReadIndex on=materialize.public.tag tag_name=[lookup value=("Bob_Geldof")] // { arity: 5 } ArrangeBy keys=[[#1{messageid}], [#2{tagid}]] // { arity: 3 } @@ -1099,7 +1099,7 @@ Explained Query: Project (#0{messageid}, #1{creatorpersonid}, #3{personid}) // { arity: 3 } Join on=(#0{messageid} = #4{messageid}) type=differential // { arity: 5 } implementation - %1:person_likes_message[#2]KA » %0:l1[#0]K + %1:person_likes_message[#2{messageid}]KA » %0:l1[#0{messageid}]K Get l1 // { arity: 2 } ArrangeBy keys=[[#2{messageid}]] // { arity: 3 } ReadIndex on=person_likes_message person_likes_message_messageid=[differential join] // { arity: 3 } @@ -1112,7 +1112,7 @@ Explained Query: Project (#1{creatorpersonid}) // { arity: 1 } Join on=(#0{messageid} = #2{messageid}) type=differential // { arity: 3 } implementation - %1[#0]UKA » %0:l1[#0]K + %1[#0]UKA » %0:l1[#0{messageid}]K Get l1 // { arity: 2 } ArrangeBy keys=[[#0{messageid}]] // { arity: 1 } Distinct project=[#0{messageid}] // { arity: 1 } @@ -1126,7 +1126,7 @@ Explained Query: Project (#0{creatorpersonid}, #3{popularityscore}) // { arity: 2 } Join on=(#1{personid} = #2{person2id}) type=differential // { arity: 4 } implementation - %1:popularityscoreq06[#0]UKA » %0:l3[#1]K + %1:popularityscoreq06[#0]UKA » %0:l3[#1{person2id}]K ArrangeBy keys=[[#1{personid}]] // { arity: 2 } Filter (#1{personid}) IS NOT NULL // { arity: 2 } Get l3 // { arity: 2 } @@ -1190,9 +1190,9 @@ Explained Query: Project (#1{name}, #5{messageid}, #16{creatorpersonid}) // { arity: 3 } Join on=(#0{id} = #6{tagid} AND #5{messageid} = #8{messageid}) type=delta // { arity: 20 } implementation - %0:tag » %1:message_hastag_tag[#2]KA » %2:message[#1]KA - %1:message_hastag_tag » %0:tag[#0]KA » %2:message[#1]KA - %2:message » %1:message_hastag_tag[#1]KA » %0:tag[#0]KA + %0:tag » %1:message_hastag_tag[#2{tagid}]KA » %2:message[#1{messageid}]KA + %1:message_hastag_tag » %0:tag[#0{id}]KA » %2:message[#1{messageid}]KA + %2:message » %1:message_hastag_tag[#1{messageid}]KA » %0:tag[#0{id}]KA ArrangeBy keys=[[#0{id}]] // { arity: 4 } ReadIndex on=tag tag_id=[delta join 1st input (full scan)] // { arity: 4 } ArrangeBy keys=[[#1{messageid}], [#2{tagid}]] // { arity: 3 } @@ -1203,7 +1203,7 @@ Explained Query: Project (#0{name}..=#2{creatorpersonid}, #4{personid}) // { arity: 4 } Join on=(#1{messageid} = #5{messageid}) type=differential // { arity: 6 } implementation - %1:person_likes_message[#2]KA » %0:l0[#1]K + %1:person_likes_message[#2{messageid}]KA » %0:l0[#1{messageid}]K ArrangeBy keys=[[#1{messageid}]] // { arity: 3 } Get l0 // { arity: 3 } ArrangeBy keys=[[#2{messageid}]] // { arity: 3 } @@ -1221,7 +1221,7 @@ Explained Query: Project (#1{creatorpersonid}) // { arity: 1 } Join on=(#0{messageid} = #2{messageid}) type=differential // { arity: 3 } implementation - %1[#0]UKA » %0:l2[#0]Kef + %1[#0]UKA » %0:l2[#0{messageid}]Kef ArrangeBy keys=[[#0{messageid}]] // { arity: 2 } Get l2 // { arity: 2 } ArrangeBy keys=[[#0{messageid}]] // { arity: 1 } @@ -1237,7 +1237,7 @@ Explained Query: Project (#0{creatorpersonid}, #3{popularityscore}) // { arity: 2 } Join on=(#1{personid} = #2{person2id}) type=differential // { arity: 4 } implementation - %1:popularityscoreq06[#0]UKA » %0:l3[#1]K + %1:popularityscoreq06[#0]UKA » %0:l3[#1{person2id}]K ArrangeBy keys=[[#1{personid}]] // { arity: 2 } Filter (#1{personid}) IS NOT NULL // { arity: 2 } Get l3 // { arity: 2 } @@ -1307,7 +1307,7 @@ Explained Query: Project (#1{messageid}) // { arity: 1 } Join on=(#2{tagid} = #3{id}) type=differential // { arity: 8 } implementation - %1:tag[#0]KAe » %0:message_hastag_tag[#2]KAe + %1:tag[#0{id}]KAe » %0:message_hastag_tag[#2{tagid}]KAe ArrangeBy keys=[[#2{tagid}]] // { arity: 3 } ReadIndex on=message_hastag_tag message_hastag_tag_tagid=[differential join] // { arity: 3 } ArrangeBy keys=[[#0{id}]] // { arity: 5 } @@ -1316,10 +1316,10 @@ Explained Query: Project (#2{messageid}, #18{name}) // { arity: 2 } Join on=(#0{messageid} = #13{parentmessageid} AND #2{messageid} = #15{messageid} AND #16{tagid} = #17{id}) type=delta // { arity: 21 } implementation - %0:l0 » %1:message[#12]KA » %2:message_hastag_tag[#1]KA » %3:tag[#0]KA - %1:message » %2:message_hastag_tag[#1]KA » %3:tag[#0]KA » %0:l0[#0]K - %2:message_hastag_tag » %1:message[#1]KA » %3:tag[#0]KA » %0:l0[#0]K - %3:tag » %2:message_hastag_tag[#2]KA » %1:message[#1]KA » %0:l0[#0]K + %0:l0 » %1:message[#12{parentmessageid}]KA » %2:message_hastag_tag[#1{messageid}]KA » %3:tag[#0{id}]KA + %1:message » %2:message_hastag_tag[#1{messageid}]KA » %3:tag[#0{id}]KA » %0:l0[#0{messageid}]K + %2:message_hastag_tag » %1:message[#1{messageid}]KA » %3:tag[#0{id}]KA » %0:l0[#0{messageid}]K + %3:tag » %2:message_hastag_tag[#2{tagid}]KA » %1:message[#1{messageid}]KA » %0:l0[#0{messageid}]K ArrangeBy keys=[[#0{messageid}]] // { arity: 1 } Get l0 // { arity: 1 } ArrangeBy keys=[[#1{messageid}], [#12{parentmessageid}]] // { arity: 13 } @@ -1432,9 +1432,9 @@ Explained Query: Project (#1{id}) // { arity: 1 } Join on=(#1{id} = #11{personid} AND #12{tagid} = #13{id}) type=delta // { arity: 18 } implementation - %0:l0 » %1:person_hasinterest_tag[#0]K » %2:l1[#0]KAe - %1:person_hasinterest_tag » %2:l1[#0]KAe » %0:l0[#1]KA - %2:l1 » %1:person_hasinterest_tag[#1]KA » %0:l0[#1]KA + %0:l0 » %1:person_hasinterest_tag[#0{personid}]K » %2:l1[#0{id}]KAe + %1:person_hasinterest_tag » %2:l1[#0{id}]KAe » %0:l0[#1{id}]KA + %2:l1 » %1:person_hasinterest_tag[#1{tagid}]KA » %0:l0[#1{id}]KA Get l0 // { arity: 11 } ArrangeBy keys=[[#0{personid}], [#1{tagid}]] // { arity: 2 } Project (#1{personid}, #2{tagid}) // { arity: 2 } @@ -1446,10 +1446,10 @@ Explained Query: Filter (#8{creationdate} < 2010-06-28 00:00:00 UTC) AND (2010-06-14 00:00:00 UTC < #8{creationdate}) // { arity: 32 } Join on=(#0{id} = #7{tagid} AND #6{messageid} = #9{messageid} AND #17{creatorpersonid} = #22{id}) type=delta // { arity: 32 } implementation - %0:l1 » %1:message_hastag_tag[#2]KA » %2:message[#1]KAiif » %3:l0[#1]KA - %1:message_hastag_tag » %0:l1[#0]KAe » %2:message[#1]KAiif » %3:l0[#1]KA - %2:message » %1:message_hastag_tag[#1]KA » %0:l1[#0]KAe » %3:l0[#1]KA - %3:l0 » %2:message[#9]KAiif » %1:message_hastag_tag[#1]KA » %0:l1[#0]KAe + %0:l1 » %1:message_hastag_tag[#2{tagid}]KA » %2:message[#1{messageid}]KAiif » %3:l0[#1{id}]KA + %1:message_hastag_tag » %0:l1[#0{id}]KAe » %2:message[#1{messageid}]KAiif » %3:l0[#1{id}]KA + %2:message » %1:message_hastag_tag[#1{messageid}]KA » %0:l1[#0{id}]KAe » %3:l0[#1{id}]KA + %3:l0 » %2:message[#9{creatorpersonid}]KAiif » %1:message_hastag_tag[#1{messageid}]KA » %0:l1[#0{id}]KAe Get l1 // { arity: 5 } ArrangeBy keys=[[#1{messageid}], [#2{tagid}]] // { arity: 3 } ReadIndex on=message_hastag_tag message_hastag_tag_messageid=[delta join lookup] message_hastag_tag_tagid=[delta join lookup] // { arity: 3 } @@ -1463,7 +1463,7 @@ Explained Query: Project (#0{id}, #2{count}) // { arity: 2 } Join on=(#0{id} = #1{creatorpersonid}) type=differential // { arity: 3 } implementation - %1:l4[#0]UKA » %0:l2[#0]K + %1:l4[#0{personid}]UKA » %0:l2[#0{personid}]K ArrangeBy keys=[[#0{id}]] // { arity: 1 } Get l2 // { arity: 1 } Get l4 // { arity: 2 } @@ -1481,7 +1481,7 @@ Explained Query: Project (#0{creatorpersonid}, #1{count}) // { arity: 2 } Join on=(#0{creatorpersonid} = #2{id}) type=differential // { arity: 3 } implementation - %0:l4[#0]UKA » %1[#0]UKA + %0:l4[#0{personid}]UKA » %1[#0]UKA Get l4 // { arity: 2 } ArrangeBy keys=[[#0{id}]] // { arity: 1 } Distinct project=[#0{id}] // { arity: 1 } @@ -1495,7 +1495,7 @@ Explained Query: Project (#0{id}, #0{id}, #1{count}) // { arity: 3 } Get l5 // { arity: 2 } Return // { arity: 5 } - Map (coalesce(#2{sum}, 0), (bigint_to_numeric(#1) + #3)) // { arity: 5 } + Map (coalesce(#2{sum}, 0), (bigint_to_numeric(#1{score}) + #3{?column?})) // { arity: 5 } Reduce group_by=[#0, #1] aggregates=[sum(case when (#3) IS NULL then null else #2 end)] // { arity: 3 } Project (#0, #1, #6, #7) // { arity: 4 } Join on=(#0 = #2{person1id} AND #5{person2id} = case when (#4) IS NULL then null else #3{person2id} end) type=delta // { arity: 8 } @@ -1587,9 +1587,9 @@ Explained Query: Filter (#23{parentmessageid}) IS NULL AND (#11{creationdate} <= 2012-11-24 00:00:00 UTC) AND (#11{creationdate} >= 2012-08-29 00:00:00 UTC) // { arity: 26 } Join on=(#1{id} = #20{creatorpersonid} AND #12{messageid} = #24{rootpostid}) type=delta // { arity: 26 } implementation - %0:person » %1:message[#9]KAniif » %2[#0]UKA - %1:message » %2[#0]UKA » %0:person[#1]KA - %2 » %1:message[#1]KAniif » %0:person[#1]KA + %0:person » %1:message[#9{creatorpersonid}]KAniif » %2[#0]UKA + %1:message » %2[#0]UKA » %0:person[#1{id}]KA + %2 » %1:message[#1{messageid}]KAniif » %0:person[#1{id}]KA ArrangeBy keys=[[#1{id}]] // { arity: 11 } ReadIndex on=person person_id=[delta join 1st input (full scan)] // { arity: 11 } ArrangeBy keys=[[#1{messageid}], [#9{creatorpersonid}]] // { arity: 13 } @@ -1706,7 +1706,7 @@ Explained Query: Project (#6{person2id}) // { arity: 1 } Join on=(#2{person2id} = #5{person1id}) type=differential // { arity: 7 } implementation - %0:l1[#2]KAe » %1:l0[#1]KAe + %0:l1[#2{person2id}]KAe » %1:l0[#1{person1id}]KAe ArrangeBy keys=[[#2{person2id}]] // { arity: 4 } Get l1 // { arity: 4 } Get l0 // { arity: 3 } @@ -1715,12 +1715,12 @@ Explained Query: Project (#0{person2id}, #9{name}) // { arity: 2 } Join on=(#0{person2id} = #1{id} = #2{creatorpersonid} AND #3{messageid} = #4{messageid} = #6{messageid} AND #7{tagid} = #8{id}) type=delta // { arity: 12 } implementation - %0 » %1[#0]UKA » %2[#0]K » %3[#0]UKA » %4:message_hastag_tag[#1]KA » %5:tag[#0]KA - %1 » %0[#0]UKA » %2[#0]K » %3[#0]UKA » %4:message_hastag_tag[#1]KA » %5:tag[#0]KA - %2 » %0[#0]UKA » %1[#0]UKA » %3[#0]UKA » %4:message_hastag_tag[#1]KA » %5:tag[#0]KA - %3 » %4:message_hastag_tag[#1]KA » %5:tag[#0]KA » %2[#1]K » %0[#0]UKA » %1[#0]UKA - %4:message_hastag_tag » %3[#0]UKA » %5:tag[#0]KA » %2[#1]K » %0[#0]UKA » %1[#0]UKA - %5:tag » %4:message_hastag_tag[#2]KA » %3[#0]UKA » %2[#1]K » %0[#0]UKA » %1[#0]UKA + %0 » %1[#0]UKA » %2[#0]K » %3[#0]UKA » %4:message_hastag_tag[#1{messageid}]KA » %5:tag[#0{id}]KA + %1 » %0[#0]UKA » %2[#0]K » %3[#0]UKA » %4:message_hastag_tag[#1{messageid}]KA » %5:tag[#0{id}]KA + %2 » %0[#0]UKA » %1[#0]UKA » %3[#0]UKA » %4:message_hastag_tag[#1{messageid}]KA » %5:tag[#0{id}]KA + %3 » %4:message_hastag_tag[#1{messageid}]KA » %5:tag[#0{id}]KA » %2[#1]K » %0[#0]UKA » %1[#0]UKA + %4:message_hastag_tag » %3[#0]UKA » %5:tag[#0{id}]KA » %2[#1]K » %0[#0]UKA » %1[#0]UKA + %5:tag » %4:message_hastag_tag[#2{tagid}]KA » %3[#0]UKA » %2[#1]K » %0[#0]UKA » %1[#0]UKA ArrangeBy keys=[[#0{person2id}]] // { arity: 1 } Distinct project=[#0{person2id}] // { arity: 1 } Threshold // { arity: 1 } @@ -1729,9 +1729,9 @@ Explained Query: Project (#6{person2id}) // { arity: 1 } Join on=(#0{person2id} = #2{person1id} AND #3{person2id} = #5{person1id}) type=delta // { arity: 7 } implementation - %0:l2 » %1:person_knows_person[#1]KA » %2:l0[#1]KA - %1:person_knows_person » %0:l2[#0]UKA » %2:l0[#1]KA - %2:l0 » %1:person_knows_person[#2]KA » %0:l2[#0]UKA + %0:l2 » %1:person_knows_person[#1{person1id}]KA » %2:l0[#1{person1id}]KA + %1:person_knows_person » %0:l2[#0]UKA » %2:l0[#1{person1id}]KA + %2:l0 » %1:person_knows_person[#2{person2id}]KA » %0:l2[#0]UKA ArrangeBy keys=[[#0{person2id}]] // { arity: 1 } Get l2 // { arity: 1 } ArrangeBy keys=[[#1{person1id}], [#2{person2id}]] // { arity: 3 } @@ -1745,9 +1745,9 @@ Explained Query: Filter (#16{name} = "Italy") AND (#1{id}) IS NOT NULL AND (#14{partofcountryid}) IS NOT NULL // { arity: 19 } Join on=(#8{locationcityid} = #11{id} AND #14{partofcountryid} = #15{id}) type=delta // { arity: 19 } implementation - %0:person » %1:city[#0]KA » %2:country[#0]KAef - %1:city » %2:country[#0]KAef » %0:person[#8]KA - %2:country » %1:city[#3]KA » %0:person[#8]KA + %0:person » %1:city[#0{id}]KA » %2:country[#0{id}]KAef + %1:city » %2:country[#0{id}]KAef » %0:person[#8{locationcityid}]KA + %2:country » %1:city[#3{partofcountryid}]KA » %0:person[#8{locationcityid}]KA ArrangeBy keys=[[#8{locationcityid}]] // { arity: 11 } ReadIndex on=person person_locationcityid=[delta join 1st input (full scan)] // { arity: 11 } ArrangeBy keys=[[#0{id}], [#3{partofcountryid}]] // { arity: 4 } @@ -1763,9 +1763,9 @@ Explained Query: Project (#1{messageid}) // { arity: 1 } Join on=(#2{tagid} = #3{id} AND #6{typetagclassid} = #7{id}) type=delta // { arity: 12 } implementation - %0:message_hastag_tag » %1:tag[#0]KA » %2:tagclass[#0]KAe - %1:tag » %2:tagclass[#0]KAe » %0:message_hastag_tag[#2]KA - %2:tagclass » %1:tag[#3]KA » %0:message_hastag_tag[#2]KA + %0:message_hastag_tag » %1:tag[#0{id}]KA » %2:tagclass[#0{id}]KAe + %1:tag » %2:tagclass[#0{id}]KAe » %0:message_hastag_tag[#2{tagid}]KA + %2:tagclass » %1:tag[#3{typetagclassid}]KA » %0:message_hastag_tag[#2{tagid}]KA ArrangeBy keys=[[#2{tagid}]] // { arity: 3 } ReadIndex on=message_hastag_tag message_hastag_tag_tagid=[delta join 1st input (full scan)] // { arity: 3 } ArrangeBy keys=[[#0{id}], [#3{typetagclassid}]] // { arity: 4 } @@ -1840,10 +1840,10 @@ Explained Query: Filter (#16{name} = "India") AND (#19{creationdate} <= 2013-01-10 00:00:00 UTC) AND (2012-09-28 00:00:00 UTC <= #19{creationdate}) AND (#14{partofcountryid}) IS NOT NULL // { arity: 22 } Join on=(#1{id} = #20{person1id} AND #8{locationcityid} = #11{id} AND #14{partofcountryid} = #15{id}) type=delta // { arity: 22 } implementation - %0:person » %3:person_knows_person[#1]KAiif » %1:city[#0]KA » %2:country[#0]KAef - %1:city » %2:country[#0]KAef » %0:person[#8]KA » %3:person_knows_person[#1]KAiif - %2:country » %1:city[#3]KA » %0:person[#8]KA » %3:person_knows_person[#1]KAiif - %3:person_knows_person » %0:person[#1]KA » %1:city[#0]KA » %2:country[#0]KAef + %0:person » %3:person_knows_person[#1{person1id}]KAiif » %1:city[#0{id}]KA » %2:country[#0{id}]KAef + %1:city » %2:country[#0{id}]KAef » %0:person[#8{locationcityid}]KA » %3:person_knows_person[#1{person1id}]KAiif + %2:country » %1:city[#3{partofcountryid}]KA » %0:person[#8{locationcityid}]KA » %3:person_knows_person[#1{person1id}]KAiif + %3:person_knows_person » %0:person[#1{id}]KA » %1:city[#0{id}]KA » %2:country[#0{id}]KAef ArrangeBy keys=[[#1{id}], [#8{locationcityid}]] // { arity: 11 } ReadIndex on=person person_id=[delta join 1st input (full scan)] person_locationcityid=[delta join lookup] // { arity: 11 } ArrangeBy keys=[[#0{id}], [#3{partofcountryid}]] // { arity: 4 } @@ -1860,7 +1860,7 @@ Explained Query: Project () // { arity: 0 } Join on=(#0{id} = #5{person2id} AND #1{person2id} = #2{id} AND #3{person2id} = #4{id}) type=differential // { arity: 6 } implementation - %0:l1[#1]Kf » %1:l1[#0]Kf » %2:l0[#0, #1]KKf + %0:l1[#1{friendid}]Kf » %1:l1[#0{personid}]Kf » %2:l0[#0{personid}, #1{friendid}]KKf ArrangeBy keys=[[#1{person2id}]] // { arity: 2 } Get l1 // { arity: 2 } ArrangeBy keys=[[#0{id}]] // { arity: 2 } @@ -1937,7 +1937,7 @@ Explained Query: Filter (#19{length} < 120) AND (#11{creationdate} > 2012-06-03 00:00:00 UTC) AND (#15{content}) IS NOT NULL // { arity: 25 } Join on=(#1{id} = #20{creatorpersonid}) type=differential // { arity: 25 } implementation - %1:message[#9]KAeiif » %0:l0[#1]KAeiif + %1:message[#9{creatorpersonid}]KAeiif » %0:l0[#1{id}]KAeiif Get l0 // { arity: 11 } ArrangeBy keys=[[#9{creatorpersonid}]] // { arity: 14 } ReadIndex on=materialize.public.message message_rootpostlanguage=[lookup values=[("es"); ("pt"); ("ta")]] // { arity: 14 } @@ -1952,7 +1952,7 @@ Explained Query: Project (#1{id}) // { arity: 1 } Join on=(#1{id} = #11{id}) type=differential // { arity: 12 } implementation - %1[#0]UKA » %0:l0[#1]KA + %1[#0]UKA » %0:l0[#1{id}]KA Get l0 // { arity: 11 } ArrangeBy keys=[[#0{id}]] // { arity: 1 } Distinct project=[#0{id}] // { arity: 1 } @@ -2018,7 +2018,7 @@ Explained Query: ArrangeBy keys=[[#0{rootpostlanguage}]] // { arity: 1 } Distinct project=[#0{rootpostlanguage}] // { arity: 1 } Project (#0{rootpostlanguage}) // { arity: 1 } - Filter (#0{rootpostlanguage} = varchar_to_text(#1)) // { arity: 2 } + Filter (#0{rootpostlanguage} = varchar_to_text(#1{right_col0_0})) // { arity: 2 } FlatMap unnest_array({"es", "ta", "pt"}) // { arity: 2 } Distinct project=[#0{rootpostlanguage}] // { arity: 1 } Project (#13{rootpostlanguage}) // { arity: 1 } @@ -2102,9 +2102,9 @@ Explained Query: Filter (#1{name} = "India") AND (#8{creationdate} < 2012-11-09 00:00:00 UTC) AND (#0{id}) IS NOT NULL // { arity: 19 } Join on=(#0{id} = #7{partofcountryid} AND #4{id} = #16{locationcityid}) type=delta // { arity: 19 } implementation - %0:country » %1:city[#3]KA » %2:person[#8]KAif - %1:city » %0:country[#0]KAef » %2:person[#8]KAif - %2:person » %1:city[#0]KA » %0:country[#0]KAef + %0:country » %1:city[#3{partofcountryid}]KA » %2:person[#8{locationcityid}]KAif + %1:city » %0:country[#0{id}]KAef » %2:person[#8{locationcityid}]KAif + %2:person » %1:city[#0{id}]KA » %0:country[#0{id}]KAef ArrangeBy keys=[[#0{id}]] // { arity: 4 } ReadIndex on=country country_id=[delta join 1st input (full scan)] // { arity: 4 } ArrangeBy keys=[[#0{id}], [#3{partofcountryid}]] // { arity: 4 } @@ -2116,7 +2116,7 @@ Explained Query: Filter (#16{creationdate} <= 2012-11-09 00:00:00 UTC) AND (#16{creationdate} >= #6{creationdate}) // { arity: 29 } Join on=(#7{id} = #25{creatorpersonid}) type=differential // { arity: 29 } implementation - %1:message[#9]KAif » %0:l0[#7]Kif + %1:message[#9{creatorpersonid}]KAif » %0:l0[#7{id}]Kif ArrangeBy keys=[[#7{id}]] // { arity: 16 } Filter (#7{id}) IS NOT NULL // { arity: 16 } Get l0 // { arity: 16 } @@ -2157,10 +2157,10 @@ Explained Query: Filter (#0{creationdate} < 2012-11-09 00:00:00 UTC) // { arity: 28 } Join on=(#1{id} = #12{personid} AND #13{messageid} = #15{messageid} AND #23{creatorpersonid} = #27{id}) type=delta // { arity: 28 } implementation - %0:person » %1:person_likes_message[#1]KA » %2:message[#1]KA » %3:l4[#0]K - %1:person_likes_message » %0:person[#1]KAif » %2:message[#1]KA » %3:l4[#0]K - %2:message » %1:person_likes_message[#2]KA » %0:person[#1]KAif » %3:l4[#0]K - %3:l4 » %2:message[#9]KA » %1:person_likes_message[#2]KA » %0:person[#1]KAif + %0:person » %1:person_likes_message[#1{personid}]KA » %2:message[#1{messageid}]KA » %3:l4[#0{zombieid}]K + %1:person_likes_message » %0:person[#1{id}]KAif » %2:message[#1{messageid}]KA » %3:l4[#0{zombieid}]K + %2:message » %1:person_likes_message[#2{messageid}]KA » %0:person[#1{id}]KAif » %3:l4[#0{zombieid}]K + %3:l4 » %2:message[#9{creatorpersonid}]KA » %1:person_likes_message[#2{messageid}]KA » %0:person[#1{id}]KAif ArrangeBy keys=[[#1{id}]] // { arity: 11 } ReadIndex on=person person_id=[delta join 1st input (full scan)] // { arity: 11 } ArrangeBy keys=[[#1{personid}], [#2{messageid}]] // { arity: 3 } @@ -2186,7 +2186,7 @@ Explained Query: Project (#0{id}, #2{count}, #3{sum}) // { arity: 3 } Join on=(#0{id} = #1{creatorpersonid}) type=differential // { arity: 4 } implementation - %1[#0]UKA » %0:l4[#0]K + %1[#0]UKA » %0:l4[#0{zombieid}]K Get l4 // { arity: 1 } ArrangeBy keys=[[#0{creatorpersonid}]] // { arity: 3 } Reduce group_by=[#0{creatorpersonid}] aggregates=[count(*), sum(case when #1 then 1 else 0 end)] // { arity: 3 } @@ -2315,13 +2315,13 @@ Explained Query: Filter (#1{name} = "Philippines") AND (#38{name} = "Taiwan") AND (#0{id}) IS NOT NULL AND (#36{partofcountryid}) IS NOT NULL // { arity: 41 } Join on=(#0{id} = #7{partofcountryid} AND #4{id} = #16{locationcityid} AND #9{id} = #20{person1id} AND #21{person2id} = #23{id} AND #30{locationcityid} = #33{id} AND #36{partofcountryid} = #37{id}) type=delta // { arity: 41 } implementation - %0:l0 » %1:l1[#3]KA » %2:l2[#8]KA » %3:person_knows_person[#1]KA » %4:l2[#1]KA » %5:l1[#0]KA » %6:l0[#0]KAef - %1:l1 » %0:l0[#0]KAef » %2:l2[#8]KA » %3:person_knows_person[#1]KA » %4:l2[#1]KA » %5:l1[#0]KA » %6:l0[#0]KAef - %2:l2 » %1:l1[#0]KA » %0:l0[#0]KAef » %3:person_knows_person[#1]KA » %4:l2[#1]KA » %5:l1[#0]KA » %6:l0[#0]KAef - %3:person_knows_person » %2:l2[#1]KA » %1:l1[#0]KA » %0:l0[#0]KAef » %4:l2[#1]KA » %5:l1[#0]KA » %6:l0[#0]KAef - %4:l2 » %3:person_knows_person[#2]KA » %2:l2[#1]KA » %1:l1[#0]KA » %0:l0[#0]KAef » %5:l1[#0]KA » %6:l0[#0]KAef - %5:l1 » %6:l0[#0]KAef » %4:l2[#8]KA » %3:person_knows_person[#2]KA » %2:l2[#1]KA » %1:l1[#0]KA » %0:l0[#0]KAef - %6:l0 » %5:l1[#3]KA » %4:l2[#8]KA » %3:person_knows_person[#2]KA » %2:l2[#1]KA » %1:l1[#0]KA » %0:l0[#0]KAef + %0:l0 » %1:l1[#3{partofcountryid}]KA » %2:l2[#8{locationcityid}]KA » %3:person_knows_person[#1{person1id}]KA » %4:l2[#1{id}]KA » %5:l1[#0{id}]KA » %6:l0[#0{id}]KAef + %1:l1 » %0:l0[#0{id}]KAef » %2:l2[#8{locationcityid}]KA » %3:person_knows_person[#1{person1id}]KA » %4:l2[#1{id}]KA » %5:l1[#0{id}]KA » %6:l0[#0{id}]KAef + %2:l2 » %1:l1[#0{id}]KA » %0:l0[#0{id}]KAef » %3:person_knows_person[#1{person1id}]KA » %4:l2[#1{id}]KA » %5:l1[#0{id}]KA » %6:l0[#0{id}]KAef + %3:person_knows_person » %2:l2[#1{id}]KA » %1:l1[#0{id}]KA » %0:l0[#0{id}]KAef » %4:l2[#1{id}]KA » %5:l1[#0{id}]KA » %6:l0[#0{id}]KAef + %4:l2 » %3:person_knows_person[#2{person2id}]KA » %2:l2[#1{id}]KA » %1:l1[#0{id}]KA » %0:l0[#0{id}]KAef » %5:l1[#0{id}]KA » %6:l0[#0{id}]KAef + %5:l1 » %6:l0[#0{id}]KAef » %4:l2[#8{locationcityid}]KA » %3:person_knows_person[#2{person2id}]KA » %2:l2[#1{id}]KA » %1:l1[#0{id}]KA » %0:l0[#0{id}]KAef + %6:l0 » %5:l1[#3{partofcountryid}]KA » %4:l2[#8{locationcityid}]KA » %3:person_knows_person[#2{person2id}]KA » %2:l2[#1{id}]KA » %1:l1[#0{id}]KA » %0:l0[#0{id}]KAef Get l0 // { arity: 4 } Get l1 // { arity: 4 } Get l2 // { arity: 11 } @@ -2331,7 +2331,7 @@ Explained Query: Get l1 // { arity: 4 } Get l0 // { arity: 4 } cte l4 = - Map (case when #2 then #1{person2id} else #0{id} end, case when #2 then #0{id} else #1{person2id} end) // { arity: 5 } + Map (case when #2{flipped} then #1{person2id} else #0{id} end, case when #2{flipped} then #0{id} else #1{person2id} end) // { arity: 5 } Union // { arity: 3 } Project (#2{id}..=#4) // { arity: 3 } Map (false) // { arity: 5 } @@ -2358,7 +2358,7 @@ Explained Query: Project (#9{creatorpersonid}, #22{creatorpersonid}) // { arity: 2 } Join on=(#1{messageid} = #25{parentmessageid}) type=differential // { arity: 26 } implementation - %0:l6[#1]KA » %1:message[#12]KA + %0:l6[#1{messageid}]KA » %1:message[#12{parentmessageid}]KA Get l6 // { arity: 13 } ArrangeBy keys=[[#12{parentmessageid}]] // { arity: 13 } ReadIndex on=message message_parentmessageid=[differential join] // { arity: 13 } @@ -2394,7 +2394,7 @@ Explained Query: Project (#9{creatorpersonid}, #14{personid}) // { arity: 2 } Join on=(#1{messageid} = #15{messageid}) type=differential // { arity: 16 } implementation - %0:l6[#1]KA » %1:person_likes_message[#2]KA + %0:l6[#1{messageid}]KA » %1:person_likes_message[#2{messageid}]KA Get l6 // { arity: 13 } ArrangeBy keys=[[#2{messageid}]] // { arity: 3 } ReadIndex on=person_likes_message person_likes_message_messageid=[differential join] // { arity: 3 } @@ -2402,11 +2402,11 @@ Explained Query: Project (#0{id}..=#3{person2id}, #6{sum}) // { arity: 5 } Join on=(#2{id} = #4 AND #3{person2id} = #5) type=differential // { arity: 7 } implementation - %1[#0, #1]UKKA » %0:l3[#2, #3]KK + %1[#0, #1]UKKA » %0:l3[#2{person1id}, #3{person2id}]KK ArrangeBy keys=[[#2{id}, #3{person2id}]] // { arity: 4 } Get l3 // { arity: 4 } ArrangeBy keys=[[#0, #1]] // { arity: 3 } - Reduce group_by=[#1, #2] aggregates=[sum((case when #3 then case when #0 then 1 else 4 end else 0 end + case when #4 then case when #0 then 1 else 10 end else 0 end))] // { arity: 3 } + Reduce group_by=[#1, #2] aggregates=[sum((case when #3 then case when #0{flipped} then 1 else 4 end else 0 end + case when #4 then case when #0{flipped} then 1 else 10 end else 0 end))] // { arity: 3 } Project (#2..=#5, #8) // { arity: 5 } Join on=(#0{id} = #6{id} AND #1{person2id} = #7{person2id}) type=differential // { arity: 9 } implementation @@ -2532,20 +2532,20 @@ Explained Query: Filter (#0{creationdate} <= 2012-11-10 00:00:00 UTC) AND (#0{creationdate} >= 2012-11-06 00:00:00 UTC) AND (#1{id}) IS NOT NULL // { arity: 4 } ReadIndex on=forum forum_id=[*** full scan ***] // { arity: 4 } cte l3 = - Join on=(#2 = least(#0{person1id}, #1{person2id}) AND #3 = greatest(#0{person1id}, #1{person2id})) type=differential // { arity: 5 } + Join on=(#2{src} = least(#0{person1id}, #1{person2id}) AND #3{dst} = greatest(#0{person1id}, #1{person2id})) type=differential // { arity: 5 } implementation - %1[#1, #0]UKK » %0:l1[greatest(#0, #1), least(#0, #1)]KK + %1[#1{dst}, #0{src}]UKK » %0:l1[greatest(#0{person1id}, #1{person2id}), least(#0{person1id}, #1{person2id})]KK Get l1 // { arity: 2 } - ArrangeBy keys=[[#1, #0]] // { arity: 3 } + ArrangeBy keys=[[#1{dst}, #0{src}]] // { arity: 3 } Reduce group_by=[least(#0{person1id}, #1{person2id}), greatest(#0{person1id}, #1{person2id})] aggregates=[sum(case when (#2{parentmessageid}) IS NULL then 10 else 5 end)] // { arity: 3 } Project (#1{person1id}, #2{person2id}, #15{parentmessageid}) // { arity: 3 } Join on=(#1{person1id} = #12{creatorpersonid} AND #2{person2id} = #25{creatorpersonid} AND #4{messageid} = #28{parentmessageid} AND #13{containerforumid} = #29{id} AND #26{containerforumid} = #30{id}) type=delta // { arity: 31 } implementation - %0:person_knows_person » %1:message[#9]KA » %3:l2[#0]UKA » %2:message[#12]KA » %4:l2[#0]UKA - %1:message » %3:l2[#0]UKA » %0:person_knows_person[#1]KA » %2:message[#12]KA » %4:l2[#0]UKA - %2:message » %4:l2[#0]UKA » %0:person_knows_person[#2]KA » %1:message[#9]KA » %3:l2[#0]UKA - %3:l2 » %1:message[#10]KA » %0:person_knows_person[#1]KA » %2:message[#12]KA » %4:l2[#0]UKA - %4:l2 » %2:message[#10]KA » %0:person_knows_person[#2]KA » %1:message[#9]KA » %3:l2[#0]UKA + %0:person_knows_person » %1:message[#9{creatorpersonid}]KA » %3:l2[#0]UKA » %2:message[#12{parentmessageid}]KA » %4:l2[#0]UKA + %1:message » %3:l2[#0]UKA » %0:person_knows_person[#1{person1id}]KA » %2:message[#12{parentmessageid}]KA » %4:l2[#0]UKA + %2:message » %4:l2[#0]UKA » %0:person_knows_person[#2{person2id}]KA » %1:message[#9{creatorpersonid}]KA » %3:l2[#0]UKA + %3:l2 » %1:message[#10{containerforumid}]KA » %0:person_knows_person[#1{person1id}]KA » %2:message[#12{parentmessageid}]KA » %4:l2[#0]UKA + %4:l2 » %2:message[#10{containerforumid}]KA » %0:person_knows_person[#2{person2id}]KA » %1:message[#9{creatorpersonid}]KA » %3:l2[#0]UKA ArrangeBy keys=[[#1{person1id}], [#2{person2id}]] // { arity: 3 } ReadIndex on=person_knows_person person_knows_person_person1id=[delta join 1st input (full scan)] person_knows_person_person2id=[delta join lookup] // { arity: 3 } ArrangeBy keys=[[#9{creatorpersonid}], [#10{containerforumid}]] // { arity: 13 } @@ -2559,15 +2559,15 @@ Explained Query: cte l4 = Project (#2, #0{person2id}, #1{min}) // { arity: 3 } Map (1450) // { arity: 3 } - Reduce group_by=[#0{person2id}] aggregates=[min(#1)] // { arity: 2 } + Reduce group_by=[#0{person2id}] aggregates=[min(#1{w})] // { arity: 2 } Distinct project=[#0{person2id}, #1] // { arity: 2 } Union // { arity: 2 } Project (#3{person2id}, #5) // { arity: 2 } - Map ((#1 + #4)) // { arity: 6 } - Join on=(#0 = #2{person1id}) type=differential // { arity: 5 } + Map ((#1{w} + #4{w})) // { arity: 6 } + Join on=(#0{dst} = #2{person1id}) type=differential // { arity: 5 } implementation - %0:l4[#0]UK » %1[#0]K - ArrangeBy keys=[[#0]] // { arity: 2 } + %0:l4[#0{dst}]UK » %1[#0{src}]K + ArrangeBy keys=[[#0{dst}]] // { arity: 2 } Project (#1{person2id}, #2{min}) // { arity: 2 } Get l4 // { arity: 3 } ArrangeBy keys=[[#0{person1id}]] // { arity: 3 } @@ -2580,7 +2580,7 @@ Explained Query: Project (#0{person1id}, #1{person2id}) // { arity: 2 } Join on=(#2 = least(#0{person1id}, #1{person2id}) AND #3 = greatest(#0{person1id}, #1{person2id})) type=differential // { arity: 4 } implementation - %1[#1, #0]UKK » %0:l1[greatest(#0, #1), least(#0, #1)]KK + %1[#1, #0]UKK » %0:l1[greatest(#0{person1id}, #1{person2id}), least(#0{person1id}, #1{person2id})]KK Get l1 // { arity: 2 } ArrangeBy keys=[[#1, #0]] // { arity: 2 } Distinct project=[#0, #1] // { arity: 2 } @@ -2729,20 +2729,20 @@ Explained Query: Filter (#0{creationdate} <= 2012-11-10 00:00:00 UTC) AND (#0{creationdate} >= 2012-11-06 00:00:00 UTC) AND (#1{id}) IS NOT NULL // { arity: 4 } ReadIndex on=forum forum_id=[*** full scan ***] // { arity: 4 } cte l3 = - Join on=(#2 = least(#0{person1id}, #1{person2id}) AND #3 = greatest(#0{person1id}, #1{person2id})) type=differential // { arity: 5 } + Join on=(#2{src} = least(#0{person1id}, #1{person2id}) AND #3{dst} = greatest(#0{person1id}, #1{person2id})) type=differential // { arity: 5 } implementation - %1[#1, #0]UKK » %0:l1[greatest(#0, #1), least(#0, #1)]KK + %1[#1{dst}, #0{src}]UKK » %0:l1[greatest(#0{person1id}, #1{person2id}), least(#0{person1id}, #1{person2id})]KK Get l1 // { arity: 2 } - ArrangeBy keys=[[#1, #0]] // { arity: 3 } + ArrangeBy keys=[[#1{dst}, #0{src}]] // { arity: 3 } Reduce group_by=[least(#0{person1id}, #1{person2id}), greatest(#0{person1id}, #1{person2id})] aggregates=[sum(case when (#2{parentmessageid}) IS NULL then 10 else 5 end)] // { arity: 3 } Project (#1{person1id}, #2{person2id}, #15{parentmessageid}) // { arity: 3 } Join on=(#1{person1id} = #12{creatorpersonid} AND #2{person2id} = #25{creatorpersonid} AND #4{messageid} = #28{parentmessageid} AND #13{containerforumid} = #29{id} AND #26{containerforumid} = #30{id}) type=delta // { arity: 31 } implementation - %0:person_knows_person » %1:message[#9]KA » %3:l2[#0]UKA » %2:message[#12]KA » %4:l2[#0]UKA - %1:message » %3:l2[#0]UKA » %0:person_knows_person[#1]KA » %2:message[#12]KA » %4:l2[#0]UKA - %2:message » %4:l2[#0]UKA » %0:person_knows_person[#2]KA » %1:message[#9]KA » %3:l2[#0]UKA - %3:l2 » %1:message[#10]KA » %0:person_knows_person[#1]KA » %2:message[#12]KA » %4:l2[#0]UKA - %4:l2 » %2:message[#10]KA » %0:person_knows_person[#2]KA » %1:message[#9]KA » %3:l2[#0]UKA + %0:person_knows_person » %1:message[#9{creatorpersonid}]KA » %3:l2[#0]UKA » %2:message[#12{parentmessageid}]KA » %4:l2[#0]UKA + %1:message » %3:l2[#0]UKA » %0:person_knows_person[#1{person1id}]KA » %2:message[#12{parentmessageid}]KA » %4:l2[#0]UKA + %2:message » %4:l2[#0]UKA » %0:person_knows_person[#2{person2id}]KA » %1:message[#9{creatorpersonid}]KA » %3:l2[#0]UKA + %3:l2 » %1:message[#10{containerforumid}]KA » %0:person_knows_person[#1{person1id}]KA » %2:message[#12{parentmessageid}]KA » %4:l2[#0]UKA + %4:l2 » %2:message[#10{containerforumid}]KA » %0:person_knows_person[#2{person2id}]KA » %1:message[#9{creatorpersonid}]KA » %3:l2[#0]UKA ArrangeBy keys=[[#1{person1id}], [#2{person2id}]] // { arity: 3 } ReadIndex on=person_knows_person person_knows_person_person1id=[delta join 1st input (full scan)] person_knows_person_person2id=[delta join lookup] // { arity: 3 } ArrangeBy keys=[[#9{creatorpersonid}], [#10{containerforumid}]] // { arity: 13 } @@ -2761,7 +2761,7 @@ Explained Query: Project (#0{person1id}, #1{person2id}) // { arity: 2 } Join on=(#2 = least(#0{person1id}, #1{person2id}) AND #3 = greatest(#0{person1id}, #1{person2id})) type=differential // { arity: 4 } implementation - %1[#1, #0]UKK » %0:l1[greatest(#0, #1), least(#0, #1)]KK + %1[#1, #0]UKK » %0:l1[greatest(#0{person1id}, #1{person2id}), least(#0{person1id}, #1{person2id})]KK Get l1 // { arity: 2 } ArrangeBy keys=[[#1, #0]] // { arity: 2 } Distinct project=[#0, #1] // { arity: 2 } @@ -2774,9 +2774,9 @@ Explained Query: With Mutually Recursive cte l5 = Project (#1, #3{person2id}) // { arity: 2 } - Join on=(#0 = #2{person1id}) type=differential // { arity: 4 } + Join on=(#0{src} = #2{person1id}) type=differential // { arity: 4 } implementation - %0:l8[#0]K » %1:l4[#0]K + %0:l8[#0{src}]K » %1:l4[#0{src}]K ArrangeBy keys=[[#0{person2id}]] // { arity: 2 } Get l8 // { arity: 2 } ArrangeBy keys=[[#0{person1id}]] // { arity: 2 } @@ -2792,14 +2792,14 @@ Explained Query: Project () // { arity: 0 } Join on=(#0{person2id} = #1{person2id}) type=differential // { arity: 2 } implementation - %0:l6[#0]Kf » %1:l6[#0]Kf + %0:l6[#0{src}]Kf » %1:l6[#0{src}]Kf ArrangeBy keys=[[#0{person2id}]] // { arity: 1 } Project (#0{person2id}) // { arity: 1 } - Filter #1 // { arity: 2 } + Filter #1{dir} // { arity: 2 } Get l6 // { arity: 2 } ArrangeBy keys=[[#0{person2id}]] // { arity: 1 } Project (#0{person2id}) // { arity: 1 } - Filter NOT(#1) // { arity: 2 } + Filter NOT(#1{dir}) // { arity: 2 } Get l6 // { arity: 2 } cte l8 = Distinct project=[#0{person2id}, #1] // { arity: 2 } @@ -2825,7 +2825,7 @@ Explained Query: cte l9 = TopK order_by=[#3 asc nulls_last] limit=1000 // { arity: 5 } Project (#0..=#3, #5) // { arity: 5 } - Filter (#4 = false) // { arity: 6 } + Filter (#4{dead} = false) // { arity: 6 } Get l17 // { arity: 6 } cte l10 = Distinct project=[#0..=#2] // { arity: 3 } @@ -2836,29 +2836,29 @@ Explained Query: Get l10 // { arity: 3 } cte l12 = Project (#0..=#2) // { arity: 3 } - Join on=(#0 = #3 AND #1 = #4 AND #2 = #5) type=differential // { arity: 6 } + Join on=(#0 = #3{dir} AND #1 = #4{gsrc} AND #2 = #5{dst}) type=differential // { arity: 6 } implementation %1[#0..=#2]UKKKA » %0:l11[#0..=#2]UKKK Get l11 // { arity: 3 } - ArrangeBy keys=[[#0..=#2]] // { arity: 3 } - Distinct project=[#0..=#2] // { arity: 3 } + ArrangeBy keys=[[#0{dir}..=#2{dst}]] // { arity: 3 } + Distinct project=[#0{dir}..=#2{dst}] // { arity: 3 } Project (#0..=#2) // { arity: 3 } Get l9 // { arity: 5 } cte l13 = TopK group_by=[#0, #1, #2{person2id}] order_by=[#3 asc nulls_last, #4 desc nulls_first] limit=1 // { arity: 5 } Union // { arity: 5 } Project (#3, #4, #1{person2id}, #7, #8) // { arity: 5 } - Map ((#6 + #2), false) // { arity: 9 } - Join on=(#0{person1id} = #5) type=differential // { arity: 7 } + Map ((#6{w} + #2{w}), false) // { arity: 9 } + Join on=(#0{person1id} = #5{dst}) type=differential // { arity: 7 } implementation - %0:l4[#0]K » %1:l9[#2]K + %0:l4[#0{src}]K » %1:l9[#2{dst}]K ArrangeBy keys=[[#0{person1id}]] // { arity: 3 } Get l4 // { arity: 3 } - ArrangeBy keys=[[#2]] // { arity: 4 } + ArrangeBy keys=[[#2{dst}]] // { arity: 4 } Project (#0..=#3) // { arity: 4 } Get l9 // { arity: 5 } Project (#0..=#3, #9) // { arity: 5 } - Map ((#4 OR #8)) // { arity: 10 } + Map ((#4{dead} OR #8)) // { arity: 10 } Join on=(#0 = #5 AND #1 = #6 AND #2 = #7) type=differential // { arity: 9 } implementation %0:l17[#0..=#2]KKK » %1[#0..=#2]KKK @@ -2881,18 +2881,18 @@ Explained Query: Get l10 // { arity: 3 } Get l11 // { arity: 3 } cte l14 = - Reduce aggregates=[min((#0 + #1))] // { arity: 1 } + Reduce aggregates=[min((#0{w} + #1{w}))] // { arity: 1 } Project (#1, #3) // { arity: 2 } Join on=(#0{person2id} = #2{person2id}) type=differential // { arity: 4 } implementation - %0:l13[#0]Kef » %1:l13[#0]Kef + %0:l13[#0{dst}]Kef » %1:l13[#0{dst}]Kef ArrangeBy keys=[[#0{person2id}]] // { arity: 2 } Project (#2{person2id}, #3) // { arity: 2 } - Filter (#0 = false) // { arity: 5 } + Filter (#0{dir} = false) // { arity: 5 } Get l13 // { arity: 5 } ArrangeBy keys=[[#0{person2id}]] // { arity: 2 } Project (#2{person2id}, #3) // { arity: 2 } - Filter (#0 = true) // { arity: 5 } + Filter (#0{dir} = true) // { arity: 5 } Get l13 // { arity: 5 } cte l15 = Project (#1) // { arity: 1 } @@ -2909,7 +2909,7 @@ Explained Query: cte l16 = Distinct project=[] // { arity: 0 } Project () // { arity: 0 } - Filter #1 AND (#0{person2id} = -1) // { arity: 2 } + Filter #1{dir} AND (#0{person2id} = -1) // { arity: 2 } Get l8 // { arity: 2 } cte l17 = Distinct project=[#0..=#5] // { arity: 6 } @@ -2922,7 +2922,7 @@ Explained Query: Map (15393162796819, true) // { arity: 2 } Get l16 // { arity: 0 } Project (#0..=#3, #7, #8) // { arity: 6 } - Map ((#4 OR coalesce((#3 > #6), false)), (#5 + 1)) // { arity: 9 } + Map ((#4{dead} OR coalesce((#3{w} > #6), false)), (#5{iter} + 1)) // { arity: 9 } CrossJoin type=delta // { arity: 7 } implementation %0:l13 » %1[×]U » %2[×]U @@ -2948,31 +2948,31 @@ Explained Query: With cte l18 = Project (#0..=#3) // { arity: 4 } - Join on=(#4 = #5{max}) type=differential // { arity: 6 } + Join on=(#4{iter} = #5{max}) type=differential // { arity: 6 } implementation - %1[#0]UK » %0:l17[#4]K - ArrangeBy keys=[[#4]] // { arity: 5 } + %1[#0]UK » %0:l17[#4{iter}]K + ArrangeBy keys=[[#4{iter}]] // { arity: 5 } Project (#0..=#3, #5) // { arity: 5 } Get l17 // { arity: 6 } ArrangeBy keys=[[#0{max}]] // { arity: 1 } - Reduce aggregates=[max(#0)] // { arity: 1 } + Reduce aggregates=[max(#0{iter})] // { arity: 1 } Project (#5) // { arity: 1 } Get l17 // { arity: 6 } cte l19 = Reduce aggregates=[min(#0{min})] // { arity: 1 } Project (#2{min}) // { arity: 1 } - Reduce group_by=[#0, #2] aggregates=[min((#1 + #3))] // { arity: 3 } + Reduce group_by=[#0, #2] aggregates=[min((#1{w} + #3{w}))] // { arity: 3 } Project (#0, #2, #3, #5) // { arity: 4 } Join on=(#1{person2id} = #4{person2id}) type=differential // { arity: 6 } implementation - %0:l18[#1]Kef » %1:l18[#1]Kef + %0:l18[#1{dst}]Kef » %1:l18[#1{dst}]Kef ArrangeBy keys=[[#1{person2id}]] // { arity: 3 } Project (#1..=#3) // { arity: 3 } - Filter (#0 = false) // { arity: 4 } + Filter (#0{dir} = false) // { arity: 4 } Get l18 // { arity: 4 } ArrangeBy keys=[[#1{person2id}]] // { arity: 3 } Project (#1..=#3) // { arity: 3 } - Filter (#0 = true) // { arity: 4 } + Filter (#0{dir} = true) // { arity: 4 } Get l18 // { arity: 4 } Return // { arity: 1 } Project (#1) // { arity: 1 } @@ -3106,7 +3106,7 @@ Explained Query: Project (#1{messageid}) // { arity: 1 } Join on=(#2{tagid} = #3{id}) type=differential // { arity: 8 } implementation - %1:tag[#0]KAe » %0:l1[#2]KAe + %1:tag[#0{id}]KAe » %0:l1[#2{tagid}]KAe Get l1 // { arity: 3 } ArrangeBy keys=[[#0{id}]] // { arity: 5 } ReadIndex on=materialize.public.tag tag_name=[lookup value=("Diosdado_Macapagal")] // { arity: 5 } @@ -3117,9 +3117,9 @@ Explained Query: Project (#0{id}, #1{messageid}, #4{person2id}) // { arity: 3 } Join on=(#0{id} = #3{person1id} AND #4{person2id} = #5{id}) type=delta // { arity: 6 } implementation - %0:l3 » %1:l4[#1]KA » %2[#0]UKA + %0:l3 » %1:l4[#1{person1id}]KA » %2[#0]UKA %1:l4 » %2[#0]UKA » %0:l3[#0]K - %2 » %1:l4[#2]KA » %0:l3[#0]K + %2 » %1:l4[#2{person2id}]KA » %0:l3[#0]K ArrangeBy keys=[[#0{id}]] // { arity: 2 } Get l3 // { arity: 2 } Get l4 // { arity: 3 } @@ -3145,7 +3145,7 @@ Explained Query: Project (#1{messageid}) // { arity: 1 } Join on=(#2{tagid} = #3{id}) type=differential // { arity: 8 } implementation - %1:tag[#0]KAe » %0:l1[#2]KAe + %1:tag[#0{id}]KAe » %0:l1[#2{tagid}]KAe Get l1 // { arity: 3 } ArrangeBy keys=[[#0{id}]] // { arity: 5 } ReadIndex on=materialize.public.tag tag_name=[lookup value=("Thailand_Noriega")] // { arity: 5 } @@ -3153,9 +3153,9 @@ Explained Query: Project (#0{id}, #1{messageid}, #4{person2id}) // { arity: 3 } Join on=(#0{id} = #3{person1id} AND #4{person2id} = #5{id}) type=delta // { arity: 6 } implementation - %0:l6 » %1:l4[#1]KA » %2[#0]UKA + %0:l6 » %1:l4[#1{person1id}]KA » %2[#0]UKA %1:l4 » %2[#0]UKA » %0:l6[#0]K - %2 » %1:l4[#2]KA » %0:l6[#0]K + %2 » %1:l4[#2{person2id}]KA » %0:l6[#0]K ArrangeBy keys=[[#0{id}]] // { arity: 2 } Get l6 // { arity: 2 } Get l4 // { arity: 3 } @@ -3169,7 +3169,7 @@ Explained Query: Map ((#1{count_messageid} + #4{count_messageid})) // { arity: 7 } Join on=(#0{id} = #3{id}) type=differential // { arity: 6 } implementation - %0[#0]UKAif » %1[#0]UKAiif + %0[#0{personid}]UKAif » %1[#0]UKAiif ArrangeBy keys=[[#0{id}]] // { arity: 3 } Reduce group_by=[#0{id}] aggregates=[count(distinct #1{messageid}), count(distinct #2{person2id})] // { arity: 3 } Union // { arity: 3 } @@ -3255,7 +3255,7 @@ Explained Query: Project (#0{creationdate}, #1{messageid}, #9{creatorpersonid}, #10{containerforumid}, #12{parentmessageid}) // { arity: 5 } Join on=(#1{messageid} = #13{messageid}) type=differential // { arity: 14 } implementation - %1[#0]UKA » %0:message[#1]KA + %1[#0]UKA » %0:message[#1{messageid}]KA ArrangeBy keys=[[#1{messageid}]] // { arity: 13 } ReadIndex on=message message_messageid=[differential join] // { arity: 13 } ArrangeBy keys=[[#0{messageid}]] // { arity: 1 } @@ -3263,7 +3263,7 @@ Explained Query: Project (#1{messageid}) // { arity: 1 } Join on=(#2{tagid} = #3{id}) type=differential // { arity: 4 } implementation - %1[#0]UKA » %0:message_hastag_tag[#2]KA + %1[#0]UKA » %0:message_hastag_tag[#2{tagid}]KA ArrangeBy keys=[[#2{tagid}]] // { arity: 3 } ReadIndex on=message_hastag_tag message_hastag_tag_tagid=[differential join] // { arity: 3 } ArrangeBy keys=[[#0{id}]] // { arity: 1 } @@ -3279,11 +3279,11 @@ Explained Query: Filter (#2{containerforumid} != #6{containerforumid}) AND (#5{creatorpersonid} != #7{creatorpersonid}) AND ((#0{creationdate} + 12:00:00) < #3{creationdate}) // { arity: 15 } Join on=(#2{containerforumid} = #10{forumid} = #13{forumid} AND #4{messageid} = #8{parentmessageid} AND #5{creatorpersonid} = #14{personid} AND #7{creatorpersonid} = #11{personid}) type=delta // { arity: 15 } implementation - %0:l0 » %3:l1[#1]KA » %4:l1[#1]KA » %1:l0[#2]K » %2:l0[#0, #1]KK - %1:l0 » %4:l1[#2]KA » %3:l1[#1]KA » %2:l0[#0, #1]KK » %0:l0[#2]K - %2:l0 » %3:l1[#2]KA » %4:l1[#1]KA » %1:l0[#1, #2]KK » %0:l0[#2]K - %3:l1 » %4:l1[#1]KA » %0:l0[#2]K » %1:l0[#2]K » %2:l0[#0, #1]KK - %4:l1 » %3:l1[#1]KA » %0:l0[#2]K » %1:l0[#2]K » %2:l0[#0, #1]KK + %0:l0 » %3:l1[#1{forumid}]KA » %4:l1[#1{forumid}]KA » %1:l0[#2{creatorpersonid}]K » %2:l0[#0{creatorpersonid}, #1{parentmessageid}]KK + %1:l0 » %4:l1[#2{personid}]KA » %3:l1[#1{forumid}]KA » %2:l0[#0{creatorpersonid}, #1{parentmessageid}]KK » %0:l0[#2{containerforumid}]K + %2:l0 » %3:l1[#2{personid}]KA » %4:l1[#1{forumid}]KA » %1:l0[#1{messageid}, #2{creatorpersonid}]KK » %0:l0[#2{containerforumid}]K + %3:l1 » %4:l1[#1{forumid}]KA » %0:l0[#2{containerforumid}]K » %1:l0[#2{creatorpersonid}]K » %2:l0[#0{creatorpersonid}, #1{parentmessageid}]KK + %4:l1 » %3:l1[#1{forumid}]KA » %0:l0[#2{containerforumid}]K » %1:l0[#2{creatorpersonid}]K » %2:l0[#0{creatorpersonid}, #1{parentmessageid}]KK ArrangeBy keys=[[#2{containerforumid}]] // { arity: 3 } Project (#0{creationdate}, #2{creatorpersonid}, #3{containerforumid}) // { arity: 3 } Get l0 // { arity: 5 } @@ -3375,9 +3375,9 @@ Explained Query: Project (#0{personid}, #9{person2id}) // { arity: 2 } Join on=(#0{personid} = #8{person1id} AND #1{tagid} = #2{id}) type=delta // { arity: 10 } implementation - %0:person_hasinterest_tag » %1:tag[#0]KAe » %2:person_knows_person[#1]KA - %1:tag » %0:person_hasinterest_tag[#1]KA » %2:person_knows_person[#1]KA - %2:person_knows_person » %0:person_hasinterest_tag[#0]K » %1:tag[#0]KAe + %0:person_hasinterest_tag » %1:tag[#0{id}]KAe » %2:person_knows_person[#1{person1id}]KA + %1:tag » %0:person_hasinterest_tag[#1{tagid}]KA » %2:person_knows_person[#1{person1id}]KA + %2:person_knows_person » %0:person_hasinterest_tag[#0{personid}]K » %1:tag[#0{id}]KAe ArrangeBy keys=[[#0{personid}], [#1{tagid}]] // { arity: 2 } Project (#1{personid}, #2{tagid}) // { arity: 2 } ReadIndex on=person_hasinterest_tag person_hasinterest_tag_tagid=[*** full scan ***] // { arity: 3 } @@ -3390,7 +3390,7 @@ Explained Query: Filter (#0{personid} != #2{personid}) // { arity: 4 } Join on=(#1{person2id} = #3{person2id}) type=differential // { arity: 4 } implementation - %0:l0[#1]K » %1:l0[#1]K + %0:l0[#1{friendid}]K » %1:l0[#1{friendid}]K Get l0 // { arity: 2 } Get l0 // { arity: 2 } cte l2 = @@ -3474,9 +3474,9 @@ materialize.public.pathq19: Filter (#0{creatorpersonid} != #11{creatorpersonid}) AND (#16{person1id} < #17{person2id}) // { arity: 18 } Join on=(#1{parentmessageid} = #3{messageid} AND #16{person1id} = least(#0{creatorpersonid}, #11{creatorpersonid}) AND #17{person2id} = greatest(#0{creatorpersonid}, #11{creatorpersonid})) type=delta // { arity: 18 } implementation - %0:message » %1:message[#1]KA » %2:person_knows_person[#1, #2]KKAf - %1:message » %0:message[#1]KA » %2:person_knows_person[#1, #2]KKAf - %2:person_knows_person » %0:message[×] » %1:message[#1]KA + %0:message » %1:message[#1{messageid}]KA » %2:person_knows_person[#1{person1id}, #2{person2id}]KKAf + %1:message » %0:message[#1{parentmessageid}]KA » %2:person_knows_person[#1{person1id}, #2{person2id}]KKAf + %2:person_knows_person » %0:message[×] » %1:message[#1{messageid}]KA ArrangeBy keys=[[], [#1{parentmessageid}]] // { arity: 2 } Project (#9{creatorpersonid}, #12{parentmessageid}) // { arity: 2 } Filter (#12{parentmessageid}) IS NOT NULL // { arity: 13 } @@ -3566,17 +3566,17 @@ SELECT src, dst, w Explained Query: With Mutually Recursive cte l0 = - Reduce group_by=[#0{id}, #1{id}] aggregates=[min(#2)] // { arity: 3 } + Reduce group_by=[#0{id}, #1{id}] aggregates=[min(#2{w})] // { arity: 3 } Distinct project=[#0{id}..=#2] // { arity: 3 } Union // { arity: 3 } Project (#1{id}, #1{id}, #12) // { arity: 3 } Map (0) // { arity: 13 } ReadIndex on=materialize.public.person person_locationcityid=[lookup value=(655)] // { arity: 12 } Project (#0, #4{dst}, #6) // { arity: 3 } - Map ((#2 + bigint_to_double(#5{w}))) // { arity: 7 } - Join on=(#1 = #3{src}) type=differential // { arity: 6 } + Map ((#2{w} + bigint_to_double(#5{w}))) // { arity: 7 } + Join on=(#1{dst} = #3{src}) type=differential // { arity: 6 } implementation - %1:pathq19[#0]KA » %0:l0[#1]K + %1:pathq19[#0{src}]KA » %0:l0[#1{dst}]K ArrangeBy keys=[[#1{id}]] // { arity: 3 } Filter (#1{id}) IS NOT NULL // { arity: 3 } Get l0 // { arity: 3 } @@ -3601,7 +3601,7 @@ Explained Query: Project (#0{id}..=#2{min}) // { arity: 3 } Join on=(#2{min} = #3{min_min}) type=differential // { arity: 4 } implementation - %1[#0]UK » %0:l1[#2]K + %1[#0]UK » %0:l1[#2{w}]K ArrangeBy keys=[[#2{min}]] // { arity: 3 } Get l1 // { arity: 3 } ArrangeBy keys=[[#0{min_min}]] // { arity: 1 } @@ -3686,7 +3686,7 @@ Explained Query: ArrangeBy keys=[[]] // { arity: 1 } Union // { arity: 1 } Project (#1) // { arity: 1 } - Map ((#0 / 2)) // { arity: 2 } + Map ((#0{w} / 2)) // { arity: 2 } Get l7 // { arity: 1 } Map (null) // { arity: 1 } Union // { arity: 0 } @@ -3702,13 +3702,13 @@ Explained Query: Map (0) // { arity: 13 } ReadIndex on=materialize.public.person person_locationcityid=[lookup value=(655)] // { arity: 12 } Project (#0, #5{dst}, #7) // { arity: 3 } - Filter coalesce((#2 < #3), true) // { arity: 8 } - Map ((#2 + bigint_to_double(#6{w}))) // { arity: 8 } - Join on=(#1 = #4{src}) type=delta // { arity: 7 } + Filter coalesce((#2{w} < #3), true) // { arity: 8 } + Map ((#2{w} + bigint_to_double(#6{w}))) // { arity: 8 } + Join on=(#1{dst} = #4{src}) type=delta // { arity: 7 } implementation - %0:l3 » %2:l1[#0]KA » %1:l2[×] - %1:l2 » %0:l3[×] » %2:l1[#0]KA - %2:l1 » %0:l3[#1]K » %1:l2[×] + %0:l3 » %2:l1[#0{src}]KA » %1:l2[×] + %1:l2 » %0:l3[×] » %2:l1[#0{src}]KA + %2:l1 » %0:l3[#1{dst}]K » %1:l2[×] ArrangeBy keys=[[], [#1{id}]] // { arity: 3 } Filter (#1{id}) IS NOT NULL // { arity: 3 } Get l3 // { arity: 3 } @@ -3721,24 +3721,24 @@ Explained Query: Map (0) // { arity: 13 } ReadIndex on=materialize.public.person person_locationcityid=[lookup value=(1138)] // { arity: 12 } Project (#0, #5{dst}, #7) // { arity: 3 } - Filter coalesce((#2 < #3), true) // { arity: 8 } - Map ((#2 + bigint_to_double(#6{w}))) // { arity: 8 } - Join on=(#1 = #4{src}) type=delta // { arity: 7 } + Filter coalesce((#2{w} < #3), true) // { arity: 8 } + Map ((#2{w} + bigint_to_double(#6{w}))) // { arity: 8 } + Join on=(#1{dst} = #4{src}) type=delta // { arity: 7 } implementation - %0:l4 » %2:l1[#0]KA » %1:l2[×] - %1:l2 » %0:l4[×] » %2:l1[#0]KA - %2:l1 » %0:l4[#1]K » %1:l2[×] + %0:l4 » %2:l1[#0{src}]KA » %1:l2[×] + %1:l2 » %0:l4[×] » %2:l1[#0{src}]KA + %2:l1 » %0:l4[#1{dst}]K » %1:l2[×] ArrangeBy keys=[[], [#1{id}]] // { arity: 3 } Filter (#1{id}) IS NOT NULL // { arity: 3 } Get l4 // { arity: 3 } Get l2 // { arity: 1 } Get l1 // { arity: 3 } cte l5 = - Reduce group_by=[#0{id}, #2{id}] aggregates=[min((#1 + #3))] // { arity: 3 } + Reduce group_by=[#0{id}, #2{id}] aggregates=[min((#1{w} + #3{w}))] // { arity: 3 } Project (#0{id}, #2, #3{id}, #5) // { arity: 4 } Join on=(#1{id} = #4{id}) type=differential // { arity: 6 } implementation - %0:l3[#1]K » %1:l4[#1]K + %0:l3[#1{dst}]K » %1:l4[#1{dst}]K ArrangeBy keys=[[#1{id}]] // { arity: 3 } Filter (#1{id}) IS NOT NULL // { arity: 3 } Get l3 // { arity: 3 } @@ -3763,7 +3763,7 @@ Explained Query: Project (#0{id}..=#2{min}) // { arity: 3 } Join on=(#2{min} = #3{min_min}) type=differential // { arity: 4 } implementation - %1[#0]UK » %0:l5[#2]K + %1[#0]UK » %0:l5[#2{w}]K ArrangeBy keys=[[#2{min}]] // { arity: 3 } Get l5 // { arity: 3 } ArrangeBy keys=[[#0{min_min}]] // { arity: 1 } @@ -3843,7 +3843,7 @@ Explained Query: cte l1 = TopK order_by=[#3 asc nulls_last] limit=1000 // { arity: 5 } Project (#0..=#3, #5) // { arity: 5 } - Filter (#4 = false) // { arity: 6 } + Filter (#4{dead} = false) // { arity: 6 } Get l7 // { arity: 6 } cte l2 = Distinct project=[#0..=#2] // { arity: 3 } @@ -3851,34 +3851,34 @@ Explained Query: Get l7 // { arity: 6 } cte l3 = Project (#0..=#2) // { arity: 3 } - Join on=(#0 = #3 AND #1 = #4 AND #2 = #5) type=differential // { arity: 6 } + Join on=(#0 = #3{dir} AND #1 = #4{gsrc} AND #2 = #5{dst}) type=differential // { arity: 6 } implementation %1[#0..=#2]UKKKA » %0:l2[#0..=#2]UKKK ArrangeBy keys=[[#0..=#2]] // { arity: 3 } - Filter (#1) IS NOT NULL AND (#2) IS NOT NULL // { arity: 3 } + Filter (#1{gsrc}) IS NOT NULL AND (#2{dst}) IS NOT NULL // { arity: 3 } Get l2 // { arity: 3 } - ArrangeBy keys=[[#0..=#2]] // { arity: 3 } - Distinct project=[#0..=#2] // { arity: 3 } + ArrangeBy keys=[[#0{dir}..=#2{dst}]] // { arity: 3 } + Distinct project=[#0{dir}..=#2{dst}] // { arity: 3 } Project (#0..=#2) // { arity: 3 } - Filter (#1) IS NOT NULL AND (#2) IS NOT NULL // { arity: 5 } + Filter (#1{gsrc}) IS NOT NULL AND (#2{dst}) IS NOT NULL // { arity: 5 } Get l1 // { arity: 5 } cte l4 = TopK group_by=[#0, #1, #2{dst}] order_by=[#3 asc nulls_last, #4 desc nulls_first] limit=1 // { arity: 5 } Distinct project=[#0..=#4] // { arity: 5 } Union // { arity: 5 } Project (#3, #4, #1{dst}, #7, #8) // { arity: 5 } - Map ((#6 + bigint_to_double(#2{w})), false) // { arity: 9 } - Join on=(#0{src} = #5) type=differential // { arity: 7 } + Map ((#6{w} + bigint_to_double(#2{w})), false) // { arity: 9 } + Join on=(#0{src} = #5{dst}) type=differential // { arity: 7 } implementation - %0:pathq19[#0]KA » %1:l1[#2]K + %0:pathq19[#0{src}]KA » %1:l1[#2{dst}]K ArrangeBy keys=[[#0{src}]] // { arity: 3 } ReadIndex on=pathq19 pathq19_src=[differential join] // { arity: 3 } - ArrangeBy keys=[[#2]] // { arity: 4 } + ArrangeBy keys=[[#2{dst}]] // { arity: 4 } Project (#0..=#3) // { arity: 4 } - Filter (#2) IS NOT NULL // { arity: 5 } + Filter (#2{dst}) IS NOT NULL // { arity: 5 } Get l1 // { arity: 5 } Project (#0..=#3, #9) // { arity: 5 } - Map ((#4 OR #8)) // { arity: 10 } + Map ((#4{dead} OR #8)) // { arity: 10 } Join on=(#0 = #5 AND #1 = #6 AND #2 = #7) type=differential // { arity: 9 } implementation %0:l7[#0..=#2]KKK » %1[#0..=#2]KKK @@ -3902,18 +3902,18 @@ Explained Query: ArrangeBy keys=[[#0..=#2]] // { arity: 3 } Get l2 // { arity: 3 } cte l5 = - Reduce aggregates=[min((#0 + #1))] // { arity: 1 } + Reduce aggregates=[min((#0{w} + #1{w}))] // { arity: 1 } Project (#1, #3) // { arity: 2 } Join on=(#0{dst} = #2{dst}) type=differential // { arity: 4 } implementation - %0:l4[#0]Kef » %1:l4[#0]Kef + %0:l4[#0{dst}]Kef » %1:l4[#0{dst}]Kef ArrangeBy keys=[[#0{dst}]] // { arity: 2 } Project (#2{dst}, #3) // { arity: 2 } - Filter (#0 = false) AND (#2{dst}) IS NOT NULL // { arity: 5 } + Filter (#0{dir} = false) AND (#2{dst}) IS NOT NULL // { arity: 5 } Get l4 // { arity: 5 } ArrangeBy keys=[[#0{dst}]] // { arity: 2 } Project (#2{dst}, #3) // { arity: 2 } - Filter (#0 = true) AND (#2{dst}) IS NOT NULL // { arity: 5 } + Filter (#0{dir} = true) AND (#2{dst}) IS NOT NULL // { arity: 5 } Get l4 // { arity: 5 } cte l6 = Project (#1) // { arity: 1 } @@ -3940,7 +3940,7 @@ Explained Query: Map (true) // { arity: 13 } ReadIndex on=materialize.public.person person_locationcityid=[lookup value=(1138)] // { arity: 12 } Project (#0..=#3, #7, #8) // { arity: 6 } - Map ((#4 OR coalesce((#3 > #6), false)), (#5 + 1)) // { arity: 9 } + Map ((#4{dead} OR coalesce((#3{w} > #6), false)), (#5{iter} + 1)) // { arity: 9 } CrossJoin type=delta // { arity: 7 } implementation %0:l4 » %1[×]U » %2[×]U @@ -3966,36 +3966,36 @@ Explained Query: With cte l8 = Project (#0..=#3) // { arity: 4 } - Join on=(#4 = #5{max}) type=differential // { arity: 6 } + Join on=(#4{iter} = #5{max}) type=differential // { arity: 6 } implementation - %1[#0]UK » %0:l7[#4]K - ArrangeBy keys=[[#4]] // { arity: 5 } + %1[#0]UK » %0:l7[#4{iter}]K + ArrangeBy keys=[[#4{iter}]] // { arity: 5 } Project (#0..=#3, #5) // { arity: 5 } Filter (#2{id}) IS NOT NULL // { arity: 6 } Get l7 // { arity: 6 } ArrangeBy keys=[[#0{max}]] // { arity: 1 } - Reduce aggregates=[max(#0)] // { arity: 1 } + Reduce aggregates=[max(#0{iter})] // { arity: 1 } Project (#5) // { arity: 1 } Get l7 // { arity: 6 } cte l9 = - Reduce group_by=[#0{id}, #2{id}] aggregates=[min((#1 + #3))] // { arity: 3 } + Reduce group_by=[#0{id}, #2{id}] aggregates=[min((#1{w} + #3{w}))] // { arity: 3 } Project (#0{id}, #2, #3{id}, #5) // { arity: 4 } Join on=(#1{id} = #4{id}) type=differential // { arity: 6 } implementation - %0:l8[#1]Kef » %1:l8[#1]Kef + %0:l8[#1{dst}]Kef » %1:l8[#1{dst}]Kef ArrangeBy keys=[[#1{id}]] // { arity: 3 } Project (#1{id}..=#3) // { arity: 3 } - Filter (#0 = false) // { arity: 4 } + Filter (#0{dir} = false) // { arity: 4 } Get l8 // { arity: 4 } ArrangeBy keys=[[#1{id}]] // { arity: 3 } Project (#1{id}..=#3) // { arity: 3 } - Filter (#0 = true) // { arity: 4 } + Filter (#0{dir} = true) // { arity: 4 } Get l8 // { arity: 4 } Return // { arity: 3 } Project (#0{id}..=#2{min}) // { arity: 3 } Join on=(#2{min} = #3{min_min}) type=differential // { arity: 4 } implementation - %1[#0]UK » %0:l9[#2]K + %1[#0]UK » %0:l9[#2{w}]K ArrangeBy keys=[[#2{min}]] // { arity: 3 } Get l9 // { arity: 3 } ArrangeBy keys=[[#0{min_min}]] // { arity: 1 } @@ -4070,14 +4070,14 @@ Explained Query: cte l0 = Project (#2, #0{dst}, #1{min}) // { arity: 3 } Map (10995116285979) // { arity: 3 } - Reduce group_by=[#0{dst}] aggregates=[min(#1)] // { arity: 2 } + Reduce group_by=[#0{dst}] aggregates=[min(#1{w})] // { arity: 2 } Distinct project=[#0{dst}, #1] // { arity: 2 } Union // { arity: 2 } Project (#3{dst}, #5) // { arity: 2 } - Map ((#1 + integer_to_bigint(#4{w}))) // { arity: 6 } - Join on=(#0 = #2{src}) type=differential // { arity: 5 } + Map ((#1{w} + integer_to_bigint(#4{w}))) // { arity: 6 } + Join on=(#0{dst} = #2{src}) type=differential // { arity: 5 } implementation - %0:l0[#0]UK » %1:pathq20[#0]KA + %0:l0[#0{dst}]UK » %1:pathq20[#0{src}]KA ArrangeBy keys=[[#0{dst}]] // { arity: 2 } Project (#1{dst}, #2{min}) // { arity: 2 } Get l0 // { arity: 3 } @@ -4101,7 +4101,7 @@ Explained Query: Filter (#5{name} = "Balkh_Airlines") // { arity: 8 } Join on=(#2{companyid} = #4{id}) type=differential // { arity: 8 } implementation - %1:company[#0]KAef » %0:person_workat_company[#2]KAef + %1:company[#0{id}]KAef » %0:person_workat_company[#2{companyid}]KAef ArrangeBy keys=[[#2{companyid}]] // { arity: 4 } ReadIndex on=person_workat_company person_workat_company_companyid=[differential join] // { arity: 4 } ArrangeBy keys=[[#0{id}]] // { arity: 4 } @@ -4176,14 +4176,14 @@ Explained Query: Finish order_by=[#0{dst} asc nulls_last] limit=20 output=[#0, #1] With Mutually Recursive cte l0 = - Reduce group_by=[#0{dst}] aggregates=[min(#1)] // { arity: 2 } + Reduce group_by=[#0{dst}] aggregates=[min(#1{w})] // { arity: 2 } Distinct project=[#0{dst}, #1] // { arity: 2 } Union // { arity: 2 } Project (#3{dst}, #5) // { arity: 2 } - Map ((#1 + integer_to_bigint(#4{w}))) // { arity: 6 } - Join on=(#0 = #2{src}) type=differential // { arity: 5 } + Map ((#1{w} + integer_to_bigint(#4{w}))) // { arity: 6 } + Join on=(#0{dst} = #2{src}) type=differential // { arity: 5 } implementation - %0:l0[#0]UK » %1:pathq20[#0]KA + %0:l0[#0{dst}]UK » %1:pathq20[#0{src}]KA ArrangeBy keys=[[#0{dst}]] // { arity: 2 } Get l0 // { arity: 2 } ArrangeBy keys=[[#0{src}]] // { arity: 3 } @@ -4205,7 +4205,7 @@ Explained Query: Filter (#5{name} = "Balkh_Airlines") // { arity: 8 } Join on=(#2{companyid} = #4{id}) type=differential // { arity: 8 } implementation - %1:company[#0]KAef » %0:person_workat_company[#2]KAef + %1:company[#0{id}]KAef » %0:person_workat_company[#2{companyid}]KAef ArrangeBy keys=[[#2{companyid}]] // { arity: 4 } ReadIndex on=person_workat_company person_workat_company_companyid=[differential join] // { arity: 4 } ArrangeBy keys=[[#0{id}]] // { arity: 4 } @@ -4287,15 +4287,15 @@ Explained Query: cte l0 = Project (#3, #0{dst}..=#2{min}) // { arity: 4 } Map (10995116285979) // { arity: 4 } - Reduce group_by=[#0{dst}, #2{min}] aggregates=[min(#1)] // { arity: 3 } - Reduce group_by=[#0{dst}, #2] aggregates=[min(#1)] // { arity: 3 } + Reduce group_by=[#0{dst}, #2{min}] aggregates=[min(#1{hops})] // { arity: 3 } + Reduce group_by=[#0{dst}, #2] aggregates=[min(#1{w})] // { arity: 3 } Distinct project=[#0{dst}..=#2] // { arity: 3 } Union // { arity: 3 } Project (#4{dst}, #6, #7) // { arity: 3 } - Map ((#1 + integer_to_bigint(#5{w})), (#2 + 1)) // { arity: 8 } - Join on=(#0 = #3{src}) type=differential // { arity: 6 } + Map ((#1{w} + integer_to_bigint(#5{w})), (#2{hops} + 1)) // { arity: 8 } + Join on=(#0{dst} = #3{src}) type=differential // { arity: 6 } implementation - %1:pathq20[#0]KA » %0:l0[#0]K + %1:pathq20[#0{src}]KA » %0:l0[#0{dst}]K ArrangeBy keys=[[#0{dst}]] // { arity: 3 } Project (#1{dst}..=#3{min}) // { arity: 3 } Get l0 // { arity: 4 } @@ -4319,7 +4319,7 @@ Explained Query: Filter (#5{name} = "Balkh_Airlines") // { arity: 8 } Join on=(#2{companyid} = #4{id}) type=differential // { arity: 8 } implementation - %1:company[#0]KAef » %0:person_workat_company[#2]KAef + %1:company[#0{id}]KAef » %0:person_workat_company[#2{companyid}]KAef ArrangeBy keys=[[#2{companyid}]] // { arity: 4 } ReadIndex on=person_workat_company person_workat_company_companyid=[differential join] // { arity: 4 } ArrangeBy keys=[[#0{id}]] // { arity: 4 } @@ -4440,7 +4440,7 @@ Explained Query: Filter (#5{name} = "Balkh_Airlines") // { arity: 8 } Join on=(#2{companyid} = #4{id}) type=differential // { arity: 8 } implementation - %1:company[#0]KAef » %0:person_workat_company[#2]KAef + %1:company[#0{id}]KAef » %0:person_workat_company[#2{companyid}]KAef ArrangeBy keys=[[#2{companyid}]] // { arity: 4 } ReadIndex on=person_workat_company person_workat_company_companyid=[differential join] // { arity: 4 } ArrangeBy keys=[[#0{id}]] // { arity: 4 } @@ -4457,11 +4457,11 @@ Explained Query: Distinct project=[#0{dst}] // { arity: 1 } Union // { arity: 1 } Project (#2{dst}) // { arity: 1 } - Join on=(#0 = #1{src}) type=delta // { arity: 4 } + Join on=(#0{pos} = #1{src}) type=delta // { arity: 4 } implementation - %0:l3 » %1:l1[#0]KA » %2[×] - %1:l1 » %0:l3[#0]UK » %2[×] - %2 » %0:l3[×] » %1:l1[#0]KA + %0:l3 » %1:l1[#0{src}]KA » %2[×] + %1:l1 » %0:l3[#0{pos}]UK » %2[×] + %2 » %0:l3[×] » %1:l1[#0{src}]KA ArrangeBy keys=[[], [#0{dst}]] // { arity: 1 } Get l3 // { arity: 1 } Get l1 // { arity: 3 } @@ -4472,7 +4472,7 @@ Explained Query: Project () // { arity: 0 } Join on=(#0{dst} = #1{personid}) type=differential // { arity: 2 } implementation - %0:l3[#0]UK » %1:l2[#0]K + %0:l3[#0{pos}]UK » %1:l2[#0{t}]K ArrangeBy keys=[[#0{dst}]] // { arity: 1 } Get l3 // { arity: 1 } Get l2 // { arity: 1 } @@ -4483,7 +4483,7 @@ Explained Query: cte l4 = TopK order_by=[#3 asc nulls_last] limit=1000 // { arity: 5 } Project (#0..=#3, #5) // { arity: 5 } - Filter (#4 = false) // { arity: 6 } + Filter (#4{dead} = false) // { arity: 6 } Get l12 // { arity: 6 } cte l5 = Distinct project=[#0..=#2] // { arity: 3 } @@ -4494,28 +4494,28 @@ Explained Query: Get l5 // { arity: 3 } cte l7 = Project (#0..=#2) // { arity: 3 } - Join on=(#0 = #3 AND #1 = #4 AND #2 = #5) type=differential // { arity: 6 } + Join on=(#0 = #3{dir} AND #1 = #4{gsrc} AND #2 = #5{dst}) type=differential // { arity: 6 } implementation %1[#0..=#2]UKKKA » %0:l6[#0..=#2]UKKK Get l6 // { arity: 3 } - ArrangeBy keys=[[#0..=#2]] // { arity: 3 } - Distinct project=[#0..=#2] // { arity: 3 } + ArrangeBy keys=[[#0{dir}..=#2{dst}]] // { arity: 3 } + Distinct project=[#0{dir}..=#2{dst}] // { arity: 3 } Project (#0..=#2) // { arity: 3 } Get l4 // { arity: 5 } cte l8 = TopK group_by=[#0, #1, #2{dst}] order_by=[#3 asc nulls_last, #4 desc nulls_first] limit=1 // { arity: 5 } Union // { arity: 5 } Project (#3, #4, #1{dst}, #7, #8) // { arity: 5 } - Map ((#6 + integer_to_bigint(#2{w})), false) // { arity: 9 } - Join on=(#0{src} = #5) type=differential // { arity: 7 } + Map ((#6{w} + integer_to_bigint(#2{w})), false) // { arity: 9 } + Join on=(#0{src} = #5{dst}) type=differential // { arity: 7 } implementation - %0:l1[#0]KA » %1:l4[#2]K + %0:l1[#0{src}]KA » %1:l4[#2{dst}]K Get l1 // { arity: 3 } - ArrangeBy keys=[[#2]] // { arity: 4 } + ArrangeBy keys=[[#2{dst}]] // { arity: 4 } Project (#0..=#3) // { arity: 4 } Get l4 // { arity: 5 } Project (#0..=#3, #9) // { arity: 5 } - Map ((#4 OR #8)) // { arity: 10 } + Map ((#4{dead} OR #8)) // { arity: 10 } Join on=(#0 = #5 AND #1 = #6 AND #2 = #7) type=differential // { arity: 9 } implementation %0:l12[#0..=#2]KKK » %1[#0..=#2]KKK @@ -4538,18 +4538,18 @@ Explained Query: Get l5 // { arity: 3 } Get l6 // { arity: 3 } cte l9 = - Reduce aggregates=[min((#0 + #1))] // { arity: 1 } + Reduce aggregates=[min((#0{w} + #1{w}))] // { arity: 1 } Project (#1, #3) // { arity: 2 } Join on=(#0{dst} = #2{dst}) type=differential // { arity: 4 } implementation - %0:l8[#0]Kef » %1:l8[#0]Kef + %0:l8[#0{dst}]Kef » %1:l8[#0{dst}]Kef ArrangeBy keys=[[#0{dst}]] // { arity: 2 } Project (#2{dst}, #3) // { arity: 2 } - Filter (#0 = false) // { arity: 5 } + Filter (#0{dir} = false) // { arity: 5 } Get l8 // { arity: 5 } ArrangeBy keys=[[#0{dst}]] // { arity: 2 } Project (#2{dst}, #3) // { arity: 2 } - Filter (#0 = true) // { arity: 5 } + Filter (#0{dir} = true) // { arity: 5 } Get l8 // { arity: 5 } cte l10 = Project (#1) // { arity: 1 } @@ -4568,7 +4568,7 @@ Explained Query: Project () // { arity: 0 } Join on=(#0{dst} = #1{personid}) type=differential // { arity: 2 } implementation - %0:l3[#0]UK » %1:l2[#0]K + %0:l3[#0{pos}]UK » %1:l2[#0{t}]K ArrangeBy keys=[[#0{dst}]] // { arity: 1 } Get l3 // { arity: 1 } Get l2 // { arity: 1 } @@ -4592,7 +4592,7 @@ Explained Query: ArrangeBy keys=[[]] // { arity: 0 } Get l11 // { arity: 0 } Project (#0..=#3, #7, #8) // { arity: 6 } - Map ((#4 OR coalesce((#3 > #6), false)), (#5 + 1)) // { arity: 9 } + Map ((#4{dead} OR coalesce((#3{w} > #6), false)), (#5{iter} + 1)) // { arity: 9 } CrossJoin type=delta // { arity: 7 } implementation %0:l8 » %1[×]U » %2[×]U @@ -4618,36 +4618,36 @@ Explained Query: With cte l13 = Project (#0..=#3) // { arity: 4 } - Join on=(#4 = #5{max}) type=differential // { arity: 6 } + Join on=(#4{iter} = #5{max}) type=differential // { arity: 6 } implementation - %1[#0]UK » %0:l12[#4]K - ArrangeBy keys=[[#4]] // { arity: 5 } + %1[#0]UK » %0:l12[#4{iter}]K + ArrangeBy keys=[[#4{iter}]] // { arity: 5 } Project (#0..=#3, #5) // { arity: 5 } Get l12 // { arity: 6 } ArrangeBy keys=[[#0{max}]] // { arity: 1 } - Reduce aggregates=[max(#0)] // { arity: 1 } + Reduce aggregates=[max(#0{iter})] // { arity: 1 } Project (#5) // { arity: 1 } Get l12 // { arity: 6 } cte l14 = Project (#1{personid}, #2{min}) // { arity: 2 } - Reduce group_by=[#0{personid}, #2{personid}] aggregates=[min((#1 + #3))] // { arity: 3 } + Reduce group_by=[#0{personid}, #2{personid}] aggregates=[min((#1{w} + #3{w}))] // { arity: 3 } Project (#0{personid}, #2, #3{personid}, #5) // { arity: 4 } Join on=(#1{personid} = #4{personid}) type=differential // { arity: 6 } implementation - %0:l13[#1]Kef » %1:l13[#1]Kef + %0:l13[#1{dst}]Kef » %1:l13[#1{dst}]Kef ArrangeBy keys=[[#1{personid}]] // { arity: 3 } Project (#1{personid}..=#3) // { arity: 3 } - Filter (#0 = false) // { arity: 4 } + Filter (#0{dir} = false) // { arity: 4 } Get l13 // { arity: 4 } ArrangeBy keys=[[#1{personid}]] // { arity: 3 } Project (#1{personid}..=#3) // { arity: 3 } - Filter (#0 = true) // { arity: 4 } + Filter (#0{dir} = true) // { arity: 4 } Get l13 // { arity: 4 } Return // { arity: 2 } Project (#0{personid}, #1{min}) // { arity: 2 } Join on=(#1{min} = #2{min_min}) type=differential // { arity: 3 } implementation - %1[#0]UK » %0:l14[#1]K + %1[#0]UK » %0:l14[#1{w}]K ArrangeBy keys=[[#1{min}]] // { arity: 2 } Get l14 // { arity: 2 } ArrangeBy keys=[[#0{min_min}]] // { arity: 1 } diff --git a/test/sqllogictest/ldbc_bi_eager.slt b/test/sqllogictest/ldbc_bi_eager.slt index 361dcff413135..d1edd49ebc5d3 100644 --- a/test/sqllogictest/ldbc_bi_eager.slt +++ b/test/sqllogictest/ldbc_bi_eager.slt @@ -456,7 +456,7 @@ Explained Query: ReadIndex on=message message_messageid=[*** full scan ***] // { arity: 13 } Return // { arity: 7 } Project (#0..=#2, #4{count}, #7, #5{sum}, #8) // { arity: 7 } - Map ((#5{sum} / bigint_to_numeric(case when (#6{count} = 0) then null else #6{count} end)), (bigint_to_numeric(#4{count}) / #3)) // { arity: 9 } + Map ((#5{sum} / bigint_to_numeric(case when (#6{count} = 0) then null else #6{count} end)), (bigint_to_numeric(#4{count}) / #3{cnt})) // { arity: 9 } Reduce group_by=[#1..=#4] aggregates=[count(*), sum(integer_to_bigint(#0{length})), count(integer_to_bigint(#0{length}))] // { arity: 7 } CrossJoin type=differential // { arity: 5 } implementation @@ -530,7 +530,7 @@ Explained Query: Project (#5{id}, #6{name}) // { arity: 2 } Join on=(#0{id} = #8{typetagclassid}) type=differential // { arity: 9 } implementation - %0:tagclass[#0]KAe » %1:tag[#3]KAe + %0:tagclass[#0{id}]KAe » %1:tag[#3{typetagclassid}]KAe ArrangeBy keys=[[#0{id}]] // { arity: 5 } ReadIndex on=materialize.public.tagclass tagclass_name=[lookup value=("ChristianBishop")] // { arity: 5 } ArrangeBy keys=[[#3{typetagclassid}]] // { arity: 4 } @@ -542,7 +542,7 @@ Explained Query: Project (#1{name}, #3{count}, #4{count}) // { arity: 3 } Join on=(#0{id} = #2{id}) type=differential // { arity: 5 } implementation - %1[#0]UKA » %0:l1[#0]K + %1[#0]UKA » %0:l1[#0{id}]K ArrangeBy keys=[[#0{id}]] // { arity: 2 } Get l1 // { arity: 2 } ArrangeBy keys=[[#0{id}]] // { arity: 3 } @@ -551,9 +551,9 @@ Explained Query: Filter (#4{creationdate} < 2010-12-25 00:00:00 UTC) AND (#4{creationdate} >= 2010-06-08 00:00:00 UTC) // { arity: 17 } Join on=(#0{id} = #3{tagid} AND #2{messageid} = #5{messageid}) type=delta // { arity: 17 } implementation - %0:l1 » %1:message_hastag_tag[#2]KA » %2:message[#1]KAiif - %1:message_hastag_tag » %2:message[#1]KAiif » %0:l1[#0]K - %2:message » %1:message_hastag_tag[#1]KA » %0:l1[#0]K + %0:l1 » %1:message_hastag_tag[#2{tagid}]KA » %2:message[#1{messageid}]KAiif + %1:message_hastag_tag » %2:message[#1{messageid}]KAiif » %0:l1[#0{id}]K + %2:message » %1:message_hastag_tag[#1{messageid}]KA » %0:l1[#0{id}]K ArrangeBy keys=[[#0{id}]] // { arity: 1 } Project (#0{id}) // { arity: 1 } Get l1 // { arity: 2 } @@ -563,7 +563,7 @@ Explained Query: ReadIndex on=message message_messageid=[delta join lookup] // { arity: 13 } Return // { arity: 4 } Project (#0{name}, #3..=#5) // { arity: 4 } - Map (coalesce(#1{count}, 0), coalesce(#2{count}, 0), abs((#3 - #4))) // { arity: 6 } + Map (coalesce(#1{count}, 0), coalesce(#2{count}, 0), abs((#3{?column?} - #4{?column?}))) // { arity: 6 } Union // { arity: 3 } Map (null, null) // { arity: 3 } Union // { arity: 1 } @@ -628,12 +628,12 @@ Explained Query: Filter (#33{name} = "China") AND (#16{moderatorpersonid}) IS NOT NULL AND (#31{partofcountryid}) IS NOT NULL // { arity: 37 } Join on=(#1{messageid} = #36{messageid} AND #10{containerforumid} = #14{id} AND #16{moderatorpersonid} = #18{id} AND #25{locationcityid} = #28{id} AND #31{partofcountryid} = #32{id}) type=delta // { arity: 37 } implementation - %0:message » %5[#0]UKA » %1:forum[#1]KA » %2:person[#1]KA » %3:city[#0]KA » %4:country[#0]KAef - %1:forum » %0:message[#10]KA » %5[#0]UKA » %2:person[#1]KA » %3:city[#0]KA » %4:country[#0]KAef - %2:person » %1:forum[#3]KA » %0:message[#10]KA » %5[#0]UKA » %3:city[#0]KA » %4:country[#0]KAef - %3:city » %4:country[#0]KAef » %2:person[#8]KA » %1:forum[#3]KA » %0:message[#10]KA » %5[#0]UKA - %4:country » %3:city[#3]KA » %2:person[#8]KA » %1:forum[#3]KA » %0:message[#10]KA » %5[#0]UKA - %5 » %0:message[#1]KA » %1:forum[#1]KA » %2:person[#1]KA » %3:city[#0]KA » %4:country[#0]KAef + %0:message » %5[#0]UKA » %1:forum[#1{id}]KA » %2:person[#1{id}]KA » %3:city[#0{id}]KA » %4:country[#0{id}]KAef + %1:forum » %0:message[#10{containerforumid}]KA » %5[#0]UKA » %2:person[#1{id}]KA » %3:city[#0{id}]KA » %4:country[#0{id}]KAef + %2:person » %1:forum[#3{moderatorpersonid}]KA » %0:message[#10{containerforumid}]KA » %5[#0]UKA » %3:city[#0{id}]KA » %4:country[#0{id}]KAef + %3:city » %4:country[#0{id}]KAef » %2:person[#8{locationcityid}]KA » %1:forum[#3{moderatorpersonid}]KA » %0:message[#10{containerforumid}]KA » %5[#0]UKA + %4:country » %3:city[#3{partofcountryid}]KA » %2:person[#8{locationcityid}]KA » %1:forum[#3{moderatorpersonid}]KA » %0:message[#10{containerforumid}]KA » %5[#0]UKA + %5 » %0:message[#1{messageid}]KA » %1:forum[#1{id}]KA » %2:person[#1{id}]KA » %3:city[#0{id}]KA » %4:country[#0{id}]KAef ArrangeBy keys=[[#1{messageid}], [#10{containerforumid}]] // { arity: 13 } ReadIndex on=message message_messageid=[delta join 1st input (full scan)] message_containerforumid=[delta join lookup] // { arity: 13 } ArrangeBy keys=[[#1{id}], [#3{moderatorpersonid}]] // { arity: 4 } @@ -649,9 +649,9 @@ Explained Query: Project (#10{messageid}) // { arity: 1 } Join on=(#0{id} = #8{typetagclassid} AND #5{id} = #11{tagid}) type=delta // { arity: 12 } implementation - %0:tagclass » %1:tag[#3]KA » %2:message_hastag_tag[#2]KA - %1:tag » %0:tagclass[#0]KAe » %2:message_hastag_tag[#2]KA - %2:message_hastag_tag » %1:tag[#0]KA » %0:tagclass[#0]KAe + %0:tagclass » %1:tag[#3{typetagclassid}]KA » %2:message_hastag_tag[#2{tagid}]KA + %1:tag » %0:tagclass[#0{id}]KAe » %2:message_hastag_tag[#2{tagid}]KA + %2:message_hastag_tag » %1:tag[#0{id}]KA » %0:tagclass[#0{id}]KAe ArrangeBy keys=[[#0{id}]] // { arity: 5 } ReadIndex on=materialize.public.tagclass tagclass_name=[lookup value=("Philosopher")] // { arity: 5 } ArrangeBy keys=[[#0{id}], [#3{typetagclassid}]] // { arity: 4 } @@ -760,7 +760,7 @@ Explained Query: Project (#0{creationdate}..=#3{lastname}) // { arity: 4 } Join on=(#1{id} = #11{personid}) type=differential // { arity: 12 } implementation - %1[#0]UKA » %0:person[#1]KA + %1[#0]UKA » %0:person[#1{id}]KA ArrangeBy keys=[[#1{id}]] // { arity: 11 } ReadIndex on=person person_id=[differential join] // { arity: 11 } ArrangeBy keys=[[#0{personid}]] // { arity: 1 } @@ -768,7 +768,7 @@ Explained Query: Project (#3{personid}) // { arity: 1 } Join on=(#0{id} = #2{forumid}) type=differential // { arity: 4 } implementation - %1:forum_hasmember_person[#1]KA » %0:l0[#0]K + %1:forum_hasmember_person[#1{forumid}]KA » %0:l0[#0{id}]K ArrangeBy keys=[[#0{id}]] // { arity: 1 } Get l0 // { arity: 1 } ArrangeBy keys=[[#1{forumid}]] // { arity: 3 } @@ -780,9 +780,9 @@ Explained Query: Project (#0{creationdate}..=#3{lastname}, #5{messageid}) // { arity: 5 } Join on=(#1{id} = #13{creatorpersonid} AND #14{containerforumid} = #17{id}) type=delta // { arity: 18 } implementation - %0:l2 » %1:message[#9]KA » %2[#0]UKA - %1:message » %2[#0]UKA » %0:l2[#1]K - %2 » %1:message[#10]KA » %0:l2[#1]K + %0:l2 » %1:message[#9{creatorpersonid}]KA » %2[#0]UKA + %1:message » %2[#0]UKA » %0:l2[#1{id}]K + %2 » %1:message[#10{containerforumid}]KA » %0:l2[#1{id}]K Get l2 // { arity: 4 } ArrangeBy keys=[[#9{creatorpersonid}], [#10{containerforumid}]] // { arity: 13 } ReadIndex on=message message_containerforumid=[delta join lookup] message_creatorpersonid=[delta join lookup] // { arity: 13 } @@ -798,7 +798,7 @@ Explained Query: Project (#0{creationdate}..=#3{lastname}) // { arity: 4 } Join on=(#1{id} = #4{id}) type=differential // { arity: 5 } implementation - %1[#0]UKA » %0:l2[#1]K + %1[#0]UKA » %0:l2[#1{id}]K Get l2 // { arity: 4 } ArrangeBy keys=[[#0{id}]] // { arity: 1 } Distinct project=[#0{id}] // { arity: 1 } @@ -857,9 +857,9 @@ Explained Query: Project (#1{name}, #5{messageid}, #16{creatorpersonid}) // { arity: 3 } Join on=(#0{id} = #6{tagid} AND #5{messageid} = #8{messageid}) type=delta // { arity: 20 } implementation - %0:tag » %1:message_hastag_tag[#2]KA » %2:message[#1]KA - %1:message_hastag_tag » %0:tag[#0]KA » %2:message[#1]KA - %2:message » %1:message_hastag_tag[#1]KA » %0:tag[#0]KA + %0:tag » %1:message_hastag_tag[#2{tagid}]KA » %2:message[#1{messageid}]KA + %1:message_hastag_tag » %0:tag[#0{id}]KA » %2:message[#1{messageid}]KA + %2:message » %1:message_hastag_tag[#1{messageid}]KA » %0:tag[#0{id}]KA ArrangeBy keys=[[#0{id}]] // { arity: 4 } ReadIndex on=tag tag_id=[delta join 1st input (full scan)] // { arity: 4 } ArrangeBy keys=[[#1{messageid}], [#2{tagid}]] // { arity: 3 } @@ -984,9 +984,9 @@ Explained Query: Project (#6{messageid}, #17{creatorpersonid}) // { arity: 2 } Join on=(#0{id} = #7{tagid} AND #6{messageid} = #9{messageid}) type=delta // { arity: 21 } implementation - %0:tag » %1:message_hastag_tag[#2]KA » %2:message[#1]KA - %1:message_hastag_tag » %0:tag[#0]KAe » %2:message[#1]KA - %2:message » %1:message_hastag_tag[#1]KA » %0:tag[#0]KAe + %0:tag » %1:message_hastag_tag[#2{tagid}]KA » %2:message[#1{messageid}]KA + %1:message_hastag_tag » %0:tag[#0{id}]KAe » %2:message[#1{messageid}]KA + %2:message » %1:message_hastag_tag[#1{messageid}]KA » %0:tag[#0{id}]KAe ArrangeBy keys=[[#0{id}]] // { arity: 5 } ReadIndex on=materialize.public.tag tag_name=[lookup value=("Bob_Geldof")] // { arity: 5 } ArrangeBy keys=[[#1{messageid}], [#2{tagid}]] // { arity: 3 } @@ -1000,7 +1000,7 @@ Explained Query: Project (#0{messageid}, #1{creatorpersonid}, #3{personid}) // { arity: 3 } Join on=(#0{messageid} = #4{messageid}) type=differential // { arity: 5 } implementation - %1:person_likes_message[#2]KA » %0:l1[#0]K + %1:person_likes_message[#2{messageid}]KA » %0:l1[#0{messageid}]K Get l1 // { arity: 2 } ArrangeBy keys=[[#2{messageid}]] // { arity: 3 } ReadIndex on=person_likes_message person_likes_message_messageid=[differential join] // { arity: 3 } @@ -1013,7 +1013,7 @@ Explained Query: Project (#1{creatorpersonid}) // { arity: 1 } Join on=(#0{messageid} = #2{messageid}) type=differential // { arity: 3 } implementation - %1[#0]UKA » %0:l1[#0]K + %1[#0]UKA » %0:l1[#0{messageid}]K Get l1 // { arity: 2 } ArrangeBy keys=[[#0{messageid}]] // { arity: 1 } Distinct project=[#0{messageid}] // { arity: 1 } @@ -1027,7 +1027,7 @@ Explained Query: Project (#0{creatorpersonid}, #3{popularityscore}) // { arity: 2 } Join on=(#1{personid} = #2{person2id}) type=differential // { arity: 4 } implementation - %1:popularityscoreq06[#0]UKA » %0:l3[#1]K + %1:popularityscoreq06[#0]UKA » %0:l3[#1{person2id}]K ArrangeBy keys=[[#1{personid}]] // { arity: 2 } Filter (#1{personid}) IS NOT NULL // { arity: 2 } Get l3 // { arity: 2 } @@ -1090,9 +1090,9 @@ Explained Query: Project (#6{messageid}, #17{creatorpersonid}) // { arity: 2 } Join on=(#0{id} = #7{tagid} AND #6{messageid} = #9{messageid}) type=delta // { arity: 21 } implementation - %0:tag » %1:message_hastag_tag[#2]KA » %2:message[#1]KA - %1:message_hastag_tag » %0:tag[#0]KAe » %2:message[#1]KA - %2:message » %1:message_hastag_tag[#1]KA » %0:tag[#0]KAe + %0:tag » %1:message_hastag_tag[#2{tagid}]KA » %2:message[#1{messageid}]KA + %1:message_hastag_tag » %0:tag[#0{id}]KAe » %2:message[#1{messageid}]KA + %2:message » %1:message_hastag_tag[#1{messageid}]KA » %0:tag[#0{id}]KAe ArrangeBy keys=[[#0{id}]] // { arity: 5 } ReadIndex on=materialize.public.tag tag_name=[lookup value=("Bob_Geldof")] // { arity: 5 } ArrangeBy keys=[[#1{messageid}], [#2{tagid}]] // { arity: 3 } @@ -1106,7 +1106,7 @@ Explained Query: Project (#0{messageid}, #1{creatorpersonid}, #3{personid}) // { arity: 3 } Join on=(#0{messageid} = #4{messageid}) type=differential // { arity: 5 } implementation - %1:person_likes_message[#2]KA » %0:l1[#0]K + %1:person_likes_message[#2{messageid}]KA » %0:l1[#0{messageid}]K Get l1 // { arity: 2 } ArrangeBy keys=[[#2{messageid}]] // { arity: 3 } ReadIndex on=person_likes_message person_likes_message_messageid=[differential join] // { arity: 3 } @@ -1119,7 +1119,7 @@ Explained Query: Project (#1{creatorpersonid}) // { arity: 1 } Join on=(#0{messageid} = #2{messageid}) type=differential // { arity: 3 } implementation - %1[#0]UKA » %0:l1[#0]K + %1[#0]UKA » %0:l1[#0{messageid}]K Get l1 // { arity: 2 } ArrangeBy keys=[[#0{messageid}]] // { arity: 1 } Distinct project=[#0{messageid}] // { arity: 1 } @@ -1133,7 +1133,7 @@ Explained Query: Project (#0{creatorpersonid}, #3{popularityscore}) // { arity: 2 } Join on=(#1{personid} = #2{person2id}) type=differential // { arity: 4 } implementation - %1:popularityscoreq06[#0]UKA » %0:l3[#1]K + %1:popularityscoreq06[#0]UKA » %0:l3[#1{person2id}]K ArrangeBy keys=[[#1{personid}]] // { arity: 2 } Filter (#1{personid}) IS NOT NULL // { arity: 2 } Get l3 // { arity: 2 } @@ -1197,9 +1197,9 @@ Explained Query: Project (#1{name}, #5{messageid}, #16{creatorpersonid}) // { arity: 3 } Join on=(#0{id} = #6{tagid} AND #5{messageid} = #8{messageid}) type=delta // { arity: 20 } implementation - %0:tag » %1:message_hastag_tag[#2]KA » %2:message[#1]KA - %1:message_hastag_tag » %0:tag[#0]KA » %2:message[#1]KA - %2:message » %1:message_hastag_tag[#1]KA » %0:tag[#0]KA + %0:tag » %1:message_hastag_tag[#2{tagid}]KA » %2:message[#1{messageid}]KA + %1:message_hastag_tag » %0:tag[#0{id}]KA » %2:message[#1{messageid}]KA + %2:message » %1:message_hastag_tag[#1{messageid}]KA » %0:tag[#0{id}]KA ArrangeBy keys=[[#0{id}]] // { arity: 4 } ReadIndex on=tag tag_id=[delta join 1st input (full scan)] // { arity: 4 } ArrangeBy keys=[[#1{messageid}], [#2{tagid}]] // { arity: 3 } @@ -1210,7 +1210,7 @@ Explained Query: Project (#0{name}..=#2{creatorpersonid}, #4{personid}) // { arity: 4 } Join on=(#1{messageid} = #5{messageid}) type=differential // { arity: 6 } implementation - %1:person_likes_message[#2]KA » %0:l0[#1]K + %1:person_likes_message[#2{messageid}]KA » %0:l0[#1{messageid}]K ArrangeBy keys=[[#1{messageid}]] // { arity: 3 } Get l0 // { arity: 3 } ArrangeBy keys=[[#2{messageid}]] // { arity: 3 } @@ -1228,7 +1228,7 @@ Explained Query: Project (#1{creatorpersonid}) // { arity: 1 } Join on=(#0{messageid} = #2{messageid}) type=differential // { arity: 3 } implementation - %1[#0]UKA » %0:l2[#0]Kef + %1[#0]UKA » %0:l2[#0{messageid}]Kef ArrangeBy keys=[[#0{messageid}]] // { arity: 2 } Get l2 // { arity: 2 } ArrangeBy keys=[[#0{messageid}]] // { arity: 1 } @@ -1244,7 +1244,7 @@ Explained Query: Project (#0{creatorpersonid}, #3{popularityscore}) // { arity: 2 } Join on=(#1{personid} = #2{person2id}) type=differential // { arity: 4 } implementation - %1:popularityscoreq06[#0]UKA » %0:l3[#1]K + %1:popularityscoreq06[#0]UKA » %0:l3[#1{person2id}]K ArrangeBy keys=[[#1{personid}]] // { arity: 2 } Filter (#1{personid}) IS NOT NULL // { arity: 2 } Get l3 // { arity: 2 } @@ -1314,7 +1314,7 @@ Explained Query: Project (#1{messageid}) // { arity: 1 } Join on=(#2{tagid} = #3{id}) type=differential // { arity: 8 } implementation - %1:tag[#0]KAe » %0:message_hastag_tag[#2]KAe + %1:tag[#0{id}]KAe » %0:message_hastag_tag[#2{tagid}]KAe ArrangeBy keys=[[#2{tagid}]] // { arity: 3 } ReadIndex on=message_hastag_tag message_hastag_tag_tagid=[differential join] // { arity: 3 } ArrangeBy keys=[[#0{id}]] // { arity: 5 } @@ -1323,10 +1323,10 @@ Explained Query: Project (#2{messageid}, #18{name}) // { arity: 2 } Join on=(#0{messageid} = #13{parentmessageid} AND #2{messageid} = #15{messageid} AND #16{tagid} = #17{id}) type=delta // { arity: 21 } implementation - %0:l0 » %1:message[#12]KA » %2:message_hastag_tag[#1]KA » %3:tag[#0]KA - %1:message » %2:message_hastag_tag[#1]KA » %3:tag[#0]KA » %0:l0[#0]K - %2:message_hastag_tag » %1:message[#1]KA » %3:tag[#0]KA » %0:l0[#0]K - %3:tag » %2:message_hastag_tag[#2]KA » %1:message[#1]KA » %0:l0[#0]K + %0:l0 » %1:message[#12{parentmessageid}]KA » %2:message_hastag_tag[#1{messageid}]KA » %3:tag[#0{id}]KA + %1:message » %2:message_hastag_tag[#1{messageid}]KA » %3:tag[#0{id}]KA » %0:l0[#0{messageid}]K + %2:message_hastag_tag » %1:message[#1{messageid}]KA » %3:tag[#0{id}]KA » %0:l0[#0{messageid}]K + %3:tag » %2:message_hastag_tag[#2{tagid}]KA » %1:message[#1{messageid}]KA » %0:l0[#0{messageid}]K ArrangeBy keys=[[#0{messageid}]] // { arity: 1 } Get l0 // { arity: 1 } ArrangeBy keys=[[#1{messageid}], [#12{parentmessageid}]] // { arity: 13 } @@ -1439,9 +1439,9 @@ Explained Query: Project (#1{id}) // { arity: 1 } Join on=(#1{id} = #11{personid} AND #12{tagid} = #13{id}) type=delta // { arity: 18 } implementation - %0:l0 » %1:person_hasinterest_tag[#0]K » %2:l1[#0]KAe - %1:person_hasinterest_tag » %2:l1[#0]KAe » %0:l0[#1]KA - %2:l1 » %1:person_hasinterest_tag[#1]KA » %0:l0[#1]KA + %0:l0 » %1:person_hasinterest_tag[#0{personid}]K » %2:l1[#0{id}]KAe + %1:person_hasinterest_tag » %2:l1[#0{id}]KAe » %0:l0[#1{id}]KA + %2:l1 » %1:person_hasinterest_tag[#1{tagid}]KA » %0:l0[#1{id}]KA Get l0 // { arity: 11 } ArrangeBy keys=[[#0{personid}], [#1{tagid}]] // { arity: 2 } Project (#1{personid}, #2{tagid}) // { arity: 2 } @@ -1453,10 +1453,10 @@ Explained Query: Filter (#8{creationdate} < 2010-06-28 00:00:00 UTC) AND (2010-06-14 00:00:00 UTC < #8{creationdate}) // { arity: 32 } Join on=(#0{id} = #7{tagid} AND #6{messageid} = #9{messageid} AND #17{creatorpersonid} = #22{id}) type=delta // { arity: 32 } implementation - %0:l1 » %1:message_hastag_tag[#2]KA » %2:message[#1]KAiif » %3:l0[#1]KA - %1:message_hastag_tag » %0:l1[#0]KAe » %2:message[#1]KAiif » %3:l0[#1]KA - %2:message » %1:message_hastag_tag[#1]KA » %0:l1[#0]KAe » %3:l0[#1]KA - %3:l0 » %2:message[#9]KAiif » %1:message_hastag_tag[#1]KA » %0:l1[#0]KAe + %0:l1 » %1:message_hastag_tag[#2{tagid}]KA » %2:message[#1{messageid}]KAiif » %3:l0[#1{id}]KA + %1:message_hastag_tag » %0:l1[#0{id}]KAe » %2:message[#1{messageid}]KAiif » %3:l0[#1{id}]KA + %2:message » %1:message_hastag_tag[#1{messageid}]KA » %0:l1[#0{id}]KAe » %3:l0[#1{id}]KA + %3:l0 » %2:message[#9{creatorpersonid}]KAiif » %1:message_hastag_tag[#1{messageid}]KA » %0:l1[#0{id}]KAe Get l1 // { arity: 5 } ArrangeBy keys=[[#1{messageid}], [#2{tagid}]] // { arity: 3 } ReadIndex on=message_hastag_tag message_hastag_tag_messageid=[delta join lookup] message_hastag_tag_tagid=[delta join lookup] // { arity: 3 } @@ -1470,7 +1470,7 @@ Explained Query: Project (#0{id}, #2{count}) // { arity: 2 } Join on=(#0{id} = #1{creatorpersonid}) type=differential // { arity: 3 } implementation - %1:l4[#0]UKA » %0:l2[#0]K + %1:l4[#0{personid}]UKA » %0:l2[#0{personid}]K ArrangeBy keys=[[#0{id}]] // { arity: 1 } Get l2 // { arity: 1 } Get l4 // { arity: 2 } @@ -1488,7 +1488,7 @@ Explained Query: Project (#0{creatorpersonid}, #1{count}) // { arity: 2 } Join on=(#0{creatorpersonid} = #2{id}) type=differential // { arity: 3 } implementation - %0:l4[#0]UKA » %1[#0]UKA + %0:l4[#0{personid}]UKA » %1[#0]UKA Get l4 // { arity: 2 } ArrangeBy keys=[[#0{id}]] // { arity: 1 } Distinct project=[#0{id}] // { arity: 1 } @@ -1502,7 +1502,7 @@ Explained Query: Project (#0{id}, #0{id}, #1{count}) // { arity: 3 } Get l5 // { arity: 2 } Return // { arity: 5 } - Map (coalesce(#2{sum}, 0), (bigint_to_numeric(#1) + #3)) // { arity: 5 } + Map (coalesce(#2{sum}, 0), (bigint_to_numeric(#1{score}) + #3{?column?})) // { arity: 5 } Reduce group_by=[#0, #1] aggregates=[sum(case when (#3) IS NULL then null else #2 end)] // { arity: 3 } Project (#0, #1, #6, #7) // { arity: 4 } Join on=(#0 = #2{person1id} AND #5{person2id} = case when (#4) IS NULL then null else #3{person2id} end) type=delta // { arity: 8 } @@ -1594,9 +1594,9 @@ Explained Query: Filter (#23{parentmessageid}) IS NULL AND (#11{creationdate} <= 2012-11-24 00:00:00 UTC) AND (#11{creationdate} >= 2012-08-29 00:00:00 UTC) // { arity: 26 } Join on=(#1{id} = #20{creatorpersonid} AND #12{messageid} = #24{rootpostid}) type=delta // { arity: 26 } implementation - %0:person » %1:message[#9]KAniif » %2[#0]UKA - %1:message » %2[#0]UKA » %0:person[#1]KA - %2 » %1:message[#1]KAniif » %0:person[#1]KA + %0:person » %1:message[#9{creatorpersonid}]KAniif » %2[#0]UKA + %1:message » %2[#0]UKA » %0:person[#1{id}]KA + %2 » %1:message[#1{messageid}]KAniif » %0:person[#1{id}]KA ArrangeBy keys=[[#1{id}]] // { arity: 11 } ReadIndex on=person person_id=[delta join 1st input (full scan)] // { arity: 11 } ArrangeBy keys=[[#1{messageid}], [#9{creatorpersonid}]] // { arity: 13 } @@ -1713,7 +1713,7 @@ Explained Query: Project (#6{person2id}) // { arity: 1 } Join on=(#2{person2id} = #5{person1id}) type=differential // { arity: 7 } implementation - %0:l1[#2]KAe » %1:l0[#1]KAe + %0:l1[#2{person2id}]KAe » %1:l0[#1{person1id}]KAe ArrangeBy keys=[[#2{person2id}]] // { arity: 4 } Get l1 // { arity: 4 } Get l0 // { arity: 3 } @@ -1722,12 +1722,12 @@ Explained Query: Project (#0{person2id}, #9{name}) // { arity: 2 } Join on=(#0{person2id} = #1{id} = #2{creatorpersonid} AND #3{messageid} = #4{messageid} = #6{messageid} AND #7{tagid} = #8{id}) type=delta // { arity: 12 } implementation - %0 » %1[#0]UKA » %2[#0]K » %3[#0]UKA » %4:message_hastag_tag[#1]KA » %5:tag[#0]KA - %1 » %0[#0]UKA » %2[#0]K » %3[#0]UKA » %4:message_hastag_tag[#1]KA » %5:tag[#0]KA - %2 » %0[#0]UKA » %1[#0]UKA » %3[#0]UKA » %4:message_hastag_tag[#1]KA » %5:tag[#0]KA - %3 » %4:message_hastag_tag[#1]KA » %5:tag[#0]KA » %2[#1]K » %0[#0]UKA » %1[#0]UKA - %4:message_hastag_tag » %3[#0]UKA » %5:tag[#0]KA » %2[#1]K » %0[#0]UKA » %1[#0]UKA - %5:tag » %4:message_hastag_tag[#2]KA » %3[#0]UKA » %2[#1]K » %0[#0]UKA » %1[#0]UKA + %0 » %1[#0]UKA » %2[#0]K » %3[#0]UKA » %4:message_hastag_tag[#1{messageid}]KA » %5:tag[#0{id}]KA + %1 » %0[#0]UKA » %2[#0]K » %3[#0]UKA » %4:message_hastag_tag[#1{messageid}]KA » %5:tag[#0{id}]KA + %2 » %0[#0]UKA » %1[#0]UKA » %3[#0]UKA » %4:message_hastag_tag[#1{messageid}]KA » %5:tag[#0{id}]KA + %3 » %4:message_hastag_tag[#1{messageid}]KA » %5:tag[#0{id}]KA » %2[#1]K » %0[#0]UKA » %1[#0]UKA + %4:message_hastag_tag » %3[#0]UKA » %5:tag[#0{id}]KA » %2[#1]K » %0[#0]UKA » %1[#0]UKA + %5:tag » %4:message_hastag_tag[#2{tagid}]KA » %3[#0]UKA » %2[#1]K » %0[#0]UKA » %1[#0]UKA ArrangeBy keys=[[#0{person2id}]] // { arity: 1 } Distinct project=[#0{person2id}] // { arity: 1 } Threshold // { arity: 1 } @@ -1736,9 +1736,9 @@ Explained Query: Project (#6{person2id}) // { arity: 1 } Join on=(#0{person2id} = #2{person1id} AND #3{person2id} = #5{person1id}) type=delta // { arity: 7 } implementation - %0:l2 » %1:person_knows_person[#1]KA » %2:l0[#1]KA - %1:person_knows_person » %0:l2[#0]UKA » %2:l0[#1]KA - %2:l0 » %1:person_knows_person[#2]KA » %0:l2[#0]UKA + %0:l2 » %1:person_knows_person[#1{person1id}]KA » %2:l0[#1{person1id}]KA + %1:person_knows_person » %0:l2[#0]UKA » %2:l0[#1{person1id}]KA + %2:l0 » %1:person_knows_person[#2{person2id}]KA » %0:l2[#0]UKA ArrangeBy keys=[[#0{person2id}]] // { arity: 1 } Get l2 // { arity: 1 } ArrangeBy keys=[[#1{person1id}], [#2{person2id}]] // { arity: 3 } @@ -1752,9 +1752,9 @@ Explained Query: Filter (#16{name} = "Italy") AND (#1{id}) IS NOT NULL AND (#14{partofcountryid}) IS NOT NULL // { arity: 19 } Join on=(#8{locationcityid} = #11{id} AND #14{partofcountryid} = #15{id}) type=delta // { arity: 19 } implementation - %0:person » %1:city[#0]KA » %2:country[#0]KAef - %1:city » %2:country[#0]KAef » %0:person[#8]KA - %2:country » %1:city[#3]KA » %0:person[#8]KA + %0:person » %1:city[#0{id}]KA » %2:country[#0{id}]KAef + %1:city » %2:country[#0{id}]KAef » %0:person[#8{locationcityid}]KA + %2:country » %1:city[#3{partofcountryid}]KA » %0:person[#8{locationcityid}]KA ArrangeBy keys=[[#8{locationcityid}]] // { arity: 11 } ReadIndex on=person person_locationcityid=[delta join 1st input (full scan)] // { arity: 11 } ArrangeBy keys=[[#0{id}], [#3{partofcountryid}]] // { arity: 4 } @@ -1770,9 +1770,9 @@ Explained Query: Project (#1{messageid}) // { arity: 1 } Join on=(#2{tagid} = #3{id} AND #6{typetagclassid} = #7{id}) type=delta // { arity: 12 } implementation - %0:message_hastag_tag » %1:tag[#0]KA » %2:tagclass[#0]KAe - %1:tag » %2:tagclass[#0]KAe » %0:message_hastag_tag[#2]KA - %2:tagclass » %1:tag[#3]KA » %0:message_hastag_tag[#2]KA + %0:message_hastag_tag » %1:tag[#0{id}]KA » %2:tagclass[#0{id}]KAe + %1:tag » %2:tagclass[#0{id}]KAe » %0:message_hastag_tag[#2{tagid}]KA + %2:tagclass » %1:tag[#3{typetagclassid}]KA » %0:message_hastag_tag[#2{tagid}]KA ArrangeBy keys=[[#2{tagid}]] // { arity: 3 } ReadIndex on=message_hastag_tag message_hastag_tag_tagid=[delta join 1st input (full scan)] // { arity: 3 } ArrangeBy keys=[[#0{id}], [#3{typetagclassid}]] // { arity: 4 } @@ -1847,10 +1847,10 @@ Explained Query: Filter (#16{name} = "India") AND (#19{creationdate} <= 2013-01-10 00:00:00 UTC) AND (2012-09-28 00:00:00 UTC <= #19{creationdate}) AND (#14{partofcountryid}) IS NOT NULL // { arity: 22 } Join on=(#1{id} = #20{person1id} AND #8{locationcityid} = #11{id} AND #14{partofcountryid} = #15{id}) type=delta // { arity: 22 } implementation - %0:person » %3:person_knows_person[#1]KAiif » %1:city[#0]KA » %2:country[#0]KAef - %1:city » %2:country[#0]KAef » %0:person[#8]KA » %3:person_knows_person[#1]KAiif - %2:country » %1:city[#3]KA » %0:person[#8]KA » %3:person_knows_person[#1]KAiif - %3:person_knows_person » %0:person[#1]KA » %1:city[#0]KA » %2:country[#0]KAef + %0:person » %3:person_knows_person[#1{person1id}]KAiif » %1:city[#0{id}]KA » %2:country[#0{id}]KAef + %1:city » %2:country[#0{id}]KAef » %0:person[#8{locationcityid}]KA » %3:person_knows_person[#1{person1id}]KAiif + %2:country » %1:city[#3{partofcountryid}]KA » %0:person[#8{locationcityid}]KA » %3:person_knows_person[#1{person1id}]KAiif + %3:person_knows_person » %0:person[#1{id}]KA » %1:city[#0{id}]KA » %2:country[#0{id}]KAef ArrangeBy keys=[[#1{id}], [#8{locationcityid}]] // { arity: 11 } ReadIndex on=person person_id=[delta join 1st input (full scan)] person_locationcityid=[delta join lookup] // { arity: 11 } ArrangeBy keys=[[#0{id}], [#3{partofcountryid}]] // { arity: 4 } @@ -1867,7 +1867,7 @@ Explained Query: Project () // { arity: 0 } Join on=(#0{id} = #5{person2id} AND #1{person2id} = #2{id} AND #3{person2id} = #4{id}) type=differential // { arity: 6 } implementation - %0:l1[#1]Kf » %1:l1[#0]Kf » %2:l0[#0, #1]KKf + %0:l1[#1{friendid}]Kf » %1:l1[#0{personid}]Kf » %2:l0[#0{personid}, #1{friendid}]KKf ArrangeBy keys=[[#1{person2id}]] // { arity: 2 } Get l1 // { arity: 2 } ArrangeBy keys=[[#0{id}]] // { arity: 2 } @@ -1944,7 +1944,7 @@ Explained Query: Filter (#19{length} < 120) AND (#11{creationdate} > 2012-06-03 00:00:00 UTC) AND (#15{content}) IS NOT NULL // { arity: 25 } Join on=(#1{id} = #20{creatorpersonid}) type=differential // { arity: 25 } implementation - %1:message[#9]KAeiif » %0:l0[#1]KAeiif + %1:message[#9{creatorpersonid}]KAeiif » %0:l0[#1{id}]KAeiif Get l0 // { arity: 11 } ArrangeBy keys=[[#9{creatorpersonid}]] // { arity: 14 } ReadIndex on=materialize.public.message message_rootpostlanguage=[lookup values=[("es"); ("pt"); ("ta")]] // { arity: 14 } @@ -1959,7 +1959,7 @@ Explained Query: Project (#1{id}) // { arity: 1 } Join on=(#1{id} = #11{id}) type=differential // { arity: 12 } implementation - %1[#0]UKA » %0:l0[#1]KA + %1[#0]UKA » %0:l0[#1{id}]KA Get l0 // { arity: 11 } ArrangeBy keys=[[#0{id}]] // { arity: 1 } Distinct project=[#0{id}] // { arity: 1 } @@ -2025,7 +2025,7 @@ Explained Query: ArrangeBy keys=[[#0{rootpostlanguage}]] // { arity: 1 } Distinct project=[#0{rootpostlanguage}] // { arity: 1 } Project (#0{rootpostlanguage}) // { arity: 1 } - Filter (#0{rootpostlanguage} = varchar_to_text(#1)) // { arity: 2 } + Filter (#0{rootpostlanguage} = varchar_to_text(#1{right_col0_0})) // { arity: 2 } FlatMap unnest_array({"es", "ta", "pt"}) // { arity: 2 } Distinct project=[#0{rootpostlanguage}] // { arity: 1 } Project (#13{rootpostlanguage}) // { arity: 1 } @@ -2109,9 +2109,9 @@ Explained Query: Filter (#1{name} = "India") AND (#8{creationdate} < 2012-11-09 00:00:00 UTC) AND (#0{id}) IS NOT NULL // { arity: 19 } Join on=(#0{id} = #7{partofcountryid} AND #4{id} = #16{locationcityid}) type=delta // { arity: 19 } implementation - %0:country » %1:city[#3]KA » %2:person[#8]KAif - %1:city » %0:country[#0]KAef » %2:person[#8]KAif - %2:person » %1:city[#0]KA » %0:country[#0]KAef + %0:country » %1:city[#3{partofcountryid}]KA » %2:person[#8{locationcityid}]KAif + %1:city » %0:country[#0{id}]KAef » %2:person[#8{locationcityid}]KAif + %2:person » %1:city[#0{id}]KA » %0:country[#0{id}]KAef ArrangeBy keys=[[#0{id}]] // { arity: 4 } ReadIndex on=country country_id=[delta join 1st input (full scan)] // { arity: 4 } ArrangeBy keys=[[#0{id}], [#3{partofcountryid}]] // { arity: 4 } @@ -2123,7 +2123,7 @@ Explained Query: Filter (#16{creationdate} <= 2012-11-09 00:00:00 UTC) AND (#16{creationdate} >= #6{creationdate}) // { arity: 29 } Join on=(#7{id} = #25{creatorpersonid}) type=differential // { arity: 29 } implementation - %1:message[#9]KAif » %0:l0[#7]Kif + %1:message[#9{creatorpersonid}]KAif » %0:l0[#7{id}]Kif ArrangeBy keys=[[#7{id}]] // { arity: 16 } Filter (#7{id}) IS NOT NULL // { arity: 16 } Get l0 // { arity: 16 } @@ -2164,10 +2164,10 @@ Explained Query: Filter (#0{creationdate} < 2012-11-09 00:00:00 UTC) // { arity: 28 } Join on=(#1{id} = #12{personid} AND #13{messageid} = #15{messageid} AND #23{creatorpersonid} = #27{id}) type=delta // { arity: 28 } implementation - %0:person » %1:person_likes_message[#1]KA » %2:message[#1]KA » %3:l4[#0]K - %1:person_likes_message » %0:person[#1]KAif » %2:message[#1]KA » %3:l4[#0]K - %2:message » %1:person_likes_message[#2]KA » %0:person[#1]KAif » %3:l4[#0]K - %3:l4 » %2:message[#9]KA » %1:person_likes_message[#2]KA » %0:person[#1]KAif + %0:person » %1:person_likes_message[#1{personid}]KA » %2:message[#1{messageid}]KA » %3:l4[#0{zombieid}]K + %1:person_likes_message » %0:person[#1{id}]KAif » %2:message[#1{messageid}]KA » %3:l4[#0{zombieid}]K + %2:message » %1:person_likes_message[#2{messageid}]KA » %0:person[#1{id}]KAif » %3:l4[#0{zombieid}]K + %3:l4 » %2:message[#9{creatorpersonid}]KA » %1:person_likes_message[#2{messageid}]KA » %0:person[#1{id}]KAif ArrangeBy keys=[[#1{id}]] // { arity: 11 } ReadIndex on=person person_id=[delta join 1st input (full scan)] // { arity: 11 } ArrangeBy keys=[[#1{personid}], [#2{messageid}]] // { arity: 3 } @@ -2193,7 +2193,7 @@ Explained Query: Project (#0{id}, #2{count}, #3{sum}) // { arity: 3 } Join on=(#0{id} = #1{creatorpersonid}) type=differential // { arity: 4 } implementation - %1[#0]UKA » %0:l4[#0]K + %1[#0]UKA » %0:l4[#0{zombieid}]K Get l4 // { arity: 1 } ArrangeBy keys=[[#0{creatorpersonid}]] // { arity: 3 } Reduce group_by=[#0{creatorpersonid}] aggregates=[count(*), sum(case when #1 then 1 else 0 end)] // { arity: 3 } @@ -2322,13 +2322,13 @@ Explained Query: Filter (#1{name} = "Philippines") AND (#38{name} = "Taiwan") AND (#0{id}) IS NOT NULL AND (#36{partofcountryid}) IS NOT NULL // { arity: 41 } Join on=(#0{id} = #7{partofcountryid} AND #4{id} = #16{locationcityid} AND #9{id} = #20{person1id} AND #21{person2id} = #23{id} AND #30{locationcityid} = #33{id} AND #36{partofcountryid} = #37{id}) type=delta // { arity: 41 } implementation - %0:l0 » %1:l1[#3]KA » %2:l2[#8]KA » %3:person_knows_person[#1]KA » %4:l2[#1]KA » %5:l1[#0]KA » %6:l0[#0]KAef - %1:l1 » %0:l0[#0]KAef » %2:l2[#8]KA » %3:person_knows_person[#1]KA » %4:l2[#1]KA » %5:l1[#0]KA » %6:l0[#0]KAef - %2:l2 » %1:l1[#0]KA » %0:l0[#0]KAef » %3:person_knows_person[#1]KA » %4:l2[#1]KA » %5:l1[#0]KA » %6:l0[#0]KAef - %3:person_knows_person » %2:l2[#1]KA » %1:l1[#0]KA » %0:l0[#0]KAef » %4:l2[#1]KA » %5:l1[#0]KA » %6:l0[#0]KAef - %4:l2 » %3:person_knows_person[#2]KA » %2:l2[#1]KA » %1:l1[#0]KA » %0:l0[#0]KAef » %5:l1[#0]KA » %6:l0[#0]KAef - %5:l1 » %6:l0[#0]KAef » %4:l2[#8]KA » %3:person_knows_person[#2]KA » %2:l2[#1]KA » %1:l1[#0]KA » %0:l0[#0]KAef - %6:l0 » %5:l1[#3]KA » %4:l2[#8]KA » %3:person_knows_person[#2]KA » %2:l2[#1]KA » %1:l1[#0]KA » %0:l0[#0]KAef + %0:l0 » %1:l1[#3{partofcountryid}]KA » %2:l2[#8{locationcityid}]KA » %3:person_knows_person[#1{person1id}]KA » %4:l2[#1{id}]KA » %5:l1[#0{id}]KA » %6:l0[#0{id}]KAef + %1:l1 » %0:l0[#0{id}]KAef » %2:l2[#8{locationcityid}]KA » %3:person_knows_person[#1{person1id}]KA » %4:l2[#1{id}]KA » %5:l1[#0{id}]KA » %6:l0[#0{id}]KAef + %2:l2 » %1:l1[#0{id}]KA » %0:l0[#0{id}]KAef » %3:person_knows_person[#1{person1id}]KA » %4:l2[#1{id}]KA » %5:l1[#0{id}]KA » %6:l0[#0{id}]KAef + %3:person_knows_person » %2:l2[#1{id}]KA » %1:l1[#0{id}]KA » %0:l0[#0{id}]KAef » %4:l2[#1{id}]KA » %5:l1[#0{id}]KA » %6:l0[#0{id}]KAef + %4:l2 » %3:person_knows_person[#2{person2id}]KA » %2:l2[#1{id}]KA » %1:l1[#0{id}]KA » %0:l0[#0{id}]KAef » %5:l1[#0{id}]KA » %6:l0[#0{id}]KAef + %5:l1 » %6:l0[#0{id}]KAef » %4:l2[#8{locationcityid}]KA » %3:person_knows_person[#2{person2id}]KA » %2:l2[#1{id}]KA » %1:l1[#0{id}]KA » %0:l0[#0{id}]KAef + %6:l0 » %5:l1[#3{partofcountryid}]KA » %4:l2[#8{locationcityid}]KA » %3:person_knows_person[#2{person2id}]KA » %2:l2[#1{id}]KA » %1:l1[#0{id}]KA » %0:l0[#0{id}]KAef Get l0 // { arity: 4 } Get l1 // { arity: 4 } Get l2 // { arity: 11 } @@ -2338,7 +2338,7 @@ Explained Query: Get l1 // { arity: 4 } Get l0 // { arity: 4 } cte l4 = - Map (case when #2 then #1{person2id} else #0{id} end, case when #2 then #0{id} else #1{person2id} end) // { arity: 5 } + Map (case when #2{flipped} then #1{person2id} else #0{id} end, case when #2{flipped} then #0{id} else #1{person2id} end) // { arity: 5 } Union // { arity: 3 } Project (#2{id}..=#4) // { arity: 3 } Map (false) // { arity: 5 } @@ -2365,7 +2365,7 @@ Explained Query: Project (#9{creatorpersonid}, #22{creatorpersonid}) // { arity: 2 } Join on=(#1{messageid} = #25{parentmessageid}) type=differential // { arity: 26 } implementation - %0:l6[#1]KA » %1:message[#12]KA + %0:l6[#1{messageid}]KA » %1:message[#12{parentmessageid}]KA Get l6 // { arity: 13 } ArrangeBy keys=[[#12{parentmessageid}]] // { arity: 13 } ReadIndex on=message message_parentmessageid=[differential join] // { arity: 13 } @@ -2401,7 +2401,7 @@ Explained Query: Project (#9{creatorpersonid}, #14{personid}) // { arity: 2 } Join on=(#1{messageid} = #15{messageid}) type=differential // { arity: 16 } implementation - %0:l6[#1]KA » %1:person_likes_message[#2]KA + %0:l6[#1{messageid}]KA » %1:person_likes_message[#2{messageid}]KA Get l6 // { arity: 13 } ArrangeBy keys=[[#2{messageid}]] // { arity: 3 } ReadIndex on=person_likes_message person_likes_message_messageid=[differential join] // { arity: 3 } @@ -2409,11 +2409,11 @@ Explained Query: Project (#0{id}..=#3{person2id}, #6{sum}) // { arity: 5 } Join on=(#2{id} = #4 AND #3{person2id} = #5) type=differential // { arity: 7 } implementation - %1[#0, #1]UKKA » %0:l3[#2, #3]KK + %1[#0, #1]UKKA » %0:l3[#2{person1id}, #3{person2id}]KK ArrangeBy keys=[[#2{id}, #3{person2id}]] // { arity: 4 } Get l3 // { arity: 4 } ArrangeBy keys=[[#0, #1]] // { arity: 3 } - Reduce group_by=[#1, #2] aggregates=[sum((case when #3 then case when #0 then 1 else 4 end else 0 end + case when #4 then case when #0 then 1 else 10 end else 0 end))] // { arity: 3 } + Reduce group_by=[#1, #2] aggregates=[sum((case when #3 then case when #0{flipped} then 1 else 4 end else 0 end + case when #4 then case when #0{flipped} then 1 else 10 end else 0 end))] // { arity: 3 } Project (#2..=#5, #8) // { arity: 5 } Join on=(#0{id} = #6{id} AND #1{person2id} = #7{person2id}) type=differential // { arity: 9 } implementation @@ -2539,20 +2539,20 @@ Explained Query: Filter (#0{creationdate} <= 2012-11-10 00:00:00 UTC) AND (#0{creationdate} >= 2012-11-06 00:00:00 UTC) AND (#1{id}) IS NOT NULL // { arity: 4 } ReadIndex on=forum forum_id=[*** full scan ***] // { arity: 4 } cte l3 = - Join on=(#2 = least(#0{person1id}, #1{person2id}) AND #3 = greatest(#0{person1id}, #1{person2id})) type=differential // { arity: 5 } + Join on=(#2{src} = least(#0{person1id}, #1{person2id}) AND #3{dst} = greatest(#0{person1id}, #1{person2id})) type=differential // { arity: 5 } implementation - %1[#1, #0]UKK » %0:l1[greatest(#0, #1), least(#0, #1)]KK + %1[#1{dst}, #0{src}]UKK » %0:l1[greatest(#0{person1id}, #1{person2id}), least(#0{person1id}, #1{person2id})]KK Get l1 // { arity: 2 } - ArrangeBy keys=[[#1, #0]] // { arity: 3 } + ArrangeBy keys=[[#1{dst}, #0{src}]] // { arity: 3 } Reduce group_by=[least(#0{person1id}, #1{person2id}), greatest(#0{person1id}, #1{person2id})] aggregates=[sum(case when (#2{parentmessageid}) IS NULL then 10 else 5 end)] // { arity: 3 } Project (#1{person1id}, #2{person2id}, #15{parentmessageid}) // { arity: 3 } Join on=(#1{person1id} = #12{creatorpersonid} AND #2{person2id} = #25{creatorpersonid} AND #4{messageid} = #28{parentmessageid} AND #13{containerforumid} = #29{id} AND #26{containerforumid} = #30{id}) type=delta // { arity: 31 } implementation - %0:person_knows_person » %1:message[#9]KA » %3:l2[#0]UKA » %2:message[#12]KA » %4:l2[#0]UKA - %1:message » %3:l2[#0]UKA » %0:person_knows_person[#1]KA » %2:message[#12]KA » %4:l2[#0]UKA - %2:message » %4:l2[#0]UKA » %0:person_knows_person[#2]KA » %1:message[#9]KA » %3:l2[#0]UKA - %3:l2 » %1:message[#10]KA » %0:person_knows_person[#1]KA » %2:message[#12]KA » %4:l2[#0]UKA - %4:l2 » %2:message[#10]KA » %0:person_knows_person[#2]KA » %1:message[#9]KA » %3:l2[#0]UKA + %0:person_knows_person » %1:message[#9{creatorpersonid}]KA » %3:l2[#0]UKA » %2:message[#12{parentmessageid}]KA » %4:l2[#0]UKA + %1:message » %3:l2[#0]UKA » %0:person_knows_person[#1{person1id}]KA » %2:message[#12{parentmessageid}]KA » %4:l2[#0]UKA + %2:message » %4:l2[#0]UKA » %0:person_knows_person[#2{person2id}]KA » %1:message[#9{creatorpersonid}]KA » %3:l2[#0]UKA + %3:l2 » %1:message[#10{containerforumid}]KA » %0:person_knows_person[#1{person1id}]KA » %2:message[#12{parentmessageid}]KA » %4:l2[#0]UKA + %4:l2 » %2:message[#10{containerforumid}]KA » %0:person_knows_person[#2{person2id}]KA » %1:message[#9{creatorpersonid}]KA » %3:l2[#0]UKA ArrangeBy keys=[[#1{person1id}], [#2{person2id}]] // { arity: 3 } ReadIndex on=person_knows_person person_knows_person_person1id=[delta join 1st input (full scan)] person_knows_person_person2id=[delta join lookup] // { arity: 3 } ArrangeBy keys=[[#9{creatorpersonid}], [#10{containerforumid}]] // { arity: 13 } @@ -2566,15 +2566,15 @@ Explained Query: cte l4 = Project (#2, #0{person2id}, #1{min}) // { arity: 3 } Map (1450) // { arity: 3 } - Reduce group_by=[#0{person2id}] aggregates=[min(#1)] // { arity: 2 } + Reduce group_by=[#0{person2id}] aggregates=[min(#1{w})] // { arity: 2 } Distinct project=[#0{person2id}, #1] // { arity: 2 } Union // { arity: 2 } Project (#3{person2id}, #5) // { arity: 2 } - Map ((#1 + #4)) // { arity: 6 } - Join on=(#0 = #2{person1id}) type=differential // { arity: 5 } + Map ((#1{w} + #4{w})) // { arity: 6 } + Join on=(#0{dst} = #2{person1id}) type=differential // { arity: 5 } implementation - %0:l4[#0]UK » %1[#0]K - ArrangeBy keys=[[#0]] // { arity: 2 } + %0:l4[#0{dst}]UK » %1[#0{src}]K + ArrangeBy keys=[[#0{dst}]] // { arity: 2 } Project (#1{person2id}, #2{min}) // { arity: 2 } Get l4 // { arity: 3 } ArrangeBy keys=[[#0{person1id}]] // { arity: 3 } @@ -2587,7 +2587,7 @@ Explained Query: Project (#0{person1id}, #1{person2id}) // { arity: 2 } Join on=(#2 = least(#0{person1id}, #1{person2id}) AND #3 = greatest(#0{person1id}, #1{person2id})) type=differential // { arity: 4 } implementation - %1[#1, #0]UKK » %0:l1[greatest(#0, #1), least(#0, #1)]KK + %1[#1, #0]UKK » %0:l1[greatest(#0{person1id}, #1{person2id}), least(#0{person1id}, #1{person2id})]KK Get l1 // { arity: 2 } ArrangeBy keys=[[#1, #0]] // { arity: 2 } Distinct project=[#0, #1] // { arity: 2 } @@ -2736,20 +2736,20 @@ Explained Query: Filter (#0{creationdate} <= 2012-11-10 00:00:00 UTC) AND (#0{creationdate} >= 2012-11-06 00:00:00 UTC) AND (#1{id}) IS NOT NULL // { arity: 4 } ReadIndex on=forum forum_id=[*** full scan ***] // { arity: 4 } cte l3 = - Join on=(#2 = least(#0{person1id}, #1{person2id}) AND #3 = greatest(#0{person1id}, #1{person2id})) type=differential // { arity: 5 } + Join on=(#2{src} = least(#0{person1id}, #1{person2id}) AND #3{dst} = greatest(#0{person1id}, #1{person2id})) type=differential // { arity: 5 } implementation - %1[#1, #0]UKK » %0:l1[greatest(#0, #1), least(#0, #1)]KK + %1[#1{dst}, #0{src}]UKK » %0:l1[greatest(#0{person1id}, #1{person2id}), least(#0{person1id}, #1{person2id})]KK Get l1 // { arity: 2 } - ArrangeBy keys=[[#1, #0]] // { arity: 3 } + ArrangeBy keys=[[#1{dst}, #0{src}]] // { arity: 3 } Reduce group_by=[least(#0{person1id}, #1{person2id}), greatest(#0{person1id}, #1{person2id})] aggregates=[sum(case when (#2{parentmessageid}) IS NULL then 10 else 5 end)] // { arity: 3 } Project (#1{person1id}, #2{person2id}, #15{parentmessageid}) // { arity: 3 } Join on=(#1{person1id} = #12{creatorpersonid} AND #2{person2id} = #25{creatorpersonid} AND #4{messageid} = #28{parentmessageid} AND #13{containerforumid} = #29{id} AND #26{containerforumid} = #30{id}) type=delta // { arity: 31 } implementation - %0:person_knows_person » %1:message[#9]KA » %3:l2[#0]UKA » %2:message[#12]KA » %4:l2[#0]UKA - %1:message » %3:l2[#0]UKA » %0:person_knows_person[#1]KA » %2:message[#12]KA » %4:l2[#0]UKA - %2:message » %4:l2[#0]UKA » %0:person_knows_person[#2]KA » %1:message[#9]KA » %3:l2[#0]UKA - %3:l2 » %1:message[#10]KA » %0:person_knows_person[#1]KA » %2:message[#12]KA » %4:l2[#0]UKA - %4:l2 » %2:message[#10]KA » %0:person_knows_person[#2]KA » %1:message[#9]KA » %3:l2[#0]UKA + %0:person_knows_person » %1:message[#9{creatorpersonid}]KA » %3:l2[#0]UKA » %2:message[#12{parentmessageid}]KA » %4:l2[#0]UKA + %1:message » %3:l2[#0]UKA » %0:person_knows_person[#1{person1id}]KA » %2:message[#12{parentmessageid}]KA » %4:l2[#0]UKA + %2:message » %4:l2[#0]UKA » %0:person_knows_person[#2{person2id}]KA » %1:message[#9{creatorpersonid}]KA » %3:l2[#0]UKA + %3:l2 » %1:message[#10{containerforumid}]KA » %0:person_knows_person[#1{person1id}]KA » %2:message[#12{parentmessageid}]KA » %4:l2[#0]UKA + %4:l2 » %2:message[#10{containerforumid}]KA » %0:person_knows_person[#2{person2id}]KA » %1:message[#9{creatorpersonid}]KA » %3:l2[#0]UKA ArrangeBy keys=[[#1{person1id}], [#2{person2id}]] // { arity: 3 } ReadIndex on=person_knows_person person_knows_person_person1id=[delta join 1st input (full scan)] person_knows_person_person2id=[delta join lookup] // { arity: 3 } ArrangeBy keys=[[#9{creatorpersonid}], [#10{containerforumid}]] // { arity: 13 } @@ -2768,7 +2768,7 @@ Explained Query: Project (#0{person1id}, #1{person2id}) // { arity: 2 } Join on=(#2 = least(#0{person1id}, #1{person2id}) AND #3 = greatest(#0{person1id}, #1{person2id})) type=differential // { arity: 4 } implementation - %1[#1, #0]UKK » %0:l1[greatest(#0, #1), least(#0, #1)]KK + %1[#1, #0]UKK » %0:l1[greatest(#0{person1id}, #1{person2id}), least(#0{person1id}, #1{person2id})]KK Get l1 // { arity: 2 } ArrangeBy keys=[[#1, #0]] // { arity: 2 } Distinct project=[#0, #1] // { arity: 2 } @@ -2781,9 +2781,9 @@ Explained Query: With Mutually Recursive cte l5 = Project (#1, #3{person2id}) // { arity: 2 } - Join on=(#0 = #2{person1id}) type=differential // { arity: 4 } + Join on=(#0{src} = #2{person1id}) type=differential // { arity: 4 } implementation - %0:l8[#0]K » %1:l4[#0]K + %0:l8[#0{src}]K » %1:l4[#0{src}]K ArrangeBy keys=[[#0{person2id}]] // { arity: 2 } Get l8 // { arity: 2 } ArrangeBy keys=[[#0{person1id}]] // { arity: 2 } @@ -2799,14 +2799,14 @@ Explained Query: Project () // { arity: 0 } Join on=(#0{person2id} = #1{person2id}) type=differential // { arity: 2 } implementation - %0:l6[#0]Kf » %1:l6[#0]Kf + %0:l6[#0{src}]Kf » %1:l6[#0{src}]Kf ArrangeBy keys=[[#0{person2id}]] // { arity: 1 } Project (#0{person2id}) // { arity: 1 } - Filter #1 // { arity: 2 } + Filter #1{dir} // { arity: 2 } Get l6 // { arity: 2 } ArrangeBy keys=[[#0{person2id}]] // { arity: 1 } Project (#0{person2id}) // { arity: 1 } - Filter NOT(#1) // { arity: 2 } + Filter NOT(#1{dir}) // { arity: 2 } Get l6 // { arity: 2 } cte l8 = Distinct project=[#0{person2id}, #1] // { arity: 2 } @@ -2832,7 +2832,7 @@ Explained Query: cte l9 = TopK order_by=[#3 asc nulls_last] limit=1000 // { arity: 5 } Project (#0..=#3, #5) // { arity: 5 } - Filter (#4 = false) // { arity: 6 } + Filter (#4{dead} = false) // { arity: 6 } Get l17 // { arity: 6 } cte l10 = Distinct project=[#0..=#2] // { arity: 3 } @@ -2843,29 +2843,29 @@ Explained Query: Get l10 // { arity: 3 } cte l12 = Project (#0..=#2) // { arity: 3 } - Join on=(#0 = #3 AND #1 = #4 AND #2 = #5) type=differential // { arity: 6 } + Join on=(#0 = #3{dir} AND #1 = #4{gsrc} AND #2 = #5{dst}) type=differential // { arity: 6 } implementation %1[#0..=#2]UKKKA » %0:l11[#0..=#2]UKKK Get l11 // { arity: 3 } - ArrangeBy keys=[[#0..=#2]] // { arity: 3 } - Distinct project=[#0..=#2] // { arity: 3 } + ArrangeBy keys=[[#0{dir}..=#2{dst}]] // { arity: 3 } + Distinct project=[#0{dir}..=#2{dst}] // { arity: 3 } Project (#0..=#2) // { arity: 3 } Get l9 // { arity: 5 } cte l13 = TopK group_by=[#0, #1, #2{person2id}] order_by=[#3 asc nulls_last, #4 desc nulls_first] limit=1 // { arity: 5 } Union // { arity: 5 } Project (#3, #4, #1{person2id}, #7, #8) // { arity: 5 } - Map ((#6 + #2), false) // { arity: 9 } - Join on=(#0{person1id} = #5) type=differential // { arity: 7 } + Map ((#6{w} + #2{w}), false) // { arity: 9 } + Join on=(#0{person1id} = #5{dst}) type=differential // { arity: 7 } implementation - %0:l4[#0]K » %1:l9[#2]K + %0:l4[#0{src}]K » %1:l9[#2{dst}]K ArrangeBy keys=[[#0{person1id}]] // { arity: 3 } Get l4 // { arity: 3 } - ArrangeBy keys=[[#2]] // { arity: 4 } + ArrangeBy keys=[[#2{dst}]] // { arity: 4 } Project (#0..=#3) // { arity: 4 } Get l9 // { arity: 5 } Project (#0..=#3, #9) // { arity: 5 } - Map ((#4 OR #8)) // { arity: 10 } + Map ((#4{dead} OR #8)) // { arity: 10 } Join on=(#0 = #5 AND #1 = #6 AND #2 = #7) type=differential // { arity: 9 } implementation %0:l17[#0..=#2]KKK » %1[#0..=#2]KKK @@ -2888,18 +2888,18 @@ Explained Query: Get l10 // { arity: 3 } Get l11 // { arity: 3 } cte l14 = - Reduce aggregates=[min((#0 + #1))] // { arity: 1 } + Reduce aggregates=[min((#0{w} + #1{w}))] // { arity: 1 } Project (#1, #3) // { arity: 2 } Join on=(#0{person2id} = #2{person2id}) type=differential // { arity: 4 } implementation - %0:l13[#0]Kef » %1:l13[#0]Kef + %0:l13[#0{dst}]Kef » %1:l13[#0{dst}]Kef ArrangeBy keys=[[#0{person2id}]] // { arity: 2 } Project (#2{person2id}, #3) // { arity: 2 } - Filter (#0 = false) // { arity: 5 } + Filter (#0{dir} = false) // { arity: 5 } Get l13 // { arity: 5 } ArrangeBy keys=[[#0{person2id}]] // { arity: 2 } Project (#2{person2id}, #3) // { arity: 2 } - Filter (#0 = true) // { arity: 5 } + Filter (#0{dir} = true) // { arity: 5 } Get l13 // { arity: 5 } cte l15 = Project (#1) // { arity: 1 } @@ -2916,7 +2916,7 @@ Explained Query: cte l16 = Distinct project=[] // { arity: 0 } Project () // { arity: 0 } - Filter #1 AND (#0{person2id} = -1) // { arity: 2 } + Filter #1{dir} AND (#0{person2id} = -1) // { arity: 2 } Get l8 // { arity: 2 } cte l17 = Distinct project=[#0..=#5] // { arity: 6 } @@ -2929,7 +2929,7 @@ Explained Query: Map (15393162796819, true) // { arity: 2 } Get l16 // { arity: 0 } Project (#0..=#3, #7, #8) // { arity: 6 } - Map ((#4 OR coalesce((#3 > #6), false)), (#5 + 1)) // { arity: 9 } + Map ((#4{dead} OR coalesce((#3{w} > #6), false)), (#5{iter} + 1)) // { arity: 9 } CrossJoin type=delta // { arity: 7 } implementation %0:l13 » %1[×]U » %2[×]U @@ -2955,31 +2955,31 @@ Explained Query: With cte l18 = Project (#0..=#3) // { arity: 4 } - Join on=(#4 = #5{max}) type=differential // { arity: 6 } + Join on=(#4{iter} = #5{max}) type=differential // { arity: 6 } implementation - %1[#0]UK » %0:l17[#4]K - ArrangeBy keys=[[#4]] // { arity: 5 } + %1[#0]UK » %0:l17[#4{iter}]K + ArrangeBy keys=[[#4{iter}]] // { arity: 5 } Project (#0..=#3, #5) // { arity: 5 } Get l17 // { arity: 6 } ArrangeBy keys=[[#0{max}]] // { arity: 1 } - Reduce aggregates=[max(#0)] // { arity: 1 } + Reduce aggregates=[max(#0{iter})] // { arity: 1 } Project (#5) // { arity: 1 } Get l17 // { arity: 6 } cte l19 = Reduce aggregates=[min(#0{min})] // { arity: 1 } Project (#2{min}) // { arity: 1 } - Reduce group_by=[#0, #2] aggregates=[min((#1 + #3))] // { arity: 3 } + Reduce group_by=[#0, #2] aggregates=[min((#1{w} + #3{w}))] // { arity: 3 } Project (#0, #2, #3, #5) // { arity: 4 } Join on=(#1{person2id} = #4{person2id}) type=differential // { arity: 6 } implementation - %0:l18[#1]Kef » %1:l18[#1]Kef + %0:l18[#1{dst}]Kef » %1:l18[#1{dst}]Kef ArrangeBy keys=[[#1{person2id}]] // { arity: 3 } Project (#1..=#3) // { arity: 3 } - Filter (#0 = false) // { arity: 4 } + Filter (#0{dir} = false) // { arity: 4 } Get l18 // { arity: 4 } ArrangeBy keys=[[#1{person2id}]] // { arity: 3 } Project (#1..=#3) // { arity: 3 } - Filter (#0 = true) // { arity: 4 } + Filter (#0{dir} = true) // { arity: 4 } Get l18 // { arity: 4 } Return // { arity: 1 } Project (#1) // { arity: 1 } @@ -3113,7 +3113,7 @@ Explained Query: Project (#1{messageid}) // { arity: 1 } Join on=(#2{tagid} = #3{id}) type=differential // { arity: 8 } implementation - %1:tag[#0]KAe » %0:l1[#2]KAe + %1:tag[#0{id}]KAe » %0:l1[#2{tagid}]KAe Get l1 // { arity: 3 } ArrangeBy keys=[[#0{id}]] // { arity: 5 } ReadIndex on=materialize.public.tag tag_name=[lookup value=("Diosdado_Macapagal")] // { arity: 5 } @@ -3124,9 +3124,9 @@ Explained Query: Project (#0{id}, #1{messageid}, #4{person2id}) // { arity: 3 } Join on=(#0{id} = #3{person1id} AND #4{person2id} = #5{id}) type=delta // { arity: 6 } implementation - %0:l3 » %1:l4[#1]KA » %2[#0]UKA + %0:l3 » %1:l4[#1{person1id}]KA » %2[#0]UKA %1:l4 » %2[#0]UKA » %0:l3[#0]K - %2 » %1:l4[#2]KA » %0:l3[#0]K + %2 » %1:l4[#2{person2id}]KA » %0:l3[#0]K ArrangeBy keys=[[#0{id}]] // { arity: 2 } Get l3 // { arity: 2 } Get l4 // { arity: 3 } @@ -3152,7 +3152,7 @@ Explained Query: Project (#1{messageid}) // { arity: 1 } Join on=(#2{tagid} = #3{id}) type=differential // { arity: 8 } implementation - %1:tag[#0]KAe » %0:l1[#2]KAe + %1:tag[#0{id}]KAe » %0:l1[#2{tagid}]KAe Get l1 // { arity: 3 } ArrangeBy keys=[[#0{id}]] // { arity: 5 } ReadIndex on=materialize.public.tag tag_name=[lookup value=("Thailand_Noriega")] // { arity: 5 } @@ -3160,9 +3160,9 @@ Explained Query: Project (#0{id}, #1{messageid}, #4{person2id}) // { arity: 3 } Join on=(#0{id} = #3{person1id} AND #4{person2id} = #5{id}) type=delta // { arity: 6 } implementation - %0:l6 » %1:l4[#1]KA » %2[#0]UKA + %0:l6 » %1:l4[#1{person1id}]KA » %2[#0]UKA %1:l4 » %2[#0]UKA » %0:l6[#0]K - %2 » %1:l4[#2]KA » %0:l6[#0]K + %2 » %1:l4[#2{person2id}]KA » %0:l6[#0]K ArrangeBy keys=[[#0{id}]] // { arity: 2 } Get l6 // { arity: 2 } Get l4 // { arity: 3 } @@ -3176,7 +3176,7 @@ Explained Query: Map ((#1{count_messageid} + #4{count_messageid})) // { arity: 7 } Join on=(#0{id} = #3{id}) type=differential // { arity: 6 } implementation - %0[#0]UKAif » %1[#0]UKAiif + %0[#0{personid}]UKAif » %1[#0]UKAiif ArrangeBy keys=[[#0{id}]] // { arity: 3 } Reduce group_by=[#0{id}] aggregates=[count(distinct #1{messageid}), count(distinct #2{person2id})] // { arity: 3 } Union // { arity: 3 } @@ -3262,7 +3262,7 @@ Explained Query: Project (#0{creationdate}, #1{messageid}, #9{creatorpersonid}, #10{containerforumid}, #12{parentmessageid}) // { arity: 5 } Join on=(#1{messageid} = #13{messageid}) type=differential // { arity: 14 } implementation - %1[#0]UKA » %0:message[#1]KA + %1[#0]UKA » %0:message[#1{messageid}]KA ArrangeBy keys=[[#1{messageid}]] // { arity: 13 } ReadIndex on=message message_messageid=[differential join] // { arity: 13 } ArrangeBy keys=[[#0{messageid}]] // { arity: 1 } @@ -3270,7 +3270,7 @@ Explained Query: Project (#1{messageid}) // { arity: 1 } Join on=(#2{tagid} = #3{id}) type=differential // { arity: 4 } implementation - %1[#0]UKA » %0:message_hastag_tag[#2]KA + %1[#0]UKA » %0:message_hastag_tag[#2{tagid}]KA ArrangeBy keys=[[#2{tagid}]] // { arity: 3 } ReadIndex on=message_hastag_tag message_hastag_tag_tagid=[differential join] // { arity: 3 } ArrangeBy keys=[[#0{id}]] // { arity: 1 } @@ -3286,11 +3286,11 @@ Explained Query: Filter (#2{containerforumid} != #6{containerforumid}) AND (#5{creatorpersonid} != #7{creatorpersonid}) AND ((#0{creationdate} + 12:00:00) < #3{creationdate}) // { arity: 15 } Join on=(#2{containerforumid} = #10{forumid} = #13{forumid} AND #4{messageid} = #8{parentmessageid} AND #5{creatorpersonid} = #14{personid} AND #7{creatorpersonid} = #11{personid}) type=delta // { arity: 15 } implementation - %0:l0 » %3:l1[#1]KA » %4:l1[#1]KA » %1:l0[#2]K » %2:l0[#0, #1]KK - %1:l0 » %4:l1[#2]KA » %3:l1[#1]KA » %2:l0[#0, #1]KK » %0:l0[#2]K - %2:l0 » %3:l1[#2]KA » %4:l1[#1]KA » %1:l0[#1, #2]KK » %0:l0[#2]K - %3:l1 » %4:l1[#1]KA » %0:l0[#2]K » %1:l0[#2]K » %2:l0[#0, #1]KK - %4:l1 » %3:l1[#1]KA » %0:l0[#2]K » %1:l0[#2]K » %2:l0[#0, #1]KK + %0:l0 » %3:l1[#1{forumid}]KA » %4:l1[#1{forumid}]KA » %1:l0[#2{creatorpersonid}]K » %2:l0[#0{creatorpersonid}, #1{parentmessageid}]KK + %1:l0 » %4:l1[#2{personid}]KA » %3:l1[#1{forumid}]KA » %2:l0[#0{creatorpersonid}, #1{parentmessageid}]KK » %0:l0[#2{containerforumid}]K + %2:l0 » %3:l1[#2{personid}]KA » %4:l1[#1{forumid}]KA » %1:l0[#1{messageid}, #2{creatorpersonid}]KK » %0:l0[#2{containerforumid}]K + %3:l1 » %4:l1[#1{forumid}]KA » %0:l0[#2{containerforumid}]K » %1:l0[#2{creatorpersonid}]K » %2:l0[#0{creatorpersonid}, #1{parentmessageid}]KK + %4:l1 » %3:l1[#1{forumid}]KA » %0:l0[#2{containerforumid}]K » %1:l0[#2{creatorpersonid}]K » %2:l0[#0{creatorpersonid}, #1{parentmessageid}]KK ArrangeBy keys=[[#2{containerforumid}]] // { arity: 3 } Project (#0{creationdate}, #2{creatorpersonid}, #3{containerforumid}) // { arity: 3 } Get l0 // { arity: 5 } @@ -3382,9 +3382,9 @@ Explained Query: Project (#0{personid}, #9{person2id}) // { arity: 2 } Join on=(#0{personid} = #8{person1id} AND #1{tagid} = #2{id}) type=delta // { arity: 10 } implementation - %0:person_hasinterest_tag » %1:tag[#0]KAe » %2:person_knows_person[#1]KA - %1:tag » %0:person_hasinterest_tag[#1]KA » %2:person_knows_person[#1]KA - %2:person_knows_person » %0:person_hasinterest_tag[#0]K » %1:tag[#0]KAe + %0:person_hasinterest_tag » %1:tag[#0{id}]KAe » %2:person_knows_person[#1{person1id}]KA + %1:tag » %0:person_hasinterest_tag[#1{tagid}]KA » %2:person_knows_person[#1{person1id}]KA + %2:person_knows_person » %0:person_hasinterest_tag[#0{personid}]K » %1:tag[#0{id}]KAe ArrangeBy keys=[[#0{personid}], [#1{tagid}]] // { arity: 2 } Project (#1{personid}, #2{tagid}) // { arity: 2 } ReadIndex on=person_hasinterest_tag person_hasinterest_tag_tagid=[*** full scan ***] // { arity: 3 } @@ -3397,7 +3397,7 @@ Explained Query: Filter (#0{personid} != #2{personid}) // { arity: 4 } Join on=(#1{person2id} = #3{person2id}) type=differential // { arity: 4 } implementation - %0:l0[#1]K » %1:l0[#1]K + %0:l0[#1{friendid}]K » %1:l0[#1{friendid}]K Get l0 // { arity: 2 } Get l0 // { arity: 2 } cte l2 = @@ -3481,9 +3481,9 @@ materialize.public.pathq19: Filter (#0{creatorpersonid} != #11{creatorpersonid}) AND (#16{person1id} < #17{person2id}) // { arity: 18 } Join on=(#1{parentmessageid} = #3{messageid} AND #16{person1id} = least(#0{creatorpersonid}, #11{creatorpersonid}) AND #17{person2id} = greatest(#0{creatorpersonid}, #11{creatorpersonid})) type=delta // { arity: 18 } implementation - %0:message » %1:message[#1]KA » %2:person_knows_person[#1, #2]KKAf - %1:message » %0:message[#1]KA » %2:person_knows_person[#1, #2]KKAf - %2:person_knows_person » %0:message[×] » %1:message[#1]KA + %0:message » %1:message[#1{messageid}]KA » %2:person_knows_person[#1{person1id}, #2{person2id}]KKAf + %1:message » %0:message[#1{parentmessageid}]KA » %2:person_knows_person[#1{person1id}, #2{person2id}]KKAf + %2:person_knows_person » %0:message[×] » %1:message[#1{messageid}]KA ArrangeBy keys=[[], [#1{parentmessageid}]] // { arity: 2 } Project (#9{creatorpersonid}, #12{parentmessageid}) // { arity: 2 } Filter (#12{parentmessageid}) IS NOT NULL // { arity: 13 } @@ -3573,17 +3573,17 @@ SELECT src, dst, w Explained Query: With Mutually Recursive cte l0 = - Reduce group_by=[#0{id}, #1{id}] aggregates=[min(#2)] // { arity: 3 } + Reduce group_by=[#0{id}, #1{id}] aggregates=[min(#2{w})] // { arity: 3 } Distinct project=[#0{id}..=#2] // { arity: 3 } Union // { arity: 3 } Project (#1{id}, #1{id}, #12) // { arity: 3 } Map (0) // { arity: 13 } ReadIndex on=materialize.public.person person_locationcityid=[lookup value=(655)] // { arity: 12 } Project (#0, #4{dst}, #6) // { arity: 3 } - Map ((#2 + bigint_to_double(#5{w}))) // { arity: 7 } - Join on=(#1 = #3{src}) type=differential // { arity: 6 } + Map ((#2{w} + bigint_to_double(#5{w}))) // { arity: 7 } + Join on=(#1{dst} = #3{src}) type=differential // { arity: 6 } implementation - %1:pathq19[#0]KA » %0:l0[#1]K + %1:pathq19[#0{src}]KA » %0:l0[#1{dst}]K ArrangeBy keys=[[#1{id}]] // { arity: 3 } Filter (#1{id}) IS NOT NULL // { arity: 3 } Get l0 // { arity: 3 } @@ -3608,7 +3608,7 @@ Explained Query: Project (#0{id}..=#2{min}) // { arity: 3 } Join on=(#2{min} = #3{min_min}) type=differential // { arity: 4 } implementation - %1[#0]UK » %0:l1[#2]K + %1[#0]UK » %0:l1[#2{w}]K ArrangeBy keys=[[#2{min}]] // { arity: 3 } Get l1 // { arity: 3 } ArrangeBy keys=[[#0{min_min}]] // { arity: 1 } @@ -3693,7 +3693,7 @@ Explained Query: ArrangeBy keys=[[]] // { arity: 1 } Union // { arity: 1 } Project (#1) // { arity: 1 } - Map ((#0 / 2)) // { arity: 2 } + Map ((#0{w} / 2)) // { arity: 2 } Get l7 // { arity: 1 } Map (null) // { arity: 1 } Union // { arity: 0 } @@ -3709,13 +3709,13 @@ Explained Query: Map (0) // { arity: 13 } ReadIndex on=materialize.public.person person_locationcityid=[lookup value=(655)] // { arity: 12 } Project (#0, #5{dst}, #7) // { arity: 3 } - Filter coalesce((#2 < #3), true) // { arity: 8 } - Map ((#2 + bigint_to_double(#6{w}))) // { arity: 8 } - Join on=(#1 = #4{src}) type=delta // { arity: 7 } + Filter coalesce((#2{w} < #3), true) // { arity: 8 } + Map ((#2{w} + bigint_to_double(#6{w}))) // { arity: 8 } + Join on=(#1{dst} = #4{src}) type=delta // { arity: 7 } implementation - %0:l3 » %2:l1[#0]KA » %1:l2[×] - %1:l2 » %0:l3[×] » %2:l1[#0]KA - %2:l1 » %0:l3[#1]K » %1:l2[×] + %0:l3 » %2:l1[#0{src}]KA » %1:l2[×] + %1:l2 » %0:l3[×] » %2:l1[#0{src}]KA + %2:l1 » %0:l3[#1{dst}]K » %1:l2[×] ArrangeBy keys=[[], [#1{id}]] // { arity: 3 } Filter (#1{id}) IS NOT NULL // { arity: 3 } Get l3 // { arity: 3 } @@ -3728,24 +3728,24 @@ Explained Query: Map (0) // { arity: 13 } ReadIndex on=materialize.public.person person_locationcityid=[lookup value=(1138)] // { arity: 12 } Project (#0, #5{dst}, #7) // { arity: 3 } - Filter coalesce((#2 < #3), true) // { arity: 8 } - Map ((#2 + bigint_to_double(#6{w}))) // { arity: 8 } - Join on=(#1 = #4{src}) type=delta // { arity: 7 } + Filter coalesce((#2{w} < #3), true) // { arity: 8 } + Map ((#2{w} + bigint_to_double(#6{w}))) // { arity: 8 } + Join on=(#1{dst} = #4{src}) type=delta // { arity: 7 } implementation - %0:l4 » %2:l1[#0]KA » %1:l2[×] - %1:l2 » %0:l4[×] » %2:l1[#0]KA - %2:l1 » %0:l4[#1]K » %1:l2[×] + %0:l4 » %2:l1[#0{src}]KA » %1:l2[×] + %1:l2 » %0:l4[×] » %2:l1[#0{src}]KA + %2:l1 » %0:l4[#1{dst}]K » %1:l2[×] ArrangeBy keys=[[], [#1{id}]] // { arity: 3 } Filter (#1{id}) IS NOT NULL // { arity: 3 } Get l4 // { arity: 3 } Get l2 // { arity: 1 } Get l1 // { arity: 3 } cte l5 = - Reduce group_by=[#0{id}, #2{id}] aggregates=[min((#1 + #3))] // { arity: 3 } + Reduce group_by=[#0{id}, #2{id}] aggregates=[min((#1{w} + #3{w}))] // { arity: 3 } Project (#0{id}, #2, #3{id}, #5) // { arity: 4 } Join on=(#1{id} = #4{id}) type=differential // { arity: 6 } implementation - %0:l3[#1]K » %1:l4[#1]K + %0:l3[#1{dst}]K » %1:l4[#1{dst}]K ArrangeBy keys=[[#1{id}]] // { arity: 3 } Filter (#1{id}) IS NOT NULL // { arity: 3 } Get l3 // { arity: 3 } @@ -3770,7 +3770,7 @@ Explained Query: Project (#0{id}..=#2{min}) // { arity: 3 } Join on=(#2{min} = #3{min_min}) type=differential // { arity: 4 } implementation - %1[#0]UK » %0:l5[#2]K + %1[#0]UK » %0:l5[#2{w}]K ArrangeBy keys=[[#2{min}]] // { arity: 3 } Get l5 // { arity: 3 } ArrangeBy keys=[[#0{min_min}]] // { arity: 1 } @@ -3850,7 +3850,7 @@ Explained Query: cte l1 = TopK order_by=[#3 asc nulls_last] limit=1000 // { arity: 5 } Project (#0..=#3, #5) // { arity: 5 } - Filter (#4 = false) // { arity: 6 } + Filter (#4{dead} = false) // { arity: 6 } Get l7 // { arity: 6 } cte l2 = Distinct project=[#0..=#2] // { arity: 3 } @@ -3858,34 +3858,34 @@ Explained Query: Get l7 // { arity: 6 } cte l3 = Project (#0..=#2) // { arity: 3 } - Join on=(#0 = #3 AND #1 = #4 AND #2 = #5) type=differential // { arity: 6 } + Join on=(#0 = #3{dir} AND #1 = #4{gsrc} AND #2 = #5{dst}) type=differential // { arity: 6 } implementation %1[#0..=#2]UKKKA » %0:l2[#0..=#2]UKKK ArrangeBy keys=[[#0..=#2]] // { arity: 3 } - Filter (#1) IS NOT NULL AND (#2) IS NOT NULL // { arity: 3 } + Filter (#1{gsrc}) IS NOT NULL AND (#2{dst}) IS NOT NULL // { arity: 3 } Get l2 // { arity: 3 } - ArrangeBy keys=[[#0..=#2]] // { arity: 3 } - Distinct project=[#0..=#2] // { arity: 3 } + ArrangeBy keys=[[#0{dir}..=#2{dst}]] // { arity: 3 } + Distinct project=[#0{dir}..=#2{dst}] // { arity: 3 } Project (#0..=#2) // { arity: 3 } - Filter (#1) IS NOT NULL AND (#2) IS NOT NULL // { arity: 5 } + Filter (#1{gsrc}) IS NOT NULL AND (#2{dst}) IS NOT NULL // { arity: 5 } Get l1 // { arity: 5 } cte l4 = TopK group_by=[#0, #1, #2{dst}] order_by=[#3 asc nulls_last, #4 desc nulls_first] limit=1 // { arity: 5 } Distinct project=[#0..=#4] // { arity: 5 } Union // { arity: 5 } Project (#3, #4, #1{dst}, #7, #8) // { arity: 5 } - Map ((#6 + bigint_to_double(#2{w})), false) // { arity: 9 } - Join on=(#0{src} = #5) type=differential // { arity: 7 } + Map ((#6{w} + bigint_to_double(#2{w})), false) // { arity: 9 } + Join on=(#0{src} = #5{dst}) type=differential // { arity: 7 } implementation - %0:pathq19[#0]KA » %1:l1[#2]K + %0:pathq19[#0{src}]KA » %1:l1[#2{dst}]K ArrangeBy keys=[[#0{src}]] // { arity: 3 } ReadIndex on=pathq19 pathq19_src=[differential join] // { arity: 3 } - ArrangeBy keys=[[#2]] // { arity: 4 } + ArrangeBy keys=[[#2{dst}]] // { arity: 4 } Project (#0..=#3) // { arity: 4 } - Filter (#2) IS NOT NULL // { arity: 5 } + Filter (#2{dst}) IS NOT NULL // { arity: 5 } Get l1 // { arity: 5 } Project (#0..=#3, #9) // { arity: 5 } - Map ((#4 OR #8)) // { arity: 10 } + Map ((#4{dead} OR #8)) // { arity: 10 } Join on=(#0 = #5 AND #1 = #6 AND #2 = #7) type=differential // { arity: 9 } implementation %0:l7[#0..=#2]KKK » %1[#0..=#2]KKK @@ -3909,18 +3909,18 @@ Explained Query: ArrangeBy keys=[[#0..=#2]] // { arity: 3 } Get l2 // { arity: 3 } cte l5 = - Reduce aggregates=[min((#0 + #1))] // { arity: 1 } + Reduce aggregates=[min((#0{w} + #1{w}))] // { arity: 1 } Project (#1, #3) // { arity: 2 } Join on=(#0{dst} = #2{dst}) type=differential // { arity: 4 } implementation - %0:l4[#0]Kef » %1:l4[#0]Kef + %0:l4[#0{dst}]Kef » %1:l4[#0{dst}]Kef ArrangeBy keys=[[#0{dst}]] // { arity: 2 } Project (#2{dst}, #3) // { arity: 2 } - Filter (#0 = false) AND (#2{dst}) IS NOT NULL // { arity: 5 } + Filter (#0{dir} = false) AND (#2{dst}) IS NOT NULL // { arity: 5 } Get l4 // { arity: 5 } ArrangeBy keys=[[#0{dst}]] // { arity: 2 } Project (#2{dst}, #3) // { arity: 2 } - Filter (#0 = true) AND (#2{dst}) IS NOT NULL // { arity: 5 } + Filter (#0{dir} = true) AND (#2{dst}) IS NOT NULL // { arity: 5 } Get l4 // { arity: 5 } cte l6 = Project (#1) // { arity: 1 } @@ -3947,7 +3947,7 @@ Explained Query: Map (true) // { arity: 13 } ReadIndex on=materialize.public.person person_locationcityid=[lookup value=(1138)] // { arity: 12 } Project (#0..=#3, #7, #8) // { arity: 6 } - Map ((#4 OR coalesce((#3 > #6), false)), (#5 + 1)) // { arity: 9 } + Map ((#4{dead} OR coalesce((#3{w} > #6), false)), (#5{iter} + 1)) // { arity: 9 } CrossJoin type=delta // { arity: 7 } implementation %0:l4 » %1[×]U » %2[×]U @@ -3973,36 +3973,36 @@ Explained Query: With cte l8 = Project (#0..=#3) // { arity: 4 } - Join on=(#4 = #5{max}) type=differential // { arity: 6 } + Join on=(#4{iter} = #5{max}) type=differential // { arity: 6 } implementation - %1[#0]UK » %0:l7[#4]K - ArrangeBy keys=[[#4]] // { arity: 5 } + %1[#0]UK » %0:l7[#4{iter}]K + ArrangeBy keys=[[#4{iter}]] // { arity: 5 } Project (#0..=#3, #5) // { arity: 5 } Filter (#2{id}) IS NOT NULL // { arity: 6 } Get l7 // { arity: 6 } ArrangeBy keys=[[#0{max}]] // { arity: 1 } - Reduce aggregates=[max(#0)] // { arity: 1 } + Reduce aggregates=[max(#0{iter})] // { arity: 1 } Project (#5) // { arity: 1 } Get l7 // { arity: 6 } cte l9 = - Reduce group_by=[#0{id}, #2{id}] aggregates=[min((#1 + #3))] // { arity: 3 } + Reduce group_by=[#0{id}, #2{id}] aggregates=[min((#1{w} + #3{w}))] // { arity: 3 } Project (#0{id}, #2, #3{id}, #5) // { arity: 4 } Join on=(#1{id} = #4{id}) type=differential // { arity: 6 } implementation - %0:l8[#1]Kef » %1:l8[#1]Kef + %0:l8[#1{dst}]Kef » %1:l8[#1{dst}]Kef ArrangeBy keys=[[#1{id}]] // { arity: 3 } Project (#1{id}..=#3) // { arity: 3 } - Filter (#0 = false) // { arity: 4 } + Filter (#0{dir} = false) // { arity: 4 } Get l8 // { arity: 4 } ArrangeBy keys=[[#1{id}]] // { arity: 3 } Project (#1{id}..=#3) // { arity: 3 } - Filter (#0 = true) // { arity: 4 } + Filter (#0{dir} = true) // { arity: 4 } Get l8 // { arity: 4 } Return // { arity: 3 } Project (#0{id}..=#2{min}) // { arity: 3 } Join on=(#2{min} = #3{min_min}) type=differential // { arity: 4 } implementation - %1[#0]UK » %0:l9[#2]K + %1[#0]UK » %0:l9[#2{w}]K ArrangeBy keys=[[#2{min}]] // { arity: 3 } Get l9 // { arity: 3 } ArrangeBy keys=[[#0{min_min}]] // { arity: 1 } @@ -4077,14 +4077,14 @@ Explained Query: cte l0 = Project (#2, #0{dst}, #1{min}) // { arity: 3 } Map (10995116285979) // { arity: 3 } - Reduce group_by=[#0{dst}] aggregates=[min(#1)] // { arity: 2 } + Reduce group_by=[#0{dst}] aggregates=[min(#1{w})] // { arity: 2 } Distinct project=[#0{dst}, #1] // { arity: 2 } Union // { arity: 2 } Project (#3{dst}, #5) // { arity: 2 } - Map ((#1 + integer_to_bigint(#4{w}))) // { arity: 6 } - Join on=(#0 = #2{src}) type=differential // { arity: 5 } + Map ((#1{w} + integer_to_bigint(#4{w}))) // { arity: 6 } + Join on=(#0{dst} = #2{src}) type=differential // { arity: 5 } implementation - %0:l0[#0]UK » %1:pathq20[#0]KA + %0:l0[#0{dst}]UK » %1:pathq20[#0{src}]KA ArrangeBy keys=[[#0{dst}]] // { arity: 2 } Project (#1{dst}, #2{min}) // { arity: 2 } Get l0 // { arity: 3 } @@ -4108,7 +4108,7 @@ Explained Query: Filter (#5{name} = "Balkh_Airlines") // { arity: 8 } Join on=(#2{companyid} = #4{id}) type=differential // { arity: 8 } implementation - %1:company[#0]KAef » %0:person_workat_company[#2]KAef + %1:company[#0{id}]KAef » %0:person_workat_company[#2{companyid}]KAef ArrangeBy keys=[[#2{companyid}]] // { arity: 4 } ReadIndex on=person_workat_company person_workat_company_companyid=[differential join] // { arity: 4 } ArrangeBy keys=[[#0{id}]] // { arity: 4 } @@ -4183,14 +4183,14 @@ Explained Query: Finish order_by=[#0{dst} asc nulls_last] limit=20 output=[#0, #1] With Mutually Recursive cte l0 = - Reduce group_by=[#0{dst}] aggregates=[min(#1)] // { arity: 2 } + Reduce group_by=[#0{dst}] aggregates=[min(#1{w})] // { arity: 2 } Distinct project=[#0{dst}, #1] // { arity: 2 } Union // { arity: 2 } Project (#3{dst}, #5) // { arity: 2 } - Map ((#1 + integer_to_bigint(#4{w}))) // { arity: 6 } - Join on=(#0 = #2{src}) type=differential // { arity: 5 } + Map ((#1{w} + integer_to_bigint(#4{w}))) // { arity: 6 } + Join on=(#0{dst} = #2{src}) type=differential // { arity: 5 } implementation - %0:l0[#0]UK » %1:pathq20[#0]KA + %0:l0[#0{dst}]UK » %1:pathq20[#0{src}]KA ArrangeBy keys=[[#0{dst}]] // { arity: 2 } Get l0 // { arity: 2 } ArrangeBy keys=[[#0{src}]] // { arity: 3 } @@ -4212,7 +4212,7 @@ Explained Query: Filter (#5{name} = "Balkh_Airlines") // { arity: 8 } Join on=(#2{companyid} = #4{id}) type=differential // { arity: 8 } implementation - %1:company[#0]KAef » %0:person_workat_company[#2]KAef + %1:company[#0{id}]KAef » %0:person_workat_company[#2{companyid}]KAef ArrangeBy keys=[[#2{companyid}]] // { arity: 4 } ReadIndex on=person_workat_company person_workat_company_companyid=[differential join] // { arity: 4 } ArrangeBy keys=[[#0{id}]] // { arity: 4 } @@ -4294,15 +4294,15 @@ Explained Query: cte l0 = Project (#3, #0{dst}..=#2{min}) // { arity: 4 } Map (10995116285979) // { arity: 4 } - Reduce group_by=[#0{dst}, #2{min}] aggregates=[min(#1)] // { arity: 3 } - Reduce group_by=[#0{dst}, #2] aggregates=[min(#1)] // { arity: 3 } + Reduce group_by=[#0{dst}, #2{min}] aggregates=[min(#1{hops})] // { arity: 3 } + Reduce group_by=[#0{dst}, #2] aggregates=[min(#1{w})] // { arity: 3 } Distinct project=[#0{dst}..=#2] // { arity: 3 } Union // { arity: 3 } Project (#4{dst}, #6, #7) // { arity: 3 } - Map ((#1 + integer_to_bigint(#5{w})), (#2 + 1)) // { arity: 8 } - Join on=(#0 = #3{src}) type=differential // { arity: 6 } + Map ((#1{w} + integer_to_bigint(#5{w})), (#2{hops} + 1)) // { arity: 8 } + Join on=(#0{dst} = #3{src}) type=differential // { arity: 6 } implementation - %1:pathq20[#0]KA » %0:l0[#0]K + %1:pathq20[#0{src}]KA » %0:l0[#0{dst}]K ArrangeBy keys=[[#0{dst}]] // { arity: 3 } Project (#1{dst}..=#3{min}) // { arity: 3 } Get l0 // { arity: 4 } @@ -4326,7 +4326,7 @@ Explained Query: Filter (#5{name} = "Balkh_Airlines") // { arity: 8 } Join on=(#2{companyid} = #4{id}) type=differential // { arity: 8 } implementation - %1:company[#0]KAef » %0:person_workat_company[#2]KAef + %1:company[#0{id}]KAef » %0:person_workat_company[#2{companyid}]KAef ArrangeBy keys=[[#2{companyid}]] // { arity: 4 } ReadIndex on=person_workat_company person_workat_company_companyid=[differential join] // { arity: 4 } ArrangeBy keys=[[#0{id}]] // { arity: 4 } @@ -4447,7 +4447,7 @@ Explained Query: Filter (#5{name} = "Balkh_Airlines") // { arity: 8 } Join on=(#2{companyid} = #4{id}) type=differential // { arity: 8 } implementation - %1:company[#0]KAef » %0:person_workat_company[#2]KAef + %1:company[#0{id}]KAef » %0:person_workat_company[#2{companyid}]KAef ArrangeBy keys=[[#2{companyid}]] // { arity: 4 } ReadIndex on=person_workat_company person_workat_company_companyid=[differential join] // { arity: 4 } ArrangeBy keys=[[#0{id}]] // { arity: 4 } @@ -4464,11 +4464,11 @@ Explained Query: Distinct project=[#0{dst}] // { arity: 1 } Union // { arity: 1 } Project (#2{dst}) // { arity: 1 } - Join on=(#0 = #1{src}) type=delta // { arity: 4 } + Join on=(#0{pos} = #1{src}) type=delta // { arity: 4 } implementation - %0:l3 » %1:l1[#0]KA » %2[×] - %1:l1 » %0:l3[#0]UK » %2[×] - %2 » %0:l3[×] » %1:l1[#0]KA + %0:l3 » %1:l1[#0{src}]KA » %2[×] + %1:l1 » %0:l3[#0{pos}]UK » %2[×] + %2 » %0:l3[×] » %1:l1[#0{src}]KA ArrangeBy keys=[[], [#0{dst}]] // { arity: 1 } Get l3 // { arity: 1 } Get l1 // { arity: 3 } @@ -4479,7 +4479,7 @@ Explained Query: Project () // { arity: 0 } Join on=(#0{dst} = #1{personid}) type=differential // { arity: 2 } implementation - %0:l3[#0]UK » %1:l2[#0]K + %0:l3[#0{pos}]UK » %1:l2[#0{t}]K ArrangeBy keys=[[#0{dst}]] // { arity: 1 } Get l3 // { arity: 1 } Get l2 // { arity: 1 } @@ -4490,7 +4490,7 @@ Explained Query: cte l4 = TopK order_by=[#3 asc nulls_last] limit=1000 // { arity: 5 } Project (#0..=#3, #5) // { arity: 5 } - Filter (#4 = false) // { arity: 6 } + Filter (#4{dead} = false) // { arity: 6 } Get l12 // { arity: 6 } cte l5 = Distinct project=[#0..=#2] // { arity: 3 } @@ -4501,28 +4501,28 @@ Explained Query: Get l5 // { arity: 3 } cte l7 = Project (#0..=#2) // { arity: 3 } - Join on=(#0 = #3 AND #1 = #4 AND #2 = #5) type=differential // { arity: 6 } + Join on=(#0 = #3{dir} AND #1 = #4{gsrc} AND #2 = #5{dst}) type=differential // { arity: 6 } implementation %1[#0..=#2]UKKKA » %0:l6[#0..=#2]UKKK Get l6 // { arity: 3 } - ArrangeBy keys=[[#0..=#2]] // { arity: 3 } - Distinct project=[#0..=#2] // { arity: 3 } + ArrangeBy keys=[[#0{dir}..=#2{dst}]] // { arity: 3 } + Distinct project=[#0{dir}..=#2{dst}] // { arity: 3 } Project (#0..=#2) // { arity: 3 } Get l4 // { arity: 5 } cte l8 = TopK group_by=[#0, #1, #2{dst}] order_by=[#3 asc nulls_last, #4 desc nulls_first] limit=1 // { arity: 5 } Union // { arity: 5 } Project (#3, #4, #1{dst}, #7, #8) // { arity: 5 } - Map ((#6 + integer_to_bigint(#2{w})), false) // { arity: 9 } - Join on=(#0{src} = #5) type=differential // { arity: 7 } + Map ((#6{w} + integer_to_bigint(#2{w})), false) // { arity: 9 } + Join on=(#0{src} = #5{dst}) type=differential // { arity: 7 } implementation - %0:l1[#0]KA » %1:l4[#2]K + %0:l1[#0{src}]KA » %1:l4[#2{dst}]K Get l1 // { arity: 3 } - ArrangeBy keys=[[#2]] // { arity: 4 } + ArrangeBy keys=[[#2{dst}]] // { arity: 4 } Project (#0..=#3) // { arity: 4 } Get l4 // { arity: 5 } Project (#0..=#3, #9) // { arity: 5 } - Map ((#4 OR #8)) // { arity: 10 } + Map ((#4{dead} OR #8)) // { arity: 10 } Join on=(#0 = #5 AND #1 = #6 AND #2 = #7) type=differential // { arity: 9 } implementation %0:l12[#0..=#2]KKK » %1[#0..=#2]KKK @@ -4545,18 +4545,18 @@ Explained Query: Get l5 // { arity: 3 } Get l6 // { arity: 3 } cte l9 = - Reduce aggregates=[min((#0 + #1))] // { arity: 1 } + Reduce aggregates=[min((#0{w} + #1{w}))] // { arity: 1 } Project (#1, #3) // { arity: 2 } Join on=(#0{dst} = #2{dst}) type=differential // { arity: 4 } implementation - %0:l8[#0]Kef » %1:l8[#0]Kef + %0:l8[#0{dst}]Kef » %1:l8[#0{dst}]Kef ArrangeBy keys=[[#0{dst}]] // { arity: 2 } Project (#2{dst}, #3) // { arity: 2 } - Filter (#0 = false) // { arity: 5 } + Filter (#0{dir} = false) // { arity: 5 } Get l8 // { arity: 5 } ArrangeBy keys=[[#0{dst}]] // { arity: 2 } Project (#2{dst}, #3) // { arity: 2 } - Filter (#0 = true) // { arity: 5 } + Filter (#0{dir} = true) // { arity: 5 } Get l8 // { arity: 5 } cte l10 = Project (#1) // { arity: 1 } @@ -4575,7 +4575,7 @@ Explained Query: Project () // { arity: 0 } Join on=(#0{dst} = #1{personid}) type=differential // { arity: 2 } implementation - %0:l3[#0]UK » %1:l2[#0]K + %0:l3[#0{pos}]UK » %1:l2[#0{t}]K ArrangeBy keys=[[#0{dst}]] // { arity: 1 } Get l3 // { arity: 1 } Get l2 // { arity: 1 } @@ -4599,7 +4599,7 @@ Explained Query: ArrangeBy keys=[[]] // { arity: 0 } Get l11 // { arity: 0 } Project (#0..=#3, #7, #8) // { arity: 6 } - Map ((#4 OR coalesce((#3 > #6), false)), (#5 + 1)) // { arity: 9 } + Map ((#4{dead} OR coalesce((#3{w} > #6), false)), (#5{iter} + 1)) // { arity: 9 } CrossJoin type=delta // { arity: 7 } implementation %0:l8 » %1[×]U » %2[×]U @@ -4625,36 +4625,36 @@ Explained Query: With cte l13 = Project (#0..=#3) // { arity: 4 } - Join on=(#4 = #5{max}) type=differential // { arity: 6 } + Join on=(#4{iter} = #5{max}) type=differential // { arity: 6 } implementation - %1[#0]UK » %0:l12[#4]K - ArrangeBy keys=[[#4]] // { arity: 5 } + %1[#0]UK » %0:l12[#4{iter}]K + ArrangeBy keys=[[#4{iter}]] // { arity: 5 } Project (#0..=#3, #5) // { arity: 5 } Get l12 // { arity: 6 } ArrangeBy keys=[[#0{max}]] // { arity: 1 } - Reduce aggregates=[max(#0)] // { arity: 1 } + Reduce aggregates=[max(#0{iter})] // { arity: 1 } Project (#5) // { arity: 1 } Get l12 // { arity: 6 } cte l14 = Project (#1{personid}, #2{min}) // { arity: 2 } - Reduce group_by=[#0{personid}, #2{personid}] aggregates=[min((#1 + #3))] // { arity: 3 } + Reduce group_by=[#0{personid}, #2{personid}] aggregates=[min((#1{w} + #3{w}))] // { arity: 3 } Project (#0{personid}, #2, #3{personid}, #5) // { arity: 4 } Join on=(#1{personid} = #4{personid}) type=differential // { arity: 6 } implementation - %0:l13[#1]Kef » %1:l13[#1]Kef + %0:l13[#1{dst}]Kef » %1:l13[#1{dst}]Kef ArrangeBy keys=[[#1{personid}]] // { arity: 3 } Project (#1{personid}..=#3) // { arity: 3 } - Filter (#0 = false) // { arity: 4 } + Filter (#0{dir} = false) // { arity: 4 } Get l13 // { arity: 4 } ArrangeBy keys=[[#1{personid}]] // { arity: 3 } Project (#1{personid}..=#3) // { arity: 3 } - Filter (#0 = true) // { arity: 4 } + Filter (#0{dir} = true) // { arity: 4 } Get l13 // { arity: 4 } Return // { arity: 2 } Project (#0{personid}, #1{min}) // { arity: 2 } Join on=(#1{min} = #2{min_min}) type=differential // { arity: 3 } implementation - %1[#0]UK » %0:l14[#1]K + %1[#0]UK » %0:l14[#1{w}]K ArrangeBy keys=[[#1{min}]] // { arity: 2 } Get l14 // { arity: 2 } ArrangeBy keys=[[#0{min_min}]] // { arity: 1 } diff --git a/test/sqllogictest/not-null-propagation.slt b/test/sqllogictest/not-null-propagation.slt index c398d120cb933..db3125b40fc8f 100644 --- a/test/sqllogictest/not-null-propagation.slt +++ b/test/sqllogictest/not-null-propagation.slt @@ -636,7 +636,7 @@ Explained Query: FlatMap wrap1(#0{col_not_null}, null) // { types: "(integer, integer?)" } Get l1 // { types: "(integer)" } cte l3 = - Reduce group_by=[#0{col_not_null}] aggregates=[any((#1 = 1))] // { types: "(integer, boolean?)" } + Reduce group_by=[#0{col_not_null}] aggregates=[any((#1{right_col0_0} = 1))] // { types: "(integer, boolean?)" } Get l2 // { types: "(integer, integer?)" } cte l4 = Union // { types: "(integer, boolean?)" } @@ -648,7 +648,7 @@ Explained Query: Get l3 // { types: "(integer, boolean?)" } Get l1 // { types: "(integer)" } cte l5 = - Reduce group_by=[#0{col_not_null}] aggregates=[all((#1 = 1))] // { types: "(integer, boolean?)" } + Reduce group_by=[#0{col_not_null}] aggregates=[all((#1{right_col0_2} = 1))] // { types: "(integer, boolean?)" } Get l2 // { types: "(integer, integer?)" } cte l6 = Union // { types: "(integer, boolean?)" } @@ -785,7 +785,7 @@ Explained Query: Distinct project=[] // { types: "()" } Get l0 // { types: "()" } Return // { types: "(boolean, boolean)" } - Map (NOT(#0)) // { types: "(boolean, boolean)" } + Map (NOT(#0{?column?})) // { types: "(boolean, boolean)" } CrossJoin type=differential // { types: "(boolean)" } ArrangeBy keys=[[]] // { types: "()" } Get l0 // { types: "()" } diff --git a/test/sqllogictest/outer_join_lowering.slt b/test/sqllogictest/outer_join_lowering.slt index d14bdd32eb7e1..5a98ae209bd61 100644 --- a/test/sqllogictest/outer_join_lowering.slt +++ b/test/sqllogictest/outer_join_lowering.slt @@ -693,7 +693,7 @@ With Distinct project=[#12{dim01_d01}] // { arity: 1 } Get l3 // { arity: 17 } cte l5 = - Reduce group_by=[#0{dim01_d01}] aggregates=[any((#0{dim01_d01} = #1))] // { arity: 2 } + Reduce group_by=[#0{dim01_d01}] aggregates=[any((#0{dim01_d01} = #1{right_col0_0}))] // { arity: 2 } FlatMap unnest_array(strtoarray("{24, 42}")) // { arity: 2 } Get l4 // { arity: 1 } cte l6 = diff --git a/test/sqllogictest/outer_join_simplification.slt b/test/sqllogictest/outer_join_simplification.slt index 9dc93935a4890..4987b832c017d 100644 --- a/test/sqllogictest/outer_join_simplification.slt +++ b/test/sqllogictest/outer_join_simplification.slt @@ -643,8 +643,8 @@ Explained Query: With Mutually Recursive cte l0 = Project (#0..=#2, #4{v}) - Join on=(#0 = #3{a}) type=differential - ArrangeBy keys=[[#0]] + Join on=(#0{a} = #3{a}) type=differential + ArrangeBy keys=[[#0{a}]] Project (#0..=#2) Filter (#0{a}) IS NOT NULL Get l1 @@ -755,7 +755,7 @@ Explained Query: Distinct project=[#0{a}..=#2{u}] Union Project (#11..=#13) - Map ((#7) IS NULL, (#0 + case when (#4) IS NULL then null else #0 end), (#1 + case when #10 then null else #1 end), (#2 || smallint_to_text((case when #10 then null else #6{c} end + case when (#9) IS NULL then null else #8{c} end)))) + Map ((#7) IS NULL, (#0{a} + case when (#4) IS NULL then null else #0 end), (#1{b} + case when #10 then null else #1 end), (#2{u} || smallint_to_text((case when #10 then null else #6{c} end + case when (#9) IS NULL then null else #8{c} end)))) Join on=(#0 = #3{a} AND #1 = #5{b} AND #8{c} = case when (#7) IS NULL then null else #6{c} end) type=delta ArrangeBy keys=[[#0{a}], [#1{b}]] Get l1 diff --git a/test/sqllogictest/record.slt b/test/sqllogictest/record.slt index b78b8887daa32..777ff03096119 100644 --- a/test/sqllogictest/record.slt +++ b/test/sqllogictest/record.slt @@ -31,7 +31,7 @@ EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) ---- Explained Query: Project (#2, #3) // { arity: 2 } - Map (row(#0{a}, #0{a}), record_get[1](#2)) // { arity: 4 } + Map (row(#0{a}, #0{a}), record_get[1](#2{record})) // { arity: 4 } ReadStorage materialize.public.t1 // { arity: 2 } Source materialize.public.t1 diff --git a/test/sqllogictest/reduce_mfp.slt b/test/sqllogictest/reduce_mfp.slt index 68fc845972b78..ed387e3aa5e22 100644 --- a/test/sqllogictest/reduce_mfp.slt +++ b/test/sqllogictest/reduce_mfp.slt @@ -45,16 +45,16 @@ MATERIALIZED VIEW mv_fusable_mfp_accumulable; ---- materialize.public.mv_fusable_mfp_accumulable: Reduce::Accumulable - simple_aggrs[0]=(0, 0, sum(#1)) - simple_aggrs[1]=(1, 1, count(#1)) + simple_aggrs[0]=(0, 0, sum(#1{b})) + simple_aggrs[1]=(1, 1, count(#1{b})) val_plan project=(#1, #1) key_plan project=(#0) mfp_after project=(#0, #1) - filter=(((#3 - integer_to_bigint(#0)) > 2) AND ((#3 / integer_to_bigint((1 + #0))) >= 1)) - map=((#2 + 1)) + filter=(((#3 - integer_to_bigint(#0{a})) > 2) AND ((#3 / integer_to_bigint((1 + #0{a}))) >= 1)) + map=((#2{?column?} + 1)) Get::PassArrangements materialize.public.t raw=true @@ -85,18 +85,18 @@ MATERIALIZED VIEW mv_complex_mfp_accumulable; materialize.public.mv_complex_mfp_accumulable: Mfp project=(#0, #3) - map=((#1 + 1)) + map=((#1{?column?} + 1)) input_key=#0 Reduce::Accumulable - simple_aggrs[0]=(0, 0, sum(#1)) - simple_aggrs[1]=(1, 1, count(#1)) + simple_aggrs[0]=(0, 0, sum(#1{b})) + simple_aggrs[1]=(1, 1, count(#1{b})) val_plan project=(#1, #1) key_plan project=(#0) mfp_after - filter=(((#3 - integer_to_bigint(#0)) > 2) AND ((#3 / integer_to_bigint((1 + #0))) >= 1)) - map=((#2 + 1)) + filter=(((#3 - integer_to_bigint(#0{a})) > 2) AND ((#3 / integer_to_bigint((1 + #0{a}))) >= 1)) + map=((#2{?column?} + 1)) Get::PassArrangements materialize.public.t raw=true diff --git a/test/sqllogictest/scalar_subqueries_select_list.slt b/test/sqllogictest/scalar_subqueries_select_list.slt index f2cf06c332830..52ba1b1099334 100644 --- a/test/sqllogictest/scalar_subqueries_select_list.slt +++ b/test/sqllogictest/scalar_subqueries_select_list.slt @@ -102,7 +102,7 @@ Explained Query: Project (#0{f1}) // { arity: 1 } Join on=(#0{f1} = #1{f1}) type=differential // { arity: 2 } implementation - %0:l0[#0]UKA » %1:t1[#0]K + %0:l0[#0{f1}]UKA » %1:t1[#0{f1}]K ArrangeBy keys=[[#0{f1}]] // { arity: 1 } Get l0 // { arity: 1 } ArrangeBy keys=[[#0{f1}]] // { arity: 1 } @@ -174,13 +174,13 @@ Explained Query: Union // { arity: 2 } Join on=(#1{f1} = (#0{f1} + 1)) type=differential // { arity: 2 } implementation - %0:l1[(#0 + 1)]K » %1:l2[#0]K + %0:l1[(#0{f1} + 1)]K » %1:l2[#0{f1}]K ArrangeBy keys=[[(#0{f1} + 1)]] // { arity: 1 } Get l1 // { arity: 1 } Get l2 // { arity: 1 } Join on=(#1{f1} = (#0{f1} + 2)) type=differential // { arity: 2 } implementation - %0:l1[(#0 + 2)]K » %1:l2[#0]K + %0:l1[(#0{f1} + 2)]K » %1:l2[#0{f1}]K ArrangeBy keys=[[(#0{f1} + 2)]] // { arity: 1 } Get l1 // { arity: 1 } Get l2 // { arity: 1 } @@ -241,7 +241,7 @@ Explained Query: cte l3 = Join on=(#1{f1} = (#0{f1} + 1)) type=differential // { arity: 2 } implementation - %0:l1[(#0 + 1)]K » %1:l2[#0]K + %0:l1[(#0{f1} + 1)]K » %1:l2[#0{f1}]K ArrangeBy keys=[[(#0{f1} + 1)]] // { arity: 1 } Get l1 // { arity: 1 } Get l2 // { arity: 1 } @@ -257,7 +257,7 @@ Explained Query: cte l5 = Join on=(#1{f1} = (#0{f1} + 2)) type=differential // { arity: 2 } implementation - %0:l1[(#0 + 2)]K » %1:l2[#0]K + %0:l1[(#0{f1} + 2)]K » %1:l2[#0{f1}]K ArrangeBy keys=[[(#0{f1} + 2)]] // { arity: 1 } Get l1 // { arity: 1 } Get l2 // { arity: 1 } @@ -331,7 +331,7 @@ Explained Query: Project (#0{f1}) // { arity: 1 } Join on=(#0{f1} = #1{f1}) type=differential // { arity: 2 } implementation - %0:l0[#0]UKA » %1:t1[#0]K + %0:l0[#0{f1}]UKA » %1:t1[#0{f1}]K ArrangeBy keys=[[#0{f1}]] // { arity: 1 } Get l0 // { arity: 1 } ArrangeBy keys=[[#0{f1}]] // { arity: 1 } @@ -410,7 +410,7 @@ Explained Query: Project (#0{f1}) // { arity: 1 } Join on=(#0{f1} = #1{f1}) type=differential // { arity: 2 } implementation - %0:l0[#0]UKA » %1:t1[#0]K + %0:l0[#0{f1}]UKA » %1:t1[#0{f1}]K ArrangeBy keys=[[#0{f1}]] // { arity: 1 } Get l0 // { arity: 1 } ArrangeBy keys=[[#0{f1}]] // { arity: 1 } @@ -499,7 +499,7 @@ Explained Query: Project (#0{f1}) // { arity: 1 } Join on=(#0{f1} = #1{f1}) type=differential // { arity: 2 } implementation - %0:l0[#0]UKA » %1:t2[#0]K + %0:l0[#0{f1}]UKA » %1:t2[#0{f1}]K ArrangeBy keys=[[#0{f1}]] // { arity: 1 } Get l0 // { arity: 1 } ArrangeBy keys=[[#0{f1}]] // { arity: 1 } @@ -512,7 +512,7 @@ Explained Query: Project (#0{f1}) // { arity: 1 } Join on=(#0{f1} = #1{f1}) type=differential // { arity: 2 } implementation - %0:l2[#0]UKA » %1:t1[#0]K + %0:l2[#0{f1}]UKA » %1:t1[#0{f1}]K ArrangeBy keys=[[#0{f1}]] // { arity: 1 } Get l2 // { arity: 1 } ArrangeBy keys=[[#0{f1}]] // { arity: 1 } @@ -608,7 +608,7 @@ Explained Query: Project (#0{f1}) // { arity: 1 } Join on=(#0{f1} = #1{f1}) type=differential // { arity: 2 } implementation - %0:l0[#0]UKA » %1:l1[#0]K + %0:l0[#0{f1}]UKA » %1:l1[#0{f1}]K ArrangeBy keys=[[#0{f1}]] // { arity: 1 } Get l0 // { arity: 1 } Get l1 // { arity: 1 } @@ -646,7 +646,7 @@ Explained Query: Project (#0{f1}) // { arity: 1 } Join on=(#0{f1} = #1{f1}) type=differential // { arity: 2 } implementation - %0:l5[#0]UKA » %1:l1[#0]K + %0:l5[#0{f1}]UKA » %1:l1[#0{f1}]K ArrangeBy keys=[[#0{f1}]] // { arity: 1 } Get l5 // { arity: 1 } Get l1 // { arity: 1 } @@ -721,9 +721,9 @@ Explained Query: Project (#0{f1}) // { arity: 1 } Join on=(#0{f1} = #1{f1} = #2{f1}) type=delta // { arity: 3 } implementation - %0:l0 » %1:t1[#0]K » %2:t2[#0]K - %1:t1 » %0:l0[#0]UKA » %2:t2[#0]K - %2:t2 » %0:l0[#0]UKA » %1:t1[#0]K + %0:l0 » %1:t1[#0{f1}]K » %2:t2[#0{f1}]K + %1:t1 » %0:l0[#0]UKA » %2:t2[#0{f1}]K + %2:t2 » %0:l0[#0]UKA » %1:t1[#0{f1}]K ArrangeBy keys=[[#0{f1}]] // { arity: 1 } Get l0 // { arity: 1 } ArrangeBy keys=[[#0{f1}]] // { arity: 1 } @@ -807,7 +807,7 @@ Explained Query: Project (#0{f1}, #1{f1}) // { arity: 2 } Join on=(#0{f1} = #2{f1}) type=differential // { arity: 3 } implementation - %0:l1[#0]UKf » %1:t1[#0]Kf + %0:l1[#0{f1}]UKf » %1:t1[#0{f1}]Kf ArrangeBy keys=[[#0{f1}]] // { arity: 2 } Filter (#0{f1} = #1{f1}) // { arity: 2 } Get l1 // { arity: 2 } diff --git a/test/sqllogictest/subquery.slt b/test/sqllogictest/subquery.slt index 8fd47eb5b1af3..a6450535bf8b5 100644 --- a/test/sqllogictest/subquery.slt +++ b/test/sqllogictest/subquery.slt @@ -180,7 +180,7 @@ query BBBBBBBBBBBBBBB ---- true false false true false false NULL true NULL NULL NULL NULL NULL NULL NULL -query error subquery has 0 columns available but 1 columns specified +query error db error: ERROR: subquery1 has 0 columns available but 1 columns specified SELECT 1 < ALL(SELECT * FROM nullary) query error Expected subselect to return 1 column, got 0 columns @@ -192,7 +192,7 @@ SELECT * FROM (SELECT); ---- -query error subquery has 2 columns available but 1 columns specified +query error db error: ERROR: subquery1 has 2 columns available but 1 columns specified SELECT 1 < ALL(SELECT 1, 2) statement ok @@ -276,9 +276,9 @@ Explained Query: Project (#0{a}, #0{a}, #2{b}) // { arity: 3 } Join on=(#0{a} = #1{a}) type=delta // { arity: 3 } implementation - %0:t1 » %2[×]UA » %1:t3[#0]K - %1:t3 » %2[×]UA » %0:t1[#0]K - %2 » %0:t1[×] » %1:t3[#0]K + %0:t1 » %2[×]UA » %1:t3[#0{a}]K + %1:t3 » %2[×]UA » %0:t1[#0{a}]K + %2 » %0:t1[×] » %1:t3[#0{a}]K ArrangeBy keys=[[], [#0{a}]] // { arity: 1 } ReadStorage materialize.public.t1 // { arity: 1 } ArrangeBy keys=[[#0{a}]] // { arity: 2 } @@ -303,9 +303,9 @@ Explained Query: Project (#0{a}, #0{a}, #2{b}) // { arity: 3 } Join on=(#0{a} = #1{a} AND #2{b} = #3{b}) type=delta // { arity: 4 } implementation - %0:t1 » %1:t3[#0]K » %2[#0]UKA - %1:t3 » %2[#0]UKA » %0:t1[#0]K - %2 » %1:t3[#1]K » %0:t1[#0]K + %0:t1 » %1:t3[#0{a}]K » %2[#0]UKA + %1:t3 » %2[#0]UKA » %0:t1[#0{a}]K + %2 » %1:t3[#1]K » %0:t1[#0{a}]K ArrangeBy keys=[[#0{a}]] // { arity: 1 } ReadStorage materialize.public.t1 // { arity: 1 } ArrangeBy keys=[[#0{a}], [#1{b}]] // { arity: 2 } @@ -343,7 +343,7 @@ Explained Query: Map ((ascii(substr(replace(#1{likee}, "o", "i"), 2, 1)) * 2)) // { arity: 5 } Join on=(#0{liker} = #2{peep}) type=differential // { arity: 4 } implementation - %0:likes[#0]K » %1:age[#0]K + %0:likes[#0{liker}]K » %1:age[#0{peep}]K ArrangeBy keys=[[#0{liker}]] // { arity: 2 } Filter (#0{liker}) IS NOT NULL // { arity: 2 } ReadStorage materialize.public.likes // { arity: 2 } diff --git a/test/sqllogictest/table_func.slt b/test/sqllogictest/table_func.slt index 130fe71bbc904..62f83e1c80ce6 100644 --- a/test/sqllogictest/table_func.slt +++ b/test/sqllogictest/table_func.slt @@ -201,7 +201,7 @@ EXPLAIN RAW PLAN FOR SELECT * FROM x, generate_series(1, a) ---- CrossJoin Get materialize.public.x - CallTable generate_series(1, #^0, 1) + CallTable generate_series(1, #^0{a}, 1) Target cluster: quickstart @@ -212,7 +212,7 @@ EXPLAIN RAW PLAN FOR SELECT * FROM x, generate_series(100::bigint, a) ---- CrossJoin Get materialize.public.x - CallTable generate_series(integer_to_bigint(100), integer_to_bigint(#^0), 1) + CallTable generate_series(integer_to_bigint(100), integer_to_bigint(#^0{a}), 1) Target cluster: quickstart @@ -274,7 +274,7 @@ Explained Query: Project (#0{a}..=#2{a}) // { arity: 3 } Join on=(#1{b} = #3{b}) type=differential // { arity: 4 } implementation - %0:l0[#1]K » %1:l0[#1]K + %0:l0[#1{b}]K » %1:l0[#1{b}]K Get l0 // { arity: 2 } Get l0 // { arity: 2 } @@ -300,7 +300,7 @@ Explained Query: Project (#0{a}..=#2{a}) // { arity: 3 } Join on=(#1{b} = #3{b}) type=differential // { arity: 4 } implementation - %0:l0[#1]K » %1:l0[#1]K + %0:l0[#1{b}]K » %1:l0[#1{b}]K Get l0 // { arity: 2 } Get l0 // { arity: 2 } @@ -324,12 +324,12 @@ Explained Query: ReadStorage materialize.public.x // { arity: 2 } Return // { arity: 5 } Project (#0{a}..=#2{a}, #1{b}, #3) // { arity: 5 } - Filter (#0{a} = #3) // { arity: 4 } + Filter (#0{a} = #3{b}) // { arity: 4 } FlatMap generate_series(#0{a}, #1{b}, 1) // { arity: 4 } Project (#0{a}..=#2{a}) // { arity: 3 } Join on=(#1{b} = #3{b}) type=differential // { arity: 4 } implementation - %0:l0[#1]K » %1:l0[#1]K + %0:l0[#1{b}]K » %1:l0[#1{b}]K Get l0 // { arity: 2 } Get l0 // { arity: 2 } @@ -1446,7 +1446,7 @@ query T multiline EXPLAIN RAW PLAN FOR SELECT jsonb_object_keys('{"1":2}'::JSONB), jsonb_object_keys('{"3":4}'::JSONB); ---- Project (#5, #6) - Map (case when (#1) IS NULL then null else #0 end, case when (#3) IS NULL then null else #2 end) + Map (case when (#1) IS NULL then null else #0{jsonb_object_keys} end, case when (#3) IS NULL then null else #2{jsonb_object_keys} end) Project (#0, #1, #3..=#5) Map (coalesce(#2, #4)) FullOuterJoin (#2 = #4) diff --git a/test/sqllogictest/tpch_create_index.slt b/test/sqllogictest/tpch_create_index.slt index d45c93816e29a..5b93a6111a45b 100644 --- a/test/sqllogictest/tpch_create_index.slt +++ b/test/sqllogictest/tpch_create_index.slt @@ -285,11 +285,11 @@ materialize.public.q02: Filter (#5{p_size} = 15) AND (#26{r_name} = "EUROPE") AND like["%BRASS"](varchar_to_text(#4{p_type})) // { arity: 28 } Join on=(#0{p_partkey} = #16{ps_partkey} AND #9{s_suppkey} = #17{ps_suppkey} AND #12{s_nationkey} = #21{n_nationkey} AND #23{n_regionkey} = #25{r_regionkey}) type=delta // { arity: 28 } implementation - %0:part » %2:l1[#0]KA » %1:l0[#0]KA » %3:l2[#0]KA » %4:l3[#0]KAef - %1:l0 » %2:l1[#1]KA » %0:part[#0]KAelf » %3:l2[#0]KA » %4:l3[#0]KAef - %2:l1 » %0:part[#0]KAelf » %1:l0[#0]KA » %3:l2[#0]KA » %4:l3[#0]KAef - %3:l2 » %4:l3[#0]KAef » %1:l0[#3]KA » %2:l1[#1]KA » %0:part[#0]KAelf - %4:l3 » %3:l2[#2]KA » %1:l0[#3]KA » %2:l1[#1]KA » %0:part[#0]KAelf + %0:part » %2:l1[#0{ps_partkey}]KA » %1:l0[#0{s_suppkey}]KA » %3:l2[#0{n_nationkey}]KA » %4:l3[#0{r_regionkey}]KAef + %1:l0 » %2:l1[#1{ps_suppkey}]KA » %0:part[#0{p_partkey}]KAelf » %3:l2[#0{n_nationkey}]KA » %4:l3[#0{r_regionkey}]KAef + %2:l1 » %0:part[#0{p_partkey}]KAelf » %1:l0[#0{s_suppkey}]KA » %3:l2[#0{n_nationkey}]KA » %4:l3[#0{r_regionkey}]KAef + %3:l2 » %4:l3[#0{r_regionkey}]KAef » %1:l0[#3{s_nationkey}]KA » %2:l1[#1{ps_suppkey}]KA » %0:part[#0{p_partkey}]KAelf + %4:l3 » %3:l2[#2{n_regionkey}]KA » %1:l0[#3{s_nationkey}]KA » %2:l1[#1{ps_suppkey}]KA » %0:part[#0{p_partkey}]KAelf ArrangeBy keys=[[#0{p_partkey}]] // { arity: 9 } ReadIndex on=part pk_part_partkey=[delta join 1st input (full scan)] // { arity: 9 } Get l0 // { arity: 7 } @@ -300,7 +300,7 @@ materialize.public.q02: Project (#5{s_acctbal}, #2{s_name}, #8{n_name}, #0{p_partkey}, #1{p_mfgr}, #3{s_address}, #4{s_phone}, #6{s_comment}) // { arity: 8 } Join on=(#0{p_partkey} = #9{p_partkey} AND #7{ps_supplycost} = #10{min_ps_supplycost}) type=differential // { arity: 11 } implementation - %1[#0, #1]UKK » %0:l4[#0, #7]KK + %1[#0, #1]UKK » %0:l4[#0, #7{ps_supplycost}]KK ArrangeBy keys=[[#0{p_partkey}, #7{ps_supplycost}]] // { arity: 9 } Get l4 // { arity: 9 } ArrangeBy keys=[[#0{p_partkey}, #1{min_ps_supplycost}]] // { arity: 2 } @@ -309,11 +309,11 @@ materialize.public.q02: Filter (#18{r_name} = "EUROPE") // { arity: 20 } Join on=(#0{p_partkey} = #1{ps_partkey} AND #2{ps_suppkey} = #6{s_suppkey} AND #9{s_nationkey} = #13{n_nationkey} AND #15{n_regionkey} = #17{r_regionkey}) type=delta // { arity: 20 } implementation - %0 » %1:l1[#0]KA » %2:l0[#0]KA » %3:l2[#0]KA » %4:l3[#0]KAef - %1:l1 » %0[#0]UKA » %2:l0[#0]KA » %3:l2[#0]KA » %4:l3[#0]KAef - %2:l0 » %1:l1[#1]KA » %0[#0]UKA » %3:l2[#0]KA » %4:l3[#0]KAef - %3:l2 » %4:l3[#0]KAef » %2:l0[#3]KA » %1:l1[#1]KA » %0[#0]UKA - %4:l3 » %3:l2[#2]KA » %2:l0[#3]KA » %1:l1[#1]KA » %0[#0]UKA + %0 » %1:l1[#0{ps_partkey}]KA » %2:l0[#0{s_suppkey}]KA » %3:l2[#0{n_nationkey}]KA » %4:l3[#0{r_regionkey}]KAef + %1:l1 » %0[#0]UKA » %2:l0[#0{s_suppkey}]KA » %3:l2[#0{n_nationkey}]KA » %4:l3[#0{r_regionkey}]KAef + %2:l0 » %1:l1[#1{ps_suppkey}]KA » %0[#0]UKA » %3:l2[#0{n_nationkey}]KA » %4:l3[#0{r_regionkey}]KAef + %3:l2 » %4:l3[#0{r_regionkey}]KAef » %2:l0[#3{s_nationkey}]KA » %1:l1[#1{ps_suppkey}]KA » %0[#0]UKA + %4:l3 » %3:l2[#2{n_regionkey}]KA » %2:l0[#3{s_nationkey}]KA » %1:l1[#1{ps_suppkey}]KA » %0[#0]UKA ArrangeBy keys=[[#0{p_partkey}]] // { arity: 1 } Distinct project=[#0{p_partkey}] // { arity: 1 } Project (#0{p_partkey}) // { arity: 1 } @@ -381,9 +381,9 @@ materialize.public.q03: Filter (#6{c_mktsegment} = "BUILDING") AND (#12{o_orderdate} < 1995-03-15) AND (#27{l_shipdate} > 1995-03-15) // { arity: 33 } Join on=(#0{c_custkey} = #9{o_custkey} AND #8{o_orderkey} = #17{l_orderkey}) type=delta // { arity: 33 } implementation - %0:customer » %1:orders[#1]KAif » %2:lineitem[#0]KAif - %1:orders » %0:customer[#0]KAef » %2:lineitem[#0]KAif - %2:lineitem » %1:orders[#0]KAif » %0:customer[#0]KAef + %0:customer » %1:orders[#1{o_custkey}]KAif » %2:lineitem[#0{l_orderkey}]KAif + %1:orders » %0:customer[#0{c_custkey}]KAef » %2:lineitem[#0{l_orderkey}]KAif + %2:lineitem » %1:orders[#0{o_orderkey}]KAif » %0:customer[#0{c_custkey}]KAef ArrangeBy keys=[[#0{c_custkey}]] // { arity: 8 } ReadIndex on=customer pk_customer_custkey=[delta join 1st input (full scan)] // { arity: 8 } ArrangeBy keys=[[#0{o_orderkey}], [#1{o_custkey}]] // { arity: 9 } @@ -443,7 +443,7 @@ materialize.public.q04: Filter (#4{o_orderdate} >= 1993-07-01) AND (date_to_timestamp(#4{o_orderdate}) < 1993-10-01 00:00:00) // { arity: 10 } Join on=(#0{o_orderkey} = #9{l_orderkey}) type=differential // { arity: 10 } implementation - %1[#0]UKA » %0:orders[#0]KAiif + %1[#0]UKA » %0:orders[#0{o_orderkey}]KAiif ArrangeBy keys=[[#0{o_orderkey}]] // { arity: 9 } ReadIndex on=orders pk_orders_orderkey=[differential join] // { arity: 9 } ArrangeBy keys=[[#0{l_orderkey}]] // { arity: 1 } @@ -505,12 +505,12 @@ materialize.public.q05: Filter (#45{r_name} = "ASIA") AND (#12{o_orderdate} < 1995-01-01) AND (#12{o_orderdate} >= 1994-01-01) // { arity: 47 } Join on=(#0{c_custkey} = #9{o_custkey} AND #3{c_nationkey} = #36{s_nationkey} = #40{n_nationkey} AND #8{o_orderkey} = #17{l_orderkey} AND #19{l_suppkey} = #33{s_suppkey} AND #42{n_regionkey} = #44{r_regionkey}) type=delta // { arity: 47 } implementation - %0:customer » %1:orders[#1]KAiif » %2:lineitem[#0]KA » %3:supplier[#3]KA » %4:nation[#0]KA » %5:region[#0]KAef - %1:orders » %0:customer[#0]KA » %2:lineitem[#0]KA » %3:supplier[#3]KA » %4:nation[#0]KA » %5:region[#0]KAef - %2:lineitem » %1:orders[#0]KAiif » %0:customer[#0]KA » %3:supplier[#3]KA » %4:nation[#0]KA » %5:region[#0]KAef - %3:supplier » %0:customer[#3]KA » %1:orders[#1]KAiif » %2:lineitem[#2]KA » %4:nation[#0]KA » %5:region[#0]KAef - %4:nation » %5:region[#0]KAef » %0:customer[#3]KA » %1:orders[#1]KAiif » %2:lineitem[#0]KA » %3:supplier[#3]KA - %5:region » %4:nation[#2]KA » %0:customer[#3]KA » %1:orders[#1]KAiif » %2:lineitem[#0]KA » %3:supplier[#3]KA + %0:customer » %1:orders[#1{o_custkey}]KAiif » %2:lineitem[#0{l_orderkey}]KA » %3:supplier[#3{s_nationkey}]KA » %4:nation[#0{n_nationkey}]KA » %5:region[#0{r_regionkey}]KAef + %1:orders » %0:customer[#0{c_custkey}]KA » %2:lineitem[#0{l_orderkey}]KA » %3:supplier[#3{s_nationkey}]KA » %4:nation[#0{n_nationkey}]KA » %5:region[#0{r_regionkey}]KAef + %2:lineitem » %1:orders[#0{o_orderkey}]KAiif » %0:customer[#0{c_custkey}]KA » %3:supplier[#3{s_nationkey}]KA » %4:nation[#0{n_nationkey}]KA » %5:region[#0{r_regionkey}]KAef + %3:supplier » %0:customer[#3{c_nationkey}]KA » %1:orders[#1{o_custkey}]KAiif » %2:lineitem[#2{l_suppkey}]KA » %4:nation[#0{n_nationkey}]KA » %5:region[#0{r_regionkey}]KAef + %4:nation » %5:region[#0{r_regionkey}]KAef » %0:customer[#3{c_nationkey}]KA » %1:orders[#1{o_custkey}]KAiif » %2:lineitem[#0{l_orderkey}]KA » %3:supplier[#3{s_nationkey}]KA + %5:region » %4:nation[#2{n_regionkey}]KA » %0:customer[#3{c_nationkey}]KA » %1:orders[#1{o_custkey}]KAiif » %2:lineitem[#0{l_orderkey}]KA » %3:supplier[#3{s_nationkey}]KA ArrangeBy keys=[[#0{c_custkey}], [#3{c_nationkey}]] // { arity: 8 } ReadIndex on=customer pk_customer_custkey=[delta join 1st input (full scan)] fk_customer_nationkey=[delta join lookup] // { arity: 8 } ArrangeBy keys=[[#0{o_orderkey}], [#1{o_custkey}]] // { arity: 9 } @@ -655,12 +655,12 @@ materialize.public.q07: Map ((#41{n_name} = "FRANCE"), (#41{n_name} = "GERMANY"), (#45{n_name} = "FRANCE"), (#45{n_name} = "GERMANY")) // { arity: 52 } Join on=(#0{s_suppkey} = #9{l_suppkey} AND #3{s_nationkey} = #40{n_nationkey} AND #7{l_orderkey} = #23{o_orderkey} AND #24{o_custkey} = #32{c_custkey} AND #35{c_nationkey} = #44{n_nationkey}) type=delta // { arity: 48 } implementation - %0:supplier » %4:l0[#0]KAef » %1:lineitem[#2]KAiif » %2:orders[#0]KA » %3:customer[#0]KA » %5:l0[#0]KAef - %1:lineitem » %0:supplier[#0]KA » %4:l0[#0]KAef » %2:orders[#0]KA » %3:customer[#0]KA » %5:l0[#0]KAef - %2:orders » %1:lineitem[#0]KAiif » %0:supplier[#0]KA » %4:l0[#0]KAef » %3:customer[#0]KA » %5:l0[#0]KAef - %3:customer » %5:l0[#0]KAef » %2:orders[#1]KA » %1:lineitem[#0]KAiif » %0:supplier[#0]KA » %4:l0[#0]KAef - %4:l0 » %0:supplier[#3]KA » %1:lineitem[#2]KAiif » %2:orders[#0]KA » %3:customer[#0]KA » %5:l0[#0]KAef - %5:l0 » %3:customer[#3]KA » %2:orders[#1]KA » %1:lineitem[#0]KAiif » %0:supplier[#0]KA » %4:l0[#0]KAef + %0:supplier » %4:l0[#0{n_nationkey}]KAef » %1:lineitem[#2{l_suppkey}]KAiif » %2:orders[#0{o_orderkey}]KA » %3:customer[#0{c_custkey}]KA » %5:l0[#0{n_nationkey}]KAef + %1:lineitem » %0:supplier[#0{s_suppkey}]KA » %4:l0[#0{n_nationkey}]KAef » %2:orders[#0{o_orderkey}]KA » %3:customer[#0{c_custkey}]KA » %5:l0[#0{n_nationkey}]KAef + %2:orders » %1:lineitem[#0{l_orderkey}]KAiif » %0:supplier[#0{s_suppkey}]KA » %4:l0[#0{n_nationkey}]KAef » %3:customer[#0{c_custkey}]KA » %5:l0[#0{n_nationkey}]KAef + %3:customer » %5:l0[#0{n_nationkey}]KAef » %2:orders[#1{o_custkey}]KA » %1:lineitem[#0{l_orderkey}]KAiif » %0:supplier[#0{s_suppkey}]KA » %4:l0[#0{n_nationkey}]KAef + %4:l0 » %0:supplier[#3{s_nationkey}]KA » %1:lineitem[#2{l_suppkey}]KAiif » %2:orders[#0{o_orderkey}]KA » %3:customer[#0{c_custkey}]KA » %5:l0[#0{n_nationkey}]KAef + %5:l0 » %3:customer[#3{c_nationkey}]KA » %2:orders[#1{o_custkey}]KA » %1:lineitem[#0{l_orderkey}]KAiif » %0:supplier[#0{s_suppkey}]KA » %4:l0[#0{n_nationkey}]KAef ArrangeBy keys=[[#0{s_suppkey}], [#3{s_nationkey}]] // { arity: 7 } ReadIndex on=supplier pk_supplier_suppkey=[delta join 1st input (full scan)] fk_supplier_nationkey=[delta join lookup] // { arity: 7 } ArrangeBy keys=[[#0{l_orderkey}], [#2{l_suppkey}]] // { arity: 16 } @@ -747,14 +747,14 @@ materialize.public.q08: Filter (#58{r_name} = "AMERICA") AND (#36{o_orderdate} <= 1996-12-31) AND (#36{o_orderdate} >= 1995-01-01) AND ("ECONOMY ANODIZED STEEL" = varchar_to_text(#4{p_type})) // { arity: 60 } Join on=(#0{p_partkey} = #17{l_partkey} AND #9{s_suppkey} = #18{l_suppkey} AND #12{s_nationkey} = #53{n_nationkey} AND #16{l_orderkey} = #32{o_orderkey} AND #33{o_custkey} = #41{c_custkey} AND #44{c_nationkey} = #49{n_nationkey} AND #51{n_regionkey} = #57{r_regionkey}) type=delta // { arity: 60 } implementation - %0:part » %2:lineitem[#1]KA » %3:orders[#0]KAiif » %1:supplier[#0]KA » %4:customer[#0]KA » %5:nation[#0]KA » %7:region[#0]KAef » %6:nation[#0]KA - %1:supplier » %2:lineitem[#2]KA » %0:part[#0]KAef » %3:orders[#0]KAiif » %4:customer[#0]KA » %5:nation[#0]KA » %7:region[#0]KAef » %6:nation[#0]KA - %2:lineitem » %0:part[#0]KAef » %3:orders[#0]KAiif » %1:supplier[#0]KA » %4:customer[#0]KA » %5:nation[#0]KA » %7:region[#0]KAef » %6:nation[#0]KA - %3:orders » %2:lineitem[#0]KA » %0:part[#0]KAef » %1:supplier[#0]KA » %4:customer[#0]KA » %5:nation[#0]KA » %7:region[#0]KAef » %6:nation[#0]KA - %4:customer » %3:orders[#1]KAiif » %2:lineitem[#0]KA » %0:part[#0]KAef » %1:supplier[#0]KA » %5:nation[#0]KA » %7:region[#0]KAef » %6:nation[#0]KA - %5:nation » %7:region[#0]KAef » %4:customer[#3]KA » %3:orders[#1]KAiif » %2:lineitem[#0]KA » %0:part[#0]KAef » %1:supplier[#0]KA » %6:nation[#0]KA - %6:nation » %1:supplier[#3]KA » %2:lineitem[#2]KA » %0:part[#0]KAef » %3:orders[#0]KAiif » %4:customer[#0]KA » %5:nation[#0]KA » %7:region[#0]KAef - %7:region » %5:nation[#2]KA » %4:customer[#3]KA » %3:orders[#1]KAiif » %2:lineitem[#0]KA » %0:part[#0]KAef » %1:supplier[#0]KA » %6:nation[#0]KA + %0:part » %2:lineitem[#1{l_partkey}]KA » %3:orders[#0{o_orderkey}]KAiif » %1:supplier[#0{s_suppkey}]KA » %4:customer[#0{c_custkey}]KA » %5:nation[#0{n_nationkey}]KA » %7:region[#0{r_regionkey}]KAef » %6:nation[#0{n_nationkey}]KA + %1:supplier » %2:lineitem[#2{l_suppkey}]KA » %0:part[#0{p_partkey}]KAef » %3:orders[#0{o_orderkey}]KAiif » %4:customer[#0{c_custkey}]KA » %5:nation[#0{n_nationkey}]KA » %7:region[#0{r_regionkey}]KAef » %6:nation[#0{n_nationkey}]KA + %2:lineitem » %0:part[#0{p_partkey}]KAef » %3:orders[#0{o_orderkey}]KAiif » %1:supplier[#0{s_suppkey}]KA » %4:customer[#0{c_custkey}]KA » %5:nation[#0{n_nationkey}]KA » %7:region[#0{r_regionkey}]KAef » %6:nation[#0{n_nationkey}]KA + %3:orders » %2:lineitem[#0{l_orderkey}]KA » %0:part[#0{p_partkey}]KAef » %1:supplier[#0{s_suppkey}]KA » %4:customer[#0{c_custkey}]KA » %5:nation[#0{n_nationkey}]KA » %7:region[#0{r_regionkey}]KAef » %6:nation[#0{n_nationkey}]KA + %4:customer » %3:orders[#1{o_custkey}]KAiif » %2:lineitem[#0{l_orderkey}]KA » %0:part[#0{p_partkey}]KAef » %1:supplier[#0{s_suppkey}]KA » %5:nation[#0{n_nationkey}]KA » %7:region[#0{r_regionkey}]KAef » %6:nation[#0{n_nationkey}]KA + %5:nation » %7:region[#0{r_regionkey}]KAef » %4:customer[#3{c_nationkey}]KA » %3:orders[#1{o_custkey}]KAiif » %2:lineitem[#0{l_orderkey}]KA » %0:part[#0{p_partkey}]KAef » %1:supplier[#0{s_suppkey}]KA » %6:nation[#0{n_nationkey}]KA + %6:nation » %1:supplier[#3{s_nationkey}]KA » %2:lineitem[#2{l_suppkey}]KA » %0:part[#0{p_partkey}]KAef » %3:orders[#0{o_orderkey}]KAiif » %4:customer[#0{c_custkey}]KA » %5:nation[#0{n_nationkey}]KA » %7:region[#0{r_regionkey}]KAef + %7:region » %5:nation[#2{n_regionkey}]KA » %4:customer[#3{c_nationkey}]KA » %3:orders[#1{o_custkey}]KAiif » %2:lineitem[#0{l_orderkey}]KA » %0:part[#0{p_partkey}]KAef » %1:supplier[#0{s_suppkey}]KA » %6:nation[#0{n_nationkey}]KA ArrangeBy keys=[[#0{p_partkey}]] // { arity: 9 } ReadIndex on=part pk_part_partkey=[delta join 1st input (full scan)] // { arity: 9 } ArrangeBy keys=[[#0{s_suppkey}], [#3{s_nationkey}]] // { arity: 7 } @@ -844,12 +844,12 @@ materialize.public.q09: Filter like["%green%"](varchar_to_text(#1{p_name})) // { arity: 50 } Join on=(#0{p_partkey} = #17{l_partkey} = #32{ps_partkey} AND #9{s_suppkey} = #18{l_suppkey} = #33{ps_suppkey} AND #12{s_nationkey} = #46{n_nationkey} AND #16{l_orderkey} = #37{o_orderkey}) type=delta // { arity: 50 } implementation - %0:part » %2:lineitem[#1]KA » %3:partsupp[#0, #1]KKA » %1:supplier[#0]KA » %4:orders[#0]KA » %5:nation[#0]KA - %1:supplier » %2:lineitem[#2]KA » %3:partsupp[#0, #1]KKA » %0:part[#0]KAlf » %4:orders[#0]KA » %5:nation[#0]KA - %2:lineitem » %3:partsupp[#0, #1]KKA » %0:part[#0]KAlf » %1:supplier[#0]KA » %4:orders[#0]KA » %5:nation[#0]KA - %3:partsupp » %2:lineitem[#1, #2]KKA » %0:part[#0]KAlf » %1:supplier[#0]KA » %4:orders[#0]KA » %5:nation[#0]KA - %4:orders » %2:lineitem[#0]KA » %3:partsupp[#0, #1]KKA » %0:part[#0]KAlf » %1:supplier[#0]KA » %5:nation[#0]KA - %5:nation » %1:supplier[#3]KA » %2:lineitem[#2]KA » %3:partsupp[#0, #1]KKA » %0:part[#0]KAlf » %4:orders[#0]KA + %0:part » %2:lineitem[#1{l_partkey}]KA » %3:partsupp[#0{ps_partkey}, #1{ps_suppkey}]KKA » %1:supplier[#0{s_suppkey}]KA » %4:orders[#0{o_orderkey}]KA » %5:nation[#0{n_nationkey}]KA + %1:supplier » %2:lineitem[#2{l_suppkey}]KA » %3:partsupp[#0{ps_partkey}, #1{ps_suppkey}]KKA » %0:part[#0{p_partkey}]KAlf » %4:orders[#0{o_orderkey}]KA » %5:nation[#0{n_nationkey}]KA + %2:lineitem » %3:partsupp[#0{ps_partkey}, #1{ps_suppkey}]KKA » %0:part[#0{p_partkey}]KAlf » %1:supplier[#0{s_suppkey}]KA » %4:orders[#0{o_orderkey}]KA » %5:nation[#0{n_nationkey}]KA + %3:partsupp » %2:lineitem[#1{l_partkey}, #2{l_suppkey}]KKA » %0:part[#0{p_partkey}]KAlf » %1:supplier[#0{s_suppkey}]KA » %4:orders[#0{o_orderkey}]KA » %5:nation[#0{n_nationkey}]KA + %4:orders » %2:lineitem[#0{l_orderkey}]KA » %3:partsupp[#0{ps_partkey}, #1{ps_suppkey}]KKA » %0:part[#0{p_partkey}]KAlf » %1:supplier[#0{s_suppkey}]KA » %5:nation[#0{n_nationkey}]KA + %5:nation » %1:supplier[#3{s_nationkey}]KA » %2:lineitem[#2{l_suppkey}]KA » %3:partsupp[#0{ps_partkey}, #1{ps_suppkey}]KKA » %0:part[#0{p_partkey}]KAlf » %4:orders[#0{o_orderkey}]KA ArrangeBy keys=[[#0{p_partkey}]] // { arity: 9 } ReadIndex on=part pk_part_partkey=[delta join 1st input (full scan)] // { arity: 9 } ArrangeBy keys=[[#0{s_suppkey}], [#3{s_nationkey}]] // { arity: 7 } @@ -933,10 +933,10 @@ materialize.public.q10: Filter (#25{l_returnflag} = "R") AND (#12{o_orderdate} < 1994-01-01) AND (#12{o_orderdate} >= 1993-10-01) AND (date_to_timestamp(#12{o_orderdate}) < 1994-01-01 00:00:00) // { arity: 37 } Join on=(#0{c_custkey} = #9{o_custkey} AND #3{c_nationkey} = #33{n_nationkey} AND #8{o_orderkey} = #17{l_orderkey}) type=delta // { arity: 37 } implementation - %0:customer » %1:orders[#1]KAiiif » %2:lineitem[#0]KAef » %3:nation[#0]KA - %1:orders » %2:lineitem[#0]KAef » %0:customer[#0]KA » %3:nation[#0]KA - %2:lineitem » %1:orders[#0]KAiiif » %0:customer[#0]KA » %3:nation[#0]KA - %3:nation » %0:customer[#3]KA » %1:orders[#1]KAiiif » %2:lineitem[#0]KAef + %0:customer » %1:orders[#1{o_custkey}]KAiiif » %2:lineitem[#0{l_orderkey}]KAef » %3:nation[#0{n_nationkey}]KA + %1:orders » %2:lineitem[#0{l_orderkey}]KAef » %0:customer[#0{c_custkey}]KA » %3:nation[#0{n_nationkey}]KA + %2:lineitem » %1:orders[#0{o_orderkey}]KAiiif » %0:customer[#0{c_custkey}]KA » %3:nation[#0{n_nationkey}]KA + %3:nation » %0:customer[#3{c_nationkey}]KA » %1:orders[#1{o_custkey}]KAiiif » %2:lineitem[#0{l_orderkey}]KAef ArrangeBy keys=[[#0{c_custkey}], [#3{c_nationkey}]] // { arity: 8 } ReadIndex on=customer pk_customer_custkey=[delta join 1st input (full scan)] fk_customer_nationkey=[delta join lookup] // { arity: 8 } ArrangeBy keys=[[#0{o_orderkey}], [#1{o_custkey}]] // { arity: 9 } @@ -1007,9 +1007,9 @@ materialize.public.q11: Filter (#13{n_name} = "GERMANY") // { arity: 16 } Join on=(#1{ps_suppkey} = #5{s_suppkey} AND #8{s_nationkey} = #12{n_nationkey}) type=delta // { arity: 16 } implementation - %0:partsupp » %1:supplier[#0]KA » %2:nation[#0]KAef - %1:supplier » %2:nation[#0]KAef » %0:partsupp[#1]KA - %2:nation » %1:supplier[#3]KA » %0:partsupp[#1]KA + %0:partsupp » %1:supplier[#0{s_suppkey}]KA » %2:nation[#0{n_nationkey}]KAef + %1:supplier » %2:nation[#0{n_nationkey}]KAef » %0:partsupp[#1{ps_suppkey}]KA + %2:nation » %1:supplier[#3{s_nationkey}]KA » %0:partsupp[#1{ps_suppkey}]KA ArrangeBy keys=[[#1{ps_suppkey}]] // { arity: 5 } ReadIndex on=partsupp fk_partsupp_suppkey=[delta join 1st input (full scan)] // { arity: 5 } ArrangeBy keys=[[#0{s_suppkey}], [#3{s_nationkey}]] // { arity: 7 } @@ -1089,7 +1089,7 @@ materialize.public.q12: Filter (#21{l_receiptdate} >= 1994-01-01) AND (#19{l_shipdate} < #20{l_commitdate}) AND (#20{l_commitdate} < #21{l_receiptdate}) AND (date_to_timestamp(#21{l_receiptdate}) < 1995-01-01 00:00:00) AND ((#23{l_shipmode} = "MAIL") OR (#23{l_shipmode} = "SHIP")) // { arity: 25 } Join on=(#0{o_orderkey} = #9{l_orderkey}) type=differential // { arity: 25 } implementation - %1:lineitem[#0]KAeiif » %0:orders[#0]KAeiif + %1:lineitem[#0{l_orderkey}]KAeiif » %0:orders[#0{o_orderkey}]KAeiif ArrangeBy keys=[[#0{o_orderkey}]] // { arity: 9 } ReadIndex on=orders pk_orders_orderkey=[differential join] // { arity: 9 } ArrangeBy keys=[[#0{l_orderkey}]] // { arity: 16 } @@ -1148,7 +1148,7 @@ materialize.public.q13: Filter NOT(like["%special%requests%"](varchar_to_text(#16{o_comment}))) // { arity: 17 } Join on=(#0{c_custkey} = #9{o_custkey}) type=differential // { arity: 17 } implementation - %1:orders[#1]KAf » %0:l0[#0]KAf + %1:orders[#1{o_custkey}]KAf » %0:l0[#0{c_custkey}]KAf Get l0 // { arity: 8 } ArrangeBy keys=[[#1{o_custkey}]] // { arity: 9 } ReadIndex on=orders fk_orders_custkey=[differential join] // { arity: 9 } @@ -1163,7 +1163,7 @@ materialize.public.q13: Project (#0{c_custkey}) // { arity: 1 } Join on=(#0{c_custkey} = #8{c_custkey}) type=differential // { arity: 9 } implementation - %1[#0]UKA » %0:l0[#0]KA + %1[#0]UKA » %0:l0[#0{c_custkey}]KA Get l0 // { arity: 8 } ArrangeBy keys=[[#0{c_custkey}]] // { arity: 1 } Distinct project=[#0{c_custkey}] // { arity: 1 } @@ -1217,7 +1217,7 @@ materialize.public.q14: Filter (#10{l_shipdate} >= 1995-09-01) AND (date_to_timestamp(#10{l_shipdate}) < 1995-10-01 00:00:00) // { arity: 25 } Join on=(#1{l_partkey} = #16{p_partkey}) type=differential // { arity: 25 } implementation - %0:lineitem[#1]KAiif » %1:part[#0]KAiif + %0:lineitem[#1{l_partkey}]KAiif » %1:part[#0{p_partkey}]KAiif ArrangeBy keys=[[#1{l_partkey}]] // { arity: 16 } ReadIndex on=lineitem fk_lineitem_partkey=[differential join] // { arity: 16 } ArrangeBy keys=[[#0{p_partkey}]] // { arity: 9 } @@ -1302,8 +1302,8 @@ materialize.public.q15: Join on=(#0{s_suppkey} = #7{l_suppkey} AND #8{sum} = #9{max_sum}) type=delta // { arity: 10 } implementation %0:supplier » %1:l0[#0]UKA » %2[#0]UK - %1:l0 » %2[#0]UK » %0:supplier[#0]KA - %2 » %1:l0[#1]K » %0:supplier[#0]KA + %1:l0 » %2[#0]UK » %0:supplier[#0{s_suppkey}]KA + %2 » %1:l0[#1{total_revenue}]K » %0:supplier[#0{s_suppkey}]KA ArrangeBy keys=[[#0{s_suppkey}]] // { arity: 7 } ReadIndex on=supplier pk_supplier_suppkey=[delta join 1st input (full scan)] // { arity: 7 } ArrangeBy keys=[[#0{l_suppkey}], [#1{sum}]] // { arity: 2 } @@ -1373,7 +1373,7 @@ materialize.public.q16: Filter (#8{p_brand} != "Brand#45") AND NOT(like["MEDIUM POLISHED%"](varchar_to_text(#9{p_type}))) AND ((#10{p_size} = 3) OR (#10{p_size} = 9) OR (#10{p_size} = 14) OR (#10{p_size} = 19) OR (#10{p_size} = 23) OR (#10{p_size} = 36) OR (#10{p_size} = 45) OR (#10{p_size} = 49)) // { arity: 14 } Join on=(#0{ps_partkey} = #5{p_partkey}) type=differential // { arity: 14 } implementation - %1:part[#0]KAef » %0:partsupp[#0]KAef + %1:part[#0{p_partkey}]KAef » %0:partsupp[#0{ps_partkey}]KAef ArrangeBy keys=[[#0{ps_partkey}]] // { arity: 5 } ReadIndex on=partsupp fk_partsupp_partkey=[differential join] // { arity: 5 } ArrangeBy keys=[[#0{p_partkey}]] // { arity: 9 } @@ -1458,7 +1458,7 @@ materialize.public.q17: Filter (#19{p_brand} = "Brand#23") AND (#22{p_container} = "MED BOX") // { arity: 25 } Join on=(#1{l_partkey} = #16{p_partkey}) type=differential // { arity: 25 } implementation - %1:part[#0]KAef » %0:l0[#1]KAef + %1:part[#0{p_partkey}]KAef » %0:l0[#1{l_partkey}]KAef Get l0 // { arity: 16 } ArrangeBy keys=[[#0{p_partkey}]] // { arity: 9 } ReadIndex on=part pk_part_partkey=[differential join] // { arity: 9 } @@ -1476,7 +1476,7 @@ materialize.public.q17: Project (#0{l_partkey}, #5{l_quantity}) // { arity: 2 } Join on=(#0{l_partkey} = #2{l_partkey}) type=differential // { arity: 17 } implementation - %0[#0]UKA » %1:l0[#1]KA + %0[#0{p_partkey}]UKA » %1:l0[#1{l_partkey}]KA ArrangeBy keys=[[#0{l_partkey}]] // { arity: 1 } Distinct project=[#0{l_partkey}] // { arity: 1 } Project (#0{l_partkey}) // { arity: 1 } @@ -1559,9 +1559,9 @@ materialize.public.q18: Project (#0{c_custkey}, #1{c_name}, #8{o_orderkey}, #11{o_totalprice}, #12{o_orderdate}, #21{l_quantity}) // { arity: 6 } Join on=(#0{c_custkey} = #9{o_custkey} AND #8{o_orderkey} = #17{l_orderkey}) type=delta // { arity: 33 } implementation - %0:customer » %1:orders[#1]KA » %2:l0[#0]KA - %1:orders » %0:customer[#0]KA » %2:l0[#0]KA - %2:l0 » %1:orders[#0]KA » %0:customer[#0]KA + %0:customer » %1:orders[#1{o_custkey}]KA » %2:l0[#0{l_orderkey}]KA + %1:orders » %0:customer[#0{c_custkey}]KA » %2:l0[#0{l_orderkey}]KA + %2:l0 » %1:orders[#0{o_orderkey}]KA » %0:customer[#0{c_custkey}]KA ArrangeBy keys=[[#0{c_custkey}]] // { arity: 8 } ReadIndex on=customer pk_customer_custkey=[delta join 1st input (full scan)] // { arity: 8 } ArrangeBy keys=[[#0{o_orderkey}], [#1{o_custkey}]] // { arity: 9 } @@ -1581,7 +1581,7 @@ materialize.public.q18: Project (#0{o_orderkey}, #5{l_quantity}) // { arity: 2 } Join on=(#0{o_orderkey} = #1{l_orderkey}) type=differential // { arity: 17 } implementation - %0[#0]UKA » %1:l0[#0]KA + %0[#0]UKA » %1:l0[#0{l_orderkey}]KA ArrangeBy keys=[[#0{o_orderkey}]] // { arity: 1 } Distinct project=[#0{o_orderkey}] // { arity: 1 } Project (#2{o_orderkey}) // { arity: 1 } @@ -1657,7 +1657,7 @@ materialize.public.q19: Map ((#4{l_quantity} <= 20), (#4{l_quantity} >= 10), (#4{l_quantity} <= 30), (#4{l_quantity} >= 20), (#4{l_quantity} <= 11), (#4{l_quantity} >= 1), (#19{p_brand} = "Brand#12"), (#21{p_size} <= 5), ((#22{p_container} = "SM BOX") OR (#22{p_container} = "SM PKG") OR (#22{p_container} = "SM CASE") OR (#22{p_container} = "SM PACK")), (#19{p_brand} = "Brand#23"), (#21{p_size} <= 10), ((#22{p_container} = "MED BAG") OR (#22{p_container} = "MED BOX") OR (#22{p_container} = "MED PKG") OR (#22{p_container} = "MED PACK")), (#19{p_brand} = "Brand#34"), (#21{p_size} <= 15), ((#22{p_container} = "LG BOX") OR (#22{p_container} = "LG PKG") OR (#22{p_container} = "LG CASE") OR (#22{p_container} = "LG PACK"))) // { arity: 40 } Join on=(#1{l_partkey} = #16{p_partkey}) type=differential // { arity: 25 } implementation - %1:part[#0]KAeiiif » %0:lineitem[#1]KAeiiiiif + %1:part[#0{p_partkey}]KAeiiif » %0:lineitem[#1{l_partkey}]KAeiiiiif ArrangeBy keys=[[#1{l_partkey}]] // { arity: 16 } ReadIndex on=lineitem fk_lineitem_partkey=[differential join] // { arity: 16 } ArrangeBy keys=[[#0{p_partkey}]] // { arity: 9 } @@ -1740,7 +1740,7 @@ materialize.public.q20: Filter (#8{n_name} = "CANADA") // { arity: 11 } Join on=(#3{s_nationkey} = #7{n_nationkey}) type=differential // { arity: 11 } implementation - %1:nation[#0]KAef » %0:supplier[#3]KAef + %1:nation[#0{n_nationkey}]KAef » %0:supplier[#3{s_nationkey}]KAef ArrangeBy keys=[[#3{s_nationkey}]] // { arity: 7 } ReadIndex on=supplier fk_supplier_nationkey=[differential join] // { arity: 7 } ArrangeBy keys=[[#0{n_nationkey}]] // { arity: 4 } @@ -1751,7 +1751,7 @@ materialize.public.q20: implementation %0 » %1:partsupp[×] » %2[#0]UKA %1:partsupp » %2[#0]UKA » %0[×] - %2 » %1:partsupp[#0]KA » %0[×] + %2 » %1:partsupp[#0{ps_partkey}]KA » %0[×] ArrangeBy keys=[[]] // { arity: 1 } Distinct project=[#0{s_suppkey}] // { arity: 1 } Project (#0{s_suppkey}) // { arity: 1 } @@ -1777,7 +1777,7 @@ materialize.public.q20: Filter (integer_to_numeric(#2{ps_availqty}) > #5) // { arity: 6 } Join on=(#0{s_suppkey} = #4{ps_suppkey} AND #1{ps_partkey} = #3{ps_partkey}) type=differential // { arity: 6 } implementation - %1[#1, #0]UKK » %0:l1[#0, #1]KKf + %1[#1, #0]UKK » %0:l1[#0{s_suppkey}, #1]KKf ArrangeBy keys=[[#0{s_suppkey}, #1{ps_partkey}]] // { arity: 3 } Project (#0{s_suppkey}, #1{ps_partkey}, #3{ps_availqty}) // { arity: 3 } Filter (#0{s_suppkey} = #2{ps_suppkey}) // { arity: 4 } @@ -1790,7 +1790,7 @@ materialize.public.q20: Filter (#12{l_shipdate} >= 1995-01-01) AND (date_to_timestamp(#12{l_shipdate}) < 1996-01-01 00:00:00) // { arity: 18 } Join on=(#0{ps_partkey} = #3{l_partkey} AND #1{ps_suppkey} = #4{l_suppkey}) type=differential // { arity: 18 } implementation - %0[#0, #1]UKKA » %1:lineitem[#1, #2]KKAiif + %0[#0{ps_partkey}, #1{ps_suppkey}]UKKA » %1:lineitem[#1{l_partkey}, #2{l_suppkey}]KKAiif ArrangeBy keys=[[#0{ps_partkey}, #1{ps_suppkey}]] // { arity: 2 } Distinct project=[#0{ps_partkey}, #1{ps_suppkey}] // { arity: 2 } Project (#1{ps_partkey}, #2{ps_suppkey}) // { arity: 2 } @@ -1870,10 +1870,10 @@ materialize.public.q21: Filter (#25{o_orderstatus} = "F") AND (#33{n_name} = "SAUDI ARABIA") AND (#19{l_receiptdate} > #18{l_commitdate}) // { arity: 36 } Join on=(#0{s_suppkey} = #9{l_suppkey} AND #3{s_nationkey} = #32{n_nationkey} AND #7{l_orderkey} = #23{o_orderkey}) type=delta // { arity: 36 } implementation - %0:supplier » %3:nation[#0]KAef » %1:lineitem[#2]KAf » %2:orders[#0]KAef - %1:lineitem » %2:orders[#0]KAef » %0:supplier[#0]KA » %3:nation[#0]KAef - %2:orders » %1:lineitem[#0]KAf » %0:supplier[#0]KA » %3:nation[#0]KAef - %3:nation » %0:supplier[#3]KA » %1:lineitem[#2]KAf » %2:orders[#0]KAef + %0:supplier » %3:nation[#0{n_nationkey}]KAef » %1:lineitem[#2{l_suppkey}]KAf » %2:orders[#0{o_orderkey}]KAef + %1:lineitem » %2:orders[#0{o_orderkey}]KAef » %0:supplier[#0{s_suppkey}]KA » %3:nation[#0{n_nationkey}]KAef + %2:orders » %1:lineitem[#0{l_orderkey}]KAf » %0:supplier[#0{s_suppkey}]KA » %3:nation[#0{n_nationkey}]KAef + %3:nation » %0:supplier[#3{s_nationkey}]KA » %1:lineitem[#2{l_suppkey}]KAf » %2:orders[#0{o_orderkey}]KAef ArrangeBy keys=[[#0{s_suppkey}], [#3{s_nationkey}]] // { arity: 7 } ReadIndex on=supplier pk_supplier_suppkey=[delta join 1st input (full scan)] fk_supplier_nationkey=[delta join lookup] // { arity: 7 } ArrangeBy keys=[[#0{l_orderkey}], [#2{l_suppkey}]] // { arity: 16 } @@ -1898,7 +1898,7 @@ materialize.public.q21: Filter (#1{s_suppkey} != #4{l_suppkey}) // { arity: 18 } Join on=(#0{l_orderkey} = #2{l_orderkey}) type=differential // { arity: 18 } implementation - %1:l1[#0]KA » %0[#0]K + %1:l1[#0{l_orderkey}]KA » %0[#0{l_orderkey}]K ArrangeBy keys=[[#0{l_orderkey}]] // { arity: 2 } Distinct project=[#1{l_orderkey}, #0{s_suppkey}] // { arity: 2 } Project (#0{s_suppkey}, #2{l_orderkey}) // { arity: 2 } @@ -1924,7 +1924,7 @@ materialize.public.q21: Filter (#1{s_suppkey} != #4{l_suppkey}) AND (#14{l_receiptdate} > #13{l_commitdate}) // { arity: 18 } Join on=(#0{l_orderkey} = #2{l_orderkey}) type=differential // { arity: 18 } implementation - %1:l1[#0]KAf » %0:l3[#0]Kf + %1:l1[#0{l_orderkey}]KAf » %0:l3[#0{l_orderkey}]Kf ArrangeBy keys=[[#0{l_orderkey}]] // { arity: 2 } Get l3 // { arity: 2 } Get l1 // { arity: 16 } diff --git a/test/sqllogictest/tpch_create_materialized_view.slt b/test/sqllogictest/tpch_create_materialized_view.slt index 6b1ba55752d4a..3612e07ca5529 100644 --- a/test/sqllogictest/tpch_create_materialized_view.slt +++ b/test/sqllogictest/tpch_create_materialized_view.slt @@ -264,11 +264,11 @@ materialize.public.q02: Filter (#5{p_size} = 15) AND (#26{r_name} = "EUROPE") AND like["%BRASS"](varchar_to_text(#4{p_type})) // { arity: 28 } Join on=(#0{p_partkey} = #16{ps_partkey} AND #9{s_suppkey} = #17{ps_suppkey} AND #12{s_nationkey} = #21{n_nationkey} AND #23{n_regionkey} = #25{r_regionkey}) type=delta // { arity: 28 } implementation - %0:part » %2:l1[#0]KA » %1:l0[#0]KA » %3:l2[#0]KA » %4:l3[#0]KAef - %1:l0 » %2:l1[#1]KA » %0:part[#0]KAelf » %3:l2[#0]KA » %4:l3[#0]KAef - %2:l1 » %0:part[#0]KAelf » %1:l0[#0]KA » %3:l2[#0]KA » %4:l3[#0]KAef - %3:l2 » %4:l3[#0]KAef » %1:l0[#3]KA » %2:l1[#1]KA » %0:part[#0]KAelf - %4:l3 » %3:l2[#2]KA » %1:l0[#3]KA » %2:l1[#1]KA » %0:part[#0]KAelf + %0:part » %2:l1[#0{ps_partkey}]KA » %1:l0[#0{s_suppkey}]KA » %3:l2[#0{n_nationkey}]KA » %4:l3[#0{r_regionkey}]KAef + %1:l0 » %2:l1[#1{ps_suppkey}]KA » %0:part[#0{p_partkey}]KAelf » %3:l2[#0{n_nationkey}]KA » %4:l3[#0{r_regionkey}]KAef + %2:l1 » %0:part[#0{p_partkey}]KAelf » %1:l0[#0{s_suppkey}]KA » %3:l2[#0{n_nationkey}]KA » %4:l3[#0{r_regionkey}]KAef + %3:l2 » %4:l3[#0{r_regionkey}]KAef » %1:l0[#3{s_nationkey}]KA » %2:l1[#1{ps_suppkey}]KA » %0:part[#0{p_partkey}]KAelf + %4:l3 » %3:l2[#2{n_regionkey}]KA » %1:l0[#3{s_nationkey}]KA » %2:l1[#1{ps_suppkey}]KA » %0:part[#0{p_partkey}]KAelf ArrangeBy keys=[[#0{p_partkey}]] // { arity: 9 } ReadIndex on=part pk_part_partkey=[delta join 1st input (full scan)] // { arity: 9 } Get l0 // { arity: 7 } @@ -279,7 +279,7 @@ materialize.public.q02: Project (#5{s_acctbal}, #2{s_name}, #8{n_name}, #0{p_partkey}, #1{p_mfgr}, #3{s_address}, #4{s_phone}, #6{s_comment}) // { arity: 8 } Join on=(#0{p_partkey} = #9{p_partkey} AND #7{ps_supplycost} = #10{min_ps_supplycost}) type=differential // { arity: 11 } implementation - %1[#0, #1]UKK » %0:l4[#0, #7]KK + %1[#0, #1]UKK » %0:l4[#0, #7{ps_supplycost}]KK ArrangeBy keys=[[#0{p_partkey}, #7{ps_supplycost}]] // { arity: 9 } Get l4 // { arity: 9 } ArrangeBy keys=[[#0{p_partkey}, #1{min_ps_supplycost}]] // { arity: 2 } @@ -288,11 +288,11 @@ materialize.public.q02: Filter (#18{r_name} = "EUROPE") // { arity: 20 } Join on=(#0{p_partkey} = #1{ps_partkey} AND #2{ps_suppkey} = #6{s_suppkey} AND #9{s_nationkey} = #13{n_nationkey} AND #15{n_regionkey} = #17{r_regionkey}) type=delta // { arity: 20 } implementation - %0 » %1:l1[#0]KA » %2:l0[#0]KA » %3:l2[#0]KA » %4:l3[#0]KAef - %1:l1 » %0[#0]UKA » %2:l0[#0]KA » %3:l2[#0]KA » %4:l3[#0]KAef - %2:l0 » %1:l1[#1]KA » %0[#0]UKA » %3:l2[#0]KA » %4:l3[#0]KAef - %3:l2 » %4:l3[#0]KAef » %2:l0[#3]KA » %1:l1[#1]KA » %0[#0]UKA - %4:l3 » %3:l2[#2]KA » %2:l0[#3]KA » %1:l1[#1]KA » %0[#0]UKA + %0 » %1:l1[#0{ps_partkey}]KA » %2:l0[#0{s_suppkey}]KA » %3:l2[#0{n_nationkey}]KA » %4:l3[#0{r_regionkey}]KAef + %1:l1 » %0[#0]UKA » %2:l0[#0{s_suppkey}]KA » %3:l2[#0{n_nationkey}]KA » %4:l3[#0{r_regionkey}]KAef + %2:l0 » %1:l1[#1{ps_suppkey}]KA » %0[#0]UKA » %3:l2[#0{n_nationkey}]KA » %4:l3[#0{r_regionkey}]KAef + %3:l2 » %4:l3[#0{r_regionkey}]KAef » %2:l0[#3{s_nationkey}]KA » %1:l1[#1{ps_suppkey}]KA » %0[#0]UKA + %4:l3 » %3:l2[#2{n_regionkey}]KA » %2:l0[#3{s_nationkey}]KA » %1:l1[#1{ps_suppkey}]KA » %0[#0]UKA ArrangeBy keys=[[#0{p_partkey}]] // { arity: 1 } Distinct project=[#0{p_partkey}] // { arity: 1 } Project (#0{p_partkey}) // { arity: 1 } @@ -351,9 +351,9 @@ materialize.public.q03: Filter (#6{c_mktsegment} = "BUILDING") AND (#12{o_orderdate} < 1995-03-15) AND (#27{l_shipdate} > 1995-03-15) // { arity: 33 } Join on=(#0{c_custkey} = #9{o_custkey} AND #8{o_orderkey} = #17{l_orderkey}) type=delta // { arity: 33 } implementation - %0:customer » %1:orders[#1]KAif » %2:lineitem[#0]KAif - %1:orders » %0:customer[#0]KAef » %2:lineitem[#0]KAif - %2:lineitem » %1:orders[#0]KAif » %0:customer[#0]KAef + %0:customer » %1:orders[#1{o_custkey}]KAif » %2:lineitem[#0{l_orderkey}]KAif + %1:orders » %0:customer[#0{c_custkey}]KAef » %2:lineitem[#0{l_orderkey}]KAif + %2:lineitem » %1:orders[#0{o_orderkey}]KAif » %0:customer[#0{c_custkey}]KAef ArrangeBy keys=[[#0{c_custkey}]] // { arity: 8 } ReadIndex on=customer pk_customer_custkey=[delta join 1st input (full scan)] // { arity: 8 } ArrangeBy keys=[[#0{o_orderkey}], [#1{o_custkey}]] // { arity: 9 } @@ -404,7 +404,7 @@ materialize.public.q04: Filter (#4{o_orderdate} >= 1993-07-01) AND (date_to_timestamp(#4{o_orderdate}) < 1993-10-01 00:00:00) // { arity: 10 } Join on=(#0{o_orderkey} = #9{l_orderkey}) type=differential // { arity: 10 } implementation - %1[#0]UKA » %0:orders[#0]KAiif + %1[#0]UKA » %0:orders[#0{o_orderkey}]KAiif ArrangeBy keys=[[#0{o_orderkey}]] // { arity: 9 } ReadIndex on=orders pk_orders_orderkey=[differential join] // { arity: 9 } ArrangeBy keys=[[#0{l_orderkey}]] // { arity: 1 } @@ -457,12 +457,12 @@ materialize.public.q05: Filter (#45{r_name} = "ASIA") AND (#12{o_orderdate} < 1995-01-01) AND (#12{o_orderdate} >= 1994-01-01) // { arity: 47 } Join on=(#0{c_custkey} = #9{o_custkey} AND #3{c_nationkey} = #36{s_nationkey} = #40{n_nationkey} AND #8{o_orderkey} = #17{l_orderkey} AND #19{l_suppkey} = #33{s_suppkey} AND #42{n_regionkey} = #44{r_regionkey}) type=delta // { arity: 47 } implementation - %0:customer » %1:orders[#1]KAiif » %2:lineitem[#0]KA » %3:supplier[#3]KA » %4:nation[#0]KA » %5:region[#0]KAef - %1:orders » %0:customer[#0]KA » %2:lineitem[#0]KA » %3:supplier[#3]KA » %4:nation[#0]KA » %5:region[#0]KAef - %2:lineitem » %1:orders[#0]KAiif » %0:customer[#0]KA » %3:supplier[#3]KA » %4:nation[#0]KA » %5:region[#0]KAef - %3:supplier » %0:customer[#3]KA » %1:orders[#1]KAiif » %2:lineitem[#2]KA » %4:nation[#0]KA » %5:region[#0]KAef - %4:nation » %5:region[#0]KAef » %0:customer[#3]KA » %1:orders[#1]KAiif » %2:lineitem[#0]KA » %3:supplier[#3]KA - %5:region » %4:nation[#2]KA » %0:customer[#3]KA » %1:orders[#1]KAiif » %2:lineitem[#0]KA » %3:supplier[#3]KA + %0:customer » %1:orders[#1{o_custkey}]KAiif » %2:lineitem[#0{l_orderkey}]KA » %3:supplier[#3{s_nationkey}]KA » %4:nation[#0{n_nationkey}]KA » %5:region[#0{r_regionkey}]KAef + %1:orders » %0:customer[#0{c_custkey}]KA » %2:lineitem[#0{l_orderkey}]KA » %3:supplier[#3{s_nationkey}]KA » %4:nation[#0{n_nationkey}]KA » %5:region[#0{r_regionkey}]KAef + %2:lineitem » %1:orders[#0{o_orderkey}]KAiif » %0:customer[#0{c_custkey}]KA » %3:supplier[#3{s_nationkey}]KA » %4:nation[#0{n_nationkey}]KA » %5:region[#0{r_regionkey}]KAef + %3:supplier » %0:customer[#3{c_nationkey}]KA » %1:orders[#1{o_custkey}]KAiif » %2:lineitem[#2{l_suppkey}]KA » %4:nation[#0{n_nationkey}]KA » %5:region[#0{r_regionkey}]KAef + %4:nation » %5:region[#0{r_regionkey}]KAef » %0:customer[#3{c_nationkey}]KA » %1:orders[#1{o_custkey}]KAiif » %2:lineitem[#0{l_orderkey}]KA » %3:supplier[#3{s_nationkey}]KA + %5:region » %4:nation[#2{n_regionkey}]KA » %0:customer[#3{c_nationkey}]KA » %1:orders[#1{o_custkey}]KAiif » %2:lineitem[#0{l_orderkey}]KA » %3:supplier[#3{s_nationkey}]KA ArrangeBy keys=[[#0{c_custkey}], [#3{c_nationkey}]] // { arity: 8 } ReadIndex on=customer pk_customer_custkey=[delta join 1st input (full scan)] fk_customer_nationkey=[delta join lookup] // { arity: 8 } ArrangeBy keys=[[#0{o_orderkey}], [#1{o_custkey}]] // { arity: 9 } @@ -589,12 +589,12 @@ materialize.public.q07: Map ((#41{n_name} = "FRANCE"), (#41{n_name} = "GERMANY"), (#45{n_name} = "FRANCE"), (#45{n_name} = "GERMANY")) // { arity: 52 } Join on=(#0{s_suppkey} = #9{l_suppkey} AND #3{s_nationkey} = #40{n_nationkey} AND #7{l_orderkey} = #23{o_orderkey} AND #24{o_custkey} = #32{c_custkey} AND #35{c_nationkey} = #44{n_nationkey}) type=delta // { arity: 48 } implementation - %0:supplier » %4:l0[#0]KAef » %1:lineitem[#2]KAiif » %2:orders[#0]KA » %3:customer[#0]KA » %5:l0[#0]KAef - %1:lineitem » %0:supplier[#0]KA » %4:l0[#0]KAef » %2:orders[#0]KA » %3:customer[#0]KA » %5:l0[#0]KAef - %2:orders » %1:lineitem[#0]KAiif » %0:supplier[#0]KA » %4:l0[#0]KAef » %3:customer[#0]KA » %5:l0[#0]KAef - %3:customer » %5:l0[#0]KAef » %2:orders[#1]KA » %1:lineitem[#0]KAiif » %0:supplier[#0]KA » %4:l0[#0]KAef - %4:l0 » %0:supplier[#3]KA » %1:lineitem[#2]KAiif » %2:orders[#0]KA » %3:customer[#0]KA » %5:l0[#0]KAef - %5:l0 » %3:customer[#3]KA » %2:orders[#1]KA » %1:lineitem[#0]KAiif » %0:supplier[#0]KA » %4:l0[#0]KAef + %0:supplier » %4:l0[#0{n_nationkey}]KAef » %1:lineitem[#2{l_suppkey}]KAiif » %2:orders[#0{o_orderkey}]KA » %3:customer[#0{c_custkey}]KA » %5:l0[#0{n_nationkey}]KAef + %1:lineitem » %0:supplier[#0{s_suppkey}]KA » %4:l0[#0{n_nationkey}]KAef » %2:orders[#0{o_orderkey}]KA » %3:customer[#0{c_custkey}]KA » %5:l0[#0{n_nationkey}]KAef + %2:orders » %1:lineitem[#0{l_orderkey}]KAiif » %0:supplier[#0{s_suppkey}]KA » %4:l0[#0{n_nationkey}]KAef » %3:customer[#0{c_custkey}]KA » %5:l0[#0{n_nationkey}]KAef + %3:customer » %5:l0[#0{n_nationkey}]KAef » %2:orders[#1{o_custkey}]KA » %1:lineitem[#0{l_orderkey}]KAiif » %0:supplier[#0{s_suppkey}]KA » %4:l0[#0{n_nationkey}]KAef + %4:l0 » %0:supplier[#3{s_nationkey}]KA » %1:lineitem[#2{l_suppkey}]KAiif » %2:orders[#0{o_orderkey}]KA » %3:customer[#0{c_custkey}]KA » %5:l0[#0{n_nationkey}]KAef + %5:l0 » %3:customer[#3{c_nationkey}]KA » %2:orders[#1{o_custkey}]KA » %1:lineitem[#0{l_orderkey}]KAiif » %0:supplier[#0{s_suppkey}]KA » %4:l0[#0{n_nationkey}]KAef ArrangeBy keys=[[#0{s_suppkey}], [#3{s_nationkey}]] // { arity: 7 } ReadIndex on=supplier pk_supplier_suppkey=[delta join 1st input (full scan)] fk_supplier_nationkey=[delta join lookup] // { arity: 7 } ArrangeBy keys=[[#0{l_orderkey}], [#2{l_suppkey}]] // { arity: 16 } @@ -672,14 +672,14 @@ materialize.public.q08: Filter (#58{r_name} = "AMERICA") AND (#36{o_orderdate} <= 1996-12-31) AND (#36{o_orderdate} >= 1995-01-01) AND ("ECONOMY ANODIZED STEEL" = varchar_to_text(#4{p_type})) // { arity: 60 } Join on=(#0{p_partkey} = #17{l_partkey} AND #9{s_suppkey} = #18{l_suppkey} AND #12{s_nationkey} = #53{n_nationkey} AND #16{l_orderkey} = #32{o_orderkey} AND #33{o_custkey} = #41{c_custkey} AND #44{c_nationkey} = #49{n_nationkey} AND #51{n_regionkey} = #57{r_regionkey}) type=delta // { arity: 60 } implementation - %0:part » %2:lineitem[#1]KA » %3:orders[#0]KAiif » %1:supplier[#0]KA » %4:customer[#0]KA » %5:nation[#0]KA » %7:region[#0]KAef » %6:nation[#0]KA - %1:supplier » %2:lineitem[#2]KA » %0:part[#0]KAef » %3:orders[#0]KAiif » %4:customer[#0]KA » %5:nation[#0]KA » %7:region[#0]KAef » %6:nation[#0]KA - %2:lineitem » %0:part[#0]KAef » %3:orders[#0]KAiif » %1:supplier[#0]KA » %4:customer[#0]KA » %5:nation[#0]KA » %7:region[#0]KAef » %6:nation[#0]KA - %3:orders » %2:lineitem[#0]KA » %0:part[#0]KAef » %1:supplier[#0]KA » %4:customer[#0]KA » %5:nation[#0]KA » %7:region[#0]KAef » %6:nation[#0]KA - %4:customer » %3:orders[#1]KAiif » %2:lineitem[#0]KA » %0:part[#0]KAef » %1:supplier[#0]KA » %5:nation[#0]KA » %7:region[#0]KAef » %6:nation[#0]KA - %5:nation » %7:region[#0]KAef » %4:customer[#3]KA » %3:orders[#1]KAiif » %2:lineitem[#0]KA » %0:part[#0]KAef » %1:supplier[#0]KA » %6:nation[#0]KA - %6:nation » %1:supplier[#3]KA » %2:lineitem[#2]KA » %0:part[#0]KAef » %3:orders[#0]KAiif » %4:customer[#0]KA » %5:nation[#0]KA » %7:region[#0]KAef - %7:region » %5:nation[#2]KA » %4:customer[#3]KA » %3:orders[#1]KAiif » %2:lineitem[#0]KA » %0:part[#0]KAef » %1:supplier[#0]KA » %6:nation[#0]KA + %0:part » %2:lineitem[#1{l_partkey}]KA » %3:orders[#0{o_orderkey}]KAiif » %1:supplier[#0{s_suppkey}]KA » %4:customer[#0{c_custkey}]KA » %5:nation[#0{n_nationkey}]KA » %7:region[#0{r_regionkey}]KAef » %6:nation[#0{n_nationkey}]KA + %1:supplier » %2:lineitem[#2{l_suppkey}]KA » %0:part[#0{p_partkey}]KAef » %3:orders[#0{o_orderkey}]KAiif » %4:customer[#0{c_custkey}]KA » %5:nation[#0{n_nationkey}]KA » %7:region[#0{r_regionkey}]KAef » %6:nation[#0{n_nationkey}]KA + %2:lineitem » %0:part[#0{p_partkey}]KAef » %3:orders[#0{o_orderkey}]KAiif » %1:supplier[#0{s_suppkey}]KA » %4:customer[#0{c_custkey}]KA » %5:nation[#0{n_nationkey}]KA » %7:region[#0{r_regionkey}]KAef » %6:nation[#0{n_nationkey}]KA + %3:orders » %2:lineitem[#0{l_orderkey}]KA » %0:part[#0{p_partkey}]KAef » %1:supplier[#0{s_suppkey}]KA » %4:customer[#0{c_custkey}]KA » %5:nation[#0{n_nationkey}]KA » %7:region[#0{r_regionkey}]KAef » %6:nation[#0{n_nationkey}]KA + %4:customer » %3:orders[#1{o_custkey}]KAiif » %2:lineitem[#0{l_orderkey}]KA » %0:part[#0{p_partkey}]KAef » %1:supplier[#0{s_suppkey}]KA » %5:nation[#0{n_nationkey}]KA » %7:region[#0{r_regionkey}]KAef » %6:nation[#0{n_nationkey}]KA + %5:nation » %7:region[#0{r_regionkey}]KAef » %4:customer[#3{c_nationkey}]KA » %3:orders[#1{o_custkey}]KAiif » %2:lineitem[#0{l_orderkey}]KA » %0:part[#0{p_partkey}]KAef » %1:supplier[#0{s_suppkey}]KA » %6:nation[#0{n_nationkey}]KA + %6:nation » %1:supplier[#3{s_nationkey}]KA » %2:lineitem[#2{l_suppkey}]KA » %0:part[#0{p_partkey}]KAef » %3:orders[#0{o_orderkey}]KAiif » %4:customer[#0{c_custkey}]KA » %5:nation[#0{n_nationkey}]KA » %7:region[#0{r_regionkey}]KAef + %7:region » %5:nation[#2{n_regionkey}]KA » %4:customer[#3{c_nationkey}]KA » %3:orders[#1{o_custkey}]KAiif » %2:lineitem[#0{l_orderkey}]KA » %0:part[#0{p_partkey}]KAef » %1:supplier[#0{s_suppkey}]KA » %6:nation[#0{n_nationkey}]KA ArrangeBy keys=[[#0{p_partkey}]] // { arity: 9 } ReadIndex on=part pk_part_partkey=[delta join 1st input (full scan)] // { arity: 9 } ArrangeBy keys=[[#0{s_suppkey}], [#3{s_nationkey}]] // { arity: 7 } @@ -760,12 +760,12 @@ materialize.public.q09: Filter like["%green%"](varchar_to_text(#1{p_name})) // { arity: 50 } Join on=(#0{p_partkey} = #17{l_partkey} = #32{ps_partkey} AND #9{s_suppkey} = #18{l_suppkey} = #33{ps_suppkey} AND #12{s_nationkey} = #46{n_nationkey} AND #16{l_orderkey} = #37{o_orderkey}) type=delta // { arity: 50 } implementation - %0:part » %2:lineitem[#1]KA » %3:partsupp[#0, #1]KKA » %1:supplier[#0]KA » %4:orders[#0]KA » %5:nation[#0]KA - %1:supplier » %2:lineitem[#2]KA » %3:partsupp[#0, #1]KKA » %0:part[#0]KAlf » %4:orders[#0]KA » %5:nation[#0]KA - %2:lineitem » %3:partsupp[#0, #1]KKA » %0:part[#0]KAlf » %1:supplier[#0]KA » %4:orders[#0]KA » %5:nation[#0]KA - %3:partsupp » %2:lineitem[#1, #2]KKA » %0:part[#0]KAlf » %1:supplier[#0]KA » %4:orders[#0]KA » %5:nation[#0]KA - %4:orders » %2:lineitem[#0]KA » %3:partsupp[#0, #1]KKA » %0:part[#0]KAlf » %1:supplier[#0]KA » %5:nation[#0]KA - %5:nation » %1:supplier[#3]KA » %2:lineitem[#2]KA » %3:partsupp[#0, #1]KKA » %0:part[#0]KAlf » %4:orders[#0]KA + %0:part » %2:lineitem[#1{l_partkey}]KA » %3:partsupp[#0{ps_partkey}, #1{ps_suppkey}]KKA » %1:supplier[#0{s_suppkey}]KA » %4:orders[#0{o_orderkey}]KA » %5:nation[#0{n_nationkey}]KA + %1:supplier » %2:lineitem[#2{l_suppkey}]KA » %3:partsupp[#0{ps_partkey}, #1{ps_suppkey}]KKA » %0:part[#0{p_partkey}]KAlf » %4:orders[#0{o_orderkey}]KA » %5:nation[#0{n_nationkey}]KA + %2:lineitem » %3:partsupp[#0{ps_partkey}, #1{ps_suppkey}]KKA » %0:part[#0{p_partkey}]KAlf » %1:supplier[#0{s_suppkey}]KA » %4:orders[#0{o_orderkey}]KA » %5:nation[#0{n_nationkey}]KA + %3:partsupp » %2:lineitem[#1{l_partkey}, #2{l_suppkey}]KKA » %0:part[#0{p_partkey}]KAlf » %1:supplier[#0{s_suppkey}]KA » %4:orders[#0{o_orderkey}]KA » %5:nation[#0{n_nationkey}]KA + %4:orders » %2:lineitem[#0{l_orderkey}]KA » %3:partsupp[#0{ps_partkey}, #1{ps_suppkey}]KKA » %0:part[#0{p_partkey}]KAlf » %1:supplier[#0{s_suppkey}]KA » %5:nation[#0{n_nationkey}]KA + %5:nation » %1:supplier[#3{s_nationkey}]KA » %2:lineitem[#2{l_suppkey}]KA » %3:partsupp[#0{ps_partkey}, #1{ps_suppkey}]KKA » %0:part[#0{p_partkey}]KAlf » %4:orders[#0{o_orderkey}]KA ArrangeBy keys=[[#0{p_partkey}]] // { arity: 9 } ReadIndex on=part pk_part_partkey=[delta join 1st input (full scan)] // { arity: 9 } ArrangeBy keys=[[#0{s_suppkey}], [#3{s_nationkey}]] // { arity: 7 } @@ -840,10 +840,10 @@ materialize.public.q10: Filter (#25{l_returnflag} = "R") AND (#12{o_orderdate} < 1994-01-01) AND (#12{o_orderdate} >= 1993-10-01) AND (date_to_timestamp(#12{o_orderdate}) < 1994-01-01 00:00:00) // { arity: 37 } Join on=(#0{c_custkey} = #9{o_custkey} AND #3{c_nationkey} = #33{n_nationkey} AND #8{o_orderkey} = #17{l_orderkey}) type=delta // { arity: 37 } implementation - %0:customer » %1:orders[#1]KAiiif » %2:lineitem[#0]KAef » %3:nation[#0]KA - %1:orders » %2:lineitem[#0]KAef » %0:customer[#0]KA » %3:nation[#0]KA - %2:lineitem » %1:orders[#0]KAiiif » %0:customer[#0]KA » %3:nation[#0]KA - %3:nation » %0:customer[#3]KA » %1:orders[#1]KAiiif » %2:lineitem[#0]KAef + %0:customer » %1:orders[#1{o_custkey}]KAiiif » %2:lineitem[#0{l_orderkey}]KAef » %3:nation[#0{n_nationkey}]KA + %1:orders » %2:lineitem[#0{l_orderkey}]KAef » %0:customer[#0{c_custkey}]KA » %3:nation[#0{n_nationkey}]KA + %2:lineitem » %1:orders[#0{o_orderkey}]KAiiif » %0:customer[#0{c_custkey}]KA » %3:nation[#0{n_nationkey}]KA + %3:nation » %0:customer[#3{c_nationkey}]KA » %1:orders[#1{o_custkey}]KAiiif » %2:lineitem[#0{l_orderkey}]KAef ArrangeBy keys=[[#0{c_custkey}], [#3{c_nationkey}]] // { arity: 8 } ReadIndex on=customer pk_customer_custkey=[delta join 1st input (full scan)] fk_customer_nationkey=[delta join lookup] // { arity: 8 } ArrangeBy keys=[[#0{o_orderkey}], [#1{o_custkey}]] // { arity: 9 } @@ -905,9 +905,9 @@ materialize.public.q11: Filter (#13{n_name} = "GERMANY") // { arity: 16 } Join on=(#1{ps_suppkey} = #5{s_suppkey} AND #8{s_nationkey} = #12{n_nationkey}) type=delta // { arity: 16 } implementation - %0:partsupp » %1:supplier[#0]KA » %2:nation[#0]KAef - %1:supplier » %2:nation[#0]KAef » %0:partsupp[#1]KA - %2:nation » %1:supplier[#3]KA » %0:partsupp[#1]KA + %0:partsupp » %1:supplier[#0{s_suppkey}]KA » %2:nation[#0{n_nationkey}]KAef + %1:supplier » %2:nation[#0{n_nationkey}]KAef » %0:partsupp[#1{ps_suppkey}]KA + %2:nation » %1:supplier[#3{s_nationkey}]KA » %0:partsupp[#1{ps_suppkey}]KA ArrangeBy keys=[[#1{ps_suppkey}]] // { arity: 5 } ReadIndex on=partsupp fk_partsupp_suppkey=[delta join 1st input (full scan)] // { arity: 5 } ArrangeBy keys=[[#0{s_suppkey}], [#3{s_nationkey}]] // { arity: 7 } @@ -978,7 +978,7 @@ materialize.public.q12: Filter (#21{l_receiptdate} >= 1994-01-01) AND (#19{l_shipdate} < #20{l_commitdate}) AND (#20{l_commitdate} < #21{l_receiptdate}) AND (date_to_timestamp(#21{l_receiptdate}) < 1995-01-01 00:00:00) AND ((#23{l_shipmode} = "MAIL") OR (#23{l_shipmode} = "SHIP")) // { arity: 25 } Join on=(#0{o_orderkey} = #9{l_orderkey}) type=differential // { arity: 25 } implementation - %1:lineitem[#0]KAeiif » %0:orders[#0]KAeiif + %1:lineitem[#0{l_orderkey}]KAeiif » %0:orders[#0{o_orderkey}]KAeiif ArrangeBy keys=[[#0{o_orderkey}]] // { arity: 9 } ReadIndex on=orders pk_orders_orderkey=[differential join] // { arity: 9 } ArrangeBy keys=[[#0{l_orderkey}]] // { arity: 16 } @@ -1028,7 +1028,7 @@ materialize.public.q13: Filter NOT(like["%special%requests%"](varchar_to_text(#16{o_comment}))) // { arity: 17 } Join on=(#0{c_custkey} = #9{o_custkey}) type=differential // { arity: 17 } implementation - %1:orders[#1]KAf » %0:l0[#0]KAf + %1:orders[#1{o_custkey}]KAf » %0:l0[#0{c_custkey}]KAf Get l0 // { arity: 8 } ArrangeBy keys=[[#1{o_custkey}]] // { arity: 9 } ReadIndex on=orders fk_orders_custkey=[differential join] // { arity: 9 } @@ -1043,7 +1043,7 @@ materialize.public.q13: Project (#0{c_custkey}) // { arity: 1 } Join on=(#0{c_custkey} = #8{c_custkey}) type=differential // { arity: 9 } implementation - %1[#0]UKA » %0:l0[#0]KA + %1[#0]UKA » %0:l0[#0{c_custkey}]KA Get l0 // { arity: 8 } ArrangeBy keys=[[#0{c_custkey}]] // { arity: 1 } Distinct project=[#0{c_custkey}] // { arity: 1 } @@ -1088,7 +1088,7 @@ materialize.public.q14: Filter (#10{l_shipdate} >= 1995-09-01) AND (date_to_timestamp(#10{l_shipdate}) < 1995-10-01 00:00:00) // { arity: 25 } Join on=(#1{l_partkey} = #16{p_partkey}) type=differential // { arity: 25 } implementation - %0:lineitem[#1]KAiif » %1:part[#0]KAiif + %0:lineitem[#1{l_partkey}]KAiif » %1:part[#0{p_partkey}]KAiif ArrangeBy keys=[[#1{l_partkey}]] // { arity: 16 } ReadIndex on=lineitem fk_lineitem_partkey=[differential join] // { arity: 16 } ArrangeBy keys=[[#0{p_partkey}]] // { arity: 9 } @@ -1164,8 +1164,8 @@ materialize.public.q15: Join on=(#0{s_suppkey} = #7{l_suppkey} AND #8{sum} = #9{max_sum}) type=delta // { arity: 10 } implementation %0:supplier » %1:l0[#0]UKA » %2[#0]UK - %1:l0 » %2[#0]UK » %0:supplier[#0]KA - %2 » %1:l0[#1]K » %0:supplier[#0]KA + %1:l0 » %2[#0]UK » %0:supplier[#0{s_suppkey}]KA + %2 » %1:l0[#1{total_revenue}]K » %0:supplier[#0{s_suppkey}]KA ArrangeBy keys=[[#0{s_suppkey}]] // { arity: 7 } ReadIndex on=supplier pk_supplier_suppkey=[delta join 1st input (full scan)] // { arity: 7 } ArrangeBy keys=[[#0{l_suppkey}], [#1{sum}]] // { arity: 2 } @@ -1229,7 +1229,7 @@ materialize.public.q16: Filter (#8{p_brand} != "Brand#45") AND NOT(like["MEDIUM POLISHED%"](varchar_to_text(#9{p_type}))) AND ((#10{p_size} = 3) OR (#10{p_size} = 9) OR (#10{p_size} = 14) OR (#10{p_size} = 19) OR (#10{p_size} = 23) OR (#10{p_size} = 36) OR (#10{p_size} = 45) OR (#10{p_size} = 49)) // { arity: 14 } Join on=(#0{ps_partkey} = #5{p_partkey}) type=differential // { arity: 14 } implementation - %1:part[#0]KAef » %0:partsupp[#0]KAef + %1:part[#0{p_partkey}]KAef » %0:partsupp[#0{ps_partkey}]KAef ArrangeBy keys=[[#0{ps_partkey}]] // { arity: 5 } ReadIndex on=partsupp fk_partsupp_partkey=[differential join] // { arity: 5 } ArrangeBy keys=[[#0{p_partkey}]] // { arity: 9 } @@ -1305,7 +1305,7 @@ materialize.public.q17: Filter (#19{p_brand} = "Brand#23") AND (#22{p_container} = "MED BOX") // { arity: 25 } Join on=(#1{l_partkey} = #16{p_partkey}) type=differential // { arity: 25 } implementation - %1:part[#0]KAef » %0:l0[#1]KAef + %1:part[#0{p_partkey}]KAef » %0:l0[#1{l_partkey}]KAef Get l0 // { arity: 16 } ArrangeBy keys=[[#0{p_partkey}]] // { arity: 9 } ReadIndex on=part pk_part_partkey=[differential join] // { arity: 9 } @@ -1323,7 +1323,7 @@ materialize.public.q17: Project (#0{l_partkey}, #5{l_quantity}) // { arity: 2 } Join on=(#0{l_partkey} = #2{l_partkey}) type=differential // { arity: 17 } implementation - %0[#0]UKA » %1:l0[#1]KA + %0[#0{p_partkey}]UKA » %1:l0[#1{l_partkey}]KA ArrangeBy keys=[[#0{l_partkey}]] // { arity: 1 } Distinct project=[#0{l_partkey}] // { arity: 1 } Project (#0{l_partkey}) // { arity: 1 } @@ -1397,9 +1397,9 @@ materialize.public.q18: Project (#0{c_custkey}, #1{c_name}, #8{o_orderkey}, #11{o_totalprice}, #12{o_orderdate}, #21{l_quantity}) // { arity: 6 } Join on=(#0{c_custkey} = #9{o_custkey} AND #8{o_orderkey} = #17{l_orderkey}) type=delta // { arity: 33 } implementation - %0:customer » %1:orders[#1]KA » %2:l0[#0]KA - %1:orders » %0:customer[#0]KA » %2:l0[#0]KA - %2:l0 » %1:orders[#0]KA » %0:customer[#0]KA + %0:customer » %1:orders[#1{o_custkey}]KA » %2:l0[#0{l_orderkey}]KA + %1:orders » %0:customer[#0{c_custkey}]KA » %2:l0[#0{l_orderkey}]KA + %2:l0 » %1:orders[#0{o_orderkey}]KA » %0:customer[#0{c_custkey}]KA ArrangeBy keys=[[#0{c_custkey}]] // { arity: 8 } ReadIndex on=customer pk_customer_custkey=[delta join 1st input (full scan)] // { arity: 8 } ArrangeBy keys=[[#0{o_orderkey}], [#1{o_custkey}]] // { arity: 9 } @@ -1419,7 +1419,7 @@ materialize.public.q18: Project (#0{o_orderkey}, #5{l_quantity}) // { arity: 2 } Join on=(#0{o_orderkey} = #1{l_orderkey}) type=differential // { arity: 17 } implementation - %0[#0]UKA » %1:l0[#0]KA + %0[#0]UKA » %1:l0[#0{l_orderkey}]KA ArrangeBy keys=[[#0{o_orderkey}]] // { arity: 1 } Distinct project=[#0{o_orderkey}] // { arity: 1 } Project (#2{o_orderkey}) // { arity: 1 } @@ -1486,7 +1486,7 @@ materialize.public.q19: Map ((#4{l_quantity} <= 20), (#4{l_quantity} >= 10), (#4{l_quantity} <= 30), (#4{l_quantity} >= 20), (#4{l_quantity} <= 11), (#4{l_quantity} >= 1), (#19{p_brand} = "Brand#12"), (#21{p_size} <= 5), ((#22{p_container} = "SM BOX") OR (#22{p_container} = "SM PKG") OR (#22{p_container} = "SM CASE") OR (#22{p_container} = "SM PACK")), (#19{p_brand} = "Brand#23"), (#21{p_size} <= 10), ((#22{p_container} = "MED BAG") OR (#22{p_container} = "MED BOX") OR (#22{p_container} = "MED PKG") OR (#22{p_container} = "MED PACK")), (#19{p_brand} = "Brand#34"), (#21{p_size} <= 15), ((#22{p_container} = "LG BOX") OR (#22{p_container} = "LG PKG") OR (#22{p_container} = "LG CASE") OR (#22{p_container} = "LG PACK"))) // { arity: 40 } Join on=(#1{l_partkey} = #16{p_partkey}) type=differential // { arity: 25 } implementation - %1:part[#0]KAeiiif » %0:lineitem[#1]KAeiiiiif + %1:part[#0{p_partkey}]KAeiiif » %0:lineitem[#1{l_partkey}]KAeiiiiif ArrangeBy keys=[[#1{l_partkey}]] // { arity: 16 } ReadIndex on=lineitem fk_lineitem_partkey=[differential join] // { arity: 16 } ArrangeBy keys=[[#0{p_partkey}]] // { arity: 9 } @@ -1560,7 +1560,7 @@ materialize.public.q20: Filter (#8{n_name} = "CANADA") // { arity: 11 } Join on=(#3{s_nationkey} = #7{n_nationkey}) type=differential // { arity: 11 } implementation - %1:nation[#0]KAef » %0:supplier[#3]KAef + %1:nation[#0{n_nationkey}]KAef » %0:supplier[#3{s_nationkey}]KAef ArrangeBy keys=[[#3{s_nationkey}]] // { arity: 7 } ReadIndex on=supplier fk_supplier_nationkey=[differential join] // { arity: 7 } ArrangeBy keys=[[#0{n_nationkey}]] // { arity: 4 } @@ -1571,7 +1571,7 @@ materialize.public.q20: implementation %0 » %1:partsupp[×] » %2[#0]UKA %1:partsupp » %2[#0]UKA » %0[×] - %2 » %1:partsupp[#0]KA » %0[×] + %2 » %1:partsupp[#0{ps_partkey}]KA » %0[×] ArrangeBy keys=[[]] // { arity: 1 } Distinct project=[#0{s_suppkey}] // { arity: 1 } Project (#0{s_suppkey}) // { arity: 1 } @@ -1597,7 +1597,7 @@ materialize.public.q20: Filter (integer_to_numeric(#2{ps_availqty}) > #5) // { arity: 6 } Join on=(#0{s_suppkey} = #4{ps_suppkey} AND #1{ps_partkey} = #3{ps_partkey}) type=differential // { arity: 6 } implementation - %1[#1, #0]UKK » %0:l1[#0, #1]KKf + %1[#1, #0]UKK » %0:l1[#0{s_suppkey}, #1]KKf ArrangeBy keys=[[#0{s_suppkey}, #1{ps_partkey}]] // { arity: 3 } Project (#0{s_suppkey}, #1{ps_partkey}, #3{ps_availqty}) // { arity: 3 } Filter (#0{s_suppkey} = #2{ps_suppkey}) // { arity: 4 } @@ -1610,7 +1610,7 @@ materialize.public.q20: Filter (#12{l_shipdate} >= 1995-01-01) AND (date_to_timestamp(#12{l_shipdate}) < 1996-01-01 00:00:00) // { arity: 18 } Join on=(#0{ps_partkey} = #3{l_partkey} AND #1{ps_suppkey} = #4{l_suppkey}) type=differential // { arity: 18 } implementation - %0[#0, #1]UKKA » %1:lineitem[#1, #2]KKAiif + %0[#0{ps_partkey}, #1{ps_suppkey}]UKKA » %1:lineitem[#1{l_partkey}, #2{l_suppkey}]KKAiif ArrangeBy keys=[[#0{ps_partkey}, #1{ps_suppkey}]] // { arity: 2 } Distinct project=[#0{ps_partkey}, #1{ps_suppkey}] // { arity: 2 } Project (#1{ps_partkey}, #2{ps_suppkey}) // { arity: 2 } @@ -1681,10 +1681,10 @@ materialize.public.q21: Filter (#25{o_orderstatus} = "F") AND (#33{n_name} = "SAUDI ARABIA") AND (#19{l_receiptdate} > #18{l_commitdate}) // { arity: 36 } Join on=(#0{s_suppkey} = #9{l_suppkey} AND #3{s_nationkey} = #32{n_nationkey} AND #7{l_orderkey} = #23{o_orderkey}) type=delta // { arity: 36 } implementation - %0:supplier » %3:nation[#0]KAef » %1:lineitem[#2]KAf » %2:orders[#0]KAef - %1:lineitem » %2:orders[#0]KAef » %0:supplier[#0]KA » %3:nation[#0]KAef - %2:orders » %1:lineitem[#0]KAf » %0:supplier[#0]KA » %3:nation[#0]KAef - %3:nation » %0:supplier[#3]KA » %1:lineitem[#2]KAf » %2:orders[#0]KAef + %0:supplier » %3:nation[#0{n_nationkey}]KAef » %1:lineitem[#2{l_suppkey}]KAf » %2:orders[#0{o_orderkey}]KAef + %1:lineitem » %2:orders[#0{o_orderkey}]KAef » %0:supplier[#0{s_suppkey}]KA » %3:nation[#0{n_nationkey}]KAef + %2:orders » %1:lineitem[#0{l_orderkey}]KAf » %0:supplier[#0{s_suppkey}]KA » %3:nation[#0{n_nationkey}]KAef + %3:nation » %0:supplier[#3{s_nationkey}]KA » %1:lineitem[#2{l_suppkey}]KAf » %2:orders[#0{o_orderkey}]KAef ArrangeBy keys=[[#0{s_suppkey}], [#3{s_nationkey}]] // { arity: 7 } ReadIndex on=supplier pk_supplier_suppkey=[delta join 1st input (full scan)] fk_supplier_nationkey=[delta join lookup] // { arity: 7 } ArrangeBy keys=[[#0{l_orderkey}], [#2{l_suppkey}]] // { arity: 16 } @@ -1709,7 +1709,7 @@ materialize.public.q21: Filter (#1{s_suppkey} != #4{l_suppkey}) // { arity: 18 } Join on=(#0{l_orderkey} = #2{l_orderkey}) type=differential // { arity: 18 } implementation - %1:l1[#0]KA » %0[#0]K + %1:l1[#0{l_orderkey}]KA » %0[#0{l_orderkey}]K ArrangeBy keys=[[#0{l_orderkey}]] // { arity: 2 } Distinct project=[#1{l_orderkey}, #0{s_suppkey}] // { arity: 2 } Project (#0{s_suppkey}, #2{l_orderkey}) // { arity: 2 } @@ -1735,7 +1735,7 @@ materialize.public.q21: Filter (#1{s_suppkey} != #4{l_suppkey}) AND (#14{l_receiptdate} > #13{l_commitdate}) // { arity: 18 } Join on=(#0{l_orderkey} = #2{l_orderkey}) type=differential // { arity: 18 } implementation - %1:l1[#0]KAf » %0:l3[#0]Kf + %1:l1[#0{l_orderkey}]KAf » %0:l3[#0{l_orderkey}]Kf ArrangeBy keys=[[#0{l_orderkey}]] // { arity: 2 } Get l3 // { arity: 2 } Get l1 // { arity: 16 } @@ -1912,25 +1912,25 @@ TopK order_by=[#0 asc nulls_last] Project (#1, #2) With cte [l3 as subquery-3] = - Reduce aggregates=[any((#^0 = #0))] + Reduce aggregates=[any((#^0{s_suppkey} = #0{right_col0_0}))] Project (#1) With cte [l2 as subquery-2] = Project (#1) - Map ((0.5 * #0)) - Reduce aggregates=[sum(#4)] - Filter ((((#1 = #^0) AND (#2 = #^1)) AND (#10 >= text_to_date("1995-01-01"))) AND (date_to_timestamp(#10) < (text_to_date("1995-01-01") + 1 year))) + Map ((0.5 * #0{?column?})) + Reduce aggregates=[sum(#4{l_quantity})] + Filter ((((#1{l_partkey} = #^0{ps_partkey}) AND (#2{l_suppkey} = #^1{ps_suppkey})) AND (#10{l_shipdate} >= text_to_date("1995-01-01"))) AND (date_to_timestamp(#10{l_shipdate}) < (text_to_date("1995-01-01") + 1 year))) Get materialize.public.lineitem cte [l1 as subquery-1] = - Reduce aggregates=[any((#^0 = #0))] + Reduce aggregates=[any((#^0{ps_partkey} = #0{right_col0_2}))] Project (#0) - Filter (varchar_to_text(#1) like "forest%") + Filter (varchar_to_text(#1{p_name}) like "forest%") Get materialize.public.part Return - Filter (select(Get l1) AND (integer_to_numeric(#2) > select(Get l2))) + Filter (select(Get l1) AND (integer_to_numeric(#2{ps_availqty}) > select(Get l2))) Get materialize.public.partsupp Return - Filter ((select(Get l3) AND (#3 = #7)) AND (#8 = text_to_char[len=unbounded]("CANADA"))) + Filter ((select(Get l3) AND (#3{s_nationkey} = #7{n_nationkey})) AND (#8{n_name} = text_to_char[len=unbounded]("CANADA"))) CrossJoin Get materialize.public.supplier Get materialize.public.nation diff --git a/test/sqllogictest/tpch_select.slt b/test/sqllogictest/tpch_select.slt index e3f690a4ddc2b..b548df8d66169 100644 --- a/test/sqllogictest/tpch_select.slt +++ b/test/sqllogictest/tpch_select.slt @@ -263,11 +263,11 @@ Explained Query: Filter (#5{p_size} = 15) AND (#26{r_name} = "EUROPE") AND like["%BRASS"](varchar_to_text(#4{p_type})) // { arity: 28 } Join on=(#0{p_partkey} = #16{ps_partkey} AND #9{s_suppkey} = #17{ps_suppkey} AND #12{s_nationkey} = #21{n_nationkey} AND #23{n_regionkey} = #25{r_regionkey}) type=delta // { arity: 28 } implementation - %0:part » %2:l1[#0]KA » %1:l0[#0]KA » %3:l2[#0]KA » %4:l3[#0]KAef - %1:l0 » %2:l1[#1]KA » %0:part[#0]KAelf » %3:l2[#0]KA » %4:l3[#0]KAef - %2:l1 » %0:part[#0]KAelf » %1:l0[#0]KA » %3:l2[#0]KA » %4:l3[#0]KAef - %3:l2 » %4:l3[#0]KAef » %1:l0[#3]KA » %2:l1[#1]KA » %0:part[#0]KAelf - %4:l3 » %3:l2[#2]KA » %1:l0[#3]KA » %2:l1[#1]KA » %0:part[#0]KAelf + %0:part » %2:l1[#0{ps_partkey}]KA » %1:l0[#0{s_suppkey}]KA » %3:l2[#0{n_nationkey}]KA » %4:l3[#0{r_regionkey}]KAef + %1:l0 » %2:l1[#1{ps_suppkey}]KA » %0:part[#0{p_partkey}]KAelf » %3:l2[#0{n_nationkey}]KA » %4:l3[#0{r_regionkey}]KAef + %2:l1 » %0:part[#0{p_partkey}]KAelf » %1:l0[#0{s_suppkey}]KA » %3:l2[#0{n_nationkey}]KA » %4:l3[#0{r_regionkey}]KAef + %3:l2 » %4:l3[#0{r_regionkey}]KAef » %1:l0[#3{s_nationkey}]KA » %2:l1[#1{ps_suppkey}]KA » %0:part[#0{p_partkey}]KAelf + %4:l3 » %3:l2[#2{n_regionkey}]KA » %1:l0[#3{s_nationkey}]KA » %2:l1[#1{ps_suppkey}]KA » %0:part[#0{p_partkey}]KAelf ArrangeBy keys=[[#0{p_partkey}]] // { arity: 9 } ReadIndex on=part pk_part_partkey=[delta join 1st input (full scan)] // { arity: 9 } Get l0 // { arity: 7 } @@ -278,7 +278,7 @@ Explained Query: Project (#5{s_acctbal}, #2{s_name}, #8{n_name}, #0{p_partkey}, #1{p_mfgr}, #3{s_address}, #4{s_phone}, #6{s_comment}) // { arity: 8 } Join on=(#0{p_partkey} = #9{p_partkey} AND #7{ps_supplycost} = #10{min_ps_supplycost}) type=differential // { arity: 11 } implementation - %1[#0, #1]UKK » %0:l4[#0, #7]KK + %1[#0, #1]UKK » %0:l4[#0, #7{ps_supplycost}]KK ArrangeBy keys=[[#0{p_partkey}, #7{ps_supplycost}]] // { arity: 9 } Get l4 // { arity: 9 } ArrangeBy keys=[[#0{p_partkey}, #1{min_ps_supplycost}]] // { arity: 2 } @@ -287,11 +287,11 @@ Explained Query: Filter (#18{r_name} = "EUROPE") // { arity: 20 } Join on=(#0{p_partkey} = #1{ps_partkey} AND #2{ps_suppkey} = #6{s_suppkey} AND #9{s_nationkey} = #13{n_nationkey} AND #15{n_regionkey} = #17{r_regionkey}) type=delta // { arity: 20 } implementation - %0 » %1:l1[#0]KA » %2:l0[#0]KA » %3:l2[#0]KA » %4:l3[#0]KAef - %1:l1 » %0[#0]UKA » %2:l0[#0]KA » %3:l2[#0]KA » %4:l3[#0]KAef - %2:l0 » %1:l1[#1]KA » %0[#0]UKA » %3:l2[#0]KA » %4:l3[#0]KAef - %3:l2 » %4:l3[#0]KAef » %2:l0[#3]KA » %1:l1[#1]KA » %0[#0]UKA - %4:l3 » %3:l2[#2]KA » %2:l0[#3]KA » %1:l1[#1]KA » %0[#0]UKA + %0 » %1:l1[#0{ps_partkey}]KA » %2:l0[#0{s_suppkey}]KA » %3:l2[#0{n_nationkey}]KA » %4:l3[#0{r_regionkey}]KAef + %1:l1 » %0[#0]UKA » %2:l0[#0{s_suppkey}]KA » %3:l2[#0{n_nationkey}]KA » %4:l3[#0{r_regionkey}]KAef + %2:l0 » %1:l1[#1{ps_suppkey}]KA » %0[#0]UKA » %3:l2[#0{n_nationkey}]KA » %4:l3[#0{r_regionkey}]KAef + %3:l2 » %4:l3[#0{r_regionkey}]KAef » %2:l0[#3{s_nationkey}]KA » %1:l1[#1{ps_suppkey}]KA » %0[#0]UKA + %4:l3 » %3:l2[#2{n_regionkey}]KA » %2:l0[#3{s_nationkey}]KA » %1:l1[#1{ps_suppkey}]KA » %0[#0]UKA ArrangeBy keys=[[#0{p_partkey}]] // { arity: 1 } Distinct project=[#0{p_partkey}] // { arity: 1 } Project (#0{p_partkey}) // { arity: 1 } @@ -350,9 +350,9 @@ Explained Query: Filter (#6{c_mktsegment} = "BUILDING") AND (#12{o_orderdate} < 1995-03-15) AND (#27{l_shipdate} > 1995-03-15) // { arity: 33 } Join on=(#0{c_custkey} = #9{o_custkey} AND #8{o_orderkey} = #17{l_orderkey}) type=delta // { arity: 33 } implementation - %0:customer » %1:orders[#1]KAif » %2:lineitem[#0]KAif - %1:orders » %0:customer[#0]KAef » %2:lineitem[#0]KAif - %2:lineitem » %1:orders[#0]KAif » %0:customer[#0]KAef + %0:customer » %1:orders[#1{o_custkey}]KAif » %2:lineitem[#0{l_orderkey}]KAif + %1:orders » %0:customer[#0{c_custkey}]KAef » %2:lineitem[#0{l_orderkey}]KAif + %2:lineitem » %1:orders[#0{o_orderkey}]KAif » %0:customer[#0{c_custkey}]KAef ArrangeBy keys=[[#0{c_custkey}]] // { arity: 8 } ReadIndex on=customer pk_customer_custkey=[delta join 1st input (full scan)] // { arity: 8 } ArrangeBy keys=[[#0{o_orderkey}], [#1{o_custkey}]] // { arity: 9 } @@ -403,7 +403,7 @@ Explained Query: Filter (#4{o_orderdate} >= 1993-07-01) AND (date_to_timestamp(#4{o_orderdate}) < 1993-10-01 00:00:00) // { arity: 10 } Join on=(#0{o_orderkey} = #9{l_orderkey}) type=differential // { arity: 10 } implementation - %1[#0]UKA » %0:orders[#0]KAiif + %1[#0]UKA » %0:orders[#0{o_orderkey}]KAiif ArrangeBy keys=[[#0{o_orderkey}]] // { arity: 9 } ReadIndex on=orders pk_orders_orderkey=[differential join] // { arity: 9 } ArrangeBy keys=[[#0{l_orderkey}]] // { arity: 1 } @@ -456,12 +456,12 @@ Explained Query: Filter (#45{r_name} = "ASIA") AND (#12{o_orderdate} < 1995-01-01) AND (#12{o_orderdate} >= 1994-01-01) // { arity: 47 } Join on=(#0{c_custkey} = #9{o_custkey} AND #3{c_nationkey} = #36{s_nationkey} = #40{n_nationkey} AND #8{o_orderkey} = #17{l_orderkey} AND #19{l_suppkey} = #33{s_suppkey} AND #42{n_regionkey} = #44{r_regionkey}) type=delta // { arity: 47 } implementation - %0:customer » %1:orders[#1]KAiif » %2:lineitem[#0]KA » %3:supplier[#3]KA » %4:nation[#0]KA » %5:region[#0]KAef - %1:orders » %0:customer[#0]KA » %2:lineitem[#0]KA » %3:supplier[#3]KA » %4:nation[#0]KA » %5:region[#0]KAef - %2:lineitem » %1:orders[#0]KAiif » %0:customer[#0]KA » %3:supplier[#3]KA » %4:nation[#0]KA » %5:region[#0]KAef - %3:supplier » %0:customer[#3]KA » %1:orders[#1]KAiif » %2:lineitem[#2]KA » %4:nation[#0]KA » %5:region[#0]KAef - %4:nation » %5:region[#0]KAef » %0:customer[#3]KA » %1:orders[#1]KAiif » %2:lineitem[#0]KA » %3:supplier[#3]KA - %5:region » %4:nation[#2]KA » %0:customer[#3]KA » %1:orders[#1]KAiif » %2:lineitem[#0]KA » %3:supplier[#3]KA + %0:customer » %1:orders[#1{o_custkey}]KAiif » %2:lineitem[#0{l_orderkey}]KA » %3:supplier[#3{s_nationkey}]KA » %4:nation[#0{n_nationkey}]KA » %5:region[#0{r_regionkey}]KAef + %1:orders » %0:customer[#0{c_custkey}]KA » %2:lineitem[#0{l_orderkey}]KA » %3:supplier[#3{s_nationkey}]KA » %4:nation[#0{n_nationkey}]KA » %5:region[#0{r_regionkey}]KAef + %2:lineitem » %1:orders[#0{o_orderkey}]KAiif » %0:customer[#0{c_custkey}]KA » %3:supplier[#3{s_nationkey}]KA » %4:nation[#0{n_nationkey}]KA » %5:region[#0{r_regionkey}]KAef + %3:supplier » %0:customer[#3{c_nationkey}]KA » %1:orders[#1{o_custkey}]KAiif » %2:lineitem[#2{l_suppkey}]KA » %4:nation[#0{n_nationkey}]KA » %5:region[#0{r_regionkey}]KAef + %4:nation » %5:region[#0{r_regionkey}]KAef » %0:customer[#3{c_nationkey}]KA » %1:orders[#1{o_custkey}]KAiif » %2:lineitem[#0{l_orderkey}]KA » %3:supplier[#3{s_nationkey}]KA + %5:region » %4:nation[#2{n_regionkey}]KA » %0:customer[#3{c_nationkey}]KA » %1:orders[#1{o_custkey}]KAiif » %2:lineitem[#0{l_orderkey}]KA » %3:supplier[#3{s_nationkey}]KA ArrangeBy keys=[[#0{c_custkey}], [#3{c_nationkey}]] // { arity: 8 } ReadIndex on=customer pk_customer_custkey=[delta join 1st input (full scan)] fk_customer_nationkey=[delta join lookup] // { arity: 8 } ArrangeBy keys=[[#0{o_orderkey}], [#1{o_custkey}]] // { arity: 9 } @@ -587,12 +587,12 @@ Explained Query: Map ((#41{n_name} = "FRANCE"), (#41{n_name} = "GERMANY"), (#45{n_name} = "FRANCE"), (#45{n_name} = "GERMANY")) // { arity: 52 } Join on=(#0{s_suppkey} = #9{l_suppkey} AND #3{s_nationkey} = #40{n_nationkey} AND #7{l_orderkey} = #23{o_orderkey} AND #24{o_custkey} = #32{c_custkey} AND #35{c_nationkey} = #44{n_nationkey}) type=delta // { arity: 48 } implementation - %0:supplier » %4:l0[#0]KAef » %1:lineitem[#2]KAiif » %2:orders[#0]KA » %3:customer[#0]KA » %5:l0[#0]KAef - %1:lineitem » %0:supplier[#0]KA » %4:l0[#0]KAef » %2:orders[#0]KA » %3:customer[#0]KA » %5:l0[#0]KAef - %2:orders » %1:lineitem[#0]KAiif » %0:supplier[#0]KA » %4:l0[#0]KAef » %3:customer[#0]KA » %5:l0[#0]KAef - %3:customer » %5:l0[#0]KAef » %2:orders[#1]KA » %1:lineitem[#0]KAiif » %0:supplier[#0]KA » %4:l0[#0]KAef - %4:l0 » %0:supplier[#3]KA » %1:lineitem[#2]KAiif » %2:orders[#0]KA » %3:customer[#0]KA » %5:l0[#0]KAef - %5:l0 » %3:customer[#3]KA » %2:orders[#1]KA » %1:lineitem[#0]KAiif » %0:supplier[#0]KA » %4:l0[#0]KAef + %0:supplier » %4:l0[#0{n_nationkey}]KAef » %1:lineitem[#2{l_suppkey}]KAiif » %2:orders[#0{o_orderkey}]KA » %3:customer[#0{c_custkey}]KA » %5:l0[#0{n_nationkey}]KAef + %1:lineitem » %0:supplier[#0{s_suppkey}]KA » %4:l0[#0{n_nationkey}]KAef » %2:orders[#0{o_orderkey}]KA » %3:customer[#0{c_custkey}]KA » %5:l0[#0{n_nationkey}]KAef + %2:orders » %1:lineitem[#0{l_orderkey}]KAiif » %0:supplier[#0{s_suppkey}]KA » %4:l0[#0{n_nationkey}]KAef » %3:customer[#0{c_custkey}]KA » %5:l0[#0{n_nationkey}]KAef + %3:customer » %5:l0[#0{n_nationkey}]KAef » %2:orders[#1{o_custkey}]KA » %1:lineitem[#0{l_orderkey}]KAiif » %0:supplier[#0{s_suppkey}]KA » %4:l0[#0{n_nationkey}]KAef + %4:l0 » %0:supplier[#3{s_nationkey}]KA » %1:lineitem[#2{l_suppkey}]KAiif » %2:orders[#0{o_orderkey}]KA » %3:customer[#0{c_custkey}]KA » %5:l0[#0{n_nationkey}]KAef + %5:l0 » %3:customer[#3{c_nationkey}]KA » %2:orders[#1{o_custkey}]KA » %1:lineitem[#0{l_orderkey}]KAiif » %0:supplier[#0{s_suppkey}]KA » %4:l0[#0{n_nationkey}]KAef ArrangeBy keys=[[#0{s_suppkey}], [#3{s_nationkey}]] // { arity: 7 } ReadIndex on=supplier pk_supplier_suppkey=[delta join 1st input (full scan)] fk_supplier_nationkey=[delta join lookup] // { arity: 7 } ArrangeBy keys=[[#0{l_orderkey}], [#2{l_suppkey}]] // { arity: 16 } @@ -670,14 +670,14 @@ Explained Query: Filter (#58{r_name} = "AMERICA") AND (#36{o_orderdate} <= 1996-12-31) AND (#36{o_orderdate} >= 1995-01-01) AND ("ECONOMY ANODIZED STEEL" = varchar_to_text(#4{p_type})) // { arity: 60 } Join on=(#0{p_partkey} = #17{l_partkey} AND #9{s_suppkey} = #18{l_suppkey} AND #12{s_nationkey} = #53{n_nationkey} AND #16{l_orderkey} = #32{o_orderkey} AND #33{o_custkey} = #41{c_custkey} AND #44{c_nationkey} = #49{n_nationkey} AND #51{n_regionkey} = #57{r_regionkey}) type=delta // { arity: 60 } implementation - %0:part » %2:lineitem[#1]KA » %3:orders[#0]KAiif » %1:supplier[#0]KA » %4:customer[#0]KA » %5:nation[#0]KA » %7:region[#0]KAef » %6:nation[#0]KA - %1:supplier » %2:lineitem[#2]KA » %0:part[#0]KAef » %3:orders[#0]KAiif » %4:customer[#0]KA » %5:nation[#0]KA » %7:region[#0]KAef » %6:nation[#0]KA - %2:lineitem » %0:part[#0]KAef » %3:orders[#0]KAiif » %1:supplier[#0]KA » %4:customer[#0]KA » %5:nation[#0]KA » %7:region[#0]KAef » %6:nation[#0]KA - %3:orders » %2:lineitem[#0]KA » %0:part[#0]KAef » %1:supplier[#0]KA » %4:customer[#0]KA » %5:nation[#0]KA » %7:region[#0]KAef » %6:nation[#0]KA - %4:customer » %3:orders[#1]KAiif » %2:lineitem[#0]KA » %0:part[#0]KAef » %1:supplier[#0]KA » %5:nation[#0]KA » %7:region[#0]KAef » %6:nation[#0]KA - %5:nation » %7:region[#0]KAef » %4:customer[#3]KA » %3:orders[#1]KAiif » %2:lineitem[#0]KA » %0:part[#0]KAef » %1:supplier[#0]KA » %6:nation[#0]KA - %6:nation » %1:supplier[#3]KA » %2:lineitem[#2]KA » %0:part[#0]KAef » %3:orders[#0]KAiif » %4:customer[#0]KA » %5:nation[#0]KA » %7:region[#0]KAef - %7:region » %5:nation[#2]KA » %4:customer[#3]KA » %3:orders[#1]KAiif » %2:lineitem[#0]KA » %0:part[#0]KAef » %1:supplier[#0]KA » %6:nation[#0]KA + %0:part » %2:lineitem[#1{l_partkey}]KA » %3:orders[#0{o_orderkey}]KAiif » %1:supplier[#0{s_suppkey}]KA » %4:customer[#0{c_custkey}]KA » %5:nation[#0{n_nationkey}]KA » %7:region[#0{r_regionkey}]KAef » %6:nation[#0{n_nationkey}]KA + %1:supplier » %2:lineitem[#2{l_suppkey}]KA » %0:part[#0{p_partkey}]KAef » %3:orders[#0{o_orderkey}]KAiif » %4:customer[#0{c_custkey}]KA » %5:nation[#0{n_nationkey}]KA » %7:region[#0{r_regionkey}]KAef » %6:nation[#0{n_nationkey}]KA + %2:lineitem » %0:part[#0{p_partkey}]KAef » %3:orders[#0{o_orderkey}]KAiif » %1:supplier[#0{s_suppkey}]KA » %4:customer[#0{c_custkey}]KA » %5:nation[#0{n_nationkey}]KA » %7:region[#0{r_regionkey}]KAef » %6:nation[#0{n_nationkey}]KA + %3:orders » %2:lineitem[#0{l_orderkey}]KA » %0:part[#0{p_partkey}]KAef » %1:supplier[#0{s_suppkey}]KA » %4:customer[#0{c_custkey}]KA » %5:nation[#0{n_nationkey}]KA » %7:region[#0{r_regionkey}]KAef » %6:nation[#0{n_nationkey}]KA + %4:customer » %3:orders[#1{o_custkey}]KAiif » %2:lineitem[#0{l_orderkey}]KA » %0:part[#0{p_partkey}]KAef » %1:supplier[#0{s_suppkey}]KA » %5:nation[#0{n_nationkey}]KA » %7:region[#0{r_regionkey}]KAef » %6:nation[#0{n_nationkey}]KA + %5:nation » %7:region[#0{r_regionkey}]KAef » %4:customer[#3{c_nationkey}]KA » %3:orders[#1{o_custkey}]KAiif » %2:lineitem[#0{l_orderkey}]KA » %0:part[#0{p_partkey}]KAef » %1:supplier[#0{s_suppkey}]KA » %6:nation[#0{n_nationkey}]KA + %6:nation » %1:supplier[#3{s_nationkey}]KA » %2:lineitem[#2{l_suppkey}]KA » %0:part[#0{p_partkey}]KAef » %3:orders[#0{o_orderkey}]KAiif » %4:customer[#0{c_custkey}]KA » %5:nation[#0{n_nationkey}]KA » %7:region[#0{r_regionkey}]KAef + %7:region » %5:nation[#2{n_regionkey}]KA » %4:customer[#3{c_nationkey}]KA » %3:orders[#1{o_custkey}]KAiif » %2:lineitem[#0{l_orderkey}]KA » %0:part[#0{p_partkey}]KAef » %1:supplier[#0{s_suppkey}]KA » %6:nation[#0{n_nationkey}]KA ArrangeBy keys=[[#0{p_partkey}]] // { arity: 9 } ReadIndex on=part pk_part_partkey=[delta join 1st input (full scan)] // { arity: 9 } ArrangeBy keys=[[#0{s_suppkey}], [#3{s_nationkey}]] // { arity: 7 } @@ -758,12 +758,12 @@ Explained Query: Filter like["%green%"](varchar_to_text(#1{p_name})) // { arity: 50 } Join on=(#0{p_partkey} = #17{l_partkey} = #32{ps_partkey} AND #9{s_suppkey} = #18{l_suppkey} = #33{ps_suppkey} AND #12{s_nationkey} = #46{n_nationkey} AND #16{l_orderkey} = #37{o_orderkey}) type=delta // { arity: 50 } implementation - %0:part » %2:lineitem[#1]KA » %3:partsupp[#0, #1]KKA » %1:supplier[#0]KA » %4:orders[#0]KA » %5:nation[#0]KA - %1:supplier » %2:lineitem[#2]KA » %3:partsupp[#0, #1]KKA » %0:part[#0]KAlf » %4:orders[#0]KA » %5:nation[#0]KA - %2:lineitem » %3:partsupp[#0, #1]KKA » %0:part[#0]KAlf » %1:supplier[#0]KA » %4:orders[#0]KA » %5:nation[#0]KA - %3:partsupp » %2:lineitem[#1, #2]KKA » %0:part[#0]KAlf » %1:supplier[#0]KA » %4:orders[#0]KA » %5:nation[#0]KA - %4:orders » %2:lineitem[#0]KA » %3:partsupp[#0, #1]KKA » %0:part[#0]KAlf » %1:supplier[#0]KA » %5:nation[#0]KA - %5:nation » %1:supplier[#3]KA » %2:lineitem[#2]KA » %3:partsupp[#0, #1]KKA » %0:part[#0]KAlf » %4:orders[#0]KA + %0:part » %2:lineitem[#1{l_partkey}]KA » %3:partsupp[#0{ps_partkey}, #1{ps_suppkey}]KKA » %1:supplier[#0{s_suppkey}]KA » %4:orders[#0{o_orderkey}]KA » %5:nation[#0{n_nationkey}]KA + %1:supplier » %2:lineitem[#2{l_suppkey}]KA » %3:partsupp[#0{ps_partkey}, #1{ps_suppkey}]KKA » %0:part[#0{p_partkey}]KAlf » %4:orders[#0{o_orderkey}]KA » %5:nation[#0{n_nationkey}]KA + %2:lineitem » %3:partsupp[#0{ps_partkey}, #1{ps_suppkey}]KKA » %0:part[#0{p_partkey}]KAlf » %1:supplier[#0{s_suppkey}]KA » %4:orders[#0{o_orderkey}]KA » %5:nation[#0{n_nationkey}]KA + %3:partsupp » %2:lineitem[#1{l_partkey}, #2{l_suppkey}]KKA » %0:part[#0{p_partkey}]KAlf » %1:supplier[#0{s_suppkey}]KA » %4:orders[#0{o_orderkey}]KA » %5:nation[#0{n_nationkey}]KA + %4:orders » %2:lineitem[#0{l_orderkey}]KA » %3:partsupp[#0{ps_partkey}, #1{ps_suppkey}]KKA » %0:part[#0{p_partkey}]KAlf » %1:supplier[#0{s_suppkey}]KA » %5:nation[#0{n_nationkey}]KA + %5:nation » %1:supplier[#3{s_nationkey}]KA » %2:lineitem[#2{l_suppkey}]KA » %3:partsupp[#0{ps_partkey}, #1{ps_suppkey}]KKA » %0:part[#0{p_partkey}]KAlf » %4:orders[#0{o_orderkey}]KA ArrangeBy keys=[[#0{p_partkey}]] // { arity: 9 } ReadIndex on=part pk_part_partkey=[delta join 1st input (full scan)] // { arity: 9 } ArrangeBy keys=[[#0{s_suppkey}], [#3{s_nationkey}]] // { arity: 7 } @@ -838,10 +838,10 @@ Explained Query: Filter (#25{l_returnflag} = "R") AND (#12{o_orderdate} < 1994-01-01) AND (#12{o_orderdate} >= 1993-10-01) AND (date_to_timestamp(#12{o_orderdate}) < 1994-01-01 00:00:00) // { arity: 37 } Join on=(#0{c_custkey} = #9{o_custkey} AND #3{c_nationkey} = #33{n_nationkey} AND #8{o_orderkey} = #17{l_orderkey}) type=delta // { arity: 37 } implementation - %0:customer » %1:orders[#1]KAiiif » %2:lineitem[#0]KAef » %3:nation[#0]KA - %1:orders » %2:lineitem[#0]KAef » %0:customer[#0]KA » %3:nation[#0]KA - %2:lineitem » %1:orders[#0]KAiiif » %0:customer[#0]KA » %3:nation[#0]KA - %3:nation » %0:customer[#3]KA » %1:orders[#1]KAiiif » %2:lineitem[#0]KAef + %0:customer » %1:orders[#1{o_custkey}]KAiiif » %2:lineitem[#0{l_orderkey}]KAef » %3:nation[#0{n_nationkey}]KA + %1:orders » %2:lineitem[#0{l_orderkey}]KAef » %0:customer[#0{c_custkey}]KA » %3:nation[#0{n_nationkey}]KA + %2:lineitem » %1:orders[#0{o_orderkey}]KAiiif » %0:customer[#0{c_custkey}]KA » %3:nation[#0{n_nationkey}]KA + %3:nation » %0:customer[#3{c_nationkey}]KA » %1:orders[#1{o_custkey}]KAiiif » %2:lineitem[#0{l_orderkey}]KAef ArrangeBy keys=[[#0{c_custkey}], [#3{c_nationkey}]] // { arity: 8 } ReadIndex on=customer pk_customer_custkey=[delta join 1st input (full scan)] fk_customer_nationkey=[delta join lookup] // { arity: 8 } ArrangeBy keys=[[#0{o_orderkey}], [#1{o_custkey}]] // { arity: 9 } @@ -903,9 +903,9 @@ Explained Query: Filter (#13{n_name} = "GERMANY") // { arity: 16 } Join on=(#1{ps_suppkey} = #5{s_suppkey} AND #8{s_nationkey} = #12{n_nationkey}) type=delta // { arity: 16 } implementation - %0:partsupp » %1:supplier[#0]KA » %2:nation[#0]KAef - %1:supplier » %2:nation[#0]KAef » %0:partsupp[#1]KA - %2:nation » %1:supplier[#3]KA » %0:partsupp[#1]KA + %0:partsupp » %1:supplier[#0{s_suppkey}]KA » %2:nation[#0{n_nationkey}]KAef + %1:supplier » %2:nation[#0{n_nationkey}]KAef » %0:partsupp[#1{ps_suppkey}]KA + %2:nation » %1:supplier[#3{s_nationkey}]KA » %0:partsupp[#1{ps_suppkey}]KA ArrangeBy keys=[[#1{ps_suppkey}]] // { arity: 5 } ReadIndex on=partsupp fk_partsupp_suppkey=[delta join 1st input (full scan)] // { arity: 5 } ArrangeBy keys=[[#0{s_suppkey}], [#3{s_nationkey}]] // { arity: 7 } @@ -976,7 +976,7 @@ Explained Query: Filter (#21{l_receiptdate} >= 1994-01-01) AND (#19{l_shipdate} < #20{l_commitdate}) AND (#20{l_commitdate} < #21{l_receiptdate}) AND (date_to_timestamp(#21{l_receiptdate}) < 1995-01-01 00:00:00) AND ((#23{l_shipmode} = "MAIL") OR (#23{l_shipmode} = "SHIP")) // { arity: 25 } Join on=(#0{o_orderkey} = #9{l_orderkey}) type=differential // { arity: 25 } implementation - %1:lineitem[#0]KAeiif » %0:orders[#0]KAeiif + %1:lineitem[#0{l_orderkey}]KAeiif » %0:orders[#0{o_orderkey}]KAeiif ArrangeBy keys=[[#0{o_orderkey}]] // { arity: 9 } ReadIndex on=orders pk_orders_orderkey=[differential join] // { arity: 9 } ArrangeBy keys=[[#0{l_orderkey}]] // { arity: 16 } @@ -1026,7 +1026,7 @@ Explained Query: Filter NOT(like["%special%requests%"](varchar_to_text(#16{o_comment}))) // { arity: 17 } Join on=(#0{c_custkey} = #9{o_custkey}) type=differential // { arity: 17 } implementation - %1:orders[#1]KAf » %0:l0[#0]KAf + %1:orders[#1{o_custkey}]KAf » %0:l0[#0{c_custkey}]KAf Get l0 // { arity: 8 } ArrangeBy keys=[[#1{o_custkey}]] // { arity: 9 } ReadIndex on=orders fk_orders_custkey=[differential join] // { arity: 9 } @@ -1041,7 +1041,7 @@ Explained Query: Project (#0{c_custkey}) // { arity: 1 } Join on=(#0{c_custkey} = #8{c_custkey}) type=differential // { arity: 9 } implementation - %1[#0]UKA » %0:l0[#0]KA + %1[#0]UKA » %0:l0[#0{c_custkey}]KA Get l0 // { arity: 8 } ArrangeBy keys=[[#0{c_custkey}]] // { arity: 1 } Distinct project=[#0{c_custkey}] // { arity: 1 } @@ -1085,7 +1085,7 @@ Explained Query: Filter (#10{l_shipdate} >= 1995-09-01) AND (date_to_timestamp(#10{l_shipdate}) < 1995-10-01 00:00:00) // { arity: 25 } Join on=(#1{l_partkey} = #16{p_partkey}) type=differential // { arity: 25 } implementation - %0:lineitem[#1]KAiif » %1:part[#0]KAiif + %0:lineitem[#1{l_partkey}]KAiif » %1:part[#0{p_partkey}]KAiif ArrangeBy keys=[[#1{l_partkey}]] // { arity: 16 } ReadIndex on=lineitem fk_lineitem_partkey=[differential join] // { arity: 16 } ArrangeBy keys=[[#0{p_partkey}]] // { arity: 9 } @@ -1161,8 +1161,8 @@ Explained Query: Join on=(#0{s_suppkey} = #7{l_suppkey} AND #8{sum} = #9{max_sum}) type=delta // { arity: 10 } implementation %0:supplier » %1:l0[#0]UKA » %2[#0]UK - %1:l0 » %2[#0]UK » %0:supplier[#0]KA - %2 » %1:l0[#1]K » %0:supplier[#0]KA + %1:l0 » %2[#0]UK » %0:supplier[#0{s_suppkey}]KA + %2 » %1:l0[#1{total_revenue}]K » %0:supplier[#0{s_suppkey}]KA ArrangeBy keys=[[#0{s_suppkey}]] // { arity: 7 } ReadIndex on=supplier pk_supplier_suppkey=[delta join 1st input (full scan)] // { arity: 7 } ArrangeBy keys=[[#0{l_suppkey}], [#1{sum}]] // { arity: 2 } @@ -1226,7 +1226,7 @@ Explained Query: Filter (#8{p_brand} != "Brand#45") AND NOT(like["MEDIUM POLISHED%"](varchar_to_text(#9{p_type}))) AND ((#10{p_size} = 3) OR (#10{p_size} = 9) OR (#10{p_size} = 14) OR (#10{p_size} = 19) OR (#10{p_size} = 23) OR (#10{p_size} = 36) OR (#10{p_size} = 45) OR (#10{p_size} = 49)) // { arity: 14 } Join on=(#0{ps_partkey} = #5{p_partkey}) type=differential // { arity: 14 } implementation - %1:part[#0]KAef » %0:partsupp[#0]KAef + %1:part[#0{p_partkey}]KAef » %0:partsupp[#0{ps_partkey}]KAef ArrangeBy keys=[[#0{ps_partkey}]] // { arity: 5 } ReadIndex on=partsupp fk_partsupp_partkey=[differential join] // { arity: 5 } ArrangeBy keys=[[#0{p_partkey}]] // { arity: 9 } @@ -1301,7 +1301,7 @@ Explained Query: Filter (#19{p_brand} = "Brand#23") AND (#22{p_container} = "MED BOX") // { arity: 25 } Join on=(#1{l_partkey} = #16{p_partkey}) type=differential // { arity: 25 } implementation - %1:part[#0]KAef » %0:l0[#1]KAef + %1:part[#0{p_partkey}]KAef » %0:l0[#1{l_partkey}]KAef Get l0 // { arity: 16 } ArrangeBy keys=[[#0{p_partkey}]] // { arity: 9 } ReadIndex on=part pk_part_partkey=[differential join] // { arity: 9 } @@ -1319,7 +1319,7 @@ Explained Query: Project (#0{l_partkey}, #5{l_quantity}) // { arity: 2 } Join on=(#0{l_partkey} = #2{l_partkey}) type=differential // { arity: 17 } implementation - %0[#0]UKA » %1:l0[#1]KA + %0[#0{p_partkey}]UKA » %1:l0[#1{l_partkey}]KA ArrangeBy keys=[[#0{l_partkey}]] // { arity: 1 } Distinct project=[#0{l_partkey}] // { arity: 1 } Project (#0{l_partkey}) // { arity: 1 } @@ -1393,9 +1393,9 @@ Explained Query: Project (#0{c_custkey}, #1{c_name}, #8{o_orderkey}, #11{o_totalprice}, #12{o_orderdate}, #21{l_quantity}) // { arity: 6 } Join on=(#0{c_custkey} = #9{o_custkey} AND #8{o_orderkey} = #17{l_orderkey}) type=delta // { arity: 33 } implementation - %0:customer » %1:orders[#1]KA » %2:l0[#0]KA - %1:orders » %0:customer[#0]KA » %2:l0[#0]KA - %2:l0 » %1:orders[#0]KA » %0:customer[#0]KA + %0:customer » %1:orders[#1{o_custkey}]KA » %2:l0[#0{l_orderkey}]KA + %1:orders » %0:customer[#0{c_custkey}]KA » %2:l0[#0{l_orderkey}]KA + %2:l0 » %1:orders[#0{o_orderkey}]KA » %0:customer[#0{c_custkey}]KA ArrangeBy keys=[[#0{c_custkey}]] // { arity: 8 } ReadIndex on=customer pk_customer_custkey=[delta join 1st input (full scan)] // { arity: 8 } ArrangeBy keys=[[#0{o_orderkey}], [#1{o_custkey}]] // { arity: 9 } @@ -1415,7 +1415,7 @@ Explained Query: Project (#0{o_orderkey}, #5{l_quantity}) // { arity: 2 } Join on=(#0{o_orderkey} = #1{l_orderkey}) type=differential // { arity: 17 } implementation - %0[#0]UKA » %1:l0[#0]KA + %0[#0]UKA » %1:l0[#0{l_orderkey}]KA ArrangeBy keys=[[#0{o_orderkey}]] // { arity: 1 } Distinct project=[#0{o_orderkey}] // { arity: 1 } Project (#2{o_orderkey}) // { arity: 1 } @@ -1481,7 +1481,7 @@ Explained Query: Map ((#4{l_quantity} <= 20), (#4{l_quantity} >= 10), (#4{l_quantity} <= 30), (#4{l_quantity} >= 20), (#4{l_quantity} <= 11), (#4{l_quantity} >= 1), (#19{p_brand} = "Brand#12"), (#21{p_size} <= 5), ((#22{p_container} = "SM BOX") OR (#22{p_container} = "SM PKG") OR (#22{p_container} = "SM CASE") OR (#22{p_container} = "SM PACK")), (#19{p_brand} = "Brand#23"), (#21{p_size} <= 10), ((#22{p_container} = "MED BAG") OR (#22{p_container} = "MED BOX") OR (#22{p_container} = "MED PKG") OR (#22{p_container} = "MED PACK")), (#19{p_brand} = "Brand#34"), (#21{p_size} <= 15), ((#22{p_container} = "LG BOX") OR (#22{p_container} = "LG PKG") OR (#22{p_container} = "LG CASE") OR (#22{p_container} = "LG PACK"))) // { arity: 40 } Join on=(#1{l_partkey} = #16{p_partkey}) type=differential // { arity: 25 } implementation - %1:part[#0]KAeiiif » %0:lineitem[#1]KAeiiiiif + %1:part[#0{p_partkey}]KAeiiif » %0:lineitem[#1{l_partkey}]KAeiiiiif ArrangeBy keys=[[#1{l_partkey}]] // { arity: 16 } ReadIndex on=lineitem fk_lineitem_partkey=[differential join] // { arity: 16 } ArrangeBy keys=[[#0{p_partkey}]] // { arity: 9 } @@ -1555,7 +1555,7 @@ Explained Query: Filter (#8{n_name} = "CANADA") // { arity: 11 } Join on=(#3{s_nationkey} = #7{n_nationkey}) type=differential // { arity: 11 } implementation - %1:nation[#0]KAef » %0:supplier[#3]KAef + %1:nation[#0{n_nationkey}]KAef » %0:supplier[#3{s_nationkey}]KAef ArrangeBy keys=[[#3{s_nationkey}]] // { arity: 7 } ReadIndex on=supplier fk_supplier_nationkey=[differential join] // { arity: 7 } ArrangeBy keys=[[#0{n_nationkey}]] // { arity: 4 } @@ -1566,7 +1566,7 @@ Explained Query: implementation %0 » %1:partsupp[×] » %2[#0]UKA %1:partsupp » %2[#0]UKA » %0[×] - %2 » %1:partsupp[#0]KA » %0[×] + %2 » %1:partsupp[#0{ps_partkey}]KA » %0[×] ArrangeBy keys=[[]] // { arity: 1 } Distinct project=[#0{s_suppkey}] // { arity: 1 } Project (#0{s_suppkey}) // { arity: 1 } @@ -1592,7 +1592,7 @@ Explained Query: Filter (integer_to_numeric(#2{ps_availqty}) > #5) // { arity: 6 } Join on=(#0{s_suppkey} = #4{ps_suppkey} AND #1{ps_partkey} = #3{ps_partkey}) type=differential // { arity: 6 } implementation - %1[#1, #0]UKK » %0:l1[#0, #1]KKf + %1[#1, #0]UKK » %0:l1[#0{s_suppkey}, #1]KKf ArrangeBy keys=[[#0{s_suppkey}, #1{ps_partkey}]] // { arity: 3 } Project (#0{s_suppkey}, #1{ps_partkey}, #3{ps_availqty}) // { arity: 3 } Filter (#0{s_suppkey} = #2{ps_suppkey}) // { arity: 4 } @@ -1605,7 +1605,7 @@ Explained Query: Filter (#12{l_shipdate} >= 1995-01-01) AND (date_to_timestamp(#12{l_shipdate}) < 1996-01-01 00:00:00) // { arity: 18 } Join on=(#0{ps_partkey} = #3{l_partkey} AND #1{ps_suppkey} = #4{l_suppkey}) type=differential // { arity: 18 } implementation - %0[#0, #1]UKKA » %1:lineitem[#1, #2]KKAiif + %0[#0{ps_partkey}, #1{ps_suppkey}]UKKA » %1:lineitem[#1{l_partkey}, #2{l_suppkey}]KKAiif ArrangeBy keys=[[#0{ps_partkey}, #1{ps_suppkey}]] // { arity: 2 } Distinct project=[#0{ps_partkey}, #1{ps_suppkey}] // { arity: 2 } Project (#1{ps_partkey}, #2{ps_suppkey}) // { arity: 2 } @@ -1676,10 +1676,10 @@ Explained Query: Filter (#25{o_orderstatus} = "F") AND (#33{n_name} = "SAUDI ARABIA") AND (#19{l_receiptdate} > #18{l_commitdate}) // { arity: 36 } Join on=(#0{s_suppkey} = #9{l_suppkey} AND #3{s_nationkey} = #32{n_nationkey} AND #7{l_orderkey} = #23{o_orderkey}) type=delta // { arity: 36 } implementation - %0:supplier » %3:nation[#0]KAef » %1:lineitem[#2]KAf » %2:orders[#0]KAef - %1:lineitem » %2:orders[#0]KAef » %0:supplier[#0]KA » %3:nation[#0]KAef - %2:orders » %1:lineitem[#0]KAf » %0:supplier[#0]KA » %3:nation[#0]KAef - %3:nation » %0:supplier[#3]KA » %1:lineitem[#2]KAf » %2:orders[#0]KAef + %0:supplier » %3:nation[#0{n_nationkey}]KAef » %1:lineitem[#2{l_suppkey}]KAf » %2:orders[#0{o_orderkey}]KAef + %1:lineitem » %2:orders[#0{o_orderkey}]KAef » %0:supplier[#0{s_suppkey}]KA » %3:nation[#0{n_nationkey}]KAef + %2:orders » %1:lineitem[#0{l_orderkey}]KAf » %0:supplier[#0{s_suppkey}]KA » %3:nation[#0{n_nationkey}]KAef + %3:nation » %0:supplier[#3{s_nationkey}]KA » %1:lineitem[#2{l_suppkey}]KAf » %2:orders[#0{o_orderkey}]KAef ArrangeBy keys=[[#0{s_suppkey}], [#3{s_nationkey}]] // { arity: 7 } ReadIndex on=supplier pk_supplier_suppkey=[delta join 1st input (full scan)] fk_supplier_nationkey=[delta join lookup] // { arity: 7 } ArrangeBy keys=[[#0{l_orderkey}], [#2{l_suppkey}]] // { arity: 16 } @@ -1704,7 +1704,7 @@ Explained Query: Filter (#1{s_suppkey} != #4{l_suppkey}) // { arity: 18 } Join on=(#0{l_orderkey} = #2{l_orderkey}) type=differential // { arity: 18 } implementation - %1:l1[#0]KA » %0[#0]K + %1:l1[#0{l_orderkey}]KA » %0[#0{l_orderkey}]K ArrangeBy keys=[[#0{l_orderkey}]] // { arity: 2 } Distinct project=[#1{l_orderkey}, #0{s_suppkey}] // { arity: 2 } Project (#0{s_suppkey}, #2{l_orderkey}) // { arity: 2 } @@ -1730,7 +1730,7 @@ Explained Query: Filter (#1{s_suppkey} != #4{l_suppkey}) AND (#14{l_receiptdate} > #13{l_commitdate}) // { arity: 18 } Join on=(#0{l_orderkey} = #2{l_orderkey}) type=differential // { arity: 18 } implementation - %1:l1[#0]KAf » %0:l3[#0]Kf + %1:l1[#0{l_orderkey}]KAf » %0:l3[#0{l_orderkey}]Kf ArrangeBy keys=[[#0{l_orderkey}]] // { arity: 2 } Get l3 // { arity: 2 } Get l1 // { arity: 16 } @@ -1905,25 +1905,25 @@ Finish order_by=[#0 asc nulls_last] output=[#0, #1] Project (#1, #2) With cte [l3 as subquery-3] = - Reduce aggregates=[any((#^0 = #0))] + Reduce aggregates=[any((#^0{s_suppkey} = #0{right_col0_0}))] Project (#1) With cte [l2 as subquery-2] = Project (#1) - Map ((0.5 * #0)) - Reduce aggregates=[sum(#4)] - Filter ((((#1 = #^0) AND (#2 = #^1)) AND (#10 >= text_to_date("1995-01-01"))) AND (date_to_timestamp(#10) < (text_to_date("1995-01-01") + 1 year))) + Map ((0.5 * #0{?column?})) + Reduce aggregates=[sum(#4{l_quantity})] + Filter ((((#1{l_partkey} = #^0{ps_partkey}) AND (#2{l_suppkey} = #^1{ps_suppkey})) AND (#10{l_shipdate} >= text_to_date("1995-01-01"))) AND (date_to_timestamp(#10{l_shipdate}) < (text_to_date("1995-01-01") + 1 year))) Get materialize.public.lineitem cte [l1 as subquery-1] = - Reduce aggregates=[any((#^0 = #0))] + Reduce aggregates=[any((#^0{ps_partkey} = #0{right_col0_2}))] Project (#0) - Filter (varchar_to_text(#1) like "forest%") + Filter (varchar_to_text(#1{p_name}) like "forest%") Get materialize.public.part Return - Filter (select(Get l1) AND (integer_to_numeric(#2) > select(Get l2))) + Filter (select(Get l1) AND (integer_to_numeric(#2{ps_availqty}) > select(Get l2))) Get materialize.public.partsupp Return - Filter ((select(Get l3) AND (#3 = #7)) AND (#8 = text_to_char[len=unbounded]("CANADA"))) + Filter ((select(Get l3) AND (#3{s_nationkey} = #7{n_nationkey})) AND (#8{n_name} = text_to_char[len=unbounded]("CANADA"))) CrossJoin Get materialize.public.supplier Get materialize.public.nation diff --git a/test/sqllogictest/transform/aggregation_nullability.slt b/test/sqllogictest/transform/aggregation_nullability.slt index 011c3b46d111f..2df3c42d1ec28 100644 --- a/test/sqllogictest/transform/aggregation_nullability.slt +++ b/test/sqllogictest/transform/aggregation_nullability.slt @@ -33,7 +33,7 @@ Explained Query: Project (#0{f1}) // { arity: 1 } Join on=(#0{f1} = #1{f1}) type=differential // { arity: 2 } implementation - %0:l0[#0]K » %1:t2[#0]K + %0:l0[#0{f1}]K » %1:t2[#0{f1}]K Get l0 // { arity: 1 } ArrangeBy keys=[[#0{f1}]] // { arity: 1 } Project (#0{f1}) // { arity: 1 } @@ -49,7 +49,7 @@ Explained Query: Project (#0{f1}) // { arity: 1 } Join on=(#0{f1} = #1{f1}) type=differential // { arity: 2 } implementation - %1[#0]UKA » %0:l0[#0]K + %1[#0]UKA » %0:l0[#0{f1}]K Get l0 // { arity: 1 } ArrangeBy keys=[[#0{f1}]] // { arity: 1 } Distinct project=[#0{f1}] // { arity: 1 } @@ -83,7 +83,7 @@ Explained Query: Project (#0{f1}) // { arity: 1 } Join on=(#0{f1} = #1{f1}) type=differential // { arity: 2 } implementation - %0:t1[#0]K » %1:t2[#0]K + %0:t1[#0{f1}]K » %1:t2[#0{f1}]K ArrangeBy keys=[[#0{f1}]] // { arity: 1 } Project (#0{f1}) // { arity: 1 } Filter (#0{f1}) IS NOT NULL // { arity: 2 } @@ -120,7 +120,7 @@ Explained Query: Project (#0{f1}, #1{f2}) // { arity: 2 } Join on=(#0{f1} = #2{f1}) type=differential // { arity: 3 } implementation - %0:l0[#0]K » %1:t2[#0]K + %0:l0[#0{f1}]K » %1:t2[#0{f1}]K Get l0 // { arity: 2 } ArrangeBy keys=[[#0{f1}]] // { arity: 1 } Project (#0{f1}) // { arity: 1 } @@ -134,7 +134,7 @@ Explained Query: Project (#0{f1}, #1{f2}) // { arity: 2 } Join on=(#0{f1} = #2{f1}) type=differential // { arity: 3 } implementation - %1[#0]UKA » %0:l0[#0]K + %1[#0]UKA » %0:l0[#0{f1}]K Get l0 // { arity: 2 } ArrangeBy keys=[[#0{f1}]] // { arity: 1 } Distinct project=[#0{f1}] // { arity: 1 } @@ -176,7 +176,7 @@ Explained Query: Project (#0{f1}, #1{f2}) // { arity: 2 } Join on=(#0{f1} = #2{f1}) type=differential // { arity: 3 } implementation - %0:l0[#0]K » %1:t2[#0]K + %0:l0[#0{f1}]K » %1:t2[#0{f1}]K Get l0 // { arity: 2 } ArrangeBy keys=[[#0{f1}]] // { arity: 1 } Project (#0{f1}) // { arity: 1 } @@ -190,7 +190,7 @@ Explained Query: Project (#0{f1}, #1{f2}) // { arity: 2 } Join on=(#0{f1} = #2{f1}) type=differential // { arity: 3 } implementation - %1[#0]UKA » %0:l0[#0]K + %1[#0]UKA » %0:l0[#0{f1}]K Get l0 // { arity: 2 } ArrangeBy keys=[[#0{f1}]] // { arity: 1 } Distinct project=[#0{f1}] // { arity: 1 } @@ -233,7 +233,7 @@ Explained Query: Project (#0{f1}, #1{f2}) // { arity: 2 } Join on=(#0{f1} = #2{f1}) type=differential // { arity: 3 } implementation - %0:l0[#0]K » %1:t2[#0]K + %0:l0[#0{f1}]K » %1:t2[#0{f1}]K Get l0 // { arity: 2 } ArrangeBy keys=[[#0{f1}]] // { arity: 1 } Project (#0{f1}) // { arity: 1 } @@ -247,7 +247,7 @@ Explained Query: Project (#0{f1}, #1{f2}) // { arity: 2 } Join on=(#0{f1} = #2{f1}) type=differential // { arity: 3 } implementation - %1[#0]UKA » %0:l0[#0]K + %1[#0]UKA » %0:l0[#0{f1}]K Get l0 // { arity: 2 } ArrangeBy keys=[[#0{f1}]] // { arity: 1 } Distinct project=[#0{f1}] // { arity: 1 } @@ -315,7 +315,7 @@ Explained Query: Project (#0{f1}) // { arity: 1 } Join on=(#0{f1} = #1{f1}) type=differential // { arity: 2 } implementation - %0:t1[#0]Kif » %1:t2[#0]Kiif + %0:t1[#0{f1}]Kif » %1:t2[#0{f1}]Kiif ArrangeBy keys=[[#0{f1}]] // { arity: 1 } Project (#0{f1}) // { arity: 1 } Filter (#0{f1} >= 0) // { arity: 2 } @@ -355,7 +355,7 @@ Explained Query: Project (#0{f1}) // { arity: 1 } Join on=(#0{f1} = #1{f1}) type=differential // { arity: 2 } implementation - %0:t1[#0]Kif » %1:t2[#0]Kiif + %0:t1[#0{f1}]Kif » %1:t2[#0{f1}]Kiif ArrangeBy keys=[[#0{f1}]] // { arity: 1 } Project (#0{f1}) // { arity: 1 } Filter (#0{f1} >= 0) // { arity: 2 } @@ -401,7 +401,7 @@ Explained Query: Project (#0{f1}, #2{f2}) // { arity: 2 } Join on=(#0{f1} = #1{f1}) type=differential // { arity: 3 } implementation - %0:l0[#0]K » %1:t2[#0]K + %0:l0[#0{f1}]K » %1:t2[#0{f1}]K Get l0 // { arity: 1 } ArrangeBy keys=[[#0{f1}]] // { arity: 2 } Filter (#0{f1}) IS NOT NULL // { arity: 2 } @@ -414,7 +414,7 @@ Explained Query: Project (#0{f1}) // { arity: 1 } Join on=(#0{f1} = #1{f1}) type=differential // { arity: 2 } implementation - %1[#0]UKA » %0:l0[#0]K + %1[#0]UKA » %0:l0[#0{f1}]K Get l0 // { arity: 1 } ArrangeBy keys=[[#0{f1}]] // { arity: 1 } Distinct project=[#0{f1}] // { arity: 1 } @@ -457,7 +457,7 @@ Explained Query: Project (#0{f1}, #2{f2}) // { arity: 2 } Join on=(#0{f1} = #1{f1}) type=differential // { arity: 3 } implementation - %0:t1[#0]Kif » %1:t2[#0]Kiif + %0:t1[#0{f1}]Kif » %1:t2[#0{f1}]Kiif ArrangeBy keys=[[#0{f1}]] // { arity: 1 } Project (#0{f1}) // { arity: 1 } Filter (#0{f1} >= 0) // { arity: 2 } @@ -497,7 +497,7 @@ Explained Query: Project (#0{f1}) // { arity: 1 } Join on=(#0{f1} = #1{f1}) type=differential // { arity: 2 } implementation - %0:t1[#0]Kif » %1:t2[#0]Kiif + %0:t1[#0{f1}]Kif » %1:t2[#0{f1}]Kiif ArrangeBy keys=[[#0{f1}]] // { arity: 1 } Project (#0{f1}) // { arity: 1 } Filter (#0{f1} >= 0) // { arity: 2 } @@ -542,7 +542,7 @@ Explained Query: Project (#0{f1}) // { arity: 1 } Join on=(#0{f1} = #1{f1}) type=differential // { arity: 2 } implementation - %0:l0[#0]K » %1:t2[#0]K + %0:l0[#0{f1}]K » %1:t2[#0{f1}]K Get l0 // { arity: 1 } ArrangeBy keys=[[#0{f1}]] // { arity: 1 } Project (#0{f1}) // { arity: 1 } @@ -556,7 +556,7 @@ Explained Query: Project (#0{f1}) // { arity: 1 } Join on=(#0{f1} = #1{f1}) type=differential // { arity: 2 } implementation - %1[#0]UKA » %0:l0[#0]K + %1[#0]UKA » %0:l0[#0{f1}]K Get l0 // { arity: 1 } ArrangeBy keys=[[#0{f1}]] // { arity: 1 } Distinct project=[#0{f1}] // { arity: 1 } @@ -602,7 +602,7 @@ Explained Query: Project (#0{f1}, #2{f2}) // { arity: 2 } Join on=(#0{f1} = #1{f1}) type=differential // { arity: 3 } implementation - %0:l0[#0]K » %1:t2[#0]K + %0:l0[#0{f1}]K » %1:t2[#0{f1}]K Get l0 // { arity: 1 } ArrangeBy keys=[[#0{f1}]] // { arity: 2 } Filter (#0{f1}) IS NOT NULL // { arity: 2 } @@ -616,7 +616,7 @@ Explained Query: Project (#0{f1}) // { arity: 1 } Join on=(#0{f1} = #1{f1}) type=differential // { arity: 2 } implementation - %1[#0]UKA » %0:l0[#0]K + %1[#0]UKA » %0:l0[#0{f1}]K Get l0 // { arity: 1 } ArrangeBy keys=[[#0{f1}]] // { arity: 1 } Distinct project=[#0{f1}] // { arity: 1 } @@ -649,7 +649,7 @@ Explained Query: Project (#0{f1}, #2{f2}) // { arity: 2 } Join on=(#0{f1} = #1{f1}) type=differential // { arity: 3 } implementation - %0:l0[#0]K » %1:t2[#0]K + %0:l0[#0{f1}]K » %1:t2[#0{f1}]K Get l0 // { arity: 1 } ArrangeBy keys=[[#0{f1}]] // { arity: 2 } Filter (#0{f1}) IS NOT NULL // { arity: 2 } @@ -662,7 +662,7 @@ Explained Query: Project (#0{f1}) // { arity: 1 } Join on=(#0{f1} = #1{f1}) type=differential // { arity: 2 } implementation - %1[#0]UKA » %0:l0[#0]K + %1[#0]UKA » %0:l0[#0{f1}]K Get l0 // { arity: 1 } ArrangeBy keys=[[#0{f1}]] // { arity: 1 } Distinct project=[#0{f1}] // { arity: 1 } @@ -701,7 +701,7 @@ Explained Query: Project (#0{f1}, #2{f2}) // { arity: 2 } Join on=(#0{f1} = #1{f1}) type=differential // { arity: 3 } implementation - %0:t1[#0]K » %1:t2[#0]K + %0:t1[#0{f1}]K » %1:t2[#0{f1}]K ArrangeBy keys=[[#0{f1}]] // { arity: 1 } Project (#0{f1}) // { arity: 1 } Filter (#0{f1}) IS NOT NULL // { arity: 2 } @@ -741,7 +741,7 @@ Explained Query: Project (#0{f1}, #1{f2}, #3{f2}) // { arity: 3 } Join on=(#0{f1} = #2{f1}) type=differential // { arity: 4 } implementation - %0:t1[#0]K » %1:t2[#0]K + %0:t1[#0{f1}]K » %1:t2[#0{f1}]K ArrangeBy keys=[[#0{f1}]] // { arity: 2 } Filter (#0{f1}) IS NOT NULL // { arity: 2 } ReadStorage materialize.public.t1 // { arity: 2 } @@ -813,7 +813,7 @@ Explained Query: Project (#0{f1}, #1{f2}, #3{f2}) // { arity: 3 } Join on=(#1{f2} = #2{f1}) type=differential // { arity: 4 } implementation - %0:l0[#1]K » %1:t2[#0]K + %0:l0[#1{f2}]K » %1:t2[#0{f1}]K Get l0 // { arity: 2 } ArrangeBy keys=[[#0{f1}]] // { arity: 2 } Filter (#0{f1}) IS NOT NULL // { arity: 2 } @@ -826,7 +826,7 @@ Explained Query: Project (#0{f1}, #1{f2}) // { arity: 2 } Join on=(#1{f2} = #2{f2}) type=differential // { arity: 3 } implementation - %1[#0]UKA » %0:l0[#1]K + %1[#0]UKA » %0:l0[#1{f2}]K Get l0 // { arity: 2 } ArrangeBy keys=[[#0{f2}]] // { arity: 1 } Distinct project=[#0{f2}] // { arity: 1 } @@ -869,7 +869,7 @@ Explained Query: Project (#0{f1}, #1{f2}, #3{f2}) // { arity: 3 } Join on=(#1{f2} = #2{f1}) type=differential // { arity: 4 } implementation - %0:l0[#1]K » %1:t2[#0]K + %0:l0[#1{f2}]K » %1:t2[#0{f1}]K Get l0 // { arity: 2 } ArrangeBy keys=[[#0{f1}]] // { arity: 2 } Filter (#0{f1}) IS NOT NULL // { arity: 2 } @@ -882,7 +882,7 @@ Explained Query: Project (#0{f1}, #1{f2}) // { arity: 2 } Join on=(#1{f2} = #2{f2}) type=differential // { arity: 3 } implementation - %1[#0]UKA » %0:l0[#1]K + %1[#0]UKA » %0:l0[#1{f2}]K Get l0 // { arity: 2 } ArrangeBy keys=[[#0{f2}]] // { arity: 1 } Distinct project=[#0{f2}] // { arity: 1 } @@ -923,7 +923,7 @@ Explained Query: Project (#0{f1}, #3{f2}) // { arity: 2 } Join on=(#1{f2} = #2{f1}) type=differential // { arity: 4 } implementation - %0:t1[#1]K » %1:t2[#0]K + %0:t1[#1{f2}]K » %1:t2[#0{f1}]K ArrangeBy keys=[[#1{f2}]] // { arity: 2 } Filter (#1{f2}) IS NOT NULL // { arity: 2 } ReadStorage materialize.public.t1 // { arity: 2 } @@ -1056,9 +1056,9 @@ Explained Query: Project (#2{count}) // { arity: 1 } Join on=(#0{f2} = #1{max_f2}) type=delta // { arity: 3 } implementation - %0:t1 » %1[#0]UK » %2[×]UA - %1 » %2[×]UA » %0:t1[#0]K - %2 » %1[×]UA » %0:t1[#0]K + %0:t1 » %1[#0{agg2}]UK » %2[×]UA + %1 » %2[×]UA » %0:t1[#0{f2}]K + %2 » %1[×]UA » %0:t1[#0{f2}]K ArrangeBy keys=[[#0{f2}]] // { arity: 1 } Project (#1{f2}) // { arity: 1 } ReadStorage materialize.public.t1 // { arity: 2 } diff --git a/test/sqllogictest/transform/column_knowledge.slt b/test/sqllogictest/transform/column_knowledge.slt index f0666dcd768d3..48eaacdc0fee0 100644 --- a/test/sqllogictest/transform/column_knowledge.slt +++ b/test/sqllogictest/transform/column_knowledge.slt @@ -568,7 +568,7 @@ EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) Explained Query: Join on=(#1{double_col} = integer_to_double(#0{int_col})) type=differential // { arity: 2 } implementation - %0:int_table[integer_to_double(#0)]K » %1:double_table[#0]K + %0:int_table[integer_to_double(#0{int_col})]K » %1:double_table[#0{double_col}]K ArrangeBy keys=[[integer_to_double(#0{int_col})]] // { arity: 1 } ReadStorage materialize.public.int_table // { arity: 1 } ArrangeBy keys=[[#0{double_col}]] // { arity: 1 } diff --git a/test/sqllogictest/transform/demand.slt b/test/sqllogictest/transform/demand.slt index 80de9e0a46410..9781970095493 100644 --- a/test/sqllogictest/transform/demand.slt +++ b/test/sqllogictest/transform/demand.slt @@ -146,13 +146,13 @@ Explained Query: ReadStorage materialize.public.t // { arity: 1 } cte l1 = Project (#4, #5) // { arity: 2 } - Map ((#0{a} + #0{a}), (#1{a} + #3)) // { arity: 6 } - Join on=(#0{a} = #2) type=differential // { arity: 4 } + Map ((#0{a} + #0{a}), (#1{a} + #3{a})) // { arity: 6 } + Join on=(#0{a} = #2{key}) type=differential // { arity: 4 } implementation - %0:l0[#0]K » %1:l0[#0]K + %0:l0[#0{key}]K » %1:l0[#0{key}]K ArrangeBy keys=[[#0{a}]] // { arity: 2 } Get l0 // { arity: 2 } - ArrangeBy keys=[[#0]] // { arity: 2 } + ArrangeBy keys=[[#0{key}]] // { arity: 2 } Project (#2, #3) // { arity: 2 } Map ((#0{a} + 1), -(#1{a})) // { arity: 4 } Get l0 // { arity: 2 } diff --git a/test/sqllogictest/transform/filter_index.slt b/test/sqllogictest/transform/filter_index.slt index ec2d333dc89b6..ce253a50038b8 100644 --- a/test/sqllogictest/transform/filter_index.slt +++ b/test/sqllogictest/transform/filter_index.slt @@ -180,7 +180,7 @@ Explained Query: Project (#0{a}..=#2{c}, #5{d}, #6{e}) // { arity: 5 } Join on=(#0{a} = #4{a}) type=differential // { arity: 7 } implementation - %0:foo[#0]KAe » %1:bar[#0]KAe + %0:foo[#0{a}]KAe » %1:bar[#0{a}]KAe ArrangeBy keys=[[#0{a}]] // { arity: 4 } ReadIndex on=materialize.public.foo foo_idx3=[lookup value=("this")] // { arity: 4 } ArrangeBy keys=[[#0{a}]] // { arity: 3 } diff --git a/test/sqllogictest/transform/fold_vs_dataflow/2_number_fns_dataflow.slt b/test/sqllogictest/transform/fold_vs_dataflow/2_number_fns_dataflow.slt index 3f05ad188c8fe..663a78c9e4ddf 100644 --- a/test/sqllogictest/transform/fold_vs_dataflow/2_number_fns_dataflow.slt +++ b/test/sqllogictest/transform/fold_vs_dataflow/2_number_fns_dataflow.slt @@ -75,7 +75,7 @@ FROM t_using_dataflow_rendering; ---- Explained Query: Project (#0{real1}, #5..=#20, #0{real1}..=#2{numeric1}, #21..=#26, #28, #30, #32..=#44, #27, #29, #31, #0{real1}..=#2{numeric1}) - Map ((#0{real1} + 1), (#0{real1} - 1), (#0{real1} + 0), (#1{double1} + 0), (#2{numeric1} + 0), (#0{real1} + #0{real1}), (#1{double1} + #1{double1}), (#2{numeric1} + #2{numeric1}), sqrtf64(real_to_double(#0{real1})), sqrtf64(#1{double1}), sqrtnumeric(#2{numeric1}), sqrtf64(real_to_double(#10)), sqrtf64(#11), sqrtnumeric(#12), (#3{tint1} / #4{tint2}), (#4{tint2} / #3{tint1}), greatest(#0{real1}, 1), greatest(#1{double1}, 1), greatest(#2{numeric1}, 1), least(#0{real1}, 100000000000000000000000000000000000000), least(#1{double1}, 100000000000000000000000000000000000000), least(#2{numeric1}, 100000000000000000000000000000000000000), (#0{real1} = 100000000000000000000000000000000000000), case when #27 then null else #0{real1} end, (#1{double1} = 100000000000000000000000000000000000000), case when #29 then null else #1{double1} end, (#2{numeric1} = 100000000000000000000000000000000000000), case when #31 then null else #2{numeric1} end, (#0{real1} <= 100000000000000000000000000000000000000), (#1{double1} <= 100000000000000000000000000000000000000), (#2{numeric1} <= 100000000000000000000000000000000000000), (#0{real1} >= 100000000000000000000000000000000000000), (#1{double1} >= 100000000000000000000000000000000000000), (#2{numeric1} >= 100000000000000000000000000000000000000), (#0{real1} < 100000000000000000000000000000000000000), (#1{double1} < 100000000000000000000000000000000000000), (#2{numeric1} < 100000000000000000000000000000000000000), (#0{real1} > 100000000000000000000000000000000000000), (#1{double1} > 100000000000000000000000000000000000000), (#2{numeric1} > 100000000000000000000000000000000000000)) + Map ((#0{real1} + 1), (#0{real1} - 1), (#0{real1} + 0), (#1{double1} + 0), (#2{numeric1} + 0), (#0{real1} + #0{real1}), (#1{double1} + #1{double1}), (#2{numeric1} + #2{numeric1}), sqrtf64(real_to_double(#0{real1})), sqrtf64(#1{double1}), sqrtnumeric(#2{numeric1}), sqrtf64(real_to_double(#10{?column?})), sqrtf64(#11{?column?}), sqrtnumeric(#12{?column?}), (#3{tint1} / #4{tint2}), (#4{tint2} / #3{tint1}), greatest(#0{real1}, 1), greatest(#1{double1}, 1), greatest(#2{numeric1}, 1), least(#0{real1}, 100000000000000000000000000000000000000), least(#1{double1}, 100000000000000000000000000000000000000), least(#2{numeric1}, 100000000000000000000000000000000000000), (#0{real1} = 100000000000000000000000000000000000000), case when #27 then null else #0{real1} end, (#1{double1} = 100000000000000000000000000000000000000), case when #29 then null else #1{double1} end, (#2{numeric1} = 100000000000000000000000000000000000000), case when #31 then null else #2{numeric1} end, (#0{real1} <= 100000000000000000000000000000000000000), (#1{double1} <= 100000000000000000000000000000000000000), (#2{numeric1} <= 100000000000000000000000000000000000000), (#0{real1} >= 100000000000000000000000000000000000000), (#1{double1} >= 100000000000000000000000000000000000000), (#2{numeric1} >= 100000000000000000000000000000000000000), (#0{real1} < 100000000000000000000000000000000000000), (#1{double1} < 100000000000000000000000000000000000000), (#2{numeric1} < 100000000000000000000000000000000000000), (#0{real1} > 100000000000000000000000000000000000000), (#1{double1} > 100000000000000000000000000000000000000), (#2{numeric1} > 100000000000000000000000000000000000000)) ReadStorage materialize.public.t_using_dataflow_rendering Source materialize.public.t_using_dataflow_rendering diff --git a/test/sqllogictest/transform/fold_vs_dataflow/6_bytea_dataflow.slt b/test/sqllogictest/transform/fold_vs_dataflow/6_bytea_dataflow.slt index 4cbee6eb1a508..1d355d34a4e02 100644 --- a/test/sqllogictest/transform/fold_vs_dataflow/6_bytea_dataflow.slt +++ b/test/sqllogictest/transform/fold_vs_dataflow/6_bytea_dataflow.slt @@ -34,7 +34,7 @@ FROM t_using_dataflow_rendering; ---- Explained Query: Project (#1, #2) - Map (text_to_bytea(#0{f1}), digest(#1, "sha512")) + Map (text_to_bytea(#0{f1}), digest(#1{?column?}, "sha512")) ReadStorage materialize.public.t_using_dataflow_rendering Source materialize.public.t_using_dataflow_rendering diff --git a/test/sqllogictest/transform/join_fusion.slt b/test/sqllogictest/transform/join_fusion.slt index dbdfc8327ec58..7efb10aee64ed 100644 --- a/test/sqllogictest/transform/join_fusion.slt +++ b/test/sqllogictest/transform/join_fusion.slt @@ -35,9 +35,9 @@ Explained Query: Filter (#0{f1} <= #2{f1}) // { arity: 6 } Join on=(#0{f1} = #4{f1} AND #1{f2} = #3{f2}) type=delta // { arity: 6 } implementation - %0:t1 » %2:t3[#0]Kif » %1:t2[#1]K - %1:t2 » %0:t1[#1]Kif » %2:t3[#0]Kif - %2:t3 » %0:t1[#0]Kif » %1:t2[#1]K + %0:t1 » %2:t3[#0{f1}]Kif » %1:t2[#1{f2}]K + %1:t2 » %0:t1[#1{f2}]Kif » %2:t3[#0{f1}]Kif + %2:t3 » %0:t1[#0{f1}]Kif » %1:t2[#1{f2}]K ArrangeBy keys=[[#0{f1}], [#1{f2}]] // { arity: 2 } Filter (#0{f1} > 0) AND (#1{f2}) IS NOT NULL // { arity: 2 } ReadStorage materialize.public.t1 // { arity: 2 } @@ -120,9 +120,9 @@ Explained Query: Filter (#5{l_shipdate} != #11{o_orderdate}) AND (#14{c_acctbal} >= #10{o_totalprice}) // { arity: 15 } Join on=(#0{l_orderkey} = #8{o_orderkey} AND date_to_timestamp(#11{o_orderdate}) = (#5{l_shipdate} - 9 months)) type=delta // { arity: 15 } implementation - %0:lineitem » %1:orders[#0]KA » %2:customer[×] - %1:orders » %0:lineitem[#0]KA » %2:customer[×] - %2:customer » %0:lineitem[×] » %1:orders[#0]KA + %0:lineitem » %1:orders[#0{o_orderkey}]KA » %2:customer[×] + %1:orders » %0:lineitem[#0{l_orderkey}]KA » %2:customer[×] + %2:customer » %0:lineitem[×] » %1:orders[#0{o_orderkey}]KA ArrangeBy keys=[[], [#0{l_orderkey}]] // { arity: 8 } ReadIndex on=lineitem fk_lineitem_orderkey=[*** full scan ***, delta join lookup] // { arity: 8 } ArrangeBy keys=[[#0{o_orderkey}]] // { arity: 4 } @@ -157,9 +157,9 @@ Explained Query: Project (#1{o_orderkey}) // { arity: 1 } Join on=(#0{l_extendedprice} = #2{o_totalprice} AND #1{o_orderkey} = #3{l_orderkey}) type=delta // { arity: 4 } implementation - %0:lineitem » %1:orders[#1]Keiif » %2[#0]K - %1:orders » %0:lineitem[#0]Kef » %2[#0]K - %2 » %1:orders[#0]KAeiif » %0:lineitem[#0]Kef + %0:lineitem » %1:orders[#1{o_totalprice}]Keiif » %2[#0]K + %1:orders » %0:lineitem[#0{l_extendedprice}]Kef » %2[#0]K + %2 » %1:orders[#0{o_orderkey}]KAeiif » %0:lineitem[#0{l_extendedprice}]Kef ArrangeBy keys=[[#0{l_extendedprice}]] // { arity: 1 } Project (#4{l_extendedprice}) // { arity: 1 } Filter (#6{l_commitdate} = 1997-01-25) // { arity: 8 } @@ -214,9 +214,9 @@ Explained Query: Project (#1{l_partkey}, #0{l_orderkey}, #1{l_partkey}) // { arity: 3 } Join on=(#2{l_extendedprice} = #4{o_totalprice} AND #3{l_commitdate} = #5{o_orderdate}) type=delta // { arity: 6 } implementation - %0:lineitem » %1:orders[#0, #1]KKef » %2:customer[×]e - %1:orders » %0:lineitem[#2, #3]KKf » %2:customer[×]e - %2:customer » %1:orders[×]ef » %0:lineitem[#2, #3]KKf + %0:lineitem » %1:orders[#0{o_totalprice}, #1{o_orderdate}]KKef » %2:customer[×]e + %1:orders » %0:lineitem[#2{l_extendedprice}, #3{l_commitdate}]KKf » %2:customer[×]e + %2:customer » %1:orders[×]ef » %0:lineitem[#2{l_extendedprice}, #3{l_commitdate}]KKf ArrangeBy keys=[[#2{l_extendedprice}, #3{l_commitdate}]] // { arity: 4 } Project (#0{l_orderkey}, #1{l_partkey}, #4{l_extendedprice}, #6{l_commitdate}) // { arity: 4 } Filter (#4{l_extendedprice} = (#4{l_extendedprice} % 5)) // { arity: 8 } @@ -256,9 +256,9 @@ Explained Query: Project (#0{l_orderkey}..=#9{o_custkey}, #4{l_extendedprice}, #5{l_shipdate}, #12{c_custkey}..=#14{c_acctbal}) // { arity: 15 } Join on=(#4{l_extendedprice} = #10{o_totalprice} AND #5{l_shipdate} = #11{o_orderdate}) type=delta // { arity: 15 } implementation - %0:lineitem » %1:orders[#2, #3]KKe » %2:customer[×]e - %1:orders » %0:lineitem[#4, #5]KKf » %2:customer[×]e - %2:customer » %1:orders[×]e » %0:lineitem[#4, #5]KKf + %0:lineitem » %1:orders[#2{o_totalprice}, #3{o_orderdate}]KKe » %2:customer[×]e + %1:orders » %0:lineitem[#4{l_extendedprice}, #5{l_shipdate}]KKf » %2:customer[×]e + %2:customer » %1:orders[×]e » %0:lineitem[#4{l_extendedprice}, #5{l_shipdate}]KKf ArrangeBy keys=[[#4{l_extendedprice}, #5{l_shipdate}]] // { arity: 8 } Filter (date_to_timestamp(#7{l_receiptdate}) = (#5{l_shipdate} + 6 days)) // { arity: 8 } ReadIndex on=lineitem pk_lineitem_orderkey_linenumber=[*** full scan ***] // { arity: 8 } diff --git a/test/sqllogictest/transform/join_index.slt b/test/sqllogictest/transform/join_index.slt index ffb328ef588ff..60b89ef3e34c8 100644 --- a/test/sqllogictest/transform/join_index.slt +++ b/test/sqllogictest/transform/join_index.slt @@ -69,7 +69,7 @@ EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) Explained Query: Join on=(#0{a} = abs(#2{a})) type=differential // { arity: 4 } implementation - %0:foo[#0]Kef » %1:bar[abs(#0)]Kef + %0:foo[#0{a}]Kef » %1:bar[abs(#0{a})]Kef ArrangeBy keys=[[#0{a}]] // { arity: 2 } Filter (1 = (#0{a} % 2)) // { arity: 2 } ReadStorage materialize.public.foo // { arity: 2 } @@ -155,9 +155,9 @@ Explained Query: Project (#0{a}, #5{b}) // { arity: 2 } Join on=(#0{a} = #2{a} AND #3{b} = #4{a}) type=delta // { arity: 6 } implementation - %0:foo » %1:bar[#0]KA » %2:baz[#0]UK - %1:bar » %2:baz[#0]UK » %0:foo[#0]KA - %2:baz » %1:bar[#1]K » %0:foo[#0]KA + %0:foo » %1:bar[#0{a}]KA » %2:baz[#0{a}]UK + %1:bar » %2:baz[#0{a}]UK » %0:foo[#0{a}]KA + %2:baz » %1:bar[#1{b}]K » %0:foo[#0{a}]KA ArrangeBy keys=[[#0{a}]] // { arity: 2 } ReadIndex on=foo foo_idx=[delta join 1st input (full scan)] // { arity: 2 } ArrangeBy keys=[[#0{a}], [#1{b}]] // { arity: 2 } @@ -209,9 +209,9 @@ Explained Query: Project (#0{a}, #5{b}) // { arity: 2 } Join on=(#0{a} = #2{a} AND #3{b} = #4{a}) type=delta // { arity: 6 } implementation - %0:foo » %1:bar[#0]KA » %2:baz[#0]KA - %1:bar » %0:foo[#0]KA » %2:baz[#0]KA - %2:baz » %1:bar[#1]K » %0:foo[#0]KA + %0:foo » %1:bar[#0{a}]KA » %2:baz[#0{a}]KA + %1:bar » %0:foo[#0{a}]KA » %2:baz[#0{a}]KA + %2:baz » %1:bar[#1{b}]K » %0:foo[#0{a}]KA ArrangeBy keys=[[#0{a}]] // { arity: 2 } ReadIndex on=foo foo_idx=[delta join 1st input (full scan)] // { arity: 2 } ArrangeBy keys=[[#0{a}], [#1{b}]] // { arity: 2 } @@ -257,7 +257,7 @@ Explained Query: Filter (#2{a}) IS NOT NULL // { arity: 4 } Join on=(-(#2{a}) = case when (#0{a} = 0) then null else #0{a} end) type=differential // { arity: 4 } implementation - %0:foo[case when (#0 = 0) then null else #0 end]KA » %1:bar[-(#0)]KA + %0:foo[case when (#0{a} = 0) then null else #0{a} end]KA » %1:bar[-(#0{a})]KA ArrangeBy keys=[[case when (#0{a} = 0) then null else #0{a} end]] // { arity: 2 } ReadIndex on=foo foo_idx2=[differential join] // { arity: 2 } ArrangeBy keys=[[-(#0{a})]] // { arity: 2 } @@ -302,9 +302,9 @@ Explained Query: Filter (#4{a}) IS NOT NULL // { arity: 6 } Join on=(#0{a} = #2{a} AND #4{a} = (#0{a} + 4)) type=delta // { arity: 6 } implementation - %0:bar » %1:foo[#0]KA » %2:baz[#0]KA - %1:foo » %0:bar[#0]K » %2:baz[#0]KA - %2:baz » %0:bar[(#0 + 4)]KA » %1:foo[#0]KA + %0:bar » %1:foo[#0{a}]KA » %2:baz[#0{a}]KA + %1:foo » %0:bar[#0{a}]K » %2:baz[#0{a}]KA + %2:baz » %0:bar[(#0{a} + 4)]KA » %1:foo[#0{a}]KA ArrangeBy keys=[[#0{a}], [(#0{a} + 4)]] // { arity: 2 } Filter (#0{a}) IS NOT NULL // { arity: 2 } ReadIndex on=bar bar_idx2=[*** full scan ***] // { arity: 2 } @@ -416,9 +416,9 @@ Explained Query: Project (#1{b}, #3{b}, #5{b}) // { arity: 3 } Join on=(#0{a} = #2{a} AND #4{a} = (#0{a} + 4)) type=delta // { arity: 6 } implementation - %0:foo » %1:bar[#0]K » %2:baz[#0]K - %1:bar » %0:foo[#0]KA » %2:baz[#0]K - %2:baz » %0:foo[(#0 + 4)]K » %1:bar[#0]K + %0:foo » %1:bar[#0{a}]K » %2:baz[#0{a}]K + %1:bar » %0:foo[#0{a}]KA » %2:baz[#0{a}]K + %2:baz » %0:foo[(#0{a} + 4)]K » %1:bar[#0{a}]K ArrangeBy keys=[[#0{a}], [(#0{a} + 4)]] // { arity: 2 } Filter (#0{a}) IS NOT NULL // { arity: 2 } ReadIndex on=foo foo_idx=[*** full scan ***] // { arity: 2 } @@ -632,17 +632,17 @@ Explained Query: Filter (#109{x}) IS NULL AND like["a%"](#125{s}) AND (#137{x} = 71) AND (#95{x} <= 8) AND (#81{x} > 5) AND (#95{x} >= 3) AND NOT(like["b%"](#69{s})) AND (#39{x} != #40{y}) AND (#53{x} != #54{y}) // { arity: 154 } Join on=(#0{a} = #15{b} = #30{c} = #45{d} = #60{e} = #75{f} = #90{g} = #105{h} = #120{i} = #135{j} = #150{k}) type=delta // { arity: 154 } implementation - %0:big » %9:big[#9]KAef » %8:big[#8]KAlf » %7:big[#7]KAnf » %6:big[#6]KAiif » %5:big[#5]KAif » %2:big[#2]KAf » %3:big[#3]KAf » %4:big[#4]KAf » %1:big[#1]KA » %10:big[#10]KA - %1:big » %9:big[#9]KAef » %8:big[#8]KAlf » %7:big[#7]KAnf » %6:big[#6]KAiif » %5:big[#5]KAif » %2:big[#2]KAf » %3:big[#3]KAf » %4:big[#4]KAf » %0:big[#0]KA » %10:big[#10]KA - %2:big » %9:big[#9]KAef » %8:big[#8]KAlf » %7:big[#7]KAnf » %6:big[#6]KAiif » %5:big[#5]KAif » %3:big[#3]KAf » %4:big[#4]KAf » %0:big[#0]KA » %1:big[#1]KA » %10:big[#10]KA - %3:big » %9:big[#9]KAef » %8:big[#8]KAlf » %7:big[#7]KAnf » %6:big[#6]KAiif » %5:big[#5]KAif » %2:big[#2]KAf » %4:big[#4]KAf » %0:big[#0]KA » %1:big[#1]KA » %10:big[#10]KA - %4:big » %9:big[#9]KAef » %8:big[#8]KAlf » %7:big[#7]KAnf » %6:big[#6]KAiif » %5:big[#5]KAif » %2:big[#2]KAf » %3:big[#3]KAf » %0:big[#0]KA » %1:big[#1]KA » %10:big[#10]KA - %5:big » %9:big[#9]KAef » %8:big[#8]KAlf » %7:big[#7]KAnf » %6:big[#6]KAiif » %2:big[#2]KAf » %3:big[#3]KAf » %4:big[#4]KAf » %0:big[#0]KA » %1:big[#1]KA » %10:big[#10]KA - %6:big » %9:big[#9]KAef » %8:big[#8]KAlf » %7:big[#7]KAnf » %5:big[#5]KAif » %2:big[#2]KAf » %3:big[#3]KAf » %4:big[#4]KAf » %0:big[#0]KA » %1:big[#1]KA » %10:big[#10]KA - %7:big » %9:big[#9]KAef » %8:big[#8]KAlf » %6:big[#6]KAiif » %5:big[#5]KAif » %2:big[#2]KAf » %3:big[#3]KAf » %4:big[#4]KAf » %0:big[#0]KA » %1:big[#1]KA » %10:big[#10]KA - %8:big » %9:big[#9]KAef » %7:big[#7]KAnf » %6:big[#6]KAiif » %5:big[#5]KAif » %2:big[#2]KAf » %3:big[#3]KAf » %4:big[#4]KAf » %0:big[#0]KA » %1:big[#1]KA » %10:big[#10]KA - %9:big » %8:big[#8]KAlf » %7:big[#7]KAnf » %6:big[#6]KAiif » %5:big[#5]KAif » %2:big[#2]KAf » %3:big[#3]KAf » %4:big[#4]KAf » %0:big[#0]KA » %1:big[#1]KA » %10:big[#10]KA - %10:big » %9:big[#9]KAef » %8:big[#8]KAlf » %7:big[#7]KAnf » %6:big[#6]KAiif » %5:big[#5]KAif » %2:big[#2]KAf » %3:big[#3]KAf » %4:big[#4]KAf » %0:big[#0]KA » %1:big[#1]KA + %0:big » %9:big[#9{j}]KAef » %8:big[#8{i}]KAlf » %7:big[#7{h}]KAnf » %6:big[#6{g}]KAiif » %5:big[#5{f}]KAif » %2:big[#2{c}]KAf » %3:big[#3{d}]KAf » %4:big[#4{e}]KAf » %1:big[#1{b}]KA » %10:big[#10{k}]KA + %1:big » %9:big[#9{j}]KAef » %8:big[#8{i}]KAlf » %7:big[#7{h}]KAnf » %6:big[#6{g}]KAiif » %5:big[#5{f}]KAif » %2:big[#2{c}]KAf » %3:big[#3{d}]KAf » %4:big[#4{e}]KAf » %0:big[#0{a}]KA » %10:big[#10{k}]KA + %2:big » %9:big[#9{j}]KAef » %8:big[#8{i}]KAlf » %7:big[#7{h}]KAnf » %6:big[#6{g}]KAiif » %5:big[#5{f}]KAif » %3:big[#3{d}]KAf » %4:big[#4{e}]KAf » %0:big[#0{a}]KA » %1:big[#1{b}]KA » %10:big[#10{k}]KA + %3:big » %9:big[#9{j}]KAef » %8:big[#8{i}]KAlf » %7:big[#7{h}]KAnf » %6:big[#6{g}]KAiif » %5:big[#5{f}]KAif » %2:big[#2{c}]KAf » %4:big[#4{e}]KAf » %0:big[#0{a}]KA » %1:big[#1{b}]KA » %10:big[#10{k}]KA + %4:big » %9:big[#9{j}]KAef » %8:big[#8{i}]KAlf » %7:big[#7{h}]KAnf » %6:big[#6{g}]KAiif » %5:big[#5{f}]KAif » %2:big[#2{c}]KAf » %3:big[#3{d}]KAf » %0:big[#0{a}]KA » %1:big[#1{b}]KA » %10:big[#10{k}]KA + %5:big » %9:big[#9{j}]KAef » %8:big[#8{i}]KAlf » %7:big[#7{h}]KAnf » %6:big[#6{g}]KAiif » %2:big[#2{c}]KAf » %3:big[#3{d}]KAf » %4:big[#4{e}]KAf » %0:big[#0{a}]KA » %1:big[#1{b}]KA » %10:big[#10{k}]KA + %6:big » %9:big[#9{j}]KAef » %8:big[#8{i}]KAlf » %7:big[#7{h}]KAnf » %5:big[#5{f}]KAif » %2:big[#2{c}]KAf » %3:big[#3{d}]KAf » %4:big[#4{e}]KAf » %0:big[#0{a}]KA » %1:big[#1{b}]KA » %10:big[#10{k}]KA + %7:big » %9:big[#9{j}]KAef » %8:big[#8{i}]KAlf » %6:big[#6{g}]KAiif » %5:big[#5{f}]KAif » %2:big[#2{c}]KAf » %3:big[#3{d}]KAf » %4:big[#4{e}]KAf » %0:big[#0{a}]KA » %1:big[#1{b}]KA » %10:big[#10{k}]KA + %8:big » %9:big[#9{j}]KAef » %7:big[#7{h}]KAnf » %6:big[#6{g}]KAiif » %5:big[#5{f}]KAif » %2:big[#2{c}]KAf » %3:big[#3{d}]KAf » %4:big[#4{e}]KAf » %0:big[#0{a}]KA » %1:big[#1{b}]KA » %10:big[#10{k}]KA + %9:big » %8:big[#8{i}]KAlf » %7:big[#7{h}]KAnf » %6:big[#6{g}]KAiif » %5:big[#5{f}]KAif » %2:big[#2{c}]KAf » %3:big[#3{d}]KAf » %4:big[#4{e}]KAf » %0:big[#0{a}]KA » %1:big[#1{b}]KA » %10:big[#10{k}]KA + %10:big » %9:big[#9{j}]KAef » %8:big[#8{i}]KAlf » %7:big[#7{h}]KAnf » %6:big[#6{g}]KAiif » %5:big[#5{f}]KAif » %2:big[#2{c}]KAf » %3:big[#3{d}]KAf » %4:big[#4{e}]KAf » %0:big[#0{a}]KA » %1:big[#1{b}]KA ArrangeBy keys=[[#0{a}]] // { arity: 14 } ReadIndex on=big big_idx_a=[delta join 1st input (full scan)] // { arity: 14 } ArrangeBy keys=[[#1{b}]] // { arity: 14 } @@ -700,9 +700,9 @@ Explained Query: Filter like["a%"](#13{s}) // { arity: 43 } Join on=(#0{a} = #15{b} = #31{c}) type=delta // { arity: 43 } implementation - %0:big » %1:big[#1]KAe » %2:big[#2]KA - %1:big » %0:big[#0]KAlf » %2:big[#2]KA - %2:big » %1:big[#1]KAe » %0:big[#0]KAlf + %0:big » %1:big[#1{b}]KAe » %2:big[#2{c}]KA + %1:big » %0:big[#0{a}]KAlf » %2:big[#2{c}]KA + %2:big » %1:big[#1{b}]KAe » %0:big[#0{a}]KAlf ArrangeBy keys=[[#0{a}]] // { arity: 14 } ReadIndex on=big big_idx_a=[delta join 1st input (full scan)] // { arity: 14 } ArrangeBy keys=[[#1{b}]] // { arity: 15 } diff --git a/test/sqllogictest/transform/literal_constraints.slt b/test/sqllogictest/transform/literal_constraints.slt index 0a06ff6d3bebb..272a586ece707 100644 --- a/test/sqllogictest/transform/literal_constraints.slt +++ b/test/sqllogictest/transform/literal_constraints.slt @@ -171,12 +171,12 @@ Explained Query: linear_stage[0] closure project=() - lookup={ relation=0, key=[#0, #1] } + lookup={ relation=0, key=[#0{a}, #1{b}] } stream={ key=[#0, #1], thinning=() } source={ relation=1, key=[#0, #1] } Get::PassArrangements materialize.public.t1 raw=false - arrangements[0]={ key=[#0, #1], permutation=id, thinning=() } + arrangements[0]={ key=[#0{a}, #1{b}], permutation=id, thinning=() } types=[integer?, text?] ArrangeBy raw=true @@ -766,9 +766,9 @@ Explained Query: Filter (#0{a}) IS NOT NULL // { arity: 9 } Join on=(#0{a} = #3{a} = #6{a}) type=delta // { arity: 9 } implementation - %0:t1 » %1:l0[#0]KA » %2:l0[#0]KA - %1:l0 » %0:t1[#0]KAe » %2:l0[#0]KA - %2:l0 » %0:t1[#0]KAe » %1:l0[#0]KA + %0:t1 » %1:l0[#0{a}]KA » %2:l0[#0{a}]KA + %1:l0 » %0:t1[#0{a}]KAe » %2:l0[#0{a}]KA + %2:l0 » %0:t1[#0{a}]KAe » %1:l0[#0{a}]KA ArrangeBy keys=[[#0{a}]] // { arity: 3 } ReadIndex on=materialize.public.t1 idx_t1_b=[lookup values=[("l2"); ("l3")]] // { arity: 3 } Get l0 // { arity: 3 } @@ -805,7 +805,7 @@ Explained Query: Filter (#0{a}) IS NOT NULL // { arity: 6 } Join on=(#0{a} = #3{a}) type=differential // { arity: 6 } implementation - %0:t1[#0]KAe » %1:t2[#0]KAe + %0:t1[#0{a}]KAe » %1:t2[#0{a}]KAe ArrangeBy keys=[[#0{a}]] // { arity: 3 } ReadIndex on=materialize.public.t1 idx_t1_b=[lookup value=("l2")] // { arity: 3 } ArrangeBy keys=[[#0{a}]] // { arity: 3 } @@ -1332,7 +1332,7 @@ Explained Query: Union ReadIndex on=t5 idx_t5_f1=[*** full scan ***] Project (#2) - Map ((#0{f1} + #1)) + Map ((#0{f1} + #1{f1})) CrossJoin type=differential ArrangeBy keys=[[]] Project (#0{f1}) diff --git a/test/sqllogictest/transform/literal_lifting.slt b/test/sqllogictest/transform/literal_lifting.slt index cc8ebc2336540..f214e9bafdaa9 100644 --- a/test/sqllogictest/transform/literal_lifting.slt +++ b/test/sqllogictest/transform/literal_lifting.slt @@ -804,7 +804,7 @@ Explained Query: Project (#0{a}) // { arity: 1 } Join on=(#0{a} = #1) type=differential // { arity: 2 } implementation - %0:t_pk[#0]UKiif » %1[#0]UKiif + %0:t_pk[#0{a}]UKiif » %1[#0]UKiif ArrangeBy keys=[[#0{a}]] // { arity: 1 } Project (#0{a}) // { arity: 1 } Filter (#0{a} <= 195) AND (#0{a} >= 38) // { arity: 2 } @@ -847,7 +847,7 @@ Explained Query: Project (#0{a}) // { arity: 1 } Join on=(#0{a} = #1) type=differential // { arity: 2 } implementation - %1[#0]UK » %0:t[#0]Kiif + %1[#0]UK » %0:t[#0{a}]Kiif ArrangeBy keys=[[#0{a}]] // { arity: 1 } Project (#0{a}) // { arity: 1 } Filter (#0{a} <= 195) AND (#0{a} >= 38) // { arity: 2 } diff --git a/test/sqllogictest/transform/monotonic.slt b/test/sqllogictest/transform/monotonic.slt index bc53b3f119e52..f1eedd585d5e7 100644 --- a/test/sqllogictest/transform/monotonic.slt +++ b/test/sqllogictest/transform/monotonic.slt @@ -96,9 +96,9 @@ Explained Query: With Mutually Recursive cte l0 = Union - Distinct project=[#0, (#0 - 1)] monotonic + Distinct project=[#0, (#0{y} - 1)] monotonic Project (#1) - Filter (#0 < 1) + Filter (#0{x} < 1) Get l1 Constant - (1, 2) @@ -106,16 +106,16 @@ Explained Query: - (5, 6) cte l1 = Union - Distinct project=[#0, (#0 + 1)] monotonic + Distinct project=[#0, (#0{x} + 1)] monotonic Project (#0) - Filter (#0 >= 1) + Filter (#0{x} >= 1) Get l0 Constant - (1, 2) - (3, 4) - (5, 6) Return - Reduce group_by=[#0] aggregates=[max(#1)] monotonic + Reduce group_by=[#0] aggregates=[max(#1{y})] monotonic Distinct project=[#0, #1] monotonic Union Get l0 @@ -149,9 +149,9 @@ Explained Query: With Mutually Recursive cte l0 = Union - Distinct project=[#0, (#0 - 1)] + Distinct project=[#0, (#0{y} - 1)] Project (#1) - Filter (#0 < 1) + Filter (#0{x} < 1) Get l1 Constant - (1, 2) @@ -160,16 +160,16 @@ Explained Query: cte l1 = TopK limit=2 Union - Distinct project=[#0, (#0 + 1)] + Distinct project=[#0, (#0{x} + 1)] Project (#0) - Filter (#0 >= 1) + Filter (#0{x} >= 1) Get l0 Constant - (1, 2) - (3, 4) - (5, 6) Return - Reduce group_by=[#0] aggregates=[max(#1)] + Reduce group_by=[#0] aggregates=[max(#1{y})] Distinct project=[#0, #1] Union Get l0 diff --git a/test/sqllogictest/transform/normalize_lets.slt b/test/sqllogictest/transform/normalize_lets.slt index ea35552cad484..4bb9d21b8bc0e 100644 --- a/test/sqllogictest/transform/normalize_lets.slt +++ b/test/sqllogictest/transform/normalize_lets.slt @@ -104,16 +104,16 @@ Explained Query: cte l0 = Reduce group_by=[#0] Union - Filter (#0 < 27) + Filter (#0{f0} < 27) ReadStorage materialize.public.t1 Project (#1) - Map ((#0 + 1)) + Map ((#0{i} + 1)) Get l0 Return Get l0 Source materialize.public.t1 - filter=((#0 < 27)) + filter=((#0{f0} < 27)) Target cluster: quickstart @@ -203,11 +203,11 @@ Explained Query: Project (#1{dst}, #1{dst}) ReadStorage materialize.public.edges Project (#1{dst}, #3) - Join on=(#0{src} = #2) type=differential + Join on=(#0{src} = #2{node}) type=differential ArrangeBy keys=[[#0{src}]] Filter (#0{src}) IS NOT NULL ReadStorage materialize.public.edges - ArrangeBy keys=[[#0]] + ArrangeBy keys=[[#0{node}]] Filter (#0{dst}) IS NOT NULL Get l0 Return @@ -218,12 +218,12 @@ Explained Query: Map (0) Get l0 Project (#1{dst}, #3, #5) - Map ((#4 + 1)) - Join on=(#0{src} = #2) type=differential + Map ((#4{round} + 1)) + Join on=(#0{src} = #2{node}) type=differential ArrangeBy keys=[[#0{src}]] Filter (#0{src}) IS NOT NULL ReadStorage materialize.public.edges - ArrangeBy keys=[[#0]] + ArrangeBy keys=[[#0{node}]] Filter (#0{dst}) IS NOT NULL Get l1 Return @@ -255,7 +255,7 @@ Explained Query: Distinct project=[#0] monotonic Union Project (#1) - Map ((#0 + 1)) + Map ((#0{i} + 1)) Get l0 Constant - (1) @@ -282,7 +282,7 @@ Explained Query: Distinct project=[#0] monotonic Union Project (#1) - Map ((#0 + 1)) + Map ((#0{i} + 1)) Get l0 Constant - (1) @@ -309,7 +309,7 @@ Explained Query: Distinct project=[#0] monotonic Union Project (#1) - Map ((#0 + 1)) + Map ((#0{i} + 1)) Get l0 Constant - (1) @@ -448,11 +448,11 @@ Explained Query: Project (#1{dst}, #1{dst}) ReadStorage materialize.public.edges Project (#1{dst}, #3) - Join on=(#0{src} = #2) type=differential + Join on=(#0{src} = #2{node}) type=differential ArrangeBy keys=[[#0{src}]] Filter (#0{src}) IS NOT NULL ReadStorage materialize.public.edges - ArrangeBy keys=[[#0]] + ArrangeBy keys=[[#0{node}]] Filter (#0{dst}) IS NOT NULL Get l0 Return @@ -463,12 +463,12 @@ Explained Query: Map (0) Get l0 Project (#1{dst}, #3, #5) - Map ((#4 + 1)) - Join on=(#0{src} = #2) type=differential + Map ((#4{round} + 1)) + Join on=(#0{src} = #2{node}) type=differential ArrangeBy keys=[[#0{src}]] Filter (#0{src}) IS NOT NULL ReadStorage materialize.public.edges - ArrangeBy keys=[[#0]] + ArrangeBy keys=[[#0{node}]] Filter (#0{dst}) IS NOT NULL Get l1 Return @@ -575,7 +575,7 @@ Explained Query: cte l0 = Get::PassArrangements materialize.public.potato raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[text?, text?] Return With Mutually Recursive @@ -590,12 +590,12 @@ Explained Query: Union Join::Linear linear_stage[0] - lookup={ relation=0, key=[#0] } + lookup={ relation=0, key=[#0{a}] } stream={ key=[#0], thinning=() } source={ relation=1, key=[#0] } Get::PassArrangements l0 raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[text?, text?] ArrangeBy raw=true @@ -605,20 +605,20 @@ Explained Query: - ("russet") Join::Linear linear_stage[0] - lookup={ relation=1, key=[#0] } - stream={ key=[#0], thinning=(#1) } - source={ relation=0, key=[#0] } + lookup={ relation=1, key=[#0{b}] } + stream={ key=[#0{a}], thinning=(#1) } + source={ relation=0, key=[#0{a}] } Get::PassArrangements l0 raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) } types=[text?, text?] ArrangeBy raw=true - arrangements[0]={ key=[#0], permutation=id, thinning=() } + arrangements[0]={ key=[#0{b}], permutation=id, thinning=() } types=[text] Get::Collection l1 project=(#1) - filter=((#1) IS NOT NULL) + filter=((#1{b}) IS NOT NULL) raw=true Return Get::PassArrangements l1 diff --git a/test/sqllogictest/transform/predicate_pushdown.slt b/test/sqllogictest/transform/predicate_pushdown.slt index ddf8a0eabb234..aed48809c2891 100644 --- a/test/sqllogictest/transform/predicate_pushdown.slt +++ b/test/sqllogictest/transform/predicate_pushdown.slt @@ -114,7 +114,7 @@ query T multiline EXPLAIN DECORRELATED PLAN WITH(arity) FOR SELECT a FROM (SELECT DISTINCT a FROM x UNION ALL SELECT a FROM y) WHERE a = 3 ---- -Filter (#0 = 3) // { arity: 1 } +Filter (#0{a} = 3) // { arity: 1 } Union // { arity: 1 } Distinct project=[#0] // { arity: 1 } Project (#0) // { arity: 1 } @@ -169,7 +169,7 @@ Explained Query: Project (#0{f1}, #1{f2}, #0{f1}, #1{f2}) // { arity: 4 } Join on=(#0{f1} = #2{f1} AND #1{f2} = #3{f2}) type=differential // { arity: 4 } implementation - %0:t1[#0, #1]KK » %1:t2[#0, #1]KK + %0:t1[#0{f1}, #1{f2}]KK » %1:t2[#0{f1}, #1{f2}]KK ArrangeBy keys=[[#0{f1}, #1{f2}]] // { arity: 2 } Filter (#0{f1}) IS NOT NULL AND (#1{f2}) IS NOT NULL // { arity: 2 } ReadStorage materialize.public.t1 // { arity: 2 } @@ -194,7 +194,7 @@ select * from t1, t2 where t1.f1 = t2.f1 + 1 or (t1.f1 is null and t2.f1 is null Explained Query: Join on=(#0{f1} = (#2{f1} + 1)) type=differential // { arity: 4 } implementation - %0:t1[#0]K » %1:t2[(#0 + 1)]K + %0:t1[#0{f1}]K » %1:t2[(#0{f1} + 1)]K ArrangeBy keys=[[#0{f1}]] // { arity: 2 } ReadStorage materialize.public.t1 // { arity: 2 } ArrangeBy keys=[[(#0{f1} + 1)]] // { arity: 2 } @@ -214,7 +214,7 @@ select * from t1, t2 where t1.f1 = t2.f1 + 1 or (t1.f1 is null and (t2.f1 + 1) i Explained Query: Join on=(#0{f1} = (#2{f1} + 1)) type=differential // { arity: 4 } implementation - %0:t1[#0]K » %1:t2[(#0 + 1)]K + %0:t1[#0{f1}]K » %1:t2[(#0{f1} + 1)]K ArrangeBy keys=[[#0{f1}]] // { arity: 2 } ReadStorage materialize.public.t1 // { arity: 2 } ArrangeBy keys=[[(#0{f1} + 1)]] // { arity: 2 } @@ -234,7 +234,7 @@ select * from t1, t2 where t2.f1 = t1.f1 + 1 or (t1.f1 is null and (t2.f1 + 1) i Explained Query: Join on=(#2{f1} = (#0{f1} + 1)) type=differential // { arity: 4 } implementation - %0:t1[(#0 + 1)]K » %1:t2[#0]K + %0:t1[(#0{f1} + 1)]K » %1:t2[#0{f1}]K ArrangeBy keys=[[(#0{f1} + 1)]] // { arity: 2 } ReadStorage materialize.public.t1 // { arity: 2 } ArrangeBy keys=[[#0{f1}]] // { arity: 2 } @@ -254,7 +254,7 @@ select * from t1, t2 where t2.f1 = t1.f1 + 1 or (t1.f1 is null and ((t2.f1 + 1) Explained Query: Join on=(#2{f1} = (#0{f1} + 1)) type=differential // { arity: 4 } implementation - %0:t1[(#0 + 1)]K » %1:t2[#0]K + %0:t1[(#0{f1} + 1)]K » %1:t2[#0{f1}]K ArrangeBy keys=[[(#0{f1} + 1)]] // { arity: 2 } ReadStorage materialize.public.t1 // { arity: 2 } ArrangeBy keys=[[#0{f1}]] // { arity: 2 } @@ -278,7 +278,7 @@ Explained Query: Filter (((#1{f2} = 3) AND (#3{f2} = 4)) OR ((#1{f2} = 5) AND (#3{f2} = 6))) // { arity: 4 } Join on=(#0{f1} = #2{f1}) type=differential // { arity: 4 } implementation - %0:t1[#0]Kef » %1:t2[#0]Kef + %0:t1[#0{f1}]Kef » %1:t2[#0{f1}]Kef ArrangeBy keys=[[#0{f1}]] // { arity: 2 } Filter (#0{f1}) IS NOT NULL AND ((#1{f2} = 3) OR (#1{f2} = 5)) // { arity: 2 } ReadStorage materialize.public.t1 // { arity: 2 } @@ -304,7 +304,7 @@ Explained Query: Filter ((#1{f2} = 5) OR ((#1{f2} = 3) AND (#3{f2} = 4))) // { arity: 4 } Join on=(#0{f1} = #2{f1}) type=differential // { arity: 4 } implementation - %0:t1[#0]Kef » %1:t2[#0]Kef + %0:t1[#0{f1}]Kef » %1:t2[#0{f1}]Kef ArrangeBy keys=[[#0{f1}]] // { arity: 2 } Filter (#0{f1}) IS NOT NULL AND ((#1{f2} = 3) OR (#1{f2} = 5)) // { arity: 2 } ReadStorage materialize.public.t1 // { arity: 2 } @@ -365,18 +365,18 @@ Explained Query: project=(#0, #1, #0, #2) linear_stage[0] closure - filter=((#0) IS NOT NULL AND (#3 OR #4) AND (#5 OR #6) AND ((#3 AND #5) OR (#4 AND #6))) - map=((#1 = 3), (#1 = 5), (#2 = 4), (#2 = 6)) - lookup={ relation=1, key=[#0] } - stream={ key=[#0], thinning=(#1) } - source={ relation=0, key=[#0] } + filter=((#0{f1}) IS NOT NULL AND (#3 OR #4) AND (#5 OR #6) AND ((#3 AND #5) OR (#4 AND #6))) + map=((#1{f2} = 3), (#1{f2} = 5), (#2{f2} = 4), (#2{f2} = 6)) + lookup={ relation=1, key=[#0{f1}] } + stream={ key=[#0{f1}], thinning=(#1) } + source={ relation=0, key=[#0{f1}] } Get::PassArrangements materialize.public.t1 raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{f1}], permutation=id, thinning=(#1) } types=[integer?, integer?] Get::PassArrangements materialize.public.t2 raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=(#1) } + arrangements[0]={ key=[#0{f1}], permutation=id, thinning=(#1) } types=[integer?, integer?] Used Indexes: @@ -425,10 +425,10 @@ WHERE ---- Explained Query: Project (#1{name}, #3{name}) // { arity: 2 } - Filter ((#4 = "materialized-view") OR ((#4 = "view") AND (#1{name} != "doesntmatter"))) // { arity: 5 } + Filter ((#4{type} = "materialized-view") OR ((#4{type} = "view") AND (#1{name} != "doesntmatter"))) // { arity: 5 } Join on=(#0{id} = #2{schema_id}) type=differential // { arity: 5 } implementation - %0:mz_schemas[#0]UK » %1[#0]Kef + %0:mz_schemas[#0{id}]UK » %1[#0{schema_id}]Kef ArrangeBy keys=[[#0{id}]] // { arity: 2 } Project (#0{id}, #3{name}) // { arity: 2 } ReadIndex on=mz_schemas mz_schemas_ind=[*** full scan ***] // { arity: 6 } @@ -465,16 +465,16 @@ Explained Query: Threshold Union Project (#0) - Filter (#0 = 5) + Filter (#0{a} = 5) ReadStorage materialize.public.x Negate - Filter (#0 = 5) + Filter (#0{a} = 5) ReadStorage materialize.public.y Source materialize.public.x - filter=((#0 = 5)) + filter=((#0{a} = 5)) Source materialize.public.y - filter=((#0 = 5)) + filter=((#0{a} = 5)) Target cluster: quickstart @@ -488,7 +488,7 @@ SELECT a FROM y as y, LATERAL(SELECT u FROM x WHERE y.a = x.a LIMIT 5) WHERE a I Explained Query: With cte l0 = - Filter ((#0 = 41) OR (#0 = 42)) + Filter ((#0{a} = 41) OR (#0{a} = 42)) ReadStorage materialize.public.y Return Project (#0) @@ -498,19 +498,19 @@ Explained Query: ArrangeBy keys=[[#0]] TopK group_by=[#0] limit=5 Project (#0) - Join on=(#0 = #1) type=differential - ArrangeBy keys=[[#0]] + Join on=(#0{a} = #1{a}) type=differential + ArrangeBy keys=[[#0{a}]] Distinct project=[#0] Get l0 - ArrangeBy keys=[[#0]] + ArrangeBy keys=[[#0{a}]] Project (#0) - Filter ((#0 = 41) OR (#0 = 42)) + Filter ((#0{a} = 41) OR (#0{a} = 42)) ReadStorage materialize.public.x Source materialize.public.x - filter=(((#0 = 41) OR (#0 = 42))) + filter=(((#0{a} = 41) OR (#0{a} = 42))) Source materialize.public.y - filter=(((#0 = 41) OR (#0 = 42))) + filter=(((#0{a} = 41) OR (#0{a} = 42))) Target cluster: quickstart @@ -903,7 +903,7 @@ Explained Query: Union Project (#0{n}) ReadStorage materialize.public.init - Filter (#0 < 3) + Filter (#0{n} < 3) Get l2 cte l1 = Project (#1) @@ -1056,8 +1056,8 @@ SELECT * FROM ( WHERE r1 * r1 * r1 * r1 * r1 * r1 * r1 * r1 * r1 * r1 * r1 * r1 * r1 > 5; ---- Explained Query: - Filter (((((((((((((#4 * #4) * #4) * #4) * #4) * #4) * #4) * #4) * #4) * #4) * #4) * #4) * #4) > 5) - Map ((#0{x} * #1{y}), (#2 + 1), ((((((((((((((((((((((((((#0{x} + #1{y}) + #2) + #3) + #3) + #3) + #3) + #3) + #3) + #3) + #3) + #3) + #3) + #3) + #3) + #3) + #3) + #3) + #3) + #3) + #3) + #3) + #3) + #3) + #3) + #3) + #3)) + Filter (((((((((((((#4{r1} * #4{r1}) * #4{r1}) * #4{r1}) * #4{r1}) * #4{r1}) * #4{r1}) * #4{r1}) * #4{r1}) * #4{r1}) * #4{r1}) * #4{r1}) * #4{r1}) > 5) + Map ((#0{x} * #1{y}), (#2{?column?} + 1), ((((((((((((((((((((((((((#0{x} + #1{y}) + #2{z1}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2})) ReadStorage materialize.public.t Source materialize.public.t diff --git a/test/sqllogictest/transform/predicate_reduction.slt b/test/sqllogictest/transform/predicate_reduction.slt index 739463e74c392..969eac307d9ff 100644 --- a/test/sqllogictest/transform/predicate_reduction.slt +++ b/test/sqllogictest/transform/predicate_reduction.slt @@ -88,7 +88,7 @@ NULL query T multiline EXPLAIN DECORRELATED PLAN WITH(arity) FOR SELECT * FROM t1 WHERE (f1 is null)::int - 1 = 0 and ((f1 is null) or ((f1 is null)::int - 1 = 0)) ---- -Filter (((boolean_to_integer((#0) IS NULL) - 1) = 0) AND ((#0) IS NULL OR ((boolean_to_integer((#0) IS NULL) - 1) = 0))) // { arity: 2 } +Filter (((boolean_to_integer((#0{f1}) IS NULL) - 1) = 0) AND ((#0{f1}) IS NULL OR ((boolean_to_integer((#0{f1}) IS NULL) - 1) = 0))) // { arity: 2 } CrossJoin // { arity: 2 } Constant // { arity: 0 } - () diff --git a/test/sqllogictest/transform/reduce_elision.slt b/test/sqllogictest/transform/reduce_elision.slt index 0a750e1399ef7..8350e1dabd5bb 100644 --- a/test/sqllogictest/transform/reduce_elision.slt +++ b/test/sqllogictest/transform/reduce_elision.slt @@ -124,7 +124,7 @@ Explained Query: Project (#0{f0}..=#2{f0}, #1{f1}) // { arity: 4, keys: "()" } Join on=(#1{f1} = #3{f1}) type=differential // { arity: 4, keys: "()" } implementation - %1:y[#1]UK » %0:x[#1]K + %1:y[#1{f1}]UK » %0:x[#1{f1}]K ArrangeBy keys=[[#1{f1}]] // { arity: 2, keys: "()" } Filter (#1{f1}) IS NOT NULL // { arity: 2, keys: "()" } ReadStorage materialize.public.x // { arity: 2, keys: "()" } diff --git a/test/sqllogictest/transform/reduction_pushdown.slt b/test/sqllogictest/transform/reduction_pushdown.slt index e90b28f5cd46a..0c059f5c77da6 100644 --- a/test/sqllogictest/transform/reduction_pushdown.slt +++ b/test/sqllogictest/transform/reduction_pushdown.slt @@ -186,7 +186,7 @@ GROUP BY 1, 2, 3; Explained Query: With cte l0 = - Filter (#0{f2} = (#0{f2} + #1)) // { arity: 2 } + Filter (#0{f2} = (#0{f2} + #1{f2})) // { arity: 2 } TopK order_by=[#0{f2} asc nulls_last, #1 asc nulls_last] limit=1 offset=1 // { arity: 2 } Project (#1{f2}, #2) // { arity: 2 } Map ((#1{f2} + #0{f1})) // { arity: 3 } @@ -194,12 +194,12 @@ Explained Query: Return // { arity: 3 } Project (#0{f2}, #3, #2) // { arity: 3 } Map (null) // { arity: 4 } - Distinct project=[#0{f2}, (#0{f2} + #1), #1] // { arity: 3 } + Distinct project=[#0{f2}, (#0{f2} + #1{f2}), #1] // { arity: 3 } Union // { arity: 2 } Negate // { arity: 2 } CrossJoin type=differential // { arity: 2 } ArrangeBy keys=[[]] // { arity: 2 } - Filter (#1 != 4) // { arity: 2 } + Filter (#1{f2} != 4) // { arity: 2 } Get l0 // { arity: 2 } ArrangeBy keys=[[]] // { arity: 0 } Project () // { arity: 0 } diff --git a/test/sqllogictest/transform/relation_cse.slt b/test/sqllogictest/transform/relation_cse.slt index 56a6d49a877f3..b4ccda0987c3b 100644 --- a/test/sqllogictest/transform/relation_cse.slt +++ b/test/sqllogictest/transform/relation_cse.slt @@ -181,8 +181,8 @@ Explained Query: Join on=(#0{f1} = #2{f1} AND #1{f2} = #3{f1}) type=delta // { arity: 4 } implementation %0:t1 » %1:l0[#0]K » %2:l0[#0]K - %1:l0 » %0:t1[#0]KA » %2:l0[#0]K - %2:l0 » %0:t1[#1]K » %1:l0[#0]K + %1:l0 » %0:t1[#0{f1}]KA » %2:l0[#0]K + %2:l0 » %0:t1[#1{f2}]K » %1:l0[#0]K ArrangeBy keys=[[#0{f1}], [#1{f2}]] // { arity: 2 } Filter (#0{f1}) IS NOT NULL AND (#1{f2}) IS NOT NULL // { arity: 2 } ReadIndex on=t1 i1=[*** full scan ***] // { arity: 2 } @@ -219,8 +219,8 @@ Explained Query: Join on=(#0{f1} = #2{f1} AND #1{f2} = #3{f1}) type=delta // { arity: 4 } implementation %0:t1 » %1:l1[#0]K » %2:l1[#0]K - %1:l1 » %0:t1[#0]KA » %2:l1[#0]K - %2:l1 » %0:t1[#1]K » %1:l1[#0]K + %1:l1 » %0:t1[#0{f1}]KA » %2:l1[#0]K + %2:l1 » %0:t1[#1{f2}]K » %1:l1[#0]K ArrangeBy keys=[[#0{f1}], [#1{f2}]] // { arity: 2 } Filter (#0{f1}) IS NOT NULL AND (#1{f2}) IS NOT NULL // { arity: 2 } ReadIndex on=t1 i1=[*** full scan ***] // { arity: 2 } @@ -241,7 +241,7 @@ Explained Query: Project (#0{f1}, #1{f2}) // { arity: 2 } Join on=(#0{f1} = #2{f1}) type=differential // { arity: 3 } implementation - %0:t1[#0]KA » %1[#0]K + %0:t1[#0{f1}]KA » %1[#0]K ArrangeBy keys=[[#0{f1}]] // { arity: 2 } ReadIndex on=t1 i1=[differential join] // { arity: 2 } ArrangeBy keys=[[#0{f1}]] // { arity: 1 } @@ -709,7 +709,7 @@ Explained Query: Filter (#0{f1}) IS NOT NULL // { arity: 4 } Join on=(#0{f1} = #2{f1}) type=differential // { arity: 4 } implementation - %0:l0[#0]KA » %1:l0[#0]KA + %0:l0[#0{f1}]KA » %1:l0[#0{f1}]KA Get l0 // { arity: 2 } Get l0 // { arity: 2 } cte l2 = @@ -719,7 +719,7 @@ Explained Query: Project (#0{f1}, #1{f2}) // { arity: 2 } Join on=(#0{f1} = #2{f1}) type=differential // { arity: 3 } implementation - %1[#0]UKA » %0:l0[#0]KA + %1[#0]UKA » %0:l0[#0{f1}]KA Get l0 // { arity: 2 } ArrangeBy keys=[[#0{f1}]] // { arity: 1 } Distinct project=[#0{f1}] // { arity: 1 } @@ -971,7 +971,7 @@ Explained Query: Project (#0{f1}, #1{f2}) // { arity: 2 } Join on=(#0{f1} = #2{f1}) type=differential // { arity: 3 } implementation - %0:l0[#0]KA » %1[#0]K + %0:l0[#0{f1}]KA » %1[#0]K Get l0 // { arity: 2 } ArrangeBy keys=[[#0{f1}]] // { arity: 1 } Union // { arity: 1 } @@ -1643,11 +1643,11 @@ Explained Query: With Mutually Recursive cte l0 = ArrangeBy keys=[[#0]] // { arity: 2 } - Filter (#1 <= #0) // { arity: 2 } + Filter (#1{n} <= #0{bound}) // { arity: 2 } Get l1 // { arity: 2 } cte l1 = Union // { arity: 2 } - Distinct project=[#0, (#1 + #2)] monotonic // { arity: 2 } + Distinct project=[#0, (#1{n} + #2{n})] monotonic // { arity: 2 } Project (#0, #1, #3) // { arity: 3 } Join on=(#0 = #2) type=differential // { arity: 4 } implementation diff --git a/test/sqllogictest/transform/relax_must_consolidate.slt b/test/sqllogictest/transform/relax_must_consolidate.slt index 72352666a9543..15492dabe65dd 100644 --- a/test/sqllogictest/transform/relax_must_consolidate.slt +++ b/test/sqllogictest/transform/relax_must_consolidate.slt @@ -137,7 +137,7 @@ Explained Query: - () Source materialize.public.t - filter=((1 = (#0 % 2))) + filter=((1 = (#0{a} % 2))) Target cluster: quickstart @@ -174,7 +174,7 @@ Explained Query: project=(#1, #0) key_plan project=() - FlatMap generate_series(1, #0, 1) + FlatMap generate_series(1, #0{a}, 1) mfp_after project=(#1, #2) Get::PassArrangements materialize.public.t @@ -279,7 +279,7 @@ Explained Query: Source materialize.public.t project=(#0..=#2) - map=((#0 % 2)) + map=((#0{a} % 2)) Target cluster: quickstart @@ -364,7 +364,7 @@ Explained Query: Source materialize.public.t project=(#0..=#2) - map=((#0 % 2)) + map=((#0{a} % 2)) Target cluster: quickstart @@ -413,7 +413,7 @@ Explained Query: cte l0 = Get::PassArrangements materialize.public.t raw=false - arrangements[0]={ key=[#1], permutation={#0: #1, #1: #0}, thinning=(#0) } + arrangements[0]={ key=[#1{b}], permutation={#0: #1, #1: #0}, thinning=(#0) } types=[integer?, integer?] cte l1 = Reduce::Hierarchical @@ -428,17 +428,17 @@ Explained Query: linear_stage[0] closure project=(#0) - filter=((#0) IS NOT NULL AND (#1 = 5) AND (1 = (#1 % 2)) AND (#2 = 5)) - lookup={ relation=1, key=[#1] } - stream={ key=[#1], thinning=(#0) } - source={ relation=0, key=[#1] } + filter=((#0{b}) IS NOT NULL AND (#1{a} = 5) AND (1 = (#1{a} % 2)) AND (#2{a} = 5)) + lookup={ relation=1, key=[#1{b}] } + stream={ key=[#1{b}], thinning=(#0) } + source={ relation=0, key=[#1{b}] } Get::PassArrangements l0 raw=false - arrangements[0]={ key=[#1], permutation={#0: #1, #1: #0}, thinning=(#0) } + arrangements[0]={ key=[#1{b}], permutation={#0: #1, #1: #0}, thinning=(#0) } types=[integer?, integer?] Get::PassArrangements l0 raw=false - arrangements[0]={ key=[#1], permutation={#0: #1, #1: #0}, thinning=(#0) } + arrangements[0]={ key=[#1{b}], permutation={#0: #1, #1: #0}, thinning=(#0) } types=[integer?, integer?] Return Union @@ -526,20 +526,20 @@ Explained Query: project=() Join::Linear linear_stage[0] - lookup={ relation=1, key=[#0] } - stream={ key=[#0], thinning=() } - source={ relation=0, key=[#0] } + lookup={ relation=1, key=[#0{b}] } + stream={ key=[#0{b}], thinning=() } + source={ relation=0, key=[#0{b}] } ArrangeBy raw=true - arrangements[0]={ key=[#0], permutation=id, thinning=() } + arrangements[0]={ key=[#0{b}], permutation=id, thinning=() } types=[integer] Get::Collection materialize.public.t project=(#1) - filter=((1 = (#0 % 2))) + filter=((1 = (#0{a} % 2))) raw=true ArrangeBy raw=true - arrangements[0]={ key=[#0], permutation=id, thinning=() } + arrangements[0]={ key=[#0{b}], permutation=id, thinning=() } types=[integer] Get::Collection materialize.public.t project=(#1) @@ -566,7 +566,7 @@ Explained Query: - () Source materialize.public.t - filter=((#0 = 5) AND (#1) IS NOT NULL) + filter=((#0{a} = 5) AND (#1{b}) IS NOT NULL) Target cluster: quickstart @@ -605,7 +605,7 @@ Explained Query: project=() input_key=#0 Reduce::Accumulable - simple_aggrs[0]=(0, 0, sum(#0)) + simple_aggrs[0]=(0, 0, sum(#0{a})) val_plan project=(#0) key_plan @@ -769,7 +769,7 @@ Explained Query: key_plan project=(#1, #0) mfp_after - filter=((2 = (#2 + 1))) + filter=((2 = (#2{c} + 1))) Get::Collection materialize.public.t raw=true cte l1 = @@ -781,19 +781,19 @@ Explained Query: project=(#1, #0) key_plan project=() - FlatMap generate_series(1, #1, 1) + FlatMap generate_series(1, #1{a}, 1) mfp_after project=(#0, #2) Union Get::Arrangement l0 project=(#0, #1) - filter=((1 = (#1 % 2))) + filter=((1 = (#1{a} % 2))) key=#0, #1 raw=false arrangements[0]={ key=[#0, #1], permutation=id, thinning=(#2) } Get::Arrangement l0 project=(#0, #1) - filter=((1 = (#2 % 2))) + filter=((1 = (#2{c} % 2))) key=#0, #1 raw=false arrangements[0]={ key=[#0, #1], permutation=id, thinning=(#2) } @@ -1187,7 +1187,7 @@ Explained Query: - () TopK::Basic group_by=[#0] limit=1 Get::Collection l0 - filter=((#0 > 20000)) + filter=((#0{a} > 20000)) raw=true Return With diff --git a/test/sqllogictest/transform/scalar_cse.slt b/test/sqllogictest/transform/scalar_cse.slt index c8e7866af10d4..eee9e1b48aea3 100644 --- a/test/sqllogictest/transform/scalar_cse.slt +++ b/test/sqllogictest/transform/scalar_cse.slt @@ -109,7 +109,7 @@ FROM ---- Explained Query: Project (#3, #4) // { arity: 2 } - Map ((#1{b} / 2), case when (#2 = 0) then 0 else (1 / #2) end, case when (#2 != 0) then (1 / #2) else 0 end) // { arity: 5 } + Map ((#1{b} / 2), case when (#2{b} = 0) then 0 else (1 / #2) end, case when (#2{b} != 0) then (1 / #2) else 0 end) // { arity: 5 } ReadStorage materialize.public.x // { arity: 2 } Source materialize.public.x diff --git a/test/sqllogictest/transform/threshold_elision.slt b/test/sqllogictest/transform/threshold_elision.slt index 9e7a993e647d5..22b3f67cb28c3 100644 --- a/test/sqllogictest/transform/threshold_elision.slt +++ b/test/sqllogictest/transform/threshold_elision.slt @@ -322,7 +322,7 @@ Explained Query: Union // { non_negative: true } Get l0 // { non_negative: true } Negate // { non_negative: false } - Filter (#0 > 1940) // { non_negative: true } + Filter (#0{birth_year} > 1940) // { non_negative: true } Get l0 // { non_negative: true } Source materialize.public.people @@ -441,7 +441,7 @@ Explained Query: Filter (#0{id} > 1) // { non_negative: true } ReadStorage materialize.public.people // { non_negative: true } Project (#0, #2) // { non_negative: true } - Map ((#1 || "_iter")) // { non_negative: true } + Map ((#1{name} || "_iter")) // { non_negative: true } Get l0 // { non_negative: true } Return // { non_negative: true } Get l0 // { non_negative: true } @@ -482,11 +482,11 @@ Explained Query: Project (#0{id}, #4) // { non_negative: true } Map ((#1{name} || "_init")) // { non_negative: true } ReadStorage materialize.public.people // { non_negative: true } - Distinct project=[#0, (#1 || "_iter")] // { non_negative: true } + Distinct project=[#0, (#1{name} || "_iter")] // { non_negative: true } Get l1 // { non_negative: true } Negate // { non_negative: false } - Distinct project=[#0, (#1 || "_iter")] // { non_negative: true } - Filter (#0 > 1) // { non_negative: true } + Distinct project=[#0, (#1{name} || "_iter")] // { non_negative: true } + Filter (#0{id} > 1) // { non_negative: true } Get l1 // { non_negative: true } cte l1 = Union // { non_negative: true } @@ -526,10 +526,10 @@ Explained Query: Project (#0{id}, #4) // { non_negative: true } Map ((#1{name} || "_init")) // { non_negative: true } ReadStorage materialize.public.people // { non_negative: true } - Distinct project=[#0{id}, (#1 || "_iter")] // { non_negative: true } + Distinct project=[#0{id}, (#1{name} || "_iter")] // { non_negative: true } Get l0 // { non_negative: true } Negate // { non_negative: false } - Distinct project=[#0, (#1 || "_iter")] // { non_negative: true } + Distinct project=[#0, (#1{name} || "_iter")] // { non_negative: true } Filter (#0{id} > 1) // { non_negative: true } Get l0 // { non_negative: true } Return // { non_negative: true } diff --git a/test/sqllogictest/transform/union.slt b/test/sqllogictest/transform/union.slt index 4c16f0565faab..ee1587dfff57a 100644 --- a/test/sqllogictest/transform/union.slt +++ b/test/sqllogictest/transform/union.slt @@ -168,7 +168,7 @@ Explained Query: Project (#0{f1}, #1{f2}) // { arity: 2 } Join on=(#0{f1} = #2{nokey}) type=differential // { arity: 3 } implementation - %0:l0[#0]K » %1:t2[#0]K + %0:l0[#0{f1}]K » %1:t2[#0{nokey}]K Get l0 // { arity: 2 } ArrangeBy keys=[[#0{nokey}]] // { arity: 1 } Project (#1{nokey}) // { arity: 1 } @@ -180,7 +180,7 @@ Explained Query: Project (#0{f1}, #1{f2}) // { arity: 2 } Join on=(#0{f1} = #2{f1}) type=differential // { arity: 3 } implementation - %1[#0]UKA » %0:l0[#0]K + %1[#0]UKA » %0:l0[#0{f1}]K Get l0 // { arity: 2 } ArrangeBy keys=[[#0{f1}]] // { arity: 1 } Distinct project=[#0{f1}] // { arity: 1 } diff --git a/test/sqllogictest/window_funcs.slt b/test/sqllogictest/window_funcs.slt index 57ca520d63459..78a4d8c6652e1 100644 --- a/test/sqllogictest/window_funcs.slt +++ b/test/sqllogictest/window_funcs.slt @@ -156,7 +156,7 @@ ORDER BY row_number, x ---- Finish order_by=[#0 asc nulls_last, #1 asc nulls_last] output=[#0, #1] Project (#2, #0) - Map (row_number() over (partition by [#0] order by [#0 asc nulls_last])) + Map (row_number() over (partition by [#0{x}] order by [#0{x} asc nulls_last])) Get materialize.public.t Target cluster: quickstart @@ -174,7 +174,7 @@ Finish order_by=[#0 asc nulls_last, #1 asc nulls_last] output=[#0, #1] Project (#3..=#5) // { arity: 3 } Map (record_get[0](record_get[1](#2)), record_get[1](record_get[1](#2)), record_get[0](#2)) // { arity: 6 } FlatMap unnest_list(#1) // { arity: 3 } - Reduce group_by=[#0] aggregates=[row_number[order_by=[#0 asc nulls_last]](row(list[row(#0, #1)], #0))] // { arity: 2 } + Reduce group_by=[#0] aggregates=[row_number[order_by=[#0 asc nulls_last]](row(list[row(#0, #1)], #0{x}))] // { arity: 2 } CrossJoin // { arity: 2 } Constant // { arity: 0 } - () @@ -227,7 +227,7 @@ With cte l2 = Map (true) // { arity: 2 } Distinct project=[#0] // { arity: 1 } - Filter (integer_to_bigint(#0) = #1) // { arity: 2 } + Filter (integer_to_bigint(#0{f1}) = #1{right_col0_0}) // { arity: 2 } Project (#0, #4) // { arity: 2 } Map (#3) // { arity: 5 } Project (#3..=#6) // { arity: 4 } @@ -362,7 +362,7 @@ Return // { arity: 5 } Map (record_get[0](record_get[1](#2)), record_get[1](record_get[1](#2)), record_get[2](record_get[1](#2)), record_get[0](#2)) // { arity: 7 } FlatMap unnest_list(#1) // { arity: 3 } Reduce group_by=[#0] aggregates=[row_number[order_by=[]](row(list[row(#0, #1, #2)]))] // { arity: 2 } - Filter (#2 = #0) // { arity: 3 } + Filter (#2{f2} = #0{f2}) // { arity: 3 } CrossJoin // { arity: 3 } Distinct project=[#1] // { arity: 1 } Get l0 // { arity: 2 } @@ -391,7 +391,7 @@ Return // { arity: 5 } Map (record_get[0](record_get[1](#3)), record_get[1](record_get[1](#3)), record_get[2](record_get[1](#3)), record_get[0](#3)) // { arity: 8 } FlatMap unnest_list(#2) // { arity: 4 } Reduce group_by=[#0, #1] aggregates=[row_number[order_by=[]](row(list[row(#0, #1, #2)]))] // { arity: 3 } - Filter (#2 = #0) // { arity: 3 } + Filter (#2{f2} = #0{f2}) // { arity: 3 } CrossJoin // { arity: 3 } Distinct project=[#1] // { arity: 1 } Get l0 // { arity: 2 } @@ -5165,7 +5165,7 @@ SELECT 3 + lag(a) OVER (ORDER BY a) + 5 + 27 FROM foo; ---- Project (#3) - Map (lag(row(#0, 1, null)) over (order by [#0 asc nulls_last]), (((3 + #2) + 5) + 27)) + Map (lag(row(#0{a}, 1, null)) over (order by [#0{a} asc nulls_last]), (((3 + #2{?column?}) + 5) + 27)) Get materialize.public.foo Target cluster: quickstart @@ -5179,13 +5179,13 @@ FROM foo LEFT JOIN (SELECT a AS right_a FROM foo WHERE a<2) ON foo.a = right_a GROUP BY b, right_a; ---- Project (#4, #5, #0) - Map (lag(row(((10 * #1) + 3), 1, null)) over (order by [#1 asc nulls_first]), -(#3), -(#2)) - Reduce group_by=[#3, #4] aggregates=[sum(#0)] - Map (#1, #2) - LeftOuterJoin (#0 = #2) + Map (lag(row(((10 * #1{right_a}) + 3), 1, null)) over (order by [#1{right_a} asc nulls_first]), -(#3{?column?}), -(#2{?column?})) + Reduce group_by=[#3, #4] aggregates=[sum(#0{a})] + Map (#1{b}, #2{right_a}) + LeftOuterJoin (#0{a} = #2{right_a}) Get materialize.public.foo Project (#0) - Filter (#0 < 2) + Filter (#0{a} < 2) Get materialize.public.foo Target cluster: quickstart @@ -5200,7 +5200,7 @@ ORDER BY o; ---- Finish order_by=[#0 asc nulls_last] output=[#0] Project (#3) - Map (lag(row(#0, 1, null)) over (order by [#0 asc nulls_last]), (3 + #2)) + Map (lag(row(#0{a}, 1, null)) over (order by [#0{a} asc nulls_last]), (3 + #2{?column?})) Get materialize.public.foo Target cluster: quickstart @@ -5221,7 +5221,7 @@ ORDER BY a; ---- Finish order_by=[#0 asc nulls_last] output=[#0..=#5] Project (#0, #4, #4, #2, #3, #5) - Map (lag(row(#0, 1, null)) over (order by [#0 asc nulls_last]), lead(row(#0, 1, null)) over (order by [#0 asc nulls_last]), (3 + #2), (5 + #2)) + Map (lag(row(#0{a}, 1, null)) over (order by [#0{a} asc nulls_last]), lead(row(#0{a}, 1, null)) over (order by [#0{a} asc nulls_last]), (3 + #2{?column?}), (5 + #2{?column?})) Get materialize.public.foo Target cluster: quickstart @@ -5254,7 +5254,7 @@ ORDER BY a; ---- Finish order_by=[#0 asc nulls_last] output=[#0..=#2] Project (#0, #1, #3) - Map (lag(row(#0, 1, null)) over (order by [#0 asc nulls_last]), (#2 + #2)) + Map (lag(row(#0{a}, 1, null)) over (order by [#0{a} asc nulls_last]), (#2{?column?} + #2{?column?})) Get materialize.public.foo Target cluster: quickstart @@ -5281,7 +5281,7 @@ ORDER BY a; ---- Finish order_by=[#0 asc nulls_last] output=[#0..=#2] Project (#0, #1, #4) - Map (lead(row(#0, 1, null)) over (order by [#0 asc nulls_last]), lag(row(#0, 1, null)) over (order by [#0 asc nulls_last]), (#3 + #2)) + Map (lead(row(#0{a}, 1, null)) over (order by [#0{a} asc nulls_last]), lag(row(#0{a}, 1, null)) over (order by [#0{a} asc nulls_last]), (#3{?column?} + #2{?column?})) Get materialize.public.foo Target cluster: quickstart @@ -5307,7 +5307,7 @@ FROM foo; ---- Project (#0, #1) TopK group_by=[#3] limit=1 - Map (lag(row(#0, 1, 0)) over (order by [#0 asc nulls_last]), (1 + #2)) + Map (lag(row(#0{a}, 1, 0)) over (order by [#0{a} asc nulls_last]), (1 + #2{?column?})) Get materialize.public.foo Target cluster: quickstart @@ -5384,7 +5384,7 @@ ORDER BY 5 + lag(a) OVER (ORDER BY a), o; ---- Finish order_by=[#4 asc nulls_last, #3 asc nulls_last] output=[#3] TopK group_by=[#4] order_by=[#3 asc nulls_last] limit=1 - Map (lag(row(#0, 1, null)) over (order by [#0 asc nulls_last]), lead(row(#0, 1, null)) over (order by [#1 asc nulls_last]), (5 + #2)) + Map (lag(row(#0{a}, 1, null)) over (order by [#0{a} asc nulls_last]), lead(row(#0{a}, 1, null)) over (order by [#1{b} asc nulls_last]), (5 + #2{?column?})) Get materialize.public.foo Target cluster: quickstart @@ -5526,7 +5526,7 @@ SELECT FROM bools; ---- Project (#0, #1, #3) - Map (first_value(#1) over (order by [#1 desc nulls_first]), case when #0 then #2 else 42 end) + Map (first_value(#1{x}) over (order by [#1{x} desc nulls_first]), case when #0{cond} then #2{?column?} else 42 end) Get materialize.public.bools Target cluster: quickstart @@ -5971,9 +5971,9 @@ ORDER BY outer_a, outer_b; Finish order_by=[#0 asc nulls_last, #1 asc nulls_last] output=[#0..=#2] With cte [l1 as subquery-1] = - Reduce aggregates=[sum(#0)] + Reduce aggregates=[sum(#0{lead_a})] Project (#3) - Map (lead(row(#0, 1, null)) over (partition by [((4 * #0) / (#^0 + char_length(#^1)))] order by [#0 asc nulls_last]), (3 + #2)) + Map (lead(row(#0{a}, 1, null)) over (partition by [((4 * #0{a}) / (#^0{outer_a} + char_length(#^1{outer_b})))] order by [#0{a} asc nulls_last]), (3 + #2{?column?})) Get materialize.public.foo Return Map (select(Get l1)) @@ -5983,10 +5983,10 @@ Finish order_by=[#0 asc nulls_last, #1 asc nulls_last] output=[#0..=#2] Union Get materialize.public.foo Project (#2, #1) - Map ((#0 + 2)) + Map ((#0{a} + 2)) Get materialize.public.foo Project (#2, #1) - Map ((#0 + 5)) + Map ((#0{a} + 5)) Get materialize.public.foo Target cluster: quickstart @@ -6014,8 +6014,8 @@ Finish order_by=[#0 asc nulls_last] output=[#2] Project (#4..=#6) Map (record_get[0](record_get[1](#3)), record_get[1](record_get[1](#3)), record_get[0](#3)) FlatMap unnest_list(#2) - Reduce group_by=[#2, #3] aggregates=[window_agg[sum order_by=[#0 asc nulls_last, #1 asc nulls_last] rows between unbounded preceding and current row](row(row(row(#0, #1), (#1 - 3)), (#0 + 1), (#1 + 2)))] - Map ((2 * #0), (3 * #1)) + Reduce group_by=[#2, #3] aggregates=[window_agg[sum order_by=[#0 asc nulls_last, #1 asc nulls_last] rows between unbounded preceding and current row](row(row(row(#0, #1), (#1{y} - 3)), (#0{x} + 1), (#1{y} + 2)))] + Map ((2 * #0{x}), (3 * #1{y})) CrossJoin Constant - () @@ -7453,7 +7453,7 @@ ORDER BY x,y; Explained Query: Finish order_by=[#0 asc nulls_last, #1 asc nulls_last] output=[#0..=#14] Project (#3, #4, #16, #15, #14, #17, #13, #9, #11, #10, #18, #8, #7, #6, #5) - Map (record_get[1](#1), record_get[0](#2), record_get[1](#2), record_get[2](#2), record_get[4](#2), record_get[5](#2), record_get[7](#2), record_get[8](#2), record_get[10](#2), record_get[12](#2), record_get[0](#1), record_get[0](#12), record_get[1](#12), record_get[2](#12), record_get[3](#12), (#3 * #4), (#3 + #4)) + Map (record_get[1](#1), record_get[0](#2), record_get[1](#2), record_get[2](#2), record_get[4](#2), record_get[5](#2), record_get[7](#2), record_get[8](#2), record_get[10](#2), record_get[12](#2), record_get[0](#1), record_get[0](#12), record_get[1](#12), record_get[2](#12), record_get[3](#12), (#3{x} * #4{y}), (#3{x} + #4{y})) FlatMap unnest_list(#0{fused_value_window_func}) Reduce aggregates=[fused_value_window_func[lag[order_by=[#0 asc nulls_last]], last_value[order_by=[#0 asc nulls_last]], first_value[order_by=[#0 asc nulls_last]], lag[order_by=[#0 asc nulls_last]] order_by=[#0 asc nulls_last]](row(row(row(record_get[0](record_get[1](#0)), record_get[1](record_get[1](#0)), record_get[2](record_get[1](#0)), record_get[3](record_get[1](#0)), record_get[4](record_get[1](#0)), record_get[5](record_get[1](#0)), record_get[6](record_get[1](#0)), record_get[7](record_get[1](#0)), record_get[8](record_get[1](#0)), record_get[9](record_get[1](#0)), record_get[10](record_get[1](#0)), record_get[0](#0), record_get[0](#0)), row(row(record_get[1](record_get[1](#0)), 1, null), record_get[0](record_get[1](#0)), record_get[0](record_get[1](#0)), row(record_get[0](record_get[1](#0)), 1, null))), record_get[0](record_get[1](#0))))] Project (#1) @@ -7535,7 +7535,7 @@ ORDER BY x,y; Explained Query: Finish order_by=[#0 asc nulls_last, #1 asc nulls_last] output=[#0..=#7] Project (#3, #4, #8, #9, #7, #6, #5, #10) - Map (record_get[1](#1), record_get[0](#2), record_get[1](#2), record_get[2](#2), record_get[3](#2), record_get[8](#2), record_get[0](#1), (#3 * #4), (#3 + #4)) + Map (record_get[1](#1), record_get[0](#2), record_get[1](#2), record_get[2](#2), record_get[3](#2), record_get[8](#2), record_get[0](#1), (#3{x} * #4{y}), (#3{x} + #4{y})) FlatMap unnest_list(#0{first_value}) Project (#1{first_value}) Reduce group_by=[record_get[0](record_get[1](#0))] aggregates=[first_value[order_by=[#0 asc nulls_last]](row(row(row(record_get[0](record_get[1](#0)), record_get[1](record_get[1](#0)), record_get[2](record_get[1](#0)), record_get[3](record_get[1](#0)), record_get[4](record_get[1](#0)), record_get[5](record_get[1](#0)), record_get[6](record_get[1](#0)), record_get[0](#0), record_get[0](#0)), record_get[6](record_get[1](#0))), record_get[1](record_get[1](#0))))] @@ -7675,10 +7675,10 @@ Explained Query: map=(record_get[0](#0)) input_key= Reduce::Basic - aggr=(0, lead[order_by=[#0 asc nulls_last]](row(row(row(#0, #1), row(#0, (#1 - 2), 120)), #0)), fused_unnest_list=true) + aggr=(0, lead[order_by=[#0 asc nulls_last]](row(row(row(#0, #1), row(#0{x}, (#1{y} - 2), 120)), #0{x})), fused_unnest_list=true) val_plan project=(#2) - map=(row(row(row(#0, #1), row(#0, (#1 - 2), 120)), #0)) + map=(row(row(row(#0, #1), row(#0{x}, (#1{y} - 2), 120)), #0{x})) key_plan project=() Get::PassArrangements materialize.public.t9 @@ -7703,13 +7703,13 @@ Explained Query: map=(record_get[0](#1)) input_key=#0 Reduce::Basic - aggr=(0, lead[order_by=[#0 asc nulls_last]](row(row(row(#0, #1), row(#0, (#1 - 2), 120)), #0)), fused_unnest_list=true) + aggr=(0, lead[order_by=[#0 asc nulls_last]](row(row(row(#0, #1), row(#0{x}, (#1{y} - 2), 120)), #0{x})), fused_unnest_list=true) val_plan project=(#2) - map=(row(row(row(#0, #1), row(#0, (#1 - 2), 120)), #0)) + map=(row(row(row(#0, #1), row(#0{x}, (#1{y} - 2), 120)), #0{x})) key_plan project=(#2) - map=((#0 / 2)) + map=((#0{x} / 2)) Get::PassArrangements materialize.public.t9 raw=true @@ -7732,13 +7732,13 @@ Explained Query: map=(record_get[0](#2)) input_key=#0, #1 Reduce::Basic - aggr=(0, lead[order_by=[#0 asc nulls_last]](row(row(row(#0, #1), row(#0, (#1 - 2), 120)), #0)), fused_unnest_list=true) + aggr=(0, lead[order_by=[#0 asc nulls_last]](row(row(row(#0, #1), row(#0{x}, (#1{y} - 2), 120)), #0{x})), fused_unnest_list=true) val_plan project=(#2) - map=(row(row(row(#0, #1), row(#0, (#1 - 2), 120)), #0)) + map=(row(row(row(#0, #1), row(#0{x}, (#1{y} - 2), 120)), #0{x})) key_plan project=(#2, #1) - map=((#0 / 2)) + map=((#0{x} / 2)) Get::PassArrangements materialize.public.t9 raw=true @@ -7764,10 +7764,10 @@ Explained Query: map=(record_get[0](record_get[1](#0)), record_get[0](#0)) input_key= Reduce::Basic - aggr=(0, row_number[order_by=[#0 asc nulls_last]](row(list[row(#0, #1)], #0)), fused_unnest_list=true) + aggr=(0, row_number[order_by=[#0 asc nulls_last]](row(list[row(#0, #1)], #0{x})), fused_unnest_list=true) val_plan project=(#2) - map=(row(list[row(#0, #1)], #0)) + map=(row(list[row(#0, #1)], #0{x})) key_plan project=() Get::PassArrangements materialize.public.t7 @@ -7797,10 +7797,10 @@ Explained Query: map=(record_get[0](#0), record_get[1](#0), record_get[0](#2), record_get[1](#2)) input_key= Reduce::Basic - aggr=(0, lag[order_by=[#0 asc nulls_last]](row(row(row(#0, #1), row(#0, 1, null)), #0)), fused_unnest_list=true) + aggr=(0, lag[order_by=[#0 asc nulls_last]](row(row(row(#0, #1), row(#0{x}, 1, null)), #0{x})), fused_unnest_list=true) val_plan project=(#2) - map=(row(row(row(#0, #1), row(#0, 1, null)), #0)) + map=(row(row(row(#0, #1), row(#0{x}, 1, null)), #0{x})) key_plan project=() mfp_after @@ -7831,10 +7831,10 @@ Explained Query: map=(record_get[1](#0), record_get[0](#1), record_get[1](#1), record_get[0](#0), record_get[0](#4), record_get[1](#4)) input_key= Reduce::Basic - aggr=(0, fused_value_window_func[lag[order_by=[]], lag[order_by=[]] order_by=[]](row(row(row(#0, #1), row(row(#1, 1, null), row(#0, 1, null))))), fused_unnest_list=true) + aggr=(0, fused_value_window_func[lag[order_by=[]], lag[order_by=[]] order_by=[]](row(row(row(#0, #1), row(row(#1{y}, 1, null), row(#0{x}, 1, null))))), fused_unnest_list=true) val_plan project=(#2) - map=(row(row(row(#0, #1), row(row(#1, 1, null), row(#0, 1, null))))) + map=(row(row(row(#0, #1), row(row(#1{y}, 1, null), row(#0{x}, 1, null))))) key_plan project=() Get::PassArrangements materialize.public.t7 diff --git a/test/testdrive-old-kafka-src-syntax/materializations.td b/test/testdrive-old-kafka-src-syntax/materializations.td index 9f5e7d0d6182c..1feef5316edbd 100644 --- a/test/testdrive-old-kafka-src-syntax/materializations.td +++ b/test/testdrive-old-kafka-src-syntax/materializations.td @@ -478,7 +478,34 @@ c d # in memory consumptions and should be understood before adapting the values. > SET cluster_replica = r1 -> SELECT mdod.dataflow_name, mdod.name +>[version>=13800] SELECT mdod.dataflow_name, mdod.name + FROM mz_introspection.mz_arrangement_sharing mash + JOIN mz_introspection.mz_dataflow_operator_dataflows mdod ON mash.operator_id = mdod.id + JOIN mz_introspection.mz_compute_exports USING (dataflow_id) + WHERE export_id LIKE 'u%' +"Dataflow: materialize.public.data_view_idx" "ArrangeBy[[Column(0)]]" +"Dataflow: materialize.public.data_view_idx" "ArrangeBy[[Column(0)]]-errors" +"Dataflow: materialize.public.data_view_primary_idx" "ArrangeBy[[Column(0), Column(1)]]" +"Dataflow: materialize.public.data_view_primary_idx" "ArrangeBy[[Column(0), Column(1)]]-errors" +"Dataflow: materialize.public.mat_data_idx3" "ArrangeBy[[Column(1)]]" +"Dataflow: materialize.public.mat_data_idx3" "ArrangeBy[[Column(1)]]-errors" +"Dataflow: materialize.public.mat_data_primary_idx" "ArrangeBy[[Column(0), Column(1)]]" +"Dataflow: materialize.public.mat_data_primary_idx" "ArrangeBy[[Column(0), Column(1)]]-errors" +"Dataflow: materialize.public.test1" AccumulableErrorCheck +"Dataflow: materialize.public.test1" "ArrangeAccumulable [val: empty]" +"Dataflow: materialize.public.test1" ReduceAccumulable +"Dataflow: materialize.public.test2" AccumulableErrorCheck +"Dataflow: materialize.public.test2" "ArrangeAccumulable [val: empty]" +"Dataflow: materialize.public.test2" ReduceAccumulable +"Dataflow: materialize.public.test4" "ArrangeMonotonic [val: empty]" +"Dataflow: materialize.public.test4" ReduceMonotonic +"Dataflow: materialize.public.test6" "ArrangeMonotonic [val: empty]" +"Dataflow: materialize.public.test6" ReduceMonotonic +"Dataflow: materialize.public.test7" AccumulableErrorCheck +"Dataflow: materialize.public.test7" "ArrangeAccumulable [val: empty]" +"Dataflow: materialize.public.test7" ReduceAccumulable + +>[version<13800] SELECT mdod.dataflow_name, mdod.name FROM mz_introspection.mz_arrangement_sharing mash JOIN mz_introspection.mz_dataflow_operator_dataflows mdod ON mash.operator_id = mdod.id JOIN mz_introspection.mz_compute_exports USING (dataflow_id) diff --git a/test/testdrive-old-kafka-src-syntax/monotonic.td b/test/testdrive-old-kafka-src-syntax/monotonic.td index a75245d01911c..2e1efc45f7d16 100644 --- a/test/testdrive-old-kafka-src-syntax/monotonic.td +++ b/test/testdrive-old-kafka-src-syntax/monotonic.td @@ -83,11 +83,11 @@ $ set-regex match=(.User.:\s\d+|\(u\d+\)) replacement=UID Explained Query: TopK::MonotonicTopK order_by=[#0 asc nulls_last] limit=3 must_consolidate ArrangeBy - input_key=[#0] + input_key=[#0{b}] raw=true Get::PassArrangements materialize.public.i1 raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=() } + arrangements[0]={ key=[#0{b}], permutation=id, thinning=() } types=[bigint] Used Indexes: @@ -111,11 +111,11 @@ Target cluster: quickstart Explained Query: TopK::MonotonicTopK order_by=[#1 asc nulls_last] limit=3 must_consolidate ArrangeBy - input_key=[#0, #1] + input_key=[#0{a}, #1{b}] raw=true Get::PassArrangements materialize.public.non_dbz_data_indexed raw=false - arrangements[0]={ key=[#0, #1], permutation=id, thinning=() } + arrangements[0]={ key=[#0{a}, #1{b}], permutation=id, thinning=() } types=[bigint, bigint] Used Indexes: @@ -134,11 +134,11 @@ Target cluster: quickstart Explained Query: TopK::MonotonicTopK order_by=[#0 asc nulls_last] limit=2 must_consolidate ArrangeBy - input_key=[#0] + input_key=[#0{c}] raw=true Get::PassArrangements materialize.public.i4 raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=() } + arrangements[0]={ key=[#0{c}], permutation=id, thinning=() } types=[bigint] Used Indexes: @@ -157,11 +157,11 @@ Target cluster: quickstart Explained Query: TopK::MonotonicTopK order_by=[#0 asc nulls_last] limit=2 must_consolidate ArrangeBy - input_key=[#0] + input_key=[#0{c}] raw=true Get::PassArrangements materialize.public.i6 raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=() } + arrangements[0]={ key=[#0{c}], permutation=id, thinning=() } types=[bigint] Used Indexes: @@ -183,11 +183,11 @@ Target cluster: quickstart Explained Query: TopK::MonotonicTopK order_by=[#0 asc nulls_last] limit=2 must_consolidate ArrangeBy - input_key=[#0] + input_key=[#0{b}] raw=true Get::PassArrangements materialize.public.i9 raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=() } + arrangements[0]={ key=[#0{b}], permutation=id, thinning=() } types=[bigint] Used Indexes: @@ -215,7 +215,33 @@ Target cluster: quickstart # in memory consumptions and should be understood before adapting the values. > SET cluster_replica = r1 -> SELECT mdod.dataflow_name, mdod.name +>[version>=13800] SELECT mdod.dataflow_name, mdod.name + FROM mz_introspection.mz_arrangement_sharing mash + JOIN mz_introspection.mz_dataflow_operator_dataflows mdod ON mash.operator_id = mdod.id + JOIN mz_introspection.mz_compute_exports USING (dataflow_id) + WHERE export_id LIKE 'u%' +"Dataflow: materialize.public.i1_primary_idx" "ArrangeBy[[Column(0)]]" +"Dataflow: materialize.public.i1_primary_idx" "ArrangeBy[[Column(0)]]-errors" +"Dataflow: materialize.public.i4_primary_idx" "ArrangeBy[[Column(0)]]" +"Dataflow: materialize.public.i4_primary_idx" "ArrangeBy[[Column(0)]]-errors" +"Dataflow: materialize.public.i6_primary_idx" "ArrangeBy[[Column(0)]]" +"Dataflow: materialize.public.i6_primary_idx" "ArrangeBy[[Column(0)]]-errors" +"Dataflow: materialize.public.i6_primary_idx" "Arranged TopK input" +"Dataflow: materialize.public.i6_primary_idx" "Reduced TopK input" +"Dataflow: materialize.public.i8_primary_idx" "ArrangeBy[[Column(0)]]" +"Dataflow: materialize.public.i8_primary_idx" "ArrangeBy[[Column(0)]]-errors" +"Dataflow: materialize.public.i9_primary_idx" "ArrangeBy[[Column(0)]]" +"Dataflow: materialize.public.i9_primary_idx" "ArrangeBy[[Column(0)]]-errors" +"Dataflow: materialize.public.monotonic_fused" "ArrangeMonotonic [val: empty]" +"Dataflow: materialize.public.monotonic_fused" ReduceMonotonic +"Dataflow: materialize.public.monotonic_max" "ArrangeMonotonic [val: empty]" +"Dataflow: materialize.public.monotonic_max" ReduceMonotonic +"Dataflow: materialize.public.monotonic_min" "ArrangeMonotonic [val: empty]" +"Dataflow: materialize.public.monotonic_min" ReduceMonotonic +"Dataflow: materialize.public.non_dbz_data_indexed_primary_idx" "ArrangeBy[[Column(0), Column(1)]]" +"Dataflow: materialize.public.non_dbz_data_indexed_primary_idx" "ArrangeBy[[Column(0), Column(1)]]-errors" + +>[version<13800] SELECT mdod.dataflow_name, mdod.name FROM mz_introspection.mz_arrangement_sharing mash JOIN mz_introspection.mz_dataflow_operator_dataflows mdod ON mash.operator_id = mdod.id JOIN mz_introspection.mz_compute_exports USING (dataflow_id) diff --git a/test/testdrive-old-kafka-src-syntax/top-1-monotonic.td b/test/testdrive-old-kafka-src-syntax/top-1-monotonic.td index 70c2c48137e2c..8afe1d8d488b9 100644 --- a/test/testdrive-old-kafka-src-syntax/top-1-monotonic.td +++ b/test/testdrive-old-kafka-src-syntax/top-1-monotonic.td @@ -281,7 +281,43 @@ $ kafka-ingest format=avro topic=top1 schema=${schema} timestamp=5 # in memory consumptions and should be understood before adapting the values. > SET cluster_replica = r1 -> SELECT mdod.dataflow_name, mdod.name +>[version>=13800] SELECT mdod.dataflow_name, mdod.name + FROM mz_introspection.mz_arrangement_sharing mash + JOIN mz_introspection.mz_dataflow_operator_dataflows mdod ON mash.operator_id = mdod.id + JOIN mz_introspection.mz_compute_exports USING (dataflow_id) + WHERE export_id LIKE 'u%' +"Dataflow: group_by_in_top_1" "ArrangeBy[[Column(0)]]" +"Dataflow: group_by_in_top_1" "ArrangeBy[[Column(0)]]" +"Dataflow: group_by_in_top_1" "ArrangeBy[[Column(0)]]" +"Dataflow: group_by_in_top_1" "Arranged DistinctBy" +"Dataflow: group_by_in_top_1" "Arranged DistinctBy" +"Dataflow: group_by_in_top_1" "Arranged MonotonicTop1 partial [val: empty]" +"Dataflow: group_by_in_top_1" DistinctBy +"Dataflow: group_by_in_top_1" DistinctBy +"Dataflow: group_by_in_top_1" DistinctByErrorCheck +"Dataflow: group_by_in_top_1" DistinctByErrorCheck +"Dataflow: group_by_in_top_1" MonotonicTop1 +"Dataflow: group_by_limit" "Arranged DistinctBy" +"Dataflow: group_by_limit" "Arranged MonotonicTop1 partial [val: empty]" +"Dataflow: group_by_limit" DistinctBy +"Dataflow: group_by_limit" DistinctByErrorCheck +"Dataflow: group_by_limit" MonotonicTop1 +"Dataflow: group_by_order_by_in_top_1" "ArrangeBy[[Column(0)]]" +"Dataflow: group_by_order_by_in_top_1" "ArrangeBy[[Column(0)]]" +"Dataflow: group_by_order_by_in_top_1" "ArrangeBy[[Column(0)]]" +"Dataflow: group_by_order_by_in_top_1" "Arranged DistinctBy" +"Dataflow: group_by_order_by_in_top_1" "Arranged MonotonicTop1 partial [val: empty]" +"Dataflow: group_by_order_by_in_top_1" DistinctBy +"Dataflow: group_by_order_by_in_top_1" DistinctByErrorCheck +"Dataflow: group_by_order_by_in_top_1" MonotonicTop1 +"Dataflow: limit_only" "Arranged MonotonicTop1 partial [val: empty]" +"Dataflow: limit_only" MonotonicTop1 +"Dataflow: order_by_desc_limit" "Arranged MonotonicTop1 partial [val: empty]" +"Dataflow: order_by_desc_limit" MonotonicTop1 +"Dataflow: order_by_limit" "Arranged MonotonicTop1 partial [val: empty]" +"Dataflow: order_by_limit" MonotonicTop1 + +>[version<13800] SELECT mdod.dataflow_name, mdod.name FROM mz_introspection.mz_arrangement_sharing mash JOIN mz_introspection.mz_dataflow_operator_dataflows mdod ON mash.operator_id = mdod.id JOIN mz_introspection.mz_compute_exports USING (dataflow_id) diff --git a/test/testdrive-old-kafka-src-syntax/top-k-monotonic.td b/test/testdrive-old-kafka-src-syntax/top-k-monotonic.td index e97a53de9c510..3bfe441a47133 100644 --- a/test/testdrive-old-kafka-src-syntax/top-k-monotonic.td +++ b/test/testdrive-old-kafka-src-syntax/top-k-monotonic.td @@ -278,7 +278,7 @@ a # in memory consumptions and should be understood before adapting the values. > SET cluster_replica = r1 -> SELECT mdod.dataflow_name, mdod.name +>[version<13800] SELECT mdod.dataflow_name, mdod.name FROM mz_introspection.mz_arrangement_sharing mash JOIN mz_introspection.mz_dataflow_operator_dataflows mdod ON mash.operator_id = mdod.id JOIN mz_introspection.mz_compute_exports USING (dataflow_id) @@ -287,3 +287,13 @@ a "Dataflow: materialize.public.v_other_primary_idx" ArrangeBy[[Column(0)]]-errors "Dataflow: materialize.public.v_other_primary_idx" "Arranged TopK input" "Dataflow: materialize.public.v_other_primary_idx" "Reduced TopK input" + +>[version>=13800] SELECT mdod.dataflow_name, mdod.name + FROM mz_introspection.mz_arrangement_sharing mash + JOIN mz_introspection.mz_dataflow_operator_dataflows mdod ON mash.operator_id = mdod.id + JOIN mz_introspection.mz_compute_exports USING (dataflow_id) + WHERE export_id LIKE 'u%' +"Dataflow: materialize.public.v_other_primary_idx" "ArrangeBy[[Column(0)]]" +"Dataflow: materialize.public.v_other_primary_idx" "ArrangeBy[[Column(0)]]-errors" +"Dataflow: materialize.public.v_other_primary_idx" "Arranged TopK input" +"Dataflow: materialize.public.v_other_primary_idx" "Reduced TopK input" diff --git a/test/testdrive/index-source-stuck.td b/test/testdrive/index-source-stuck.td index 17e1704b2c078..1941c3cd66322 100644 --- a/test/testdrive/index-source-stuck.td +++ b/test/testdrive/index-source-stuck.td @@ -57,7 +57,7 @@ Explained Query: With cte l0 = - Reduce aggregates=[min(#0)] + Reduce aggregates=[min(#0{counter})] ReadIndex on=mv mv_counter_idx=[*** full scan ***] Return Union @@ -77,6 +77,7 @@ Target cluster: cluster2 > SELECT 1 1 + # Should return instantly since it only uses the index and we have selected serializable isolation > SELECT min(counter) FROM mv; 1 diff --git a/test/testdrive/materializations.td b/test/testdrive/materializations.td index 92d4c3b839ddd..056c4f047a5a9 100644 --- a/test/testdrive/materializations.td +++ b/test/testdrive/materializations.td @@ -505,12 +505,12 @@ c d "Dataflow: materialize.public.test6" "Reduced Fallibly MinsMaxesHierarchical" "Dataflow: materialize.public.test6" "Reduced Fallibly MinsMaxesHierarchical" "Dataflow: materialize.public.test6" "Reduced Fallibly MinsMaxesHierarchical" -"Dataflow: materialize.public.data_view_idx" ArrangeBy[[Column(0)]] -"Dataflow: materialize.public.data_view_idx" ArrangeBy[[Column(0)]]-errors +"Dataflow: materialize.public.data_view_idx" "ArrangeBy[[Column(0)]]" +"Dataflow: materialize.public.data_view_idx" "ArrangeBy[[Column(0)]]-errors" "Dataflow: materialize.public.data_view_primary_idx" "ArrangeBy[[Column(0), Column(1)]]" "Dataflow: materialize.public.data_view_primary_idx" "ArrangeBy[[Column(0), Column(1)]]-errors" -"Dataflow: materialize.public.mat_data_idx3" ArrangeBy[[Column(1)]] -"Dataflow: materialize.public.mat_data_idx3" ArrangeBy[[Column(1)]]-errors +"Dataflow: materialize.public.mat_data_idx3" "ArrangeBy[[Column(1)]]" +"Dataflow: materialize.public.mat_data_idx3" "ArrangeBy[[Column(1)]]-errors" "Dataflow: materialize.public.test1" AccumulableErrorCheck "Dataflow: materialize.public.test1" "ArrangeAccumulable [val: empty]" "Dataflow: materialize.public.test1" ReduceAccumulable diff --git a/test/testdrive/monotonic.td b/test/testdrive/monotonic.td index 1babd27819fec..b7e24b6d2aefc 100644 --- a/test/testdrive/monotonic.td +++ b/test/testdrive/monotonic.td @@ -85,11 +85,11 @@ $ set-regex match=(.User.:\s\d+|\(u\d+\)) replacement=UID Explained Query: TopK::MonotonicTopK order_by=[#0 asc nulls_last] limit=3 must_consolidate ArrangeBy - input_key=[#0] + input_key=[#0{b}] raw=true Get::PassArrangements materialize.public.i1 raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=() } + arrangements[0]={ key=[#0{b}], permutation=id, thinning=() } types=[bigint] Used Indexes: @@ -132,11 +132,11 @@ Target cluster: quickstart Explained Query: TopK::MonotonicTopK order_by=[#0 asc nulls_last] limit=2 must_consolidate ArrangeBy - input_key=[#0] + input_key=[#0{c}] raw=true Get::PassArrangements materialize.public.i4 raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=() } + arrangements[0]={ key=[#0{c}], permutation=id, thinning=() } types=[bigint] Used Indexes: @@ -155,11 +155,11 @@ Target cluster: quickstart Explained Query: TopK::MonotonicTopK order_by=[#0 asc nulls_last] limit=2 must_consolidate ArrangeBy - input_key=[#0] + input_key=[#0{c}] raw=true Get::PassArrangements materialize.public.i6 raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=() } + arrangements[0]={ key=[#0{c}], permutation=id, thinning=() } types=[bigint] Used Indexes: @@ -181,11 +181,11 @@ Target cluster: quickstart Explained Query: TopK::MonotonicTopK order_by=[#0 asc nulls_last] limit=2 must_consolidate ArrangeBy - input_key=[#0] + input_key=[#0{b}] raw=true Get::PassArrangements materialize.public.i9 raw=false - arrangements[0]={ key=[#0], permutation=id, thinning=() } + arrangements[0]={ key=[#0{b}], permutation=id, thinning=() } types=[bigint] Used Indexes: @@ -280,17 +280,17 @@ Target cluster: quickstart "Dataflow: materialize.public.monotonic_min" "Reduced Fallibly MinsMaxesHierarchical" "Dataflow: materialize.public.monotonic_min" "Reduced Fallibly MinsMaxesHierarchical" "Dataflow: materialize.public.monotonic_min" "Reduced Fallibly MinsMaxesHierarchical" -"Dataflow: materialize.public.non_dbz_data_indexed_primary_idx" ArrangeBy[[Column(0)]] -"Dataflow: materialize.public.non_dbz_data_indexed_primary_idx" ArrangeBy[[Column(0)]]-errors -"Dataflow: materialize.public.i1_primary_idx" ArrangeBy[[Column(0)]] -"Dataflow: materialize.public.i1_primary_idx" ArrangeBy[[Column(0)]]-errors -"Dataflow: materialize.public.i4_primary_idx" ArrangeBy[[Column(0)]] -"Dataflow: materialize.public.i4_primary_idx" ArrangeBy[[Column(0)]]-errors -"Dataflow: materialize.public.i6_primary_idx" ArrangeBy[[Column(0)]] -"Dataflow: materialize.public.i6_primary_idx" ArrangeBy[[Column(0)]]-errors +"Dataflow: materialize.public.non_dbz_data_indexed_primary_idx" "ArrangeBy[[Column(0)]]" +"Dataflow: materialize.public.non_dbz_data_indexed_primary_idx" "ArrangeBy[[Column(0)]]-errors" +"Dataflow: materialize.public.i1_primary_idx" "ArrangeBy[[Column(0)]]" +"Dataflow: materialize.public.i1_primary_idx" "ArrangeBy[[Column(0)]]-errors" +"Dataflow: materialize.public.i4_primary_idx" "ArrangeBy[[Column(0)]]" +"Dataflow: materialize.public.i4_primary_idx" "ArrangeBy[[Column(0)]]-errors" +"Dataflow: materialize.public.i6_primary_idx" "ArrangeBy[[Column(0)]]" +"Dataflow: materialize.public.i6_primary_idx" "ArrangeBy[[Column(0)]]-errors" "Dataflow: materialize.public.i6_primary_idx" "Arranged TopK input" "Dataflow: materialize.public.i6_primary_idx" "Reduced TopK input" -"Dataflow: materialize.public.i8_primary_idx" ArrangeBy[[Column(0)]] -"Dataflow: materialize.public.i8_primary_idx" ArrangeBy[[Column(0)]]-errors -"Dataflow: materialize.public.i9_primary_idx" ArrangeBy[[Column(0)]] -"Dataflow: materialize.public.i9_primary_idx" ArrangeBy[[Column(0)]]-errors +"Dataflow: materialize.public.i8_primary_idx" "ArrangeBy[[Column(0)]]" +"Dataflow: materialize.public.i8_primary_idx" "ArrangeBy[[Column(0)]]-errors" +"Dataflow: materialize.public.i9_primary_idx" "ArrangeBy[[Column(0)]]" +"Dataflow: materialize.public.i9_primary_idx" "ArrangeBy[[Column(0)]]-errors" diff --git a/test/testdrive/primary-key-optimizations.td b/test/testdrive/primary-key-optimizations.td index 443ed4de57edb..8002ee635b24c 100644 --- a/test/testdrive/primary-key-optimizations.td +++ b/test/testdrive/primary-key-optimizations.td @@ -169,7 +169,7 @@ Target cluster: quickstart ? EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT DISTINCT key1, upper(key2) FROM t1_tbl; Explained Query: - Distinct project=[#0, upper(#1)] + Distinct project=[#0, upper(#1{key2})] Project (#0, #1) ReadIndex on=t1_tbl t1_tbl_primary_idx=[*** full scan ***] @@ -180,7 +180,7 @@ Target cluster: quickstart ? EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT DISTINCT key1, key2 || 'a' FROM t1_tbl; Explained Query: - Distinct project=[#0, (#1 || "a")] + Distinct project=[#0, (#1{key2} || "a")] Project (#0, #1) ReadIndex on=t1_tbl t1_tbl_primary_idx=[*** full scan ***] @@ -215,7 +215,7 @@ Target cluster: quickstart Explained Query: With cte l0 = - Reduce aggregates=[count(distinct #0)] + Reduce aggregates=[count(distinct #0{key1})] Project (#0) ReadIndex on=t1_tbl t1_tbl_primary_idx=[*** full scan ***] Return diff --git a/test/testdrive/render-delta-join.td b/test/testdrive/render-delta-join.td index 260560eb50b74..2be0b06781d59 100644 --- a/test/testdrive/render-delta-join.td +++ b/test/testdrive/render-delta-join.td @@ -34,13 +34,13 @@ count ? EXPLAIN OPTIMIZED PLAN WITH(join implementations) AS VERBOSE TEXT FOR SELECT * FROM delta_join; Explained Query: Project (#0, #1, #0, #3) - Filter (#0) IS NOT NULL - Join on=(#0 = #2) type=differential + Filter (#0{f1}) IS NOT NULL + Join on=(#0{f1} = #2{f1}) type=differential implementation - %0:t1[#0]KA » %1:t2[#0]KA - ArrangeBy keys=[[#0]] + %0:t1[#0{f1}]KA » %1:t2[#0{f1}]KA + ArrangeBy keys=[[#0{f1}]] ReadIndex on=t1 i1=[differential join] - ArrangeBy keys=[[#0]] + ArrangeBy keys=[[#0{f1}]] ReadIndex on=t2 i2=[differential join] Used Indexes: diff --git a/test/testdrive/source-linear-operators.td b/test/testdrive/source-linear-operators.td index a937ed1972258..6a1c952f9f8dd 100644 --- a/test/testdrive/source-linear-operators.td +++ b/test/testdrive/source-linear-operators.td @@ -49,11 +49,11 @@ $ set-regex match=u\d+ replacement=UID ? EXPLAIN OPTIMIZED PLAN AS VERBOSE TEXT FOR SELECT * FROM v; Explained Query: - Filter (#0 = 1) AND (#3 = 3) + Filter (#0{a} = 1) AND (#3{d} = 3) ReadStorage materialize.public.data_tbl Source materialize.public.data_tbl - filter=((#0 = 1) AND (#3 = 3)) + filter=((#0{a} = 1) AND (#3{d} = 3)) Target cluster: quickstart @@ -70,11 +70,11 @@ Target cluster: quickstart ? EXPLAIN OPTIMIZED PLAN AS VERBOSE TEXT FOR SELECT * FROM v; Explained Query: Project (#1) - Filter (#1 = 1) + Filter (#1{b} = 1) ReadStorage materialize.public.data_tbl Source materialize.public.data_tbl - filter=((#1 = 1)) + filter=((#1{b} = 1)) Target cluster: quickstart @@ -95,11 +95,11 @@ Target cluster: quickstart ? EXPLAIN OPTIMIZED PLAN AS VERBOSE TEXT FOR SELECT * FROM v; Explained Query: Project (#1) - Filter (#0 = 1) AND (#3 = 4) + Filter (#0{a} = 1) AND (#3{d} = 4) ReadStorage materialize.public.data_tbl Source materialize.public.data_tbl - filter=((#0 = 1) AND (#3 = 4)) + filter=((#0{a} = 1) AND (#3{d} = 4)) Target cluster: quickstart @@ -116,11 +116,11 @@ Target cluster: quickstart ? EXPLAIN OPTIMIZED PLAN AS VERBOSE TEXT FOR SELECT * FROM v; Explained Query: Project (#3) - Filter (#0 = 1) AND (#3 = 4) + Filter (#0{a} = 1) AND (#3{d} = 4) ReadStorage materialize.public.data_tbl Source materialize.public.data_tbl - filter=((#0 = 1) AND (#3 = 4)) + filter=((#0{a} = 1) AND (#3{d} = 4)) Target cluster: quickstart @@ -135,14 +135,14 @@ Target cluster: quickstart ? EXPLAIN OPTIMIZED PLAN AS VERBOSE TEXT FOR SELECT * FROM v; Explained Query: Project (#0) - Join on=(#0 = #1) type=differential - ArrangeBy keys=[[#0]] + Join on=(#0{a} = #1{b}) type=differential + ArrangeBy keys=[[#0{a}]] Project (#0) - Filter (#0) IS NOT NULL + Filter (#0{a}) IS NOT NULL ReadStorage materialize.public.data_tbl - ArrangeBy keys=[[#0]] + ArrangeBy keys=[[#0{b}]] Project (#1) - Filter (#3 = 4) AND (#1) IS NOT NULL + Filter (#3{d} = 4) AND (#1{b}) IS NOT NULL ReadStorage materialize.public.data_tbl Source materialize.public.data_tbl @@ -165,18 +165,18 @@ Target cluster: quickstart ? EXPLAIN OPTIMIZED PLAN AS VERBOSE TEXT FOR SELECT * FROM v; Explained Query: Project (#1) - Join on=(#0 = #2) type=differential - ArrangeBy keys=[[#0]] + Join on=(#0{a} = #2{b}) type=differential + ArrangeBy keys=[[#0{a}]] Project (#0) - Filter (#3 = 4) AND (#0) IS NOT NULL + Filter (#3{d} = 4) AND (#0{a}) IS NOT NULL ReadStorage materialize.public.data_tbl - ArrangeBy keys=[[#1]] + ArrangeBy keys=[[#1{b}]] Project (#0, #1) - Filter (#3 = 4) AND (#1) IS NOT NULL + Filter (#3{d} = 4) AND (#1{b}) IS NOT NULL ReadStorage materialize.public.data_tbl Source materialize.public.data_tbl - filter=((#3 = 4)) + filter=((#3{d} = 4)) Target cluster: quickstart @@ -194,19 +194,19 @@ Explained Query: With cte l0 = Project (#0, #2) - Filter (#0) IS NOT NULL + Filter (#0{a}) IS NOT NULL ReadStorage materialize.public.data_tbl Return Project (#2) - Join on=(#0 = #1) type=differential - ArrangeBy keys=[[#0]] + Join on=(#0{a} = #1{a}) type=differential + ArrangeBy keys=[[#0{a}]] Project (#0) Get l0 - ArrangeBy keys=[[#0]] + ArrangeBy keys=[[#0{a}]] Get l0 Source materialize.public.data_tbl - filter=((#0) IS NOT NULL) + filter=((#0{a}) IS NOT NULL) Target cluster: quickstart @@ -228,13 +228,13 @@ Explained Query: Union Project (#1, #0) Map (1) - Reduce aggregates=[sum(#0)] + Reduce aggregates=[sum(#0{b})] Project (#1) Filter (#0 = 1) ReadStorage materialize.public.data_tbl Project (#0, #4) Filter (#0 = 1) - Map (bigint_to_numeric((1 + #2))) + Map (bigint_to_numeric((1 + #2{c}))) ReadStorage materialize.public.data_tbl Source materialize.public.data_tbl @@ -275,12 +275,12 @@ Explained Query: ReadStorage materialize.public.data_tbl Negate Project (#0, #2) - Filter (#3) IS NULL + Filter (#3{d}) IS NULL ReadStorage materialize.public.data2_tbl Source materialize.public.data_tbl Source materialize.public.data2_tbl - filter=((#3) IS NULL) + filter=((#3{d}) IS NULL) Target cluster: quickstart diff --git a/test/testdrive/subexpression-replacement.td b/test/testdrive/subexpression-replacement.td index 35bd283aeb4d0..c83f79971605d 100644 --- a/test/testdrive/subexpression-replacement.td +++ b/test/testdrive/subexpression-replacement.td @@ -26,7 +26,7 @@ $ set-regex match=(\s\(u\d+\)|materialize\.public\.) replacement= ? EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT * FROM t1 WHERE col_null IS NULL AND (col_null IS NULL AND col_not_null = 5); Explained Query (fast path): - Filter (#0) IS NULL AND (#1 = 5) + Filter (#0{col_null}) IS NULL AND (#1{col_not_null} = 5) ReadIndex on=t1 t1_primary_idx=[*** full scan ***] Used Indexes: @@ -59,7 +59,7 @@ Target cluster: quickstart ? EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT * FROM t1 WHERE col_null IS NULL OR (col_null IS NULL AND col_not_null = 5); Explained Query (fast path): - Filter (#0) IS NULL + Filter (#0{col_null}) IS NULL ReadIndex on=t1 t1_primary_idx=[*** full scan ***] Used Indexes: @@ -69,7 +69,7 @@ Target cluster: quickstart ? EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT * FROM t1 WHERE col_null IS NULL OR col_null IS NULL OR (col_null IS NULL AND col_not_null = 5); Explained Query (fast path): - Filter (#0) IS NULL + Filter (#0{col_null}) IS NULL ReadIndex on=t1 t1_primary_idx=[*** full scan ***] Used Indexes: @@ -80,7 +80,7 @@ Target cluster: quickstart ? EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT * FROM t1 WHERE col_null IS NULL OR (col_null IS NULL AND col_not_null = 5) OR (col_null IS NULL AND col_not_null = 6); Explained Query (fast path): - Filter (#0) IS NULL + Filter (#0{col_null}) IS NULL ReadIndex on=t1 t1_primary_idx=[*** full scan ***] Used Indexes: @@ -92,7 +92,7 @@ Target cluster: quickstart ? EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT * FROM t1 WHERE col_null IS NULL AND (col_null IS NULL OR col_not_null = 5); Explained Query (fast path): - Filter (#0) IS NULL + Filter (#0{col_null}) IS NULL ReadIndex on=t1 t1_primary_idx=[*** full scan ***] Used Indexes: @@ -104,7 +104,7 @@ Target cluster: quickstart ? EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT * FROM t1 WHERE col_null IS NULL OR (col_null IS NULL OR col_not_null = 5); Explained Query (fast path): - Filter ((#0) IS NULL OR (#1 = 5)) + Filter ((#0{col_null}) IS NULL OR (#1{col_not_null} = 5)) ReadIndex on=t1 t1_primary_idx=[*** full scan ***] Used Indexes: @@ -116,7 +116,7 @@ Target cluster: quickstart ? EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT * FROM t1 WHERE (col_not_null + 1 / col_not_null) = 5 AND ((col_not_null + 1 / col_not_null) = 5 AND col_null = 6); Explained Query (fast path): - Filter (#0 = 6) AND (5 = (#1 + (1 / #1))) + Filter (#0{col_null} = 6) AND (5 = (#1{col_not_null} + (1 / #1{col_not_null}))) ReadIndex on=t1 t1_primary_idx=[*** full scan ***] Used Indexes: @@ -128,7 +128,7 @@ Target cluster: quickstart ? EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT * FROM t1 WHERE col_not_null + col_not_null + col_not_null = 5 AND (col_not_null + col_not_null + col_not_null = 5); Explained Query (fast path): - Filter (5 = ((#1 + #1) + #1)) + Filter (5 = ((#1{col_not_null} + #1{col_not_null}) + #1{col_not_null})) ReadIndex on=t1 t1_primary_idx=[*** full scan ***] Used Indexes: @@ -140,7 +140,7 @@ Target cluster: quickstart ? EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT * FROM t1 WHERE ((col_not_null > 3) AND (col_not_null < 5)) AND ((col_not_null > 3) AND (col_not_null < 5) OR col_not_null = 10); Explained Query (fast path): - Filter (#1 < 5) AND (#1 > 3) + Filter (#1{col_not_null} < 5) AND (#1{col_not_null} > 3) ReadIndex on=t1 t1_primary_idx=[*** full scan ***] Used Indexes: @@ -152,7 +152,7 @@ Target cluster: quickstart ? EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT * FROM t1 WHERE ((col_not_null > 3) OR (col_not_null < 5)) OR ((col_not_null > 3) OR (col_not_null < 5)); Explained Query (fast path): - Filter ((#1 < 5) OR (#1 > 3)) + Filter ((#1{col_not_null} < 5) OR (#1{col_not_null} > 3)) ReadIndex on=t1 t1_primary_idx=[*** full scan ***] Used Indexes: @@ -171,7 +171,7 @@ Target cluster: quickstart # This is not optimized ? EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT * FROM t1 WHERE (col_not_null % 2) = 1 AND (((col_not_null % 2) = 1) = TRUE); Explained Query (fast path): - Filter (1 = (#1 % 2)) + Filter (1 = (#1{col_not_null} % 2)) ReadIndex on=t1 t1_primary_idx=[*** full scan ***] Used Indexes: @@ -182,7 +182,7 @@ Target cluster: quickstart # Column used on both sides of the expression ? EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT * FROM t1 WHERE (col_not_null = col_not_null + 1) AND (col_not_null = col_not_null + 1); Explained Query (fast path): - Filter (#1 = (#1 + 1)) + Filter (#1{col_not_null} = (#1{col_not_null} + 1)) ReadIndex on=t1 t1_primary_idx=[*** full scan ***] Used Indexes: @@ -198,7 +198,7 @@ Target cluster: quickstart Explained Query (fast path): Project (#0, #1) Filter (#2 > #2) - Map (mz_sleep(integer_to_double(#1))) + Map (mz_sleep(integer_to_double(#1{col_not_null}))) ReadIndex on=t1 t1_primary_idx=[*** full scan ***] Used Indexes: @@ -210,7 +210,7 @@ Target cluster: quickstart ? EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT * FROM t1 WHERE col_not_null IN (2, 3) AND col_not_null IN (2, 3); Explained Query (fast path): - Filter ((#1 = 2) OR (#1 = 3)) + Filter ((#1{col_not_null} = 2) OR (#1{col_not_null} = 3)) ReadIndex on=t1 t1_primary_idx=[*** full scan ***] Used Indexes: @@ -222,7 +222,7 @@ Target cluster: quickstart ? EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT * FROM t1 WHERE col_not_null IN (2, 3) AND col_not_null IN (3, 4); Explained Query (fast path): - Filter (#1 = 3) + Filter (#1{col_not_null} = 3) ReadIndex on=t1 t1_primary_idx=[*** full scan ***] Used Indexes: @@ -242,7 +242,7 @@ Target cluster: quickstart ? EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT * FROM t1 WHERE col_not_null = 1 AND TRUE IN (col_not_null = 1, col_not_null = 2); Explained Query (fast path): - Filter (#1 = 1) + Filter (#1{col_not_null} = 1) ReadIndex on=t1 t1_primary_idx=[*** full scan ***] Used Indexes: @@ -255,8 +255,8 @@ Target cluster: quickstart ? EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT * FROM t1 WHERE col_not_null = 1 OR TRUE IN (col_not_null = 1, col_not_null = 2); Explained Query (fast path): Project (#0, #1) - Filter (#2 OR (#2 = true) OR (true = (#1 = 2))) - Map ((#1 = 1)) + Filter (#2 OR (#2 = true) OR (true = (#1{col_not_null} = 2))) + Map ((#1{col_not_null} = 1)) ReadIndex on=t1 t1_primary_idx=[*** full scan ***] Used Indexes: diff --git a/test/testdrive/temporal.td b/test/testdrive/temporal.td index eb74b3cb6be05..eae44ca68e011 100644 --- a/test/testdrive/temporal.td +++ b/test/testdrive/temporal.td @@ -263,7 +263,7 @@ contains:Unsupported binary temporal operation: NotEq contains:operator does not exist: mz_timestamp + integer !CREATE MATERIALIZED VIEW v1 AS SELECT * FROM first_ts WHERE mz_now() > ts OR ts = 1; -contains:Unsupported temporal predicate. Note: `mz_now()` must be directly compared to a non-temporal expression of mz_timestamp-castable type. Expression found: ((#0 = 1) OR (mz_now() > #0)) +contains:Unsupported temporal predicate. Note: `mz_now()` must be directly compared to a non-temporal expression of mz_timestamp-castable type. Expression found: ((#0{ts} = 1) OR (mz_now() > #0{ts})) !CREATE MATERIALIZED VIEW v1 AS SELECT * FROM first_ts WHERE ts BETWEEN mz_now() AND mz_now() + 1; contains:operator does not exist: mz_timestamp + integer diff --git a/test/testdrive/testdrive.td b/test/testdrive/testdrive.td index c04eb78a8ff9c..69fd568882d47 100644 --- a/test/testdrive/testdrive.td +++ b/test/testdrive/testdrive.td @@ -49,7 +49,7 @@ $ set-regex match=u\d+ replacement=UID Explained Query: CrossJoin type=differential ArrangeBy keys=[[]] - Filter (#0) IS NOT NULL + Filter (#0{f1}) IS NOT NULL ReadStorage materialize.public.t1 ArrangeBy keys=[[]] ReadStorage materialize.public.t1 diff --git a/test/testdrive/top-1-monotonic.td b/test/testdrive/top-1-monotonic.td index 176baad205e43..0348e70e5b814 100644 --- a/test/testdrive/top-1-monotonic.td +++ b/test/testdrive/top-1-monotonic.td @@ -377,9 +377,9 @@ $ kafka-ingest format=avro topic=top1 schema=${schema} timestamp=5 "Dataflow: order_by_limit" "Reduced TopK input" "Dataflow: order_by_limit" "Reduced TopK input" "Dataflow: order_by_limit" "Reduced TopK input" -"Dataflow: group_by_in_top_1" ArrangeBy[[Column(0)]] -"Dataflow: group_by_in_top_1" ArrangeBy[[Column(0)]] -"Dataflow: group_by_in_top_1" ArrangeBy[[Column(0)]] +"Dataflow: group_by_in_top_1" "ArrangeBy[[Column(0)]]" +"Dataflow: group_by_in_top_1" "ArrangeBy[[Column(0)]]" +"Dataflow: group_by_in_top_1" "ArrangeBy[[Column(0)]]" "Dataflow: group_by_in_top_1" "Arranged DistinctBy" "Dataflow: group_by_in_top_1" "Arranged DistinctBy" "Dataflow: group_by_in_top_1" DistinctBy @@ -389,9 +389,9 @@ $ kafka-ingest format=avro topic=top1 schema=${schema} timestamp=5 "Dataflow: group_by_limit" "Arranged DistinctBy" "Dataflow: group_by_limit" DistinctBy "Dataflow: group_by_limit" DistinctByErrorCheck -"Dataflow: group_by_order_by_in_top_1" ArrangeBy[[Column(0)]] -"Dataflow: group_by_order_by_in_top_1" ArrangeBy[[Column(0)]] -"Dataflow: group_by_order_by_in_top_1" ArrangeBy[[Column(0)]] +"Dataflow: group_by_order_by_in_top_1" "ArrangeBy[[Column(0)]]" +"Dataflow: group_by_order_by_in_top_1" "ArrangeBy[[Column(0)]]" +"Dataflow: group_by_order_by_in_top_1" "ArrangeBy[[Column(0)]]" "Dataflow: group_by_order_by_in_top_1" "Arranged DistinctBy" "Dataflow: group_by_order_by_in_top_1" DistinctBy "Dataflow: group_by_order_by_in_top_1" DistinctByErrorCheck diff --git a/test/testdrive/top-k-monotonic.td b/test/testdrive/top-k-monotonic.td index f46c2a56684ae..e5b4d6a96a84a 100644 --- a/test/testdrive/top-k-monotonic.td +++ b/test/testdrive/top-k-monotonic.td @@ -287,8 +287,8 @@ a JOIN mz_introspection.mz_dataflow_operator_dataflows mdod ON mash.operator_id = mdod.id JOIN mz_introspection.mz_compute_exports USING (dataflow_id) WHERE export_id LIKE 'u%' -"Dataflow: materialize.public.v_other_primary_idx" ArrangeBy[[Column(0)]] -"Dataflow: materialize.public.v_other_primary_idx" ArrangeBy[[Column(0)]]-errors +"Dataflow: materialize.public.v_other_primary_idx" "ArrangeBy[[Column(0)]]" +"Dataflow: materialize.public.v_other_primary_idx" "ArrangeBy[[Column(0)]]-errors" "Dataflow: materialize.public.v_other_primary_idx" "Arranged TopK input" "Dataflow: materialize.public.v_other_primary_idx" "Reduced TopK input" "Dataflow: materialize.public.v_other_primary_idx" "Arranged TopK input" From 97e3902bd34c63210e4209c2d810a795734d24ba Mon Sep 17 00:00:00 2001 From: Michael Greenberg Date: Wed, 23 Apr 2025 15:18:01 -0400 Subject: [PATCH 02/14] add [XXX<=version Testdrive: Target cluster: quickstart - ?[version>=13500] EXPLAIN OPTIMIZED PLAN AS VERBOSE TEXT FOR MATERIALIZED VIEW explain_mv2; + ?[version>=14300] EXPLAIN OPTIMIZED PLAN AS VERBOSE TEXT FOR MATERIALIZED VIEW explain_mv2; materialize.public.explain_mv2: Filter (#1{y} = 7) ReadStorage materialize.public.explain_item_t2 @@ -85,13 +85,24 @@ def validate(self) -> Testdrive: Target cluster: quickstart + ?[13500<=version<14300] EXPLAIN OPTIMIZED PLAN AS VERBOSE TEXT FOR MATERIALIZED VIEW explain_mv2; + materialize.public.explain_mv2: + Filter (#1 = 7) + ReadStorage materialize.public.explain_item_t2 + + Source materialize.public.explain_item_t2 + filter=((#1 = 7)) + + Target cluster: quickstart + + ?[version<13500] EXPLAIN OPTIMIZED PLAN FOR MATERIALIZED VIEW explain_mv2; materialize.public.explain_mv2: - Filter (#1{y} = 7) + Filter (#1 = 7) ReadStorage materialize.public.explain_item_t2 Source materialize.public.explain_item_t2 - filter=((#1{y} = 7)) + filter=((#1 = 7)) Target cluster: quickstart diff --git a/src/testdrive/src/parser.rs b/src/testdrive/src/parser.rs index a70854c62f5d4..7e16d41e2f320 100644 --- a/src/testdrive/src/parser.rs +++ b/src/testdrive/src/parser.rs @@ -213,23 +213,64 @@ fn parse_version_constraint( }); } }; - if line[2..9].to_string() != "version" { + let mut begin_version_kw = 2; + const MIN_VERSION: i32 = 0; + let mut min_version = MIN_VERSION; + if line.as_bytes()[2].is_ascii_digit() { + let Some(op_pos) = line.find('<') else { + return Err(PosError { + source: anyhow!("version-constraint: initial number but no '<' following"), + pos: Some(pos), + }); + }; + let min_version_str = line[2..op_pos].to_string(); + match min_version_str.parse::() { + Ok(mv) => min_version = mv, + Err(_) => { + return Err(PosError { + source: anyhow!( + "version-constraint: invalid version number {}", + min_version_str + ), + pos: Some(pos), + }); + } + }; + + if line.as_bytes()[op_pos + 1] == b'=' { + begin_version_kw = op_pos + 2; + } else { + begin_version_kw = op_pos + 1; + min_version += 1; + } + }; + + let version_start = begin_version_kw + "version".len(); + if line[begin_version_kw..version_start].to_string() != "version" { return Err(PosError { source: anyhow!( - "version-constraint: invalid property {}", - line[2..closed_brace_pos].to_string() + "version-constraint: invalid property {} (found '{}', expected 'version' {begin_version_kw})", + line[2..closed_brace_pos].to_string(), + line[begin_version_kw..version_start].to_string() ), pos: Some(pos), }); } let remainder = line[closed_brace_pos + 1..].to_string(); line_reader.push(&remainder); - const MIN_VERSION: i32 = 0; const MAX_VERSION: i32 = 9999999; - let version_pos = if line.as_bytes()[10].is_ascii_digit() { - 10 + + if version_start >= closed_brace_pos && min_version != MIN_VERSION { + return Ok(Some(VersionConstraint { + min: min_version, + max: MAX_VERSION, + })); + } + + let version_pos = if line.as_bytes()[version_start + 1].is_ascii_digit() { + version_start + 1 } else { - 11 + version_start + 2 }; let version = match line[version_pos..closed_brace_pos].parse::() { Ok(x) => x, @@ -244,31 +285,38 @@ fn parse_version_constraint( } }; - match &line[9..version_pos] { + match &line[version_start..version_pos] { "=" => Ok(Some(VersionConstraint { min: version, max: version, })), "<=" => Ok(Some(VersionConstraint { - min: MIN_VERSION, + min: min_version, max: version, })), "<" => Ok(Some(VersionConstraint { - min: MIN_VERSION, + min: min_version, max: version - 1, })), - ">=" => Ok(Some(VersionConstraint { + ">=" if min_version == MIN_VERSION => Ok(Some(VersionConstraint { min: version, max: MAX_VERSION, })), - ">" => Ok(Some(VersionConstraint { + ">" if min_version == MIN_VERSION => Ok(Some(VersionConstraint { min: version + 1, max: MAX_VERSION, })), + ">=" | ">" => Err(PosError { + source: anyhow!( + "version-constraint: found comparison operator {} with a set minimum version {min_version}", + line[version_start..version_pos].to_string() + ), + pos: Some(pos), + }), _ => Err(PosError { source: anyhow!( "version-constraint: unknown comparison operator {}", - line[9..version_pos].to_string() + line[version_start..version_pos].to_string() ), pos: Some(pos), }), diff --git a/test/bounded-memory/mzcompose.py b/test/bounded-memory/mzcompose.py index e2f78b29a0fa8..ef2177af6f6de 100644 --- a/test/bounded-memory/mzcompose.py +++ b/test/bounded-memory/mzcompose.py @@ -946,7 +946,7 @@ class KafkaScenario(Scenario): 8 9 - ? EXPLAIN OPTIMIZED PLAN WITH(cardinality) AS VERBOSE TEXT FOR SELECT pk FROM tab0 WHERE col0 <= 88 AND (((col4 <= 97.11 AND col0 IN (11,85,87,63,88) OR (col0 <= 45 AND ((((((((col0 > 79)) OR col1 <= 30.14 OR col3 >= 12))) OR col0 >= 89 OR col1 < 20.99 OR col1 >= 74.51 AND col3 > 77) AND (col0 IN (67,97,94,86,81))) AND ((col1 <= 10.70 AND col1 IS NULL AND col3 > 49 AND col3 > 66 AND (((col4 > 42.2) AND ((((col4 < 86.27) AND col3 >= 77 AND col3 < 48))) AND col3 >= 49)) AND col0 IN (SELECT col3 FROM tab0 WHERE col4 BETWEEN 20.3 AND 97.63))) AND col0 >= 25) OR ((col0 <= 35)) AND col0 < 68 OR ((col0 = 98))) OR (col1 <= 17.96) AND ((((col0 IS NULL))) OR col4 <= 2.63 AND (col0 > 2) AND col3 > 8) OR col3 <= 88 AND (((col0 IS NULL))) OR col0 >= 30)) AND col0 > 5) OR col0 > 3; + ?[version>=14300] EXPLAIN OPTIMIZED PLAN WITH(cardinality) AS VERBOSE TEXT FOR SELECT pk FROM tab0 WHERE col0 <= 88 AND (((col4 <= 97.11 AND col0 IN (11,85,87,63,88) OR (col0 <= 45 AND ((((((((col0 > 79)) OR col1 <= 30.14 OR col3 >= 12))) OR col0 >= 89 OR col1 < 20.99 OR col1 >= 74.51 AND col3 > 77) AND (col0 IN (67,97,94,86,81))) AND ((col1 <= 10.70 AND col1 IS NULL AND col3 > 49 AND col3 > 66 AND (((col4 > 42.2) AND ((((col4 < 86.27) AND col3 >= 77 AND col3 < 48))) AND col3 >= 49)) AND col0 IN (SELECT col3 FROM tab0 WHERE col4 BETWEEN 20.3 AND 97.63))) AND col0 >= 25) OR ((col0 <= 35)) AND col0 < 68 OR ((col0 = 98))) OR (col1 <= 17.96) AND ((((col0 IS NULL))) OR col4 <= 2.63 AND (col0 > 2) AND col3 > 8) OR col3 <= 88 AND (((col0 IS NULL))) OR col0 >= 30)) AND col0 > 5) OR col0 > 3; Explained Query: With cte l0 = @@ -954,13 +954,13 @@ class KafkaScenario(Scenario): Project (#1) // { cardinality: \"\" } ReadStorage materialize.public.tab0 // { cardinality: \"\" } cte l1 = - Reduce group_by=[#0] aggregates=[any((#0 = #1))] // { cardinality: \"\" } + Reduce group_by=[#0] aggregates=[any((#0{col0} = #1{right_col0_0}))] // { cardinality: \"\" } CrossJoin type=differential // { cardinality: \"\" } ArrangeBy keys=[[]] // { cardinality: \"\" } Get l0 // { cardinality: \"\" } ArrangeBy keys=[[]] // { cardinality: \"\" } Project (#4) // { cardinality: \"\" } - Filter (#5 <= 97.63) AND (#5 >= 20.3) // { cardinality: \"\" } + Filter (#5{col4} <= 97.63) AND (#5{col4} >= 20.3) // { cardinality: \"\" } ReadStorage materialize.public.tab0 // { cardinality: \"\" } cte l2 = Union // { cardinality: \"\" } @@ -969,17 +969,17 @@ class KafkaScenario(Scenario): Union // { cardinality: \"\" } Negate // { cardinality: \"\" } Project (#0) // { cardinality: \"\" } - Get l1 // { cardinality: \"\" } - Get l0 // { cardinality: \"\" } + Get l1 // { cardinality: \"\" } + Get l0 // { cardinality: \"\" } Return // { cardinality: \"\" } Project (#0) // { cardinality: \"\" } - Filter ((#1 > 3) OR ((#1 <= 88) AND (#1 > 5) AND ((#1 = 98) OR (#1 >= 30) OR (#6 AND (#2) IS NULL AND (#3 < 48) AND (#4 < 86.27) AND (#1 <= 45) AND (#2 <= 10.7) AND (#3 > 49) AND (#3 > 66) AND (#4 > 42.2) AND (#1 >= 25) AND (#3 >= 49) AND (#3 >= 77) AND ((#1 = 67) OR (#1 = 81) OR (#1 = 86) OR (#1 = 94) OR (#1 = 97)) AND ((#2 < 20.99) OR (#2 <= 30.14) OR (#1 > 79) OR (#1 >= 89) OR (#3 >= 12) OR ((#3 > 77) AND (#2 >= 74.51)))) OR (#7 AND (#3 <= 88)) OR ((#1 < 68) AND (#1 <= 35)) OR ((#2 <= 17.96) AND (#7 OR ((#4 <= 2.63) AND (#1 > 2) AND (#3 > 8)))) OR ((#4 <= 97.11) AND ((#1 = 11) OR (#1 = 63) OR (#1 = 85) OR (#1 = 87) OR (#1 = 88)))))) // { cardinality: \"\" } - Map ((#1) IS NULL) // { cardinality: \"\" } + Filter ((#1{col0} > 3) OR ((#1{col0} <= 88) AND (#1{col0} > 5) AND ((#1{col0} = 98) OR (#1{col0} >= 30) OR (#6 AND (#2{col1}) IS NULL AND (#3{col3} < 48) AND (#4{col4} < 86.27) AND (#1{col0} <= 45) AND (#2{col1} <= 10.7) AND (#3{col3} > 49) AND (#3{col3} > 66) AND (#4{col4} > 42.2) AND (#1{col0} >= 25) AND (#3{col3} >= 49) AND (#3{col3} >= 77) AND ((#1{col0} = 67) OR (#1{col0} = 81) OR (#1{col0} = 86) OR (#1{col0} = 94) OR (#1{col0} = 97)) AND ((#2{col1} < 20.99) OR (#2{col1} <= 30.14) OR (#1{col0} > 79) OR (#1{col0} >= 89) OR (#3{col3} >= 12) OR ((#3{col3} > 77) AND (#2{col1} >= 74.51)))) OR (#7 AND (#3{col3} <= 88)) OR ((#1{col0} < 68) AND (#1{col0} <= 35)) OR ((#2{col1} <= 17.96) AND (#7 OR ((#4{col4} <= 2.63) AND (#1{col0} > 2) AND (#3{col3} > 8)))) OR ((#4{col4} <= 97.11) AND ((#1{col0} = 11) OR (#1{col0} = 63) OR (#1{col0} = 85) OR (#1{col0} = 87) OR (#1{col0} = 88)))))) // { cardinality: \"\" } + Map ((#1{col0}) IS NULL) // { cardinality: \"\" } Join on=(#1 = #5) type=differential // { cardinality: \"\" } ArrangeBy keys=[[#1]] // { cardinality: \"\" } Project (#0..=#2, #4, #5) // { cardinality: \"\" } - Filter ((#1 > 3) OR ((#1 <= 88) AND (#1 > 5) AND ((#1 = 98) OR (#1 >= 30) OR (#7 AND (#4 <= 88)) OR ((#2) IS NULL AND (#4 < 48) AND (#5 < 86.27) AND (#1 <= 45) AND (#2 <= 10.7) AND (#4 > 49) AND (#4 > 66) AND (#5 > 42.2) AND (#1 >= 25) AND (#4 >= 49) AND (#4 >= 77) AND ((#1 = 67) OR (#1 = 81) OR (#1 = 86) OR (#1 = 94) OR (#1 = 97)) AND ((#2 < 20.99) OR (#2 <= 30.14) OR (#1 > 79) OR (#1 >= 89) OR (#4 >= 12) OR ((#4 > 77) AND (#2 >= 74.51)))) OR ((#1 < 68) AND (#1 <= 35)) OR ((#2 <= 17.96) AND (#7 OR ((#5 <= 2.63) AND (#1 > 2) AND (#4 > 8)))) OR ((#5 <= 97.11) AND ((#1 = 11) OR (#1 = 63) OR (#1 = 85) OR (#1 = 87) OR (#1 = 88)))))) // { cardinality: \"\" } - Map ((#1) IS NULL) // { cardinality: \"\" } + Filter ((#1{col0} > 3) OR ((#1{col0} <= 88) AND (#1{col0} > 5) AND ((#1{col0} = 98) OR (#1{col0} >= 30) OR (#7 AND (#4{col3} <= 88)) OR ((#2{col1}) IS NULL AND (#4{col3} < 48) AND (#5{col4} < 86.27) AND (#1{col0} <= 45) AND (#2{col1} <= 10.7) AND (#4{col3} > 49) AND (#4{col3} > 66) AND (#5{col4} > 42.2) AND (#1{col0} >= 25) AND (#4{col3} >= 49) AND (#4{col3} >= 77) AND ((#1{col0} = 67) OR (#1{col0} = 81) OR (#1{col0} = 86) OR (#1{col0} = 94) OR (#1{col0} = 97)) AND ((#2{col1} < 20.99) OR (#2{col1} <= 30.14) OR (#1{col0} > 79) OR (#1{col0} >= 89) OR (#4{col3} >= 12) OR ((#4{col3} > 77) AND (#2{col1} >= 74.51)))) OR ((#1{col0} < 68) AND (#1{col0} <= 35)) OR ((#2{col1} <= 17.96) AND (#7 OR ((#5{col4} <= 2.63) AND (#1{col0} > 2) AND (#4{col3} > 8)))) OR ((#5{col4} <= 97.11) AND ((#1{col0} = 11) OR (#1{col0} = 63) OR (#1{col0} = 85) OR (#1{col0} = 87) OR (#1{col0} = 88)))))) // { cardinality: \"\" } + Map ((#1{col0}) IS NULL) // { cardinality: \"\" } ReadStorage materialize.public.tab0 // { cardinality: \"\" } ArrangeBy keys=[[#0]] // { cardinality: \"\" } Union // { cardinality: \"\" } @@ -1005,6 +1005,67 @@ class KafkaScenario(Scenario): Source materialize.public.tab0 + Target cluster: quickstart + + ?[version<14300] EXPLAIN OPTIMIZED PLAN WITH(cardinality) AS VERBOSE TEXT FOR SELECT pk FROM tab0 WHERE col0 <= 88 AND (((col4 <= 97.11 AND col0 IN (11,85,87,63,88) OR (col0 <= 45 AND ((((((((col0 > 79)) OR col1 <= 30.14 OR col3 >= 12))) OR col0 >= 89 OR col1 < 20.99 OR col1 >= 74.51 AND col3 > 77) AND (col0 IN (67,97,94,86,81))) AND ((col1 <= 10.70 AND col1 IS NULL AND col3 > 49 AND col3 > 66 AND (((col4 > 42.2) AND ((((col4 < 86.27) AND col3 >= 77 AND col3 < 48))) AND col3 >= 49)) AND col0 IN (SELECT col3 FROM tab0 WHERE col4 BETWEEN 20.3 AND 97.63))) AND col0 >= 25) OR ((col0 <= 35)) AND col0 < 68 OR ((col0 = 98))) OR (col1 <= 17.96) AND ((((col0 IS NULL))) OR col4 <= 2.63 AND (col0 > 2) AND col3 > 8) OR col3 <= 88 AND (((col0 IS NULL))) OR col0 >= 30)) AND col0 > 5) OR col0 > 3; + Explained Query: + With + cte l0 = + Distinct project=[#0] // { cardinality: "" } + Project (#1) // { cardinality: "" } + ReadStorage materialize.public.tab0 // { cardinality: "" } + cte l1 = + Reduce group_by=[#0] aggregates=[any((#0 = #1))] // { cardinality: "" } + CrossJoin type=differential // { cardinality: "" } + ArrangeBy keys=[[]] // { cardinality: "" } + Get l0 // { cardinality: "" } + ArrangeBy keys=[[]] // { cardinality: "" } + Project (#4) // { cardinality: "" } + Filter (#5 <= 97.63) AND (#5 >= 20.3) // { cardinality: "" } + ReadStorage materialize.public.tab0 // { cardinality: "" } + cte l2 = + Union // { cardinality: "" } + Get l1 // { cardinality: "" } + Map (false) // { cardinality: "" } + Union // { cardinality: "" } + Negate // { cardinality: "" } + Project (#0) // { cardinality: "" } + Get l1 // { cardinality: "" } + Get l0 // { cardinality: "" } + Return // { cardinality: "" } + Project (#0) // { cardinality: "" } + Filter ((#1 > 3) OR ((#1 <= 88) AND (#1 > 5) AND ((#1 = 98) OR (#1 >= 30) OR (#6 AND (#2) IS NULL AND (#3 < 48) AND (#4 < 86.27) AND (#1 <= 45) AND (#2 <= 10.7) AND (#3 > 49) AND (#3 > 66) AND (#4 > 42.2) AND (#1 >= 25) AND (#3 >= 49) AND (#3 >= 77) AND ((#1 = 67) OR (#1 = 81) OR (#1 = 86) OR (#1 = 94) OR (#1 = 97)) AND ((#2 < 20.99) OR (#2 <= 30.14) OR (#1 > 79) OR (#1 >= 89) OR (#3 >= 12) OR ((#3 > 77) AND (#2 >= 74.51)))) OR (#7 AND (#3 <= 88)) OR ((#1 < 68) AND (#1 <= 35)) OR ((#2 <= 17.96) AND (#7 OR ((#4 <= 2.63) AND (#1 > 2) AND (#3 > 8)))) OR ((#4 <= 97.11) AND ((#1 = 11) OR (#1 = 63) OR (#1 = 85) OR (#1 = 87) OR (#1 = 88)))))) // { cardinality: "" } + Map ((#1) IS NULL) // { cardinality: "" } + Join on=(#1 = #5) type=differential // { cardinality: "" } + ArrangeBy keys=[[#1]] // { cardinality: "" } + Project (#0..=#2, #4, #5) // { cardinality: "" } + Filter ((#1 > 3) OR ((#1 <= 88) AND (#1 > 5) AND ((#1 = 98) OR (#1 >= 30) OR (#7 AND (#4 <= 88)) OR ((#2) IS NULL AND (#4 < 48) AND (#5 < 86.27) AND (#1 <= 45) AND (#2 <= 10.7) AND (#4 > 49) AND (#4 > 66) AND (#5 > 42.2) AND (#1 >= 25) AND (#4 >= 49) AND (#4 >= 77) AND ((#1 = 67) OR (#1 = 81) OR (#1 = 86) OR (#1 = 94) OR (#1 = 97)) AND ((#2 < 20.99) OR (#2 <= 30.14) OR (#1 > 79) OR (#1 >= 89) OR (#4 >= 12) OR ((#4 > 77) AND (#2 >= 74.51)))) OR ((#1 < 68) AND (#1 <= 35)) OR ((#2 <= 17.96) AND (#7 OR ((#5 <= 2.63) AND (#1 > 2) AND (#4 > 8)))) OR ((#5 <= 97.11) AND ((#1 = 11) OR (#1 = 63) OR (#1 = 85) OR (#1 = 87) OR (#1 = 88)))))) // { cardinality: "" } + Map ((#1) IS NULL) // { cardinality: "" } + ReadStorage materialize.public.tab0 // { cardinality: "" } + ArrangeBy keys=[[#0]] // { cardinality: "" } + Union // { cardinality: "" } + Filter ((#0 > 3) OR ((#0 <= 88) AND (#0 > 5) AND ((#0) IS NULL OR (#0 = 11) OR (#0 = 63) OR (#0 = 85) OR (#0 = 87) OR (#0 = 88) OR (#0 = 98) OR (#0 > 2) OR (#0 >= 30) OR (#1 AND (#0 <= 45) AND (#0 >= 25) AND ((#0 = 67) OR (#0 = 81) OR (#0 = 86) OR (#0 = 94) OR (#0 = 97))) OR ((#0 < 68) AND (#0 <= 35))))) // { cardinality: "" } + Get l2 // { cardinality: "" } + Project (#0, #18) // { cardinality: "" } + Filter (#2 OR (#3 AND #4 AND (#5 OR #6 OR #7 OR #8 OR #9 OR #10 OR #11 OR #12 OR #13 OR #17 OR (#14 AND #15 AND #16)))) AND (#2 OR (#3 AND #4 AND (#5 OR #6 OR #7 OR #8 OR #9 OR #10 OR #11 OR #12 OR #13 OR #17 OR (#14 AND #15 AND #16 AND null)))) // { cardinality: "" } + Map ((#0 > 3), (#0 <= 88), (#0 > 5), (#0) IS NULL, (#0 = 11), (#0 = 63), (#0 = 85), (#0 = 87), (#0 = 88), (#0 = 98), (#0 > 2), (#0 >= 30), (#0 <= 45), (#0 >= 25), ((#0 = 67) OR (#0 = 81) OR (#0 = 86) OR (#0 = 94) OR (#0 = 97)), ((#0 < 68) AND (#0 <= 35)), null) // { cardinality: "" } + Join on=(#0 = #1) type=differential // { cardinality: "" } + ArrangeBy keys=[[#0]] // { cardinality: "" } + Union // { cardinality: "" } + Negate // { cardinality: "" } + Project (#0) // { cardinality: "" } + Filter (#2 OR (#3 AND #4 AND (#5 OR #6 OR #7 OR #8 OR #9 OR #10 OR #11 OR #12 OR #13 OR #17 OR (#14 AND #15 AND #16)))) AND (#2 OR (#3 AND #4 AND (#5 OR #6 OR #7 OR #8 OR #9 OR #10 OR #11 OR #12 OR #13 OR #17 OR (#14 AND #15 AND #16 AND null)))) // { cardinality: "" } + Map ((#0 > 3), (#0 <= 88), (#0 > 5), (#0) IS NULL, (#0 = 11), (#0 = 63), (#0 = 85), (#0 = 87), (#0 = 88), (#0 = 98), (#0 > 2), (#0 >= 30), (#0 <= 45), (#0 >= 25), ((#0 = 67) OR (#0 = 81) OR (#0 = 86) OR (#0 = 94) OR (#0 = 97)), ((#0 < 68) AND (#0 <= 35))) // { cardinality: "" } + Get l2 // { cardinality: "" } + Project (#0) // { cardinality: "" } + Filter (#1 OR (#2 AND #3 AND (#4 OR #5 OR #6 OR #7 OR #8 OR #9 OR #10 OR #11 OR #12 OR #16 OR (#13 AND #14 AND #15)))) AND (#1 OR (#2 AND #3 AND (#4 OR #5 OR #6 OR #7 OR #8 OR #9 OR #10 OR #11 OR #12 OR #16 OR (#13 AND #14 AND #15 AND null)))) // { cardinality: "" } + Map ((#0 > 3), (#0 <= 88), (#0 > 5), (#0) IS NULL, (#0 = 11), (#0 = 63), (#0 = 85), (#0 = 87), (#0 = 88), (#0 = 98), (#0 > 2), (#0 >= 30), (#0 <= 45), (#0 >= 25), ((#0 = 67) OR (#0 = 81) OR (#0 = 86) OR (#0 = 94) OR (#0 = 97)), ((#0 < 68) AND (#0 <= 35))) // { cardinality: "" } + Get l0 // { cardinality: "" } + ArrangeBy keys=[[#0]] // { cardinality: "" } + Get l0 // { cardinality: "" } + + Source materialize.public.tab0 + Target cluster: quickstart """ ), @@ -1022,7 +1083,68 @@ class KafkaScenario(Scenario): 8 9 - ? EXPLAIN OPTIMIZED PLAN WITH(cardinality) AS VERBOSE TEXT FOR SELECT pk FROM tab0 WHERE col0 <= 88 AND (((col4 <= 97.11 AND col0 IN (11,85,87,63,88) OR (col0 <= 45 AND ((((((((col0 > 79)) OR col1 <= 30.14 OR col3 >= 12))) OR col0 >= 89 OR col1 < 20.99 OR col1 >= 74.51 AND col3 > 77) AND (col0 IN (67,97,94,86,81))) AND ((col1 <= 10.70 AND col1 IS NULL AND col3 > 49 AND col3 > 66 AND (((col4 > 42.2) AND ((((col4 < 86.27) AND col3 >= 77 AND col3 < 48))) AND col3 >= 49)) AND col0 IN (SELECT col3 FROM tab0 WHERE col4 BETWEEN 20.3 AND 97.63))) AND col0 >= 25) OR ((col0 <= 35)) AND col0 < 68 OR ((col0 = 98))) OR (col1 <= 17.96) AND ((((col0 IS NULL))) OR col4 <= 2.63 AND (col0 > 2) AND col3 > 8) OR col3 <= 88 AND (((col0 IS NULL))) OR col0 >= 30)) AND col0 > 5) OR col0 > 3; + ?[version>=14300] EXPLAIN OPTIMIZED PLAN WITH(cardinality) AS VERBOSE TEXT FOR SELECT pk FROM tab0 WHERE col0 <= 88 AND (((col4 <= 97.11 AND col0 IN (11,85,87,63,88) OR (col0 <= 45 AND ((((((((col0 > 79)) OR col1 <= 30.14 OR col3 >= 12))) OR col0 >= 89 OR col1 < 20.99 OR col1 >= 74.51 AND col3 > 77) AND (col0 IN (67,97,94,86,81))) AND ((col1 <= 10.70 AND col1 IS NULL AND col3 > 49 AND col3 > 66 AND (((col4 > 42.2) AND ((((col4 < 86.27) AND col3 >= 77 AND col3 < 48))) AND col3 >= 49)) AND col0 IN (SELECT col3 FROM tab0 WHERE col4 BETWEEN 20.3 AND 97.63))) AND col0 >= 25) OR ((col0 <= 35)) AND col0 < 68 OR ((col0 = 98))) OR (col1 <= 17.96) AND ((((col0 IS NULL))) OR col4 <= 2.63 AND (col0 > 2) AND col3 > 8) OR col3 <= 88 AND (((col0 IS NULL))) OR col0 >= 30)) AND col0 > 5) OR col0 > 3; + Explained Query: + With + cte l0 = + Distinct project=[#0] // { cardinality: \"\" } + Project (#1) // { cardinality: \"\" } + ReadStorage materialize.public.tab0 // { cardinality: \"\" } + cte l1 = + Reduce group_by=[#0] aggregates=[any((#0{col0} = #1{right_col0_0}))] // { cardinality: \"\" } + CrossJoin type=differential // { cardinality: \"\" } + ArrangeBy keys=[[]] // { cardinality: \"\" } + Get l0 // { cardinality: \"\" } + ArrangeBy keys=[[]] // { cardinality: \"\" } + Project (#4) // { cardinality: \"\" } + Filter (#5{col4} <= 97.63) AND (#5{col4} >= 20.3) // { cardinality: \"\" } + ReadStorage materialize.public.tab0 // { cardinality: \"\" } + cte l2 = + Union // { cardinality: \"\" } + Get l1 // { cardinality: \"\" } + Map (false) // { cardinality: \"\" } + Union // { cardinality: \"\" } + Negate // { cardinality: \"\" } + Project (#0) // { cardinality: \"\" } + Get l1 // { cardinality: \"\" } + Get l0 // { cardinality: \"\" } + Return // { cardinality: \"\" } + Project (#0) // { cardinality: \"\" } + Filter ((#1{col0} > 3) OR ((#1{col0} <= 88) AND (#1{col0} > 5) AND ((#1{col0} = 98) OR (#1{col0} >= 30) OR (#6 AND (#2{col1}) IS NULL AND (#3{col3} < 48) AND (#4{col4} < 86.27) AND (#1{col0} <= 45) AND (#2{col1} <= 10.7) AND (#3{col3} > 49) AND (#3{col3} > 66) AND (#4{col4} > 42.2) AND (#1{col0} >= 25) AND (#3{col3} >= 49) AND (#3{col3} >= 77) AND ((#1{col0} = 67) OR (#1{col0} = 81) OR (#1{col0} = 86) OR (#1{col0} = 94) OR (#1{col0} = 97)) AND ((#2{col1} < 20.99) OR (#2{col1} <= 30.14) OR (#1{col0} > 79) OR (#1{col0} >= 89) OR (#3{col3} >= 12) OR ((#3{col3} > 77) AND (#2{col1} >= 74.51)))) OR (#7 AND (#3{col3} <= 88)) OR ((#1{col0} < 68) AND (#1{col0} <= 35)) OR ((#2{col1} <= 17.96) AND (#7 OR ((#4{col4} <= 2.63) AND (#1{col0} > 2) AND (#3{col3} > 8)))) OR ((#4{col4} <= 97.11) AND ((#1{col0} = 11) OR (#1{col0} = 63) OR (#1{col0} = 85) OR (#1{col0} = 87) OR (#1{col0} = 88)))))) // { cardinality: \"\" } + Map ((#1{col0}) IS NULL) // { cardinality: \"\" } + Join on=(#1 = #5) type=differential // { cardinality: \"\" } + ArrangeBy keys=[[#1]] // { cardinality: \"\" } + Project (#0..=#2, #4, #5) // { cardinality: \"\" } + Filter ((#1{col0} > 3) OR ((#1{col0} <= 88) AND (#1{col0} > 5) AND ((#1{col0} = 98) OR (#1{col0} >= 30) OR (#7 AND (#4{col3} <= 88)) OR ((#2{col1}) IS NULL AND (#4{col3} < 48) AND (#5{col4} < 86.27) AND (#1{col0} <= 45) AND (#2{col1} <= 10.7) AND (#4{col3} > 49) AND (#4{col3} > 66) AND (#5{col4} > 42.2) AND (#1{col0} >= 25) AND (#4{col3} >= 49) AND (#4{col3} >= 77) AND ((#1{col0} = 67) OR (#1{col0} = 81) OR (#1{col0} = 86) OR (#1{col0} = 94) OR (#1{col0} = 97)) AND ((#2{col1} < 20.99) OR (#2{col1} <= 30.14) OR (#1{col0} > 79) OR (#1{col0} >= 89) OR (#4{col3} >= 12) OR ((#4{col3} > 77) AND (#2{col1} >= 74.51)))) OR ((#1{col0} < 68) AND (#1{col0} <= 35)) OR ((#2{col1} <= 17.96) AND (#7 OR ((#5{col4} <= 2.63) AND (#1{col0} > 2) AND (#4{col3} > 8)))) OR ((#5{col4} <= 97.11) AND ((#1{col0} = 11) OR (#1{col0} = 63) OR (#1{col0} = 85) OR (#1{col0} = 87) OR (#1{col0} = 88)))))) // { cardinality: \"\" } + Map ((#1{col0}) IS NULL) // { cardinality: \"\" } + ReadStorage materialize.public.tab0 // { cardinality: \"\" } + ArrangeBy keys=[[#0]] // { cardinality: \"\" } + Union // { cardinality: \"\" } + Filter ((#0 > 3) OR ((#0 <= 88) AND (#0 > 5) AND ((#0) IS NULL OR (#0 = 11) OR (#0 = 63) OR (#0 = 85) OR (#0 = 87) OR (#0 = 88) OR (#0 = 98) OR (#0 > 2) OR (#0 >= 30) OR (#1 AND (#0 <= 45) AND (#0 >= 25) AND ((#0 = 67) OR (#0 = 81) OR (#0 = 86) OR (#0 = 94) OR (#0 = 97))) OR ((#0 < 68) AND (#0 <= 35))))) // { cardinality: \"\" } + Get l2 // { cardinality: \"\" } + Project (#0, #18) // { cardinality: \"\" } + Filter (#2 OR (#3 AND #4 AND (#5 OR #6 OR #7 OR #8 OR #9 OR #10 OR #11 OR #12 OR #13 OR #17 OR (#14 AND #15 AND #16)))) AND (#2 OR (#3 AND #4 AND (#5 OR #6 OR #7 OR #8 OR #9 OR #10 OR #11 OR #12 OR #13 OR #17 OR (#14 AND #15 AND #16 AND null)))) // { cardinality: \"\" } + Map ((#0 > 3), (#0 <= 88), (#0 > 5), (#0) IS NULL, (#0 = 11), (#0 = 63), (#0 = 85), (#0 = 87), (#0 = 88), (#0 = 98), (#0 > 2), (#0 >= 30), (#0 <= 45), (#0 >= 25), ((#0 = 67) OR (#0 = 81) OR (#0 = 86) OR (#0 = 94) OR (#0 = 97)), ((#0 < 68) AND (#0 <= 35)), null) // { cardinality: \"\" } + Join on=(#0 = #1) type=differential // { cardinality: \"\" } + ArrangeBy keys=[[#0]] // { cardinality: \"\" } + Union // { cardinality: \"\" } + Negate // { cardinality: \"\" } + Project (#0) // { cardinality: \"\" } + Filter (#2 OR (#3 AND #4 AND (#5 OR #6 OR #7 OR #8 OR #9 OR #10 OR #11 OR #12 OR #13 OR #17 OR (#14 AND #15 AND #16)))) AND (#2 OR (#3 AND #4 AND (#5 OR #6 OR #7 OR #8 OR #9 OR #10 OR #11 OR #12 OR #13 OR #17 OR (#14 AND #15 AND #16 AND null)))) // { cardinality: \"\" } + Map ((#0 > 3), (#0 <= 88), (#0 > 5), (#0) IS NULL, (#0 = 11), (#0 = 63), (#0 = 85), (#0 = 87), (#0 = 88), (#0 = 98), (#0 > 2), (#0 >= 30), (#0 <= 45), (#0 >= 25), ((#0 = 67) OR (#0 = 81) OR (#0 = 86) OR (#0 = 94) OR (#0 = 97)), ((#0 < 68) AND (#0 <= 35))) // { cardinality: \"\" } + Get l2 // { cardinality: \"\" } + Project (#0) // { cardinality: \"\" } + Filter (#1 OR (#2 AND #3 AND (#4 OR #5 OR #6 OR #7 OR #8 OR #9 OR #10 OR #11 OR #12 OR #16 OR (#13 AND #14 AND #15)))) AND (#1 OR (#2 AND #3 AND (#4 OR #5 OR #6 OR #7 OR #8 OR #9 OR #10 OR #11 OR #12 OR #16 OR (#13 AND #14 AND #15 AND null)))) // { cardinality: \"\" } + Map ((#0 > 3), (#0 <= 88), (#0 > 5), (#0) IS NULL, (#0 = 11), (#0 = 63), (#0 = 85), (#0 = 87), (#0 = 88), (#0 = 98), (#0 > 2), (#0 >= 30), (#0 <= 45), (#0 >= 25), ((#0 = 67) OR (#0 = 81) OR (#0 = 86) OR (#0 = 94) OR (#0 = 97)), ((#0 < 68) AND (#0 <= 35))) // { cardinality: \"\" } + Get l0 // { cardinality: \"\" } + ArrangeBy keys=[[#0]] // { cardinality: \"\" } + Get l0 // { cardinality: \"\" } + + Source materialize.public.tab0 + + Target cluster: quickstart + + ?[version<14300] EXPLAIN OPTIMIZED PLAN WITH(cardinality) AS VERBOSE TEXT FOR SELECT pk FROM tab0 WHERE col0 <= 88 AND (((col4 <= 97.11 AND col0 IN (11,85,87,63,88) OR (col0 <= 45 AND ((((((((col0 > 79)) OR col1 <= 30.14 OR col3 >= 12))) OR col0 >= 89 OR col1 < 20.99 OR col1 >= 74.51 AND col3 > 77) AND (col0 IN (67,97,94,86,81))) AND ((col1 <= 10.70 AND col1 IS NULL AND col3 > 49 AND col3 > 66 AND (((col4 > 42.2) AND ((((col4 < 86.27) AND col3 >= 77 AND col3 < 48))) AND col3 >= 49)) AND col0 IN (SELECT col3 FROM tab0 WHERE col4 BETWEEN 20.3 AND 97.63))) AND col0 >= 25) OR ((col0 <= 35)) AND col0 < 68 OR ((col0 = 98))) OR (col1 <= 17.96) AND ((((col0 IS NULL))) OR col4 <= 2.63 AND (col0 > 2) AND col3 > 8) OR col3 <= 88 AND (((col0 IS NULL))) OR col0 >= 30)) AND col0 > 5) OR col0 > 3; Explained Query: With cte l0 = diff --git a/test/testdrive-old-kafka-src-syntax/monotonic.td b/test/testdrive-old-kafka-src-syntax/monotonic.td index 2e1efc45f7d16..ff53c18c08ea1 100644 --- a/test/testdrive-old-kafka-src-syntax/monotonic.td +++ b/test/testdrive-old-kafka-src-syntax/monotonic.td @@ -79,7 +79,7 @@ a min max $ set-regex match=(.User.:\s\d+|\(u\d+\)) replacement=UID -? EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v2 +?[version>=14300] EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v2 Explained Query: TopK::MonotonicTopK order_by=[#0 asc nulls_last] limit=3 must_consolidate ArrangeBy @@ -95,6 +95,22 @@ Used Indexes: Target cluster: quickstart +?[version<14300] EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v2 +Explained Query: + TopK::MonotonicTopK order_by=[#0 asc nulls_last] limit=3 must_consolidate + ArrangeBy + input_key=[#0] + raw=true + Get::PassArrangements materialize.public.i1 + raw=false + arrangements[0]={ key=[#0], permutation=id, thinning=() } + types=[bigint] + +Used Indexes: + - materialize.public.i1_primary_idx (*** full scan ***) + +Target cluster: quickstart + > CREATE SOURCE non_dbz_data_indexed IN CLUSTER ${arg.single-replica-cluster} FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-non-dbz-data-${testdrive.seed}') @@ -107,7 +123,7 @@ Target cluster: quickstart > CREATE VIEW v3 AS SELECT * FROM non_dbz_data_indexed ORDER BY b LIMIT 3 -? EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v3 +?[version>=14300] EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v3 Explained Query: TopK::MonotonicTopK order_by=[#1 asc nulls_last] limit=3 must_consolidate ArrangeBy @@ -123,6 +139,22 @@ Used Indexes: Target cluster: quickstart +?[version<14300] EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v3 +Explained Query: + TopK::MonotonicTopK order_by=[#1 asc nulls_last] limit=3 must_consolidate + ArrangeBy + input_key=[#0, #1] + raw=true + Get::PassArrangements materialize.public.non_dbz_data_indexed + raw=false + arrangements[0]={ key=[#0, #1], permutation=id, thinning=() } + types=[bigint, bigint] + +Used Indexes: + - materialize.public.non_dbz_data_indexed_primary_idx (*** full scan ***) + +Target cluster: quickstart + > CREATE VIEW i4 AS SELECT b+1 as c FROM i1; > CREATE DEFAULT INDEX ON i4; @@ -130,7 +162,7 @@ Target cluster: quickstart > CREATE VIEW v5 AS SELECT * from i4 ORDER BY c LIMIT 2; -? EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v5; +?[version>=14300] EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v5; Explained Query: TopK::MonotonicTopK order_by=[#0 asc nulls_last] limit=2 must_consolidate ArrangeBy @@ -146,6 +178,22 @@ Used Indexes: Target cluster: quickstart +?[version<14300] EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v5; +Explained Query: + TopK::MonotonicTopK order_by=[#0 asc nulls_last] limit=2 must_consolidate + ArrangeBy + input_key=[#0] + raw=true + Get::PassArrangements materialize.public.i4 + raw=false + arrangements[0]={ key=[#0], permutation=id, thinning=() } + types=[bigint] + +Used Indexes: + - materialize.public.i4_primary_idx (*** full scan ***) + +Target cluster: quickstart + > CREATE VIEW i6 AS SELECT c FROM v5; > CREATE DEFAULT INDEX ON i6; @@ -153,7 +201,7 @@ Target cluster: quickstart > CREATE VIEW v7 AS SELECT * from i6 ORDER BY c LIMIT 2; -? EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v7; +?[version>=14300] EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v7; Explained Query: TopK::MonotonicTopK order_by=[#0 asc nulls_last] limit=2 must_consolidate ArrangeBy @@ -169,6 +217,22 @@ Used Indexes: Target cluster: quickstart +?[version<14300] EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v7; +Explained Query: + TopK::MonotonicTopK order_by=[#0 asc nulls_last] limit=2 must_consolidate + ArrangeBy + input_key=[#0] + raw=true + Get::PassArrangements materialize.public.i6 + raw=false + arrangements[0]={ key=[#0], permutation=id, thinning=() } + types=[bigint] + +Used Indexes: + - materialize.public.i6_primary_idx (*** full scan ***) + +Target cluster: quickstart + > CREATE VIEW i8 AS SELECT * from (SELECT * FROM i1 UNION ALL SELECT * FROM i1); > CREATE DEFAULT INDEX ON i8; @@ -179,7 +243,7 @@ Target cluster: quickstart # Propagating monotonicity analysis in a complex situation: (i1, i1) -> i8; (i1, i8) -> i9 -? EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v10; +?[version>=14300] EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v10; Explained Query: TopK::MonotonicTopK order_by=[#0 asc nulls_last] limit=2 must_consolidate ArrangeBy @@ -195,6 +259,22 @@ Used Indexes: Target cluster: quickstart +?[version<14300] EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v10; +Explained Query: + TopK::MonotonicTopK order_by=[#0 asc nulls_last] limit=2 must_consolidate + ArrangeBy + input_key=[#0] + raw=true + Get::PassArrangements materialize.public.i9 + raw=false + arrangements[0]={ key=[#0], permutation=id, thinning=() } + types=[bigint] + +Used Indexes: + - materialize.public.i9_primary_idx (*** full scan ***) + +Target cluster: quickstart + # _No_ propagation of monotonicity through materialized views. > CREATE MATERIALIZED VIEW m1 AS SELECT b FROM non_dbz_data; diff --git a/test/testdrive-old-kafka-src-syntax/primary-key-optimizations.td b/test/testdrive-old-kafka-src-syntax/primary-key-optimizations.td index f32cbae03de51..e80beeb731706 100644 --- a/test/testdrive-old-kafka-src-syntax/primary-key-optimizations.td +++ b/test/testdrive-old-kafka-src-syntax/primary-key-optimizations.td @@ -264,7 +264,18 @@ Used Indexes: Target cluster: quickstart -?[version>=13500] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT DISTINCT key1, upper(key2) FROM t1; +?[version>=14300] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT DISTINCT key1, upper(key2) FROM t1; +Explained Query: + Distinct project=[#0, upper(#1{key2})] + Project (#0, #1) + ReadIndex on=t1 t1_primary_idx=[*** full scan ***] + +Used Indexes: + - t1_primary_idx (*** full scan ***) + +Target cluster: quickstart + +?[13500<=version<14300] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT DISTINCT key1, upper(key2) FROM t1; Explained Query: Distinct project=[#0, upper(#1)] Project (#0, #1) @@ -286,7 +297,18 @@ Used Indexes: Target cluster: quickstart -?[version>=13500] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT DISTINCT key1, key2 || 'a' FROM t1; +?[14300<=version] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT DISTINCT key1, key2 || 'a' FROM t1; +Explained Query: + Distinct project=[#0, (#1{key2} || "a")] + Project (#0, #1) + ReadIndex on=t1 t1_primary_idx=[*** full scan ***] + +Used Indexes: + - t1_primary_idx (*** full scan ***) + +Target cluster: quickstart + +?[13500<=version<14300] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT DISTINCT key1, key2 || 'a' FROM t1; Explained Query: Distinct project=[#0, (#1 || "a")] Project (#0, #1) @@ -353,6 +375,29 @@ Used Indexes: Target cluster: quickstart ?[version>=13500] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT COUNT(DISTINCT key1) FROM t1; +Explained Query: + With + cte l0 = + Reduce aggregates=[count(distinct #0{key1})] + Project (#0) + ReadIndex on=t1 t1_primary_idx=[*** full scan ***] + Return + Union + Get l0 + Map (0) + Union + Negate + Project () + Get l0 + Constant + - () + +Used Indexes: + - t1_primary_idx (*** full scan ***) + +Target cluster: quickstart + +?[13500<=version<14300] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT COUNT(DISTINCT key1) FROM t1; Explained Query: With cte l0 = @@ -776,7 +821,19 @@ Used Indexes: Target cluster: quickstart -?[version>=13500] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT DISTINCT key1, upper(key2) FROM t1_pkne; +?[version>=14300] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT DISTINCT key1, upper(key2) FROM t1_pkne; +Explained Query: + Distinct project=[#0, upper(#1{key2})] monotonic + Project (#0, #1) + ReadIndex on=t1_pkne t1_pkne_primary_idx=[*** full scan ***] + +Used Indexes: + - t1_pkne_primary_idx (*** full scan ***) + +Target cluster: quickstart + + +?[13500<=version<14300] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT DISTINCT key1, upper(key2) FROM t1_pkne; Explained Query: Distinct project=[#0, upper(#1)] monotonic Project (#0, #1) @@ -798,7 +855,18 @@ Used Indexes: Target cluster: quickstart -?[version>=13500] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT DISTINCT key1, key2 || 'a' FROM t1_pkne; +?[version>=14300] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT DISTINCT key1, key2 || 'a' FROM t1_pkne; +Explained Query: + Distinct project=[#0, (#1{key2} || "a")] monotonic + Project (#0, #1) + ReadIndex on=t1_pkne t1_pkne_primary_idx=[*** full scan ***] + +Used Indexes: + - t1_pkne_primary_idx (*** full scan ***) + +Target cluster: quickstart + +?[13500<=version<14300] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT DISTINCT key1, key2 || 'a' FROM t1_pkne; Explained Query: Distinct project=[#0, (#1 || "a")] monotonic Project (#0, #1) @@ -864,7 +932,30 @@ Used Indexes: Target cluster: quickstart -?[version>=13500] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT COUNT(DISTINCT key1) FROM t1_pkne; +?[version>=14300] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT COUNT(DISTINCT key1) FROM t1_pkne; +Explained Query: + With + cte l0 = + Reduce aggregates=[count(distinct #0{key1})] monotonic + Project (#0) + ReadIndex on=t1_pkne t1_pkne_primary_idx=[*** full scan ***] + Return + Union + Get l0 + Map (0) + Union + Negate + Project () + Get l0 + Constant + - () + +Used Indexes: + - t1_pkne_primary_idx (*** full scan ***) + +Target cluster: quickstart + +?[13500<=version<14300] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT COUNT(DISTINCT key1) FROM t1_pkne; Explained Query: With cte l0 = diff --git a/test/testdrive-old-kafka-src-syntax/testdrive.td b/test/testdrive-old-kafka-src-syntax/testdrive.td index e1f8d6f957cc3..504e85e2dac01 100644 --- a/test/testdrive-old-kafka-src-syntax/testdrive.td +++ b/test/testdrive-old-kafka-src-syntax/testdrive.td @@ -45,7 +45,20 @@ row 2 $ set-regex match=u\d+ replacement=UID -?[version>=13500] EXPLAIN OPTIMIZED PLAN AS VERBOSE TEXT FOR SELECT * FROM t1 AS a1, t1 AS a2 WHERE a1.f1 IS NOT NULL; +?[version>=14300] EXPLAIN OPTIMIZED PLAN AS VERBOSE TEXT FOR SELECT * FROM t1 AS a1, t1 AS a2 WHERE a1.f1 IS NOT NULL; +Explained Query: + CrossJoin type=differential + ArrangeBy keys=[[]] + Filter (#0{f1}) IS NOT NULL + ReadStorage materialize.public.t1 + ArrangeBy keys=[[]] + ReadStorage materialize.public.t1 + +Source materialize.public.t1 + +Target cluster: quickstart + +?[13500<=version<14300] EXPLAIN OPTIMIZED PLAN AS VERBOSE TEXT FOR SELECT * FROM t1 AS a1, t1 AS a2 WHERE a1.f1 IS NOT NULL; Explained Query: CrossJoin type=differential ArrangeBy keys=[[]] From 61dbb85ca12d5cfbe99283f7aeb549ced96abff1 Mon Sep 17 00:00:00 2001 From: Michael Greenberg Date: Wed, 23 Apr 2025 18:36:47 -0400 Subject: [PATCH 03/14] address @ggevay's comments --- src/expr/src/scalar.rs | 4 ++-- src/ore/src/treat_as_equal.rs | 4 +++- src/sql/src/plan/hir.rs | 15 ++++++++++++--- src/sql/src/plan/query.rs | 24 +++++++++--------------- src/sql/src/plan/scope.rs | 4 +++- src/sql/src/pure/postgres.rs | 2 +- 6 files changed, 30 insertions(+), 23 deletions(-) diff --git a/src/expr/src/scalar.rs b/src/expr/src/scalar.rs index 798ef692080b1..9c3008b002e54 100644 --- a/src/expr/src/scalar.rs +++ b/src/expr/src/scalar.rs @@ -282,8 +282,8 @@ impl MirScalarExpr { MirScalarExpr::Column(column, TreatAsEqual(None)) } - pub fn named_column(column: usize, name: Option>) -> Self { - MirScalarExpr::Column(column, TreatAsEqual(name)) + pub fn named_column(column: usize, name: Arc) -> Self { + MirScalarExpr::Column(column, TreatAsEqual(Some(name))) } pub fn literal(res: Result, typ: ScalarType) -> Self { diff --git a/src/ore/src/treat_as_equal.rs b/src/ore/src/treat_as_equal.rs index 660d1397e55d0..692e226cabe8d 100644 --- a/src/ore/src/treat_as_equal.rs +++ b/src/ore/src/treat_as_equal.rs @@ -21,7 +21,7 @@ use std::cmp::Ordering; use std::hash::{Hash, Hasher}; /// Behaves like `T`, but has trivial `Hash`, `Eq`, `MzReflect`, and `Ord` -/// implementations. Does not appear in `Debug` output. +/// implementations. Does not appear in `Debug` output, but _is_ serialized. #[derive(Clone, Default, Derivative)] #[derivative(Debug = "transparent")] pub struct TreatAsEqual(pub T); @@ -50,6 +50,8 @@ impl Ord for TreatAsEqual { } } +// We define the serializer to not bother recording the `TreatAsEqual` newtype +// constructor to reduce noise. impl Serialize for TreatAsEqual { fn serialize(&self, serializer: S) -> Result { self.0.serialize(serializer) diff --git a/src/sql/src/plan/hir.rs b/src/sql/src/plan/hir.rs index 53bff13f0158a..96c2d77086012 100644 --- a/src/sql/src/plan/hir.rs +++ b/src/sql/src/plan/hir.rs @@ -2967,7 +2967,9 @@ impl HirScalarExpr { contains } - /// Constructs a column reference in the current scope. + /// Constructs an unnamed column reference in the current scope. + /// Use [`HirScalarExpr::named_column`] when a name is known. + /// Use [`HirScalarExpr::unnamed_column`] for a [`ColumnRef`]. pub fn column(index: usize) -> HirScalarExpr { HirScalarExpr::Column( ColumnRef { @@ -2978,8 +2980,15 @@ impl HirScalarExpr { ) } - pub fn named_column(cr: ColumnRef, name: Option>) -> HirScalarExpr { - HirScalarExpr::Column(cr, TreatAsEqual(name)) + /// Constructs an unnamed column reference. + pub fn unnamed_column(cr: ColumnRef) -> HirScalarExpr { + HirScalarExpr::Column(cr, TreatAsEqual(None)) + } + + /// Constructs a named column reference. + /// Names are interned by a [`NameManager`]. + pub fn named_column(cr: ColumnRef, name: Arc) -> HirScalarExpr { + HirScalarExpr::Column(cr, TreatAsEqual(Some(name))) } pub fn parameter(n: usize) -> HirScalarExpr { diff --git a/src/sql/src/plan/query.rs b/src/sql/src/plan/query.rs index 028d400cb5dba..e18f4296ac14c 100644 --- a/src/sql/src/plan/query.rs +++ b/src/sql/src/plan/query.rs @@ -2608,9 +2608,6 @@ fn plan_select_from_where( for ord in order_by.iter().take(distinct_exprs.len()) { // The unusual construction of `expr` here is to ensure the // temporary column expression lives long enough. - // - // We then have to make sure we do a `NamelessHirScalarExpr` - // comparison, since this raw column reference has no name information. let mut expr = &HirScalarExpr::column(ord.column); if ord.column >= arity { expr = &map_exprs[ord.column - arity]; @@ -3779,11 +3776,11 @@ fn plan_using_constraint( vec![ CoercibleScalarExpr::Coerced(HirScalarExpr::named_column( lhs, - Some(Arc::clone(&lhs_name)), + Arc::clone(&lhs_name), )), CoercibleScalarExpr::Coerced(HirScalarExpr::named_column( rhs, - Some(Arc::clone(&rhs_name)), + Arc::clone(&rhs_name), )), ], None, @@ -3830,10 +3827,7 @@ fn plan_using_constraint( // Should be safe to use either `lhs` or `rhs` here since the column // is available in both scopes and must have the same type of the new item. // We (arbitrarily) choose the left name. - map_exprs.push(HirScalarExpr::named_column( - lhs, - Some(Arc::clone(&lhs_name)), - )); + map_exprs.push(HirScalarExpr::named_column(lhs, Arc::clone(&lhs_name))); } join_exprs.push(expr1.call_binary(expr2, BinaryFunc::Eq)); @@ -3880,7 +3874,7 @@ fn plan_expr_inner<'a>( // We've already calculated this expression. return Ok(HirScalarExpr::named_column( i, - Some(ecx.qcx.name_manager.borrow_mut().intern_scope_item(item)), + ecx.qcx.name_manager.borrow_mut().intern_scope_item(item), ) .into()); } @@ -5092,7 +5086,7 @@ fn plan_identifier(ecx: &ExprContext, names: &[Ident]) -> Result Result { - return Ok(HirScalarExpr::named_column(i, Some(i_name))); + return Ok(HirScalarExpr::named_column(i, i_name)); } Err(PlanError::UnknownColumn { similar, .. }) => similar, Err(e) => return Err(e), @@ -5132,7 +5126,7 @@ fn plan_identifier(ecx: &ExprContext, names: &[Ident]) -> Result Ok(HirScalarExpr::named_column( *column, - Some(ecx.qcx.name_manager.borrow_mut().intern_scope_item(item)), + ecx.qcx.name_manager.borrow_mut().intern_scope_item(item), )), // The name refers to a normal table. Return a record containing all the // columns of the table. @@ -5147,7 +5141,7 @@ fn plan_identifier(ecx: &ExprContext, names: &[Ident]) -> Result Result( &'a self, outer_scopes: &[Scope], diff --git a/src/sql/src/pure/postgres.rs b/src/sql/src/pure/postgres.rs index 3b00c59d1fb7b..5defe3d3a00c8 100644 --- a/src/sql/src/pure/postgres.rs +++ b/src/sql/src/pure/postgres.rs @@ -544,7 +544,7 @@ pub(crate) fn generate_column_casts( level: 0, column: i, }, - Some(Arc::from(column.name.as_str())), + Arc::from(column.name.as_str()), ); let cast_expr = plan_cast(&cast_ecx, CastContext::Explicit, col_expr, &scalar_type)?; From 20e61328731af721d26b494331bb1c60fe3671c3 Mon Sep 17 00:00:00 2001 From: Michael Greenberg Date: Wed, 23 Apr 2025 18:44:28 -0400 Subject: [PATCH 04/14] re-use column names in some lowering, per @ggevay --- src/sql/src/plan/lowering.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sql/src/plan/lowering.rs b/src/sql/src/plan/lowering.rs index 7fdacb57d410d..19dc2b8355f8f 100644 --- a/src/sql/src/plan/lowering.rs +++ b/src/sql/src/plan/lowering.rs @@ -1018,7 +1018,7 @@ impl HirScalarExpr { cond, then, els, - name: _, + name, } => { // The `If` case is complicated by the fact that we do not want to // apply the `then` or `else` logic to tuples that respectively do @@ -1112,7 +1112,7 @@ impl HirScalarExpr { Ok::(then_inner.union(else_inner)) })?; - SS::column(inner_arity) + SS::Column(inner_arity, name) } } @@ -1127,7 +1127,7 @@ impl HirScalarExpr { // When the subquery would return 0 rows for some row in the outer query, `subquery.applied_to(get_inner)` will not have any corresponding row. // Use `lookup` if you need to add default values for cases when the subquery returns 0 rows. - Exists(expr, _name) => { + Exists(expr, name) => { let apply_requires_distinct_outer = true; *inner = apply_existential_subquery( id_gen, @@ -1138,10 +1138,10 @@ impl HirScalarExpr { apply_requires_distinct_outer, context, )?; - SS::column(inner.arity() - 1) + SS::Column(inner.arity() - 1, name) } - Select(expr, _name) => { + Select(expr, name) => { let apply_requires_distinct_outer = true; *inner = apply_scalar_subquery( id_gen, @@ -1152,7 +1152,7 @@ impl HirScalarExpr { apply_requires_distinct_outer, context, )?; - SS::column(inner.arity() - 1) + SS::Column(inner.arity() - 1, name) } Windowing(expr, _name) => { let partition_by = expr.partition_by; From 4a4774ff71eea68b2fda3d27a09c44dadc00fdcc Mon Sep 17 00:00:00 2001 From: Michael Greenberg Date: Wed, 30 Apr 2025 12:04:57 -0400 Subject: [PATCH 05/14] fix doc refs --- src/sql/src/plan/hir.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sql/src/plan/hir.rs b/src/sql/src/plan/hir.rs index 96c2d77086012..08811d2241d27 100644 --- a/src/sql/src/plan/hir.rs +++ b/src/sql/src/plan/hir.rs @@ -2969,7 +2969,7 @@ impl HirScalarExpr { /// Constructs an unnamed column reference in the current scope. /// Use [`HirScalarExpr::named_column`] when a name is known. - /// Use [`HirScalarExpr::unnamed_column`] for a [`ColumnRef`]. + /// Use [`HirScalarExpr::unnamed_column`] for a `ColumnRef`. pub fn column(index: usize) -> HirScalarExpr { HirScalarExpr::Column( ColumnRef { @@ -2986,7 +2986,7 @@ impl HirScalarExpr { } /// Constructs a named column reference. - /// Names are interned by a [`NameManager`]. + /// Names are interned by a `NameManager`. pub fn named_column(cr: ColumnRef, name: Arc) -> HirScalarExpr { HirScalarExpr::Column(cr, TreatAsEqual(Some(name))) } From 4f7c51e75825e844755012341dd83690b58c5f70 Mon Sep 17 00:00:00 2001 From: Michael Greenberg Date: Wed, 30 Apr 2025 12:12:11 -0400 Subject: [PATCH 06/14] add version bound docs per @def- --- doc/developer/testdrive.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/doc/developer/testdrive.md b/doc/developer/testdrive.md index e4c0fce928e57..8489d90e71d0c 100644 --- a/doc/developer/testdrive.md +++ b/doc/developer/testdrive.md @@ -943,5 +943,21 @@ SELECT mz_version_num() < 2601; The `[version>=13000]` property allows running the action or query only when we are connected to a Materialize instance with a compatible version. The supported comparison operators are `>`, `>=`, `=`, `<=` and `<`. The version number is the same as returned from [`mz_version_num()`](https://materialize.com/docs/sql/functions/#system-information-func) and has the same format `XXXYYYZZ`, where `XX` is the major version, `YYY` is the minor version and `ZZ` is the patch version. So in the example we are only running the `SELECT 1` query if the Materialize instance is of version `v0.130.0` or higher. For lower versions no query is run and no comparison of results is performed subsequently. +You can bound the version above and below using the following syntax: + +``` +?[13500<=version<14300] SELECT 1; +1 +``` + +You can use `<` or `<=` freely. The following are equivalent: + +``` +?[version<14300] SELECT 1; +1 +?[14300>version] SELECT 1; +1 +``` + [confluent-arm]: https://github.com/confluentinc/common-docker/issues/117#issuecomment-948789717 [aws-creds]: https://github.com/MaterializeInc/i2/blob/main/doc/aws-access.md From 0616f73abd5c6d15bc02e43070d2959276687fd2 Mon Sep 17 00:00:00 2001 From: Michael Greenberg Date: Wed, 30 Apr 2025 14:57:01 -0400 Subject: [PATCH 07/14] address @ggevay's buggy name regression --- src/expr/src/explain/text.rs | 9 +-- src/transform/src/analysis.rs | 12 ++-- test/sqllogictest/github-31878.slt | 103 +++++++++++++++++++++++++++++ test/sqllogictest/mzcompose.py | 1 + 4 files changed, 116 insertions(+), 9 deletions(-) create mode 100644 test/sqllogictest/github-31878.slt diff --git a/src/expr/src/explain/text.rs b/src/expr/src/explain/text.rs index 5db392ac2840a..0c39516791ccd 100644 --- a/src/expr/src/explain/text.rs +++ b/src/expr/src/explain/text.rs @@ -1192,10 +1192,11 @@ where M::humanize_ident(*self.expr.0, ident, f) } // We don't have name inferred for this column. - _ => { - // Write the stored name. - write!(f, "#{}{{{}}}", self.expr.0, self.expr.1) - } + _ => M::humanize_ident( + *self.expr.0, + Ident::new_unchecked(self.expr.1.to_string()), + f, + ), } } } diff --git a/src/transform/src/analysis.rs b/src/transform/src/analysis.rs index f894a04402bc0..b3560e9de51cb 100644 --- a/src/transform/src/analysis.rs +++ b/src/transform/src/analysis.rs @@ -959,12 +959,14 @@ mod column_names { } impl ColumnName { - /// Return `true` iff this the variant is not unknown. + /// Return `true` iff the variant has an inferred name. pub fn is_known(&self) -> bool { - matches!( - self, - Self::Global(..) | Self::Aggregate(..) | Self::Annotated(..) - ) + match self { + Self::Global(..) | Self::Aggregate(..) => true, + // We treat annotated columns as unknown because we would rather + // override them with inferred names, if we can. + Self::Annotated(..) | Self::Unknown => false, + } } /// Humanize the column to a [`String`], returns an empty [`String`] for diff --git a/test/sqllogictest/github-31878.slt b/test/sqllogictest/github-31878.slt new file mode 100644 index 0000000000000..8c4e3fbc8bffa --- /dev/null +++ b/test/sqllogictest/github-31878.slt @@ -0,0 +1,103 @@ +# Copyright Materialize, Inc. and contributors. All rights reserved. +# +# Use of this software is governed by the Business Source License +# included in the LICENSE file at the root of this repository. +# +# As of the Change Date specified in that file, in accordance with +# the Business Source License, use of this software will be governed +# by the Apache License, Version 2.0. + +mode cockroach + +statement ok +create table t1(x int, y int); + +query T multiline +EXPLAIN OPTIMIZED PLAN WITH (humanized expressions, column names) AS VERBOSE TEXT FOR +select sum(x) + 5 as s from t1; +---- +Explained Query: + With + cte l0 = + Reduce aggregates=[sum(#0{x})] // { column_names: "(sum_x)" } + Project (#0{x}) // { column_names: "(x)" } + ReadStorage materialize.public.t1 // { column_names: "(x, y)" } + Return // { column_names: "(#0)" } + Project (#1) // { column_names: "(#0)" } + Map ((#0{sum_x} + 5)) // { column_names: "(sum_x, #1)" } + Union // { column_names: "(sum_x)" } + Get l0 // { column_names: "(sum_x)" } + Map (null) // { column_names: "(#0)" } + Union // { column_names: "()" } + Negate // { column_names: "()" } + Project () // { column_names: "()" } + Get l0 // { column_names: "(sum_x)" } + Constant // { column_names: "()" } + - () + +Source materialize.public.t1 + +Target cluster: quickstart + +EOF + +query T multiline +EXPLAIN OPTIMIZED PLAN WITH (humanized expressions) AS VERBOSE TEXT FOR +select sum(x) + 5 as s from t1; +---- +Explained Query: + With + cte l0 = + Reduce aggregates=[sum(#0{x})] + Project (#0{x}) + ReadStorage materialize.public.t1 + Return + Project (#1) + Map ((#0{sum_x} + 5)) + Union + Get l0 + Map (null) + Union + Negate + Project () + Get l0 + Constant + - () + +Source materialize.public.t1 + +Target cluster: quickstart + +EOF + +# NB no humanized expressions means we won't infer any column names +# but we _will_ get to keep the annotated names (for better or worse) + +query T multiline +EXPLAIN OPTIMIZED PLAN WITH (humanized expressions = false) AS VERBOSE TEXT FOR +select sum(x) + 5 as s from t1; +---- +Explained Query: + With + cte l0 = + Reduce aggregates=[sum(#0{x})] + Project (#0) + ReadStorage materialize.public.t1 + Return + Project (#1) + Map ((#0{"?column?"} + 5)) + Union + Get l0 + Map (null) + Union + Negate + Project () + Get l0 + Constant + - () + +Source materialize.public.t1 + +Target cluster: quickstart + +EOF diff --git a/test/sqllogictest/mzcompose.py b/test/sqllogictest/mzcompose.py index ecd7e1453a52b..56211071e2ade 100644 --- a/test/sqllogictest/mzcompose.py +++ b/test/sqllogictest/mzcompose.py @@ -262,6 +262,7 @@ def compileFastSltConfig() -> SltRunConfig: "test/sqllogictest/github-5536.slt", "test/sqllogictest/github-5717.slt", "test/sqllogictest/github-7585.slt", + "test/sqllogictest/github-31878.slt", "test/sqllogictest/id.slt", "test/sqllogictest/id_reuse.slt", "test/sqllogictest/information_schema_columns.slt", From 601b15a5a56449e0e522f4acb7be7ace6022a436 Mon Sep 17 00:00:00 2001 From: Michael Greenberg Date: Wed, 30 Apr 2025 15:08:43 -0400 Subject: [PATCH 08/14] lt, gt... let's call the whole thing off --- doc/developer/testdrive.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/developer/testdrive.md b/doc/developer/testdrive.md index 8489d90e71d0c..1ae6f1e449dae 100644 --- a/doc/developer/testdrive.md +++ b/doc/developer/testdrive.md @@ -953,9 +953,9 @@ You can bound the version above and below using the following syntax: You can use `<` or `<=` freely. The following are equivalent: ``` -?[version<14300] SELECT 1; +?[version>14300] SELECT 1; 1 -?[14300>version] SELECT 1; +?[14300 Date: Wed, 30 Apr 2025 15:51:50 -0400 Subject: [PATCH 09/14] proper quoting of identifiers --- src/expr/src/explain/text.rs | 6 +----- test/sqllogictest/advent-of-code/2023/aoc_1205.slt | 2 +- .../sqllogictest/explain/decorrelated_plan_as_text.slt | 4 ++-- test/sqllogictest/explain/physical_plan_aggregates.slt | 10 +++++----- test/sqllogictest/github-5126.slt | 2 +- test/sqllogictest/ldbc_bi.slt | 4 ++-- test/sqllogictest/ldbc_bi_eager.slt | 4 ++-- test/sqllogictest/not-null-propagation.slt | 2 +- test/sqllogictest/reduce_mfp.slt | 6 +++--- .../fold_vs_dataflow/2_number_fns_dataflow.slt | 2 +- .../transform/fold_vs_dataflow/6_bytea_dataflow.slt | 2 +- test/sqllogictest/transform/predicate_pushdown.slt | 2 +- 12 files changed, 21 insertions(+), 25 deletions(-) diff --git a/src/expr/src/explain/text.rs b/src/expr/src/explain/text.rs index 0c39516791ccd..c67eec9c760dd 100644 --- a/src/expr/src/explain/text.rs +++ b/src/expr/src/explain/text.rs @@ -1192,11 +1192,7 @@ where M::humanize_ident(*self.expr.0, ident, f) } // We don't have name inferred for this column. - _ => M::humanize_ident( - *self.expr.0, - Ident::new_unchecked(self.expr.1.to_string()), - f, - ), + _ => M::humanize_ident(*self.expr.0, Ident::new_unchecked(self.expr.1.as_ref()), f), } } } diff --git a/test/sqllogictest/advent-of-code/2023/aoc_1205.slt b/test/sqllogictest/advent-of-code/2023/aoc_1205.slt index 23df1f1907888..2492396f62f95 100644 --- a/test/sqllogictest/advent-of-code/2023/aoc_1205.slt +++ b/test/sqllogictest/advent-of-code/2023/aoc_1205.slt @@ -1240,7 +1240,7 @@ Explained Query: Distinct project=[#0..=#2] // { arity: 3 } Union // { arity: 3 } Project (#6, #4, #5) // { arity: 3 } - Map (regexp_split_to_array[" ", case_insensitive=false](btrim(#0{body})), (2 * #1{x}), text_to_bigint(array_index(#2, integer_to_bigint((#3 - 1)))), (#4{?column?} + text_to_bigint(array_index(#2, integer_to_bigint(#3)))), "seed") // { arity: 7 } + Map (regexp_split_to_array[" ", case_insensitive=false](btrim(#0{body})), (2 * #1{x}), text_to_bigint(array_index(#2, integer_to_bigint((#3 - 1)))), (#4{"?column?"} + text_to_bigint(array_index(#2, integer_to_bigint(#3)))), "seed") // { arity: 7 } FlatMap generate_series(1, ((regexp_split_to_array[" ", case_insensitive=false](btrim(#0{body})) array_length 1) / 2), 1) // { arity: 2 } Get l3 // { arity: 1 } Project (#1, #10, #11) // { arity: 3 } diff --git a/test/sqllogictest/explain/decorrelated_plan_as_text.slt b/test/sqllogictest/explain/decorrelated_plan_as_text.slt index f189bb2be9830..f3fc9e8ea28e3 100644 --- a/test/sqllogictest/explain/decorrelated_plan_as_text.slt +++ b/test/sqllogictest/explain/decorrelated_plan_as_text.slt @@ -186,7 +186,7 @@ With Get materialize.public.t Return Project (#2) - Map (abs((#0{?column?} - #1{?column?}))) + Map (abs((#0{"?column?"} - #1{"?column?"}))) Union Get l0 CrossJoin @@ -214,7 +214,7 @@ EXPLAIN DECORRELATED PLAN AS TEXT FOR SELECT abs(min(a) - max(a)) FROM t GROUP BY b ---- Project (#3) - Map (abs((#1{?column?} - #2{?column?}))) + Map (abs((#1{"?column?"} - #2{"?column?"}))) Reduce group_by=[#2] aggregates=[min(#0{a}), max(#0{a})] Project (#0..=#2) Map (#1{b}) diff --git a/test/sqllogictest/explain/physical_plan_aggregates.slt b/test/sqllogictest/explain/physical_plan_aggregates.slt index 11babd8c698b0..27ee869dfd445 100644 --- a/test/sqllogictest/explain/physical_plan_aggregates.slt +++ b/test/sqllogictest/explain/physical_plan_aggregates.slt @@ -208,7 +208,7 @@ Explained Query: delta_stage[0] closure project=(#0, #1) - filter=((#2{?column?} > 1)) + filter=((#2{"?column?"} > 1)) lookup={ relation=1, key=[#0] } stream={ key=[#0], thinning=(#1) } source={ relation=0, key=[#0] } @@ -225,7 +225,7 @@ Explained Query: stream={ key=[#0], thinning=() } initial_closure project=(#0) - filter=((#1{?column?} > 1)) + filter=((#1{"?column?"} > 1)) source={ relation=1, key=[#0] } plan_path[2] delta_stage[1] @@ -234,7 +234,7 @@ Explained Query: delta_stage[0] closure project=(#0, #1) - filter=((#2{?column?} > 1)) + filter=((#2{"?column?"} > 1)) lookup={ relation=1, key=[#0] } stream={ key=[#0], thinning=(#1) } source={ relation=2, key=[#0] } @@ -408,7 +408,7 @@ Explained Query: Return Mfp project=(#0, #1, #3) - map=((#2{?column?} > 0)) + map=((#2{"?column?"} > 0)) Union Get::Collection l1 project=(#1, #2, #0) @@ -583,7 +583,7 @@ Explained Query: linear_stage[0] closure project=(#0, #1) - ready_equivalences=#2{?column?} = #1{?column?} + ready_equivalences=#2{"?column?"} = #1{"?column?"} lookup={ relation=1, key=[#0] } stream={ key=[#0], thinning=(#1) } source={ relation=0, key=[#0] } diff --git a/test/sqllogictest/github-5126.slt b/test/sqllogictest/github-5126.slt index 4fd320b24ef0e..e9548fe655348 100644 --- a/test/sqllogictest/github-5126.slt +++ b/test/sqllogictest/github-5126.slt @@ -79,7 +79,7 @@ Return // { arity: 3 } Join on=(#1 = #3) // { arity: 7 } Get l0 // { arity: 3 } Project (#0, #3..=#5) // { arity: 4 } - Map ((#3{?column?} * 2)) // { arity: 6 } + Map ((#3{"?column?"} * 2)) // { arity: 6 } Project (#0..=#2, #7, #8) // { arity: 5 } Map ((#0{f2} * #1{f2}), #6) // { arity: 9 } Join on=(#0 = #3 AND #1 = #4 AND #2 = #5) // { arity: 7 } diff --git a/test/sqllogictest/ldbc_bi.slt b/test/sqllogictest/ldbc_bi.slt index 54d970a0ff65f..75052ee60b2e8 100644 --- a/test/sqllogictest/ldbc_bi.slt +++ b/test/sqllogictest/ldbc_bi.slt @@ -556,7 +556,7 @@ Explained Query: ReadIndex on=message message_messageid=[delta join lookup] // { arity: 13 } Return // { arity: 4 } Project (#0{name}, #3..=#5) // { arity: 4 } - Map (coalesce(#1{count}, 0), coalesce(#2{count}, 0), abs((#3{?column?} - #4{?column?}))) // { arity: 6 } + Map (coalesce(#1{count}, 0), coalesce(#2{count}, 0), abs((#3{"?column?"} - #4{"?column?"}))) // { arity: 6 } Union // { arity: 3 } Map (null, null) // { arity: 3 } Union // { arity: 1 } @@ -1495,7 +1495,7 @@ Explained Query: Project (#0{id}, #0{id}, #1{count}) // { arity: 3 } Get l5 // { arity: 2 } Return // { arity: 5 } - Map (coalesce(#2{sum}, 0), (bigint_to_numeric(#1{score}) + #3{?column?})) // { arity: 5 } + Map (coalesce(#2{sum}, 0), (bigint_to_numeric(#1{score}) + #3{"?column?"})) // { arity: 5 } Reduce group_by=[#0, #1] aggregates=[sum(case when (#3) IS NULL then null else #2 end)] // { arity: 3 } Project (#0, #1, #6, #7) // { arity: 4 } Join on=(#0 = #2{person1id} AND #5{person2id} = case when (#4) IS NULL then null else #3{person2id} end) type=delta // { arity: 8 } diff --git a/test/sqllogictest/ldbc_bi_eager.slt b/test/sqllogictest/ldbc_bi_eager.slt index d1edd49ebc5d3..302319b487b19 100644 --- a/test/sqllogictest/ldbc_bi_eager.slt +++ b/test/sqllogictest/ldbc_bi_eager.slt @@ -563,7 +563,7 @@ Explained Query: ReadIndex on=message message_messageid=[delta join lookup] // { arity: 13 } Return // { arity: 4 } Project (#0{name}, #3..=#5) // { arity: 4 } - Map (coalesce(#1{count}, 0), coalesce(#2{count}, 0), abs((#3{?column?} - #4{?column?}))) // { arity: 6 } + Map (coalesce(#1{count}, 0), coalesce(#2{count}, 0), abs((#3{"?column?"} - #4{"?column?"}))) // { arity: 6 } Union // { arity: 3 } Map (null, null) // { arity: 3 } Union // { arity: 1 } @@ -1502,7 +1502,7 @@ Explained Query: Project (#0{id}, #0{id}, #1{count}) // { arity: 3 } Get l5 // { arity: 2 } Return // { arity: 5 } - Map (coalesce(#2{sum}, 0), (bigint_to_numeric(#1{score}) + #3{?column?})) // { arity: 5 } + Map (coalesce(#2{sum}, 0), (bigint_to_numeric(#1{score}) + #3{"?column?"})) // { arity: 5 } Reduce group_by=[#0, #1] aggregates=[sum(case when (#3) IS NULL then null else #2 end)] // { arity: 3 } Project (#0, #1, #6, #7) // { arity: 4 } Join on=(#0 = #2{person1id} AND #5{person2id} = case when (#4) IS NULL then null else #3{person2id} end) type=delta // { arity: 8 } diff --git a/test/sqllogictest/not-null-propagation.slt b/test/sqllogictest/not-null-propagation.slt index db3125b40fc8f..e8fc2d029a5e3 100644 --- a/test/sqllogictest/not-null-propagation.slt +++ b/test/sqllogictest/not-null-propagation.slt @@ -785,7 +785,7 @@ Explained Query: Distinct project=[] // { types: "()" } Get l0 // { types: "()" } Return // { types: "(boolean, boolean)" } - Map (NOT(#0{?column?})) // { types: "(boolean, boolean)" } + Map (NOT(#0{"?column?"})) // { types: "(boolean, boolean)" } CrossJoin type=differential // { types: "(boolean)" } ArrangeBy keys=[[]] // { types: "()" } Get l0 // { types: "()" } diff --git a/test/sqllogictest/reduce_mfp.slt b/test/sqllogictest/reduce_mfp.slt index ed387e3aa5e22..71c9a971d11a4 100644 --- a/test/sqllogictest/reduce_mfp.slt +++ b/test/sqllogictest/reduce_mfp.slt @@ -54,7 +54,7 @@ materialize.public.mv_fusable_mfp_accumulable: mfp_after project=(#0, #1) filter=(((#3 - integer_to_bigint(#0{a})) > 2) AND ((#3 / integer_to_bigint((1 + #0{a}))) >= 1)) - map=((#2{?column?} + 1)) + map=((#2{"?column?"} + 1)) Get::PassArrangements materialize.public.t raw=true @@ -85,7 +85,7 @@ MATERIALIZED VIEW mv_complex_mfp_accumulable; materialize.public.mv_complex_mfp_accumulable: Mfp project=(#0, #3) - map=((#1{?column?} + 1)) + map=((#1{"?column?"} + 1)) input_key=#0 Reduce::Accumulable simple_aggrs[0]=(0, 0, sum(#1{b})) @@ -96,7 +96,7 @@ materialize.public.mv_complex_mfp_accumulable: project=(#0) mfp_after filter=(((#3 - integer_to_bigint(#0{a})) > 2) AND ((#3 / integer_to_bigint((1 + #0{a}))) >= 1)) - map=((#2{?column?} + 1)) + map=((#2{"?column?"} + 1)) Get::PassArrangements materialize.public.t raw=true diff --git a/test/sqllogictest/transform/fold_vs_dataflow/2_number_fns_dataflow.slt b/test/sqllogictest/transform/fold_vs_dataflow/2_number_fns_dataflow.slt index 663a78c9e4ddf..399e1cdded9ee 100644 --- a/test/sqllogictest/transform/fold_vs_dataflow/2_number_fns_dataflow.slt +++ b/test/sqllogictest/transform/fold_vs_dataflow/2_number_fns_dataflow.slt @@ -75,7 +75,7 @@ FROM t_using_dataflow_rendering; ---- Explained Query: Project (#0{real1}, #5..=#20, #0{real1}..=#2{numeric1}, #21..=#26, #28, #30, #32..=#44, #27, #29, #31, #0{real1}..=#2{numeric1}) - Map ((#0{real1} + 1), (#0{real1} - 1), (#0{real1} + 0), (#1{double1} + 0), (#2{numeric1} + 0), (#0{real1} + #0{real1}), (#1{double1} + #1{double1}), (#2{numeric1} + #2{numeric1}), sqrtf64(real_to_double(#0{real1})), sqrtf64(#1{double1}), sqrtnumeric(#2{numeric1}), sqrtf64(real_to_double(#10{?column?})), sqrtf64(#11{?column?}), sqrtnumeric(#12{?column?}), (#3{tint1} / #4{tint2}), (#4{tint2} / #3{tint1}), greatest(#0{real1}, 1), greatest(#1{double1}, 1), greatest(#2{numeric1}, 1), least(#0{real1}, 100000000000000000000000000000000000000), least(#1{double1}, 100000000000000000000000000000000000000), least(#2{numeric1}, 100000000000000000000000000000000000000), (#0{real1} = 100000000000000000000000000000000000000), case when #27 then null else #0{real1} end, (#1{double1} = 100000000000000000000000000000000000000), case when #29 then null else #1{double1} end, (#2{numeric1} = 100000000000000000000000000000000000000), case when #31 then null else #2{numeric1} end, (#0{real1} <= 100000000000000000000000000000000000000), (#1{double1} <= 100000000000000000000000000000000000000), (#2{numeric1} <= 100000000000000000000000000000000000000), (#0{real1} >= 100000000000000000000000000000000000000), (#1{double1} >= 100000000000000000000000000000000000000), (#2{numeric1} >= 100000000000000000000000000000000000000), (#0{real1} < 100000000000000000000000000000000000000), (#1{double1} < 100000000000000000000000000000000000000), (#2{numeric1} < 100000000000000000000000000000000000000), (#0{real1} > 100000000000000000000000000000000000000), (#1{double1} > 100000000000000000000000000000000000000), (#2{numeric1} > 100000000000000000000000000000000000000)) + Map ((#0{real1} + 1), (#0{real1} - 1), (#0{real1} + 0), (#1{double1} + 0), (#2{numeric1} + 0), (#0{real1} + #0{real1}), (#1{double1} + #1{double1}), (#2{numeric1} + #2{numeric1}), sqrtf64(real_to_double(#0{real1})), sqrtf64(#1{double1}), sqrtnumeric(#2{numeric1}), sqrtf64(real_to_double(#10{"?column?"})), sqrtf64(#11{"?column?"}), sqrtnumeric(#12{"?column?"}), (#3{tint1} / #4{tint2}), (#4{tint2} / #3{tint1}), greatest(#0{real1}, 1), greatest(#1{double1}, 1), greatest(#2{numeric1}, 1), least(#0{real1}, 100000000000000000000000000000000000000), least(#1{double1}, 100000000000000000000000000000000000000), least(#2{numeric1}, 100000000000000000000000000000000000000), (#0{real1} = 100000000000000000000000000000000000000), case when #27 then null else #0{real1} end, (#1{double1} = 100000000000000000000000000000000000000), case when #29 then null else #1{double1} end, (#2{numeric1} = 100000000000000000000000000000000000000), case when #31 then null else #2{numeric1} end, (#0{real1} <= 100000000000000000000000000000000000000), (#1{double1} <= 100000000000000000000000000000000000000), (#2{numeric1} <= 100000000000000000000000000000000000000), (#0{real1} >= 100000000000000000000000000000000000000), (#1{double1} >= 100000000000000000000000000000000000000), (#2{numeric1} >= 100000000000000000000000000000000000000), (#0{real1} < 100000000000000000000000000000000000000), (#1{double1} < 100000000000000000000000000000000000000), (#2{numeric1} < 100000000000000000000000000000000000000), (#0{real1} > 100000000000000000000000000000000000000), (#1{double1} > 100000000000000000000000000000000000000), (#2{numeric1} > 100000000000000000000000000000000000000)) ReadStorage materialize.public.t_using_dataflow_rendering Source materialize.public.t_using_dataflow_rendering diff --git a/test/sqllogictest/transform/fold_vs_dataflow/6_bytea_dataflow.slt b/test/sqllogictest/transform/fold_vs_dataflow/6_bytea_dataflow.slt index 1d355d34a4e02..f2f5e1da20058 100644 --- a/test/sqllogictest/transform/fold_vs_dataflow/6_bytea_dataflow.slt +++ b/test/sqllogictest/transform/fold_vs_dataflow/6_bytea_dataflow.slt @@ -34,7 +34,7 @@ FROM t_using_dataflow_rendering; ---- Explained Query: Project (#1, #2) - Map (text_to_bytea(#0{f1}), digest(#1{?column?}, "sha512")) + Map (text_to_bytea(#0{f1}), digest(#1{"?column?"}, "sha512")) ReadStorage materialize.public.t_using_dataflow_rendering Source materialize.public.t_using_dataflow_rendering diff --git a/test/sqllogictest/transform/predicate_pushdown.slt b/test/sqllogictest/transform/predicate_pushdown.slt index aed48809c2891..bbea07cfb2fb2 100644 --- a/test/sqllogictest/transform/predicate_pushdown.slt +++ b/test/sqllogictest/transform/predicate_pushdown.slt @@ -1057,7 +1057,7 @@ WHERE r1 * r1 * r1 * r1 * r1 * r1 * r1 * r1 * r1 * r1 * r1 * r1 * r1 > 5; ---- Explained Query: Filter (((((((((((((#4{r1} * #4{r1}) * #4{r1}) * #4{r1}) * #4{r1}) * #4{r1}) * #4{r1}) * #4{r1}) * #4{r1}) * #4{r1}) * #4{r1}) * #4{r1}) * #4{r1}) > 5) - Map ((#0{x} * #1{y}), (#2{?column?} + 1), ((((((((((((((((((((((((((#0{x} + #1{y}) + #2{z1}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2})) + Map ((#0{x} * #1{y}), (#2{"?column?"} + 1), ((((((((((((((((((((((((((#0{x} + #1{y}) + #2{z1}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2}) + #3{z2})) ReadStorage materialize.public.t Source materialize.public.t From 65451244309f4180b8f45ded275e1d8bc5cffcb4 Mon Sep 17 00:00:00 2001 From: Michael Greenberg Date: Wed, 30 Apr 2025 15:54:11 -0400 Subject: [PATCH 10/14] bump version tests, as time inexorably marches on --- .../checks/all_checks/explain_catalog_item.py | 4 ++-- test/bounded-memory/mzcompose.py | 8 +++---- .../load-generator-key-value.td | 2 +- .../load-generator.td | 2 +- .../monotonic.td | 20 ++++++++--------- .../primary-key-optimizations.td | 22 +++++++++---------- .../testdrive.td | 4 ++-- 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/misc/python/materialize/checks/all_checks/explain_catalog_item.py b/misc/python/materialize/checks/all_checks/explain_catalog_item.py index 0283d38c3f0c0..8952e82492dae 100644 --- a/misc/python/materialize/checks/all_checks/explain_catalog_item.py +++ b/misc/python/materialize/checks/all_checks/explain_catalog_item.py @@ -74,7 +74,7 @@ def validate(self) -> Testdrive: Target cluster: quickstart - ?[version>=14300] EXPLAIN OPTIMIZED PLAN AS VERBOSE TEXT FOR MATERIALIZED VIEW explain_mv2; + ?[version>=14400] EXPLAIN OPTIMIZED PLAN AS VERBOSE TEXT FOR MATERIALIZED VIEW explain_mv2; materialize.public.explain_mv2: Filter (#1{y} = 7) ReadStorage materialize.public.explain_item_t2 @@ -85,7 +85,7 @@ def validate(self) -> Testdrive: Target cluster: quickstart - ?[13500<=version<14300] EXPLAIN OPTIMIZED PLAN AS VERBOSE TEXT FOR MATERIALIZED VIEW explain_mv2; + ?[13500<=version<14400] EXPLAIN OPTIMIZED PLAN AS VERBOSE TEXT FOR MATERIALIZED VIEW explain_mv2; materialize.public.explain_mv2: Filter (#1 = 7) ReadStorage materialize.public.explain_item_t2 diff --git a/test/bounded-memory/mzcompose.py b/test/bounded-memory/mzcompose.py index ef2177af6f6de..dfbe9af0451d7 100644 --- a/test/bounded-memory/mzcompose.py +++ b/test/bounded-memory/mzcompose.py @@ -946,7 +946,7 @@ class KafkaScenario(Scenario): 8 9 - ?[version>=14300] EXPLAIN OPTIMIZED PLAN WITH(cardinality) AS VERBOSE TEXT FOR SELECT pk FROM tab0 WHERE col0 <= 88 AND (((col4 <= 97.11 AND col0 IN (11,85,87,63,88) OR (col0 <= 45 AND ((((((((col0 > 79)) OR col1 <= 30.14 OR col3 >= 12))) OR col0 >= 89 OR col1 < 20.99 OR col1 >= 74.51 AND col3 > 77) AND (col0 IN (67,97,94,86,81))) AND ((col1 <= 10.70 AND col1 IS NULL AND col3 > 49 AND col3 > 66 AND (((col4 > 42.2) AND ((((col4 < 86.27) AND col3 >= 77 AND col3 < 48))) AND col3 >= 49)) AND col0 IN (SELECT col3 FROM tab0 WHERE col4 BETWEEN 20.3 AND 97.63))) AND col0 >= 25) OR ((col0 <= 35)) AND col0 < 68 OR ((col0 = 98))) OR (col1 <= 17.96) AND ((((col0 IS NULL))) OR col4 <= 2.63 AND (col0 > 2) AND col3 > 8) OR col3 <= 88 AND (((col0 IS NULL))) OR col0 >= 30)) AND col0 > 5) OR col0 > 3; + ?[version>=14400] EXPLAIN OPTIMIZED PLAN WITH(cardinality) AS VERBOSE TEXT FOR SELECT pk FROM tab0 WHERE col0 <= 88 AND (((col4 <= 97.11 AND col0 IN (11,85,87,63,88) OR (col0 <= 45 AND ((((((((col0 > 79)) OR col1 <= 30.14 OR col3 >= 12))) OR col0 >= 89 OR col1 < 20.99 OR col1 >= 74.51 AND col3 > 77) AND (col0 IN (67,97,94,86,81))) AND ((col1 <= 10.70 AND col1 IS NULL AND col3 > 49 AND col3 > 66 AND (((col4 > 42.2) AND ((((col4 < 86.27) AND col3 >= 77 AND col3 < 48))) AND col3 >= 49)) AND col0 IN (SELECT col3 FROM tab0 WHERE col4 BETWEEN 20.3 AND 97.63))) AND col0 >= 25) OR ((col0 <= 35)) AND col0 < 68 OR ((col0 = 98))) OR (col1 <= 17.96) AND ((((col0 IS NULL))) OR col4 <= 2.63 AND (col0 > 2) AND col3 > 8) OR col3 <= 88 AND (((col0 IS NULL))) OR col0 >= 30)) AND col0 > 5) OR col0 > 3; Explained Query: With cte l0 = @@ -1007,7 +1007,7 @@ class KafkaScenario(Scenario): Target cluster: quickstart - ?[version<14300] EXPLAIN OPTIMIZED PLAN WITH(cardinality) AS VERBOSE TEXT FOR SELECT pk FROM tab0 WHERE col0 <= 88 AND (((col4 <= 97.11 AND col0 IN (11,85,87,63,88) OR (col0 <= 45 AND ((((((((col0 > 79)) OR col1 <= 30.14 OR col3 >= 12))) OR col0 >= 89 OR col1 < 20.99 OR col1 >= 74.51 AND col3 > 77) AND (col0 IN (67,97,94,86,81))) AND ((col1 <= 10.70 AND col1 IS NULL AND col3 > 49 AND col3 > 66 AND (((col4 > 42.2) AND ((((col4 < 86.27) AND col3 >= 77 AND col3 < 48))) AND col3 >= 49)) AND col0 IN (SELECT col3 FROM tab0 WHERE col4 BETWEEN 20.3 AND 97.63))) AND col0 >= 25) OR ((col0 <= 35)) AND col0 < 68 OR ((col0 = 98))) OR (col1 <= 17.96) AND ((((col0 IS NULL))) OR col4 <= 2.63 AND (col0 > 2) AND col3 > 8) OR col3 <= 88 AND (((col0 IS NULL))) OR col0 >= 30)) AND col0 > 5) OR col0 > 3; + ?[version<14400] EXPLAIN OPTIMIZED PLAN WITH(cardinality) AS VERBOSE TEXT FOR SELECT pk FROM tab0 WHERE col0 <= 88 AND (((col4 <= 97.11 AND col0 IN (11,85,87,63,88) OR (col0 <= 45 AND ((((((((col0 > 79)) OR col1 <= 30.14 OR col3 >= 12))) OR col0 >= 89 OR col1 < 20.99 OR col1 >= 74.51 AND col3 > 77) AND (col0 IN (67,97,94,86,81))) AND ((col1 <= 10.70 AND col1 IS NULL AND col3 > 49 AND col3 > 66 AND (((col4 > 42.2) AND ((((col4 < 86.27) AND col3 >= 77 AND col3 < 48))) AND col3 >= 49)) AND col0 IN (SELECT col3 FROM tab0 WHERE col4 BETWEEN 20.3 AND 97.63))) AND col0 >= 25) OR ((col0 <= 35)) AND col0 < 68 OR ((col0 = 98))) OR (col1 <= 17.96) AND ((((col0 IS NULL))) OR col4 <= 2.63 AND (col0 > 2) AND col3 > 8) OR col3 <= 88 AND (((col0 IS NULL))) OR col0 >= 30)) AND col0 > 5) OR col0 > 3; Explained Query: With cte l0 = @@ -1083,7 +1083,7 @@ class KafkaScenario(Scenario): 8 9 - ?[version>=14300] EXPLAIN OPTIMIZED PLAN WITH(cardinality) AS VERBOSE TEXT FOR SELECT pk FROM tab0 WHERE col0 <= 88 AND (((col4 <= 97.11 AND col0 IN (11,85,87,63,88) OR (col0 <= 45 AND ((((((((col0 > 79)) OR col1 <= 30.14 OR col3 >= 12))) OR col0 >= 89 OR col1 < 20.99 OR col1 >= 74.51 AND col3 > 77) AND (col0 IN (67,97,94,86,81))) AND ((col1 <= 10.70 AND col1 IS NULL AND col3 > 49 AND col3 > 66 AND (((col4 > 42.2) AND ((((col4 < 86.27) AND col3 >= 77 AND col3 < 48))) AND col3 >= 49)) AND col0 IN (SELECT col3 FROM tab0 WHERE col4 BETWEEN 20.3 AND 97.63))) AND col0 >= 25) OR ((col0 <= 35)) AND col0 < 68 OR ((col0 = 98))) OR (col1 <= 17.96) AND ((((col0 IS NULL))) OR col4 <= 2.63 AND (col0 > 2) AND col3 > 8) OR col3 <= 88 AND (((col0 IS NULL))) OR col0 >= 30)) AND col0 > 5) OR col0 > 3; + ?[version>=14400] EXPLAIN OPTIMIZED PLAN WITH(cardinality) AS VERBOSE TEXT FOR SELECT pk FROM tab0 WHERE col0 <= 88 AND (((col4 <= 97.11 AND col0 IN (11,85,87,63,88) OR (col0 <= 45 AND ((((((((col0 > 79)) OR col1 <= 30.14 OR col3 >= 12))) OR col0 >= 89 OR col1 < 20.99 OR col1 >= 74.51 AND col3 > 77) AND (col0 IN (67,97,94,86,81))) AND ((col1 <= 10.70 AND col1 IS NULL AND col3 > 49 AND col3 > 66 AND (((col4 > 42.2) AND ((((col4 < 86.27) AND col3 >= 77 AND col3 < 48))) AND col3 >= 49)) AND col0 IN (SELECT col3 FROM tab0 WHERE col4 BETWEEN 20.3 AND 97.63))) AND col0 >= 25) OR ((col0 <= 35)) AND col0 < 68 OR ((col0 = 98))) OR (col1 <= 17.96) AND ((((col0 IS NULL))) OR col4 <= 2.63 AND (col0 > 2) AND col3 > 8) OR col3 <= 88 AND (((col0 IS NULL))) OR col0 >= 30)) AND col0 > 5) OR col0 > 3; Explained Query: With cte l0 = @@ -1144,7 +1144,7 @@ class KafkaScenario(Scenario): Target cluster: quickstart - ?[version<14300] EXPLAIN OPTIMIZED PLAN WITH(cardinality) AS VERBOSE TEXT FOR SELECT pk FROM tab0 WHERE col0 <= 88 AND (((col4 <= 97.11 AND col0 IN (11,85,87,63,88) OR (col0 <= 45 AND ((((((((col0 > 79)) OR col1 <= 30.14 OR col3 >= 12))) OR col0 >= 89 OR col1 < 20.99 OR col1 >= 74.51 AND col3 > 77) AND (col0 IN (67,97,94,86,81))) AND ((col1 <= 10.70 AND col1 IS NULL AND col3 > 49 AND col3 > 66 AND (((col4 > 42.2) AND ((((col4 < 86.27) AND col3 >= 77 AND col3 < 48))) AND col3 >= 49)) AND col0 IN (SELECT col3 FROM tab0 WHERE col4 BETWEEN 20.3 AND 97.63))) AND col0 >= 25) OR ((col0 <= 35)) AND col0 < 68 OR ((col0 = 98))) OR (col1 <= 17.96) AND ((((col0 IS NULL))) OR col4 <= 2.63 AND (col0 > 2) AND col3 > 8) OR col3 <= 88 AND (((col0 IS NULL))) OR col0 >= 30)) AND col0 > 5) OR col0 > 3; + ?[version<14400] EXPLAIN OPTIMIZED PLAN WITH(cardinality) AS VERBOSE TEXT FOR SELECT pk FROM tab0 WHERE col0 <= 88 AND (((col4 <= 97.11 AND col0 IN (11,85,87,63,88) OR (col0 <= 45 AND ((((((((col0 > 79)) OR col1 <= 30.14 OR col3 >= 12))) OR col0 >= 89 OR col1 < 20.99 OR col1 >= 74.51 AND col3 > 77) AND (col0 IN (67,97,94,86,81))) AND ((col1 <= 10.70 AND col1 IS NULL AND col3 > 49 AND col3 > 66 AND (((col4 > 42.2) AND ((((col4 < 86.27) AND col3 >= 77 AND col3 < 48))) AND col3 >= 49)) AND col0 IN (SELECT col3 FROM tab0 WHERE col4 BETWEEN 20.3 AND 97.63))) AND col0 >= 25) OR ((col0 <= 35)) AND col0 < 68 OR ((col0 = 98))) OR (col1 <= 17.96) AND ((((col0 IS NULL))) OR col4 <= 2.63 AND (col0 > 2) AND col3 > 8) OR col3 <= 88 AND (((col0 IS NULL))) OR col0 >= 30)) AND col0 > 5) OR col0 > 3; Explained Query: With cte l0 = diff --git a/test/testdrive-old-kafka-src-syntax/load-generator-key-value.td b/test/testdrive-old-kafka-src-syntax/load-generator-key-value.td index 9d198c48f0ffd..0cea0b7e1c7dd 100644 --- a/test/testdrive-old-kafka-src-syntax/load-generator-key-value.td +++ b/test/testdrive-old-kafka-src-syntax/load-generator-key-value.td @@ -19,7 +19,7 @@ ALTER SYSTEM SET enable_load_generator_key_value = true > CREATE CLUSTER lg_cluster SIZE '${arg.default-replica-size}' $ skip-if -SELECT mz_version_num() < 14300; +SELECT mz_version_num() < 14400; # Error if trying to create with subsources ! CREATE SOURCE g FROM LOAD GENERATOR KEY VALUE( diff --git a/test/testdrive-old-kafka-src-syntax/load-generator.td b/test/testdrive-old-kafka-src-syntax/load-generator.td index e47fa8595ac7b..9ba50ffd9a1ac 100644 --- a/test/testdrive-old-kafka-src-syntax/load-generator.td +++ b/test/testdrive-old-kafka-src-syntax/load-generator.td @@ -51,7 +51,7 @@ exact:COUNTER load generators do not support SCALE FACTOR values FROM LOAD GENERATOR AUCTION (AS OF 300, UP TO 301); $ skip-if -SELECT mz_version_num() < 14300; +SELECT mz_version_num() < 14400; # Error if trying to create with subsources ! CREATE SOURCE g FROM LOAD GENERATOR COUNTER FOR ALL TABLES; diff --git a/test/testdrive-old-kafka-src-syntax/monotonic.td b/test/testdrive-old-kafka-src-syntax/monotonic.td index ff53c18c08ea1..7f9b8a42d1e23 100644 --- a/test/testdrive-old-kafka-src-syntax/monotonic.td +++ b/test/testdrive-old-kafka-src-syntax/monotonic.td @@ -79,7 +79,7 @@ a min max $ set-regex match=(.User.:\s\d+|\(u\d+\)) replacement=UID -?[version>=14300] EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v2 +?[version>=14400] EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v2 Explained Query: TopK::MonotonicTopK order_by=[#0 asc nulls_last] limit=3 must_consolidate ArrangeBy @@ -95,7 +95,7 @@ Used Indexes: Target cluster: quickstart -?[version<14300] EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v2 +?[version<14400] EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v2 Explained Query: TopK::MonotonicTopK order_by=[#0 asc nulls_last] limit=3 must_consolidate ArrangeBy @@ -123,7 +123,7 @@ Target cluster: quickstart > CREATE VIEW v3 AS SELECT * FROM non_dbz_data_indexed ORDER BY b LIMIT 3 -?[version>=14300] EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v3 +?[version>=14400] EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v3 Explained Query: TopK::MonotonicTopK order_by=[#1 asc nulls_last] limit=3 must_consolidate ArrangeBy @@ -139,7 +139,7 @@ Used Indexes: Target cluster: quickstart -?[version<14300] EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v3 +?[version<14400] EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v3 Explained Query: TopK::MonotonicTopK order_by=[#1 asc nulls_last] limit=3 must_consolidate ArrangeBy @@ -162,7 +162,7 @@ Target cluster: quickstart > CREATE VIEW v5 AS SELECT * from i4 ORDER BY c LIMIT 2; -?[version>=14300] EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v5; +?[version>=14400] EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v5; Explained Query: TopK::MonotonicTopK order_by=[#0 asc nulls_last] limit=2 must_consolidate ArrangeBy @@ -178,7 +178,7 @@ Used Indexes: Target cluster: quickstart -?[version<14300] EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v5; +?[version<14400] EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v5; Explained Query: TopK::MonotonicTopK order_by=[#0 asc nulls_last] limit=2 must_consolidate ArrangeBy @@ -201,7 +201,7 @@ Target cluster: quickstart > CREATE VIEW v7 AS SELECT * from i6 ORDER BY c LIMIT 2; -?[version>=14300] EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v7; +?[version>=14400] EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v7; Explained Query: TopK::MonotonicTopK order_by=[#0 asc nulls_last] limit=2 must_consolidate ArrangeBy @@ -217,7 +217,7 @@ Used Indexes: Target cluster: quickstart -?[version<14300] EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v7; +?[version<14400] EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v7; Explained Query: TopK::MonotonicTopK order_by=[#0 asc nulls_last] limit=2 must_consolidate ArrangeBy @@ -243,7 +243,7 @@ Target cluster: quickstart # Propagating monotonicity analysis in a complex situation: (i1, i1) -> i8; (i1, i8) -> i9 -?[version>=14300] EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v10; +?[version>=14400] EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v10; Explained Query: TopK::MonotonicTopK order_by=[#0 asc nulls_last] limit=2 must_consolidate ArrangeBy @@ -259,7 +259,7 @@ Used Indexes: Target cluster: quickstart -?[version<14300] EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v10; +?[version<14400] EXPLAIN PHYSICAL PLAN FOR SELECT * FROM v10; Explained Query: TopK::MonotonicTopK order_by=[#0 asc nulls_last] limit=2 must_consolidate ArrangeBy diff --git a/test/testdrive-old-kafka-src-syntax/primary-key-optimizations.td b/test/testdrive-old-kafka-src-syntax/primary-key-optimizations.td index e80beeb731706..3a4e93435308f 100644 --- a/test/testdrive-old-kafka-src-syntax/primary-key-optimizations.td +++ b/test/testdrive-old-kafka-src-syntax/primary-key-optimizations.td @@ -264,7 +264,7 @@ Used Indexes: Target cluster: quickstart -?[version>=14300] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT DISTINCT key1, upper(key2) FROM t1; +?[version>=14400] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT DISTINCT key1, upper(key2) FROM t1; Explained Query: Distinct project=[#0, upper(#1{key2})] Project (#0, #1) @@ -275,7 +275,7 @@ Used Indexes: Target cluster: quickstart -?[13500<=version<14300] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT DISTINCT key1, upper(key2) FROM t1; +?[13500<=version<14400] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT DISTINCT key1, upper(key2) FROM t1; Explained Query: Distinct project=[#0, upper(#1)] Project (#0, #1) @@ -297,7 +297,7 @@ Used Indexes: Target cluster: quickstart -?[14300<=version] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT DISTINCT key1, key2 || 'a' FROM t1; +?[14400<=version] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT DISTINCT key1, key2 || 'a' FROM t1; Explained Query: Distinct project=[#0, (#1{key2} || "a")] Project (#0, #1) @@ -308,7 +308,7 @@ Used Indexes: Target cluster: quickstart -?[13500<=version<14300] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT DISTINCT key1, key2 || 'a' FROM t1; +?[13500<=version<14400] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT DISTINCT key1, key2 || 'a' FROM t1; Explained Query: Distinct project=[#0, (#1 || "a")] Project (#0, #1) @@ -397,7 +397,7 @@ Used Indexes: Target cluster: quickstart -?[13500<=version<14300] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT COUNT(DISTINCT key1) FROM t1; +?[13500<=version<14400] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT COUNT(DISTINCT key1) FROM t1; Explained Query: With cte l0 = @@ -821,7 +821,7 @@ Used Indexes: Target cluster: quickstart -?[version>=14300] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT DISTINCT key1, upper(key2) FROM t1_pkne; +?[version>=14400] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT DISTINCT key1, upper(key2) FROM t1_pkne; Explained Query: Distinct project=[#0, upper(#1{key2})] monotonic Project (#0, #1) @@ -833,7 +833,7 @@ Used Indexes: Target cluster: quickstart -?[13500<=version<14300] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT DISTINCT key1, upper(key2) FROM t1_pkne; +?[13500<=version<14400] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT DISTINCT key1, upper(key2) FROM t1_pkne; Explained Query: Distinct project=[#0, upper(#1)] monotonic Project (#0, #1) @@ -855,7 +855,7 @@ Used Indexes: Target cluster: quickstart -?[version>=14300] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT DISTINCT key1, key2 || 'a' FROM t1_pkne; +?[version>=14400] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT DISTINCT key1, key2 || 'a' FROM t1_pkne; Explained Query: Distinct project=[#0, (#1{key2} || "a")] monotonic Project (#0, #1) @@ -866,7 +866,7 @@ Used Indexes: Target cluster: quickstart -?[13500<=version<14300] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT DISTINCT key1, key2 || 'a' FROM t1_pkne; +?[13500<=version<14400] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT DISTINCT key1, key2 || 'a' FROM t1_pkne; Explained Query: Distinct project=[#0, (#1 || "a")] monotonic Project (#0, #1) @@ -932,7 +932,7 @@ Used Indexes: Target cluster: quickstart -?[version>=14300] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT COUNT(DISTINCT key1) FROM t1_pkne; +?[version>=14400] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT COUNT(DISTINCT key1) FROM t1_pkne; Explained Query: With cte l0 = @@ -955,7 +955,7 @@ Used Indexes: Target cluster: quickstart -?[13500<=version<14300] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT COUNT(DISTINCT key1) FROM t1_pkne; +?[13500<=version<14400] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT COUNT(DISTINCT key1) FROM t1_pkne; Explained Query: With cte l0 = diff --git a/test/testdrive-old-kafka-src-syntax/testdrive.td b/test/testdrive-old-kafka-src-syntax/testdrive.td index 504e85e2dac01..fa55bf955b0ae 100644 --- a/test/testdrive-old-kafka-src-syntax/testdrive.td +++ b/test/testdrive-old-kafka-src-syntax/testdrive.td @@ -45,7 +45,7 @@ row 2 $ set-regex match=u\d+ replacement=UID -?[version>=14300] EXPLAIN OPTIMIZED PLAN AS VERBOSE TEXT FOR SELECT * FROM t1 AS a1, t1 AS a2 WHERE a1.f1 IS NOT NULL; +?[version>=14400] EXPLAIN OPTIMIZED PLAN AS VERBOSE TEXT FOR SELECT * FROM t1 AS a1, t1 AS a2 WHERE a1.f1 IS NOT NULL; Explained Query: CrossJoin type=differential ArrangeBy keys=[[]] @@ -58,7 +58,7 @@ Source materialize.public.t1 Target cluster: quickstart -?[13500<=version<14300] EXPLAIN OPTIMIZED PLAN AS VERBOSE TEXT FOR SELECT * FROM t1 AS a1, t1 AS a2 WHERE a1.f1 IS NOT NULL; +?[13500<=version<14400] EXPLAIN OPTIMIZED PLAN AS VERBOSE TEXT FOR SELECT * FROM t1 AS a1, t1 AS a2 WHERE a1.f1 IS NOT NULL; Explained Query: CrossJoin type=differential ArrangeBy keys=[[]] From 0dad66d5303d583ee53fa6beb85f5095d4cf7002 Mon Sep 17 00:00:00 2001 From: Michael Greenberg Date: Wed, 30 Apr 2025 16:56:30 -0400 Subject: [PATCH 11/14] missed two --- test/bounded-memory/mzcompose.py | 4 ++-- test/sqllogictest/advent-of-code/2023/aoc_1222.slt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/bounded-memory/mzcompose.py b/test/bounded-memory/mzcompose.py index dfbe9af0451d7..83c3e9bd0aaf0 100644 --- a/test/bounded-memory/mzcompose.py +++ b/test/bounded-memory/mzcompose.py @@ -969,8 +969,8 @@ class KafkaScenario(Scenario): Union // { cardinality: \"\" } Negate // { cardinality: \"\" } Project (#0) // { cardinality: \"\" } - Get l1 // { cardinality: \"\" } - Get l0 // { cardinality: \"\" } + Get l1 // { cardinality: \"\" } + Get l0 // { cardinality: \"\" } Return // { cardinality: \"\" } Project (#0) // { cardinality: \"\" } Filter ((#1{col0} > 3) OR ((#1{col0} <= 88) AND (#1{col0} > 5) AND ((#1{col0} = 98) OR (#1{col0} >= 30) OR (#6 AND (#2{col1}) IS NULL AND (#3{col3} < 48) AND (#4{col4} < 86.27) AND (#1{col0} <= 45) AND (#2{col1} <= 10.7) AND (#3{col3} > 49) AND (#3{col3} > 66) AND (#4{col4} > 42.2) AND (#1{col0} >= 25) AND (#3{col3} >= 49) AND (#3{col3} >= 77) AND ((#1{col0} = 67) OR (#1{col0} = 81) OR (#1{col0} = 86) OR (#1{col0} = 94) OR (#1{col0} = 97)) AND ((#2{col1} < 20.99) OR (#2{col1} <= 30.14) OR (#1{col0} > 79) OR (#1{col0} >= 89) OR (#3{col3} >= 12) OR ((#3{col3} > 77) AND (#2{col1} >= 74.51)))) OR (#7 AND (#3{col3} <= 88)) OR ((#1{col0} < 68) AND (#1{col0} <= 35)) OR ((#2{col1} <= 17.96) AND (#7 OR ((#4{col4} <= 2.63) AND (#1{col0} > 2) AND (#3{col3} > 8)))) OR ((#4{col4} <= 97.11) AND ((#1{col0} = 11) OR (#1{col0} = 63) OR (#1{col0} = 85) OR (#1{col0} = 87) OR (#1{col0} = 88)))))) // { cardinality: \"\" } diff --git a/test/sqllogictest/advent-of-code/2023/aoc_1222.slt b/test/sqllogictest/advent-of-code/2023/aoc_1222.slt index 00a45e4d82254..6062da6d025bf 100644 --- a/test/sqllogictest/advent-of-code/2023/aoc_1222.slt +++ b/test/sqllogictest/advent-of-code/2023/aoc_1222.slt @@ -432,7 +432,7 @@ Explained Query: Project (#0, #1) // { arity: 2 } Join on=(#1 = #3 AND #2{count} = #4{count}) type=differential // { arity: 5 } implementation - %0:l17[#1, #2{?column?}]KK » %1[#0, #1]KK + %0:l17[#1, #2{"?column?"}]KK » %1[#0, #1]KK ArrangeBy keys=[[#1, #2{count}]] // { arity: 3 } Get l17 // { arity: 3 } ArrangeBy keys=[[#0, #1{count}]] // { arity: 2 } From db7b691d73772685608a5d78a5950fa62254e63d Mon Sep 17 00:00:00 2001 From: Gabor Gevay Date: Thu, 1 May 2025 10:49:33 +0200 Subject: [PATCH 12/14] Correct indentation in bounded memory test --- test/bounded-memory/mzcompose.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/bounded-memory/mzcompose.py b/test/bounded-memory/mzcompose.py index 83c3e9bd0aaf0..b9d817a5eacb7 100644 --- a/test/bounded-memory/mzcompose.py +++ b/test/bounded-memory/mzcompose.py @@ -1106,8 +1106,8 @@ class KafkaScenario(Scenario): Union // { cardinality: \"\" } Negate // { cardinality: \"\" } Project (#0) // { cardinality: \"\" } - Get l1 // { cardinality: \"\" } - Get l0 // { cardinality: \"\" } + Get l1 // { cardinality: \"\" } + Get l0 // { cardinality: \"\" } Return // { cardinality: \"\" } Project (#0) // { cardinality: \"\" } Filter ((#1{col0} > 3) OR ((#1{col0} <= 88) AND (#1{col0} > 5) AND ((#1{col0} = 98) OR (#1{col0} >= 30) OR (#6 AND (#2{col1}) IS NULL AND (#3{col3} < 48) AND (#4{col4} < 86.27) AND (#1{col0} <= 45) AND (#2{col1} <= 10.7) AND (#3{col3} > 49) AND (#3{col3} > 66) AND (#4{col4} > 42.2) AND (#1{col0} >= 25) AND (#3{col3} >= 49) AND (#3{col3} >= 77) AND ((#1{col0} = 67) OR (#1{col0} = 81) OR (#1{col0} = 86) OR (#1{col0} = 94) OR (#1{col0} = 97)) AND ((#2{col1} < 20.99) OR (#2{col1} <= 30.14) OR (#1{col0} > 79) OR (#1{col0} >= 89) OR (#3{col3} >= 12) OR ((#3{col3} > 77) AND (#2{col1} >= 74.51)))) OR (#7 AND (#3{col3} <= 88)) OR ((#1{col0} < 68) AND (#1{col0} <= 35)) OR ((#2{col1} <= 17.96) AND (#7 OR ((#4{col4} <= 2.63) AND (#1{col0} > 2) AND (#3{col3} > 8)))) OR ((#4{col4} <= 97.11) AND ((#1{col0} = 11) OR (#1{col0} = 63) OR (#1{col0} = 85) OR (#1{col0} = 87) OR (#1{col0} = 88)))))) // { cardinality: \"\" } From 493b5542a55afb869b30ddf70f640cb938dcd1f4 Mon Sep 17 00:00:00 2001 From: Gabor Gevay Date: Thu, 1 May 2025 10:57:28 +0200 Subject: [PATCH 13/14] Delete an annoying test from under testdrive-old-kafka-src-syntax --- .../primary-key-optimizations.td | 69 ------------------- 1 file changed, 69 deletions(-) diff --git a/test/testdrive-old-kafka-src-syntax/primary-key-optimizations.td b/test/testdrive-old-kafka-src-syntax/primary-key-optimizations.td index 3a4e93435308f..5d228d05b853c 100644 --- a/test/testdrive-old-kafka-src-syntax/primary-key-optimizations.td +++ b/test/testdrive-old-kafka-src-syntax/primary-key-optimizations.td @@ -374,75 +374,6 @@ Used Indexes: Target cluster: quickstart -?[version>=13500] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT COUNT(DISTINCT key1) FROM t1; -Explained Query: - With - cte l0 = - Reduce aggregates=[count(distinct #0{key1})] - Project (#0) - ReadIndex on=t1 t1_primary_idx=[*** full scan ***] - Return - Union - Get l0 - Map (0) - Union - Negate - Project () - Get l0 - Constant - - () - -Used Indexes: - - t1_primary_idx (*** full scan ***) - -Target cluster: quickstart - -?[13500<=version<14400] EXPLAIN OPTIMIZED PLAN WITH(no notices) AS VERBOSE TEXT FOR SELECT COUNT(DISTINCT key1) FROM t1; -Explained Query: - With - cte l0 = - Reduce aggregates=[count(distinct #0)] - Project (#0) - ReadIndex on=t1 t1_primary_idx=[*** full scan ***] - Return - Union - Get l0 - Map (0) - Union - Negate - Project () - Get l0 - Constant - - () - -Used Indexes: - - t1_primary_idx (*** full scan ***) - -Target cluster: quickstart - -?[version<13500] EXPLAIN OPTIMIZED PLAN WITH(no notices) FOR SELECT COUNT(DISTINCT key1) FROM t1; -Explained Query: - With - cte l0 = - Reduce aggregates=[count(distinct #0)] - Project (#0) - ReadIndex on=t1 t1_primary_idx=[*** full scan ***] - Return - Union - Get l0 - Map (0) - Union - Negate - Project () - Get l0 - Constant - - () - -Used Indexes: - - t1_primary_idx (*** full scan ***) - -Target cluster: quickstart - # Make sure that primary key information is inherited from the source > CREATE VIEW v1 AS SELECT * FROM t1; From 2637024224365824bad33c939caf9f1fe416b697 Mon Sep 17 00:00:00 2001 From: Gabor Gevay Date: Thu, 1 May 2025 11:43:46 +0200 Subject: [PATCH 14/14] Decrease the size of sqlsmith-explain Some increase in mem usage is expected from https://github.com/MaterializeInc/materialize/pull/31878 --- ci/nightly/pipeline.template.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/nightly/pipeline.template.yml b/ci/nightly/pipeline.template.yml index b939fdf2ee50b..ff08cd58a1bbe 100644 --- a/ci/nightly/pipeline.template.yml +++ b/ci/nightly/pipeline.template.yml @@ -1352,7 +1352,7 @@ steps: plugins: - ./ci/plugins/mzcompose: composition: sqlsmith - args: [--max-joins=15, --explain-only, --runtime=1500] + args: [--max-joins=12, --explain-only, --runtime=1500] - group: SQLancer key: sqlancer