From bc3974a9f886a097f28f8301f6e3cddcd1a4bdb6 Mon Sep 17 00:00:00 2001 From: Runji Wang Date: Wed, 28 Sep 2022 19:49:40 +0800 Subject: [PATCH] chore(planner test): add name field and improve error handling (#5602) * extract head line comments to name properties Signed-off-by: Runji Wang * add name property and print location on parse error Signed-off-by: Runji Wang Signed-off-by: Runji Wang Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- src/frontend/planner_test/src/lib.rs | 24 +- .../planner_test/tests/planner_test_runner.rs | 4 +- .../planner_test/tests/testdata/agg.yaml | 218 +++++++++--------- .../planner_test/tests/testdata/array.yaml | 32 +-- .../tests/testdata/basic_query.yaml | 32 +-- .../tests/testdata/column_pruning.yaml | 44 ++-- .../testdata/common_table_expressions.yaml | 4 +- .../planner_test/tests/testdata/expr.yaml | 64 ++--- .../planner_test/tests/testdata/insert.yaml | 64 ++--- .../planner_test/tests/testdata/join.yaml | 132 +++++------ .../planner_test/tests/testdata/order_by.yaml | 56 ++--- .../tests/testdata/over_window_function.yaml | 12 +- .../tests/testdata/predicate_pushdown.yaml | 4 +- .../tests/testdata/project_set.yaml | 20 +- .../tests/testdata/range_scan.yaml | 22 +- .../planner_test/tests/testdata/subquery.yaml | 32 +-- .../testdata/subquery_expr_correlated.yaml | 52 ++--- .../tests/testdata/table_primary_key.yaml | 4 +- 18 files changed, 420 insertions(+), 400 deletions(-) diff --git a/src/frontend/planner_test/src/lib.rs b/src/frontend/planner_test/src/lib.rs index 061f49fcd47ec..9939d933e8ab3 100644 --- a/src/frontend/planner_test/src/lib.rs +++ b/src/frontend/planner_test/src/lib.rs @@ -19,6 +19,7 @@ mod resolve_id; use std::collections::BTreeMap; +use std::path::Path; use std::sync::atomic::Ordering; use std::sync::Arc; @@ -35,6 +36,7 @@ use risingwave_frontend::{ use risingwave_sqlparser::ast::{ObjectName, Statement}; use risingwave_sqlparser::parser::Parser; use serde::{Deserialize, Serialize}; + #[serde_with::skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Default)] #[serde(deny_unknown_fields)] @@ -42,6 +44,9 @@ pub struct TestCase { /// Id of the test case, used in before. pub id: Option, + /// A brief description of the test case. + pub name: Option, + /// Before running the SQL statements, the test runner will execute the specified test cases pub before: Option>, @@ -170,6 +175,7 @@ impl TestCaseResult { let case = TestCase { id: original_test_case.id.clone(), + name: original_test_case.name.clone(), before: original_test_case.before.clone(), sql: original_test_case.sql.to_string(), before_statements: original_test_case.before_statements.clone(), @@ -579,11 +585,23 @@ fn check_err(ctx: &str, expected_err: &Option, actual_err: &Option Result<()> { - println!("-- running {} --", file_name); +pub async fn run_test_file(file_path: &Path, file_content: &str) -> Result<()> { + let file_name = file_path.file_name().unwrap().to_str().unwrap(); + println!("-- running {file_name} --"); let mut failed_num = 0; - let cases: Vec = serde_yaml::from_str(file_content).unwrap(); + let cases: Vec = serde_yaml::from_str(file_content).map_err(|e| { + if let Some(loc) = e.location() { + anyhow!( + "failed to parse yaml: {e}, at {}:{}:{}", + file_path.display(), + loc.line(), + loc.column() + ) + } else { + anyhow!("failed to parse yaml: {e}") + } + })?; let cases = resolve_testcase_id(cases).expect("failed to resolve"); for (i, c) in cases.into_iter().enumerate() { diff --git a/src/frontend/planner_test/tests/planner_test_runner.rs b/src/frontend/planner_test/tests/planner_test_runner.rs index 7ed0cb5ef5189..fbdb413cc238b 100644 --- a/src/frontend/planner_test/tests/planner_test_runner.rs +++ b/src/frontend/planner_test/tests/planner_test_runner.rs @@ -54,8 +54,8 @@ fn main() { .join("testdata") .join(file_name); - let file_content = std::fs::read_to_string(path).unwrap(); - build_runtime().block_on(run_test_file(&test_case_name, &file_content))?; + let file_content = std::fs::read_to_string(&path).unwrap(); + build_runtime().block_on(run_test_file(&path, &file_content))?; Ok(()) })); } diff --git a/src/frontend/planner_test/tests/testdata/agg.yaml b/src/frontend/planner_test/tests/testdata/agg.yaml index 5f8be730537cc..980723dc830e5 100644 --- a/src/frontend/planner_test/tests/testdata/agg.yaml +++ b/src/frontend/planner_test/tests/testdata/agg.yaml @@ -90,8 +90,8 @@ └─StreamExchange { dist: HashShard(t.v3) } └─StreamProject { exprs: [t.v3, t.v1, (t.v1 + t.v2), t._row_id] } └─StreamTableScan { table: t, columns: [t.v1, t.v2, t.v3, t._row_id], pk: [t._row_id], distribution: UpstreamHashShard(t._row_id) } -- sql: | - /* test logical_agg with complex group expression */ +- name: test logical_agg with complex group expression + sql: | create table t(v1 int, v2 int); select min(v1), sum(v1 + v2) from t group by v1 + v2; logical_plan: | @@ -99,8 +99,8 @@ └─LogicalAgg { group_key: [(t.v1 + t.v2)], aggs: [min(t.v1), sum((t.v1 + t.v2))] } └─LogicalProject { exprs: [(t.v1 + t.v2), t.v1] } └─LogicalScan { table: t, columns: [t.v1, t.v2, t._row_id] } -- sql: | - /* test logical_agg with complex group expression */ +- name: test logical_agg with complex group expression + sql: | create table t(v1 int, v2 int, v3 int); select v1, sum(v1 * v2) as sum from t group by (v1 + v2) / v3, v1; logical_plan: | @@ -108,8 +108,8 @@ └─LogicalAgg { group_key: [((t.v1 + t.v2) / t.v3), t.v1], aggs: [sum((t.v1 * t.v2))] } └─LogicalProject { exprs: [((t.v1 + t.v2) / t.v3), t.v1, (t.v1 * t.v2)] } └─LogicalScan { table: t, columns: [t.v1, t.v2, t.v3, t._row_id] } -- sql: | - /* test logical_agg with complex group expression */ +- name: test logical_agg with complex group expression + sql: | create table t(v1 int, v2 int); select v1 + v2 from t group by v1 + v2; logical_plan: | @@ -117,16 +117,17 @@ └─LogicalAgg { group_key: [(t.v1 + t.v2)], aggs: [] } └─LogicalProject { exprs: [(t.v1 + t.v2)] } └─LogicalScan { table: t, columns: [t.v1, t.v2, t._row_id] } -- sql: | - /* test logical_agg with complex group expression */ - /* should complain about nested agg call */ +- name: | + test logical_agg with complex group expression + should complain about nested agg call + sql: | create table t(v1 int, v2 int); select avg(sum(v1 + v2)) from t group by v1 + v2; planner_error: |- Feature is not yet implemented: aggregate function inside aggregation calls No tracking issue yet. Feel free to submit a feature request at https://github.com/risingwavelabs/risingwave/issues/new?labels=type%2Ffeature&template=feature_request.yml -- sql: | - /* test logical_agg with complex select expression */ +- name: test logical_agg with complex select expression + sql: | create table t(v1 int, v2 int); select v1 + v2 from t group by v1, v2; logical_plan: | @@ -186,8 +187,8 @@ └─BatchHashAgg { group_key: [t.v1], aggs: [count] } └─BatchExchange { order: [], dist: HashShard(t.v1) } └─BatchScan { table: t, columns: [t.v1], distribution: SomeShard } -- sql: | - /* Use BatchSortAgg, when input provides order */ +- name: Use BatchSortAgg, when input provides order + sql: | create table t(v1 int, v2 int); create materialized view mv as select * from t order by v1 desc; select v1, max(v2) from mv group by v1; @@ -196,8 +197,8 @@ └─BatchSortAgg { group_key: [mv.v1], aggs: [max(mv.v2)] } └─BatchExchange { order: [mv.v1 DESC], dist: HashShard(mv.v1) } └─BatchScan { table: mv, columns: [mv.v1, mv.v2], distribution: SomeShard } -- sql: | - /* Use BatchSortAgg, when output requires order */ +- name: Use BatchSortAgg, when output requires order + sql: | create table t(v1 int, v2 int); select v1, max(v2) from t group by v1 order by v1 desc; batch_plan: | @@ -206,8 +207,8 @@ └─BatchExchange { order: [t.v1 DESC], dist: HashShard(t.v1) } └─BatchSort { order: [t.v1 DESC] } └─BatchScan { table: t, columns: [t.v1, t.v2], distribution: SomeShard } -- sql: | - /* Use BatchSortAgg, when required order satisfies input order */ +- name: Use BatchSortAgg, when required order satisfies input order + sql: | create table t(k1 int, k2 int, v1 int); SELECT max(v1), k1, k2 from t group by k1, k2 order by k1; batch_plan: | @@ -217,8 +218,8 @@ └─BatchExchange { order: [t.k1 ASC, t.k2 ASC], dist: HashShard(t.k1, t.k2) } └─BatchSort { order: [t.k1 ASC, t.k2 ASC] } └─BatchScan { table: t, columns: [t.k1, t.k2, t.v1], distribution: SomeShard } -- sql: | - /* Use BatchSortAgg, when output requires order with swapped output*/ +- name: Use BatchSortAgg, when output requires order with swapped output + sql: | create table t(v1 int, v2 int); select max(v2), v1 from t group by v1 order by v1 desc; batch_plan: | @@ -236,8 +237,8 @@ └─BatchExchange { order: [], dist: Single } └─BatchSimpleAgg { aggs: [count] } └─BatchScan { table: t, columns: [], distribution: SomeShard } -- sql: | - /* having with agg call */ +- name: having with agg call + sql: | create table t (v1 real); select 1 from t having sum(v1) > 5; batch_plan: | @@ -247,8 +248,8 @@ └─BatchExchange { order: [], dist: Single } └─BatchSimpleAgg { aggs: [sum(t.v1)] } └─BatchScan { table: t, columns: [t.v1], distribution: SomeShard } -- sql: | - /* having with group column */ +- name: having with group column + sql: | create table t (v1 real); select 1 from t group by v1 having v1 > 5; logical_plan: | @@ -257,22 +258,22 @@ └─LogicalAgg { group_key: [t.v1], aggs: [] } └─LogicalProject { exprs: [t.v1] } └─LogicalScan { table: t, columns: [t.v1, t._row_id] } -- sql: | - /* having with non-group column */ +- name: having with non-group column + sql: | create table t (v1 real, v2 int); select 1 from t group by v1 having v2 > 5; planner_error: 'Invalid input syntax: column must appear in the GROUP BY clause or be used in an aggregate function' -- sql: | - /* distinct without agg */ +- name: distinct without agg + sql: | create table t (v1 int, v2 int); select distinct v1 from t; logical_plan: | LogicalAgg { group_key: [t.v1], aggs: [] } └─LogicalProject { exprs: [t.v1] } └─LogicalScan { table: t, columns: [t.v1, t.v2, t._row_id] } -- sql: | - /* distinct with agg */ +- name: distinct with agg + sql: | create table t (v1 int, v2 int); select distinct sum(v1) from t group by v2; logical_plan: | @@ -281,8 +282,8 @@ └─LogicalAgg { group_key: [t.v2], aggs: [sum(t.v1)] } └─LogicalProject { exprs: [t.v2, t.v1] } └─LogicalScan { table: t, columns: [t.v1, t.v2, t._row_id] } -- sql: | - /* arguments out-of-order */ +- name: arguments out-of-order + sql: | create table t(v1 int, v2 int, v3 int); select count(v3), min(v2), max(v1) from t; batch_plan: | @@ -291,8 +292,8 @@ └─BatchSimpleAgg { aggs: [count(t.v3), min(t.v2), max(t.v1)] } └─BatchProject { exprs: [t.v3, t.v2, t.v1] } └─BatchScan { table: t, columns: [t.v1, t.v2, t.v3], distribution: SomeShard } -- sql: | - /* simple-agg arguments out-of-order */ +- name: simple-agg arguments out-of-order + sql: | create table t(v1 int, v2 int, v3 int); select min(v1) + max(v3) * count(v2) as agg from t; batch_plan: | @@ -311,8 +312,8 @@ └─StreamProject { exprs: [t.v1, t.v3, t.v2, t._row_id, Vnode(t._row_id)] } └─StreamProject { exprs: [t.v1, t.v3, t.v2, t._row_id] } └─StreamTableScan { table: t, columns: [t.v1, t.v2, t.v3, t._row_id], pk: [t._row_id], distribution: UpstreamHashShard(t._row_id) } -- sql: | - /* dup group key */ +- name: dup group key + sql: | create table t(v1 int) with (appendonly = false); select v1 from t group by v1, v1; logical_plan: | @@ -330,8 +331,8 @@ └─StreamHashAgg { group_key: [t.v1, t.v1], aggs: [count] } └─StreamExchange { dist: HashShard(t.v1) } └─StreamTableScan { table: t, columns: [t.v1, t._row_id], pk: [t._row_id], distribution: UpstreamHashShard(t._row_id) } -- sql: | - /* dup group key */ +- name: dup group key + sql: | create table t(v1 int, v2 int, v3 int) with (appendonly = false); select v2, min(v1) as min_v1, v3, max(v1) as max_v1 from t group by v3, v2, v2; logical_plan: | @@ -351,8 +352,8 @@ └─StreamExchange { dist: HashShard(t.v3, t.v2) } └─StreamProject { exprs: [t.v3, t.v2, t.v1, t._row_id] } └─StreamTableScan { table: t, columns: [t.v1, t.v2, t.v3, t._row_id], pk: [t._row_id], distribution: UpstreamHashShard(t._row_id) } -- sql: | - /* order by agg input */ +- name: order by agg input + sql: | create table t(v1 int); select sum(v1 order by v1) as s1 from t; logical_plan: | @@ -370,8 +371,8 @@ └─StreamExchange { dist: Single } └─StreamStatelessLocalSimpleAgg { aggs: [count, sum(t.v1)] } └─StreamTableScan { table: t, columns: [t.v1, t._row_id], pk: [t._row_id], distribution: UpstreamHashShard(t._row_id) } -- sql: | - /* order by other columns */ +- name: order by other columns + sql: | create table t(v1 int, v2 varchar); select sum(v1 order by v2) as s1 from t; logical_plan: | @@ -389,8 +390,8 @@ └─StreamExchange { dist: Single } └─StreamStatelessLocalSimpleAgg { aggs: [count, sum(t.v1)] } └─StreamTableScan { table: t, columns: [t.v1, t._row_id], pk: [t._row_id], distribution: UpstreamHashShard(t._row_id) } -- sql: | - /* order by ASC/DESC and default */ +- name: order by ASC/DESC and default + sql: | create table t(v1 int, v2 varchar, v3 int); select sum(v1 order by v1, v2 ASC, v3 DESC) as s1 from t; logical_plan: | @@ -408,8 +409,8 @@ └─StreamExchange { dist: Single } └─StreamStatelessLocalSimpleAgg { aggs: [count, sum(t.v1)] } └─StreamTableScan { table: t, columns: [t.v1, t._row_id], pk: [t._row_id], distribution: UpstreamHashShard(t._row_id) } -- sql: | - /* order by NULLS FIRST/LAST and default */ +- name: order by NULLS FIRST/LAST and default + sql: | create table t(v1 int, v2 varchar, v3 int); select sum(v1 order by v1, v2 NULLS FIRST, v3 NULLS LAST) as s1 from t; logical_plan: | @@ -427,8 +428,8 @@ └─StreamExchange { dist: Single } └─StreamStatelessLocalSimpleAgg { aggs: [count, sum(t.v1)] } └─StreamTableScan { table: t, columns: [t.v1, t._row_id], pk: [t._row_id], distribution: UpstreamHashShard(t._row_id) } -- sql: | - /* order by complex expressions */ +- name: order by complex expressions + sql: | create table t(v1 int, v2 varchar, v3 int); select sum(v1 order by v1 + v3 ASC, length(v2) * v3 DESC NULLS FIRST) as s1 from t; logical_plan: | @@ -446,8 +447,8 @@ └─StreamExchange { dist: Single } └─StreamStatelessLocalSimpleAgg { aggs: [count, sum(t.v1)] } └─StreamTableScan { table: t, columns: [t.v1, t._row_id], pk: [t._row_id], distribution: UpstreamHashShard(t._row_id) } -- sql: | - /* filter clause */ +- name: filter clause + sql: | create table t(v1 int); select sum(v1) FILTER (WHERE v1 > 0) AS sa from t; logical_plan: | @@ -465,9 +466,10 @@ └─StreamExchange { dist: Single } └─StreamStatelessLocalSimpleAgg { aggs: [count, sum(t.v1) filter((t.v1 > 0:Int32))] } └─StreamTableScan { table: t, columns: [t.v1, t._row_id], pk: [t._row_id], distribution: UpstreamHashShard(t._row_id) } -- sql: | - /* filter clause */ - /* extra calculation, should reuse result from project */ +- name: | + filter clause + extra calculation, should reuse result from project + sql: | create table t(a int, b int); select sum(a * b) filter (where a * b > 0) as sab from t; logical_plan: | @@ -479,8 +481,8 @@ LogicalAgg { aggs: [sum((t.a * t.b)) filter(((t.a * t.b) > 0:Int32))] } └─LogicalProject { exprs: [t.a, t.b, (t.a * t.b)] } └─LogicalScan { table: t, columns: [t.a, t.b] } -- sql: | - /* complex filter clause */ +- name: complex filter clause + sql: | create table t(a int, b int); select max(a * b) FILTER (WHERE a < b AND a + b < 100 AND a * b != a + b - 1) AS sab from t; logical_plan: | @@ -501,8 +503,8 @@ └─StreamProject { exprs: [t.a, t.b, (t.a * t.b), t._row_id, Vnode(t._row_id)] } └─StreamProject { exprs: [t.a, t.b, (t.a * t.b), t._row_id] } └─StreamTableScan { table: t, columns: [t.a, t.b, t._row_id], pk: [t._row_id], distribution: UpstreamHashShard(t._row_id) } -- sql: | - /* avg filter clause + group by */ +- name: avg filter clause + group by + sql: | create table t(a int, b int); select avg(a) FILTER (WHERE a > b) AS avga from t group by b ; logical_plan: | @@ -522,8 +524,8 @@ └─StreamExchange { dist: HashShard(t.b) } └─StreamProject { exprs: [t.b, t.a, t._row_id] } └─StreamTableScan { table: t, columns: [t.a, t.b, t._row_id], pk: [t._row_id], distribution: UpstreamHashShard(t._row_id) } -- sql: | - /* count filter clause */ +- name: count filter clause + sql: | create table t(a int, b int); select count(*) FILTER (WHERE a > b) AS cnt_agb from t; logical_plan: | @@ -541,34 +543,34 @@ └─StreamExchange { dist: Single } └─StreamStatelessLocalSimpleAgg { aggs: [count, count filter((t.a > t.b))] } └─StreamTableScan { table: t, columns: [t.a, t.b, t._row_id], pk: [t._row_id], distribution: UpstreamHashShard(t._row_id) } -- sql: | - /* filter clause + non-boolean function */ +- name: filter clause + non-boolean function + sql: | create table t(a int, b int); select avg(a) FILTER (WHERE abs(a)) AS avga from t; binder_error: 'Invalid input syntax: the type of filter clause should be boolean, but found Int32' -- sql: | - /* filter clause + subquery */ +- name: filter clause + subquery + sql: | create table t(a int, b int); select avg(a) FILTER (WHERE 0 < (select max(a) from t)) AS avga from t; binder_error: |- Feature is not yet implemented: subquery in filter clause No tracking issue yet. Feel free to submit a feature request at https://github.com/risingwavelabs/risingwave/issues/new?labels=type%2Ffeature&template=feature_request.yml -- sql: | - /* aggregation in filter clause */ +- name: aggregation in filter clause + sql: | create table t(a int, b int); select avg(a) FILTER (WHERE a < avg(b)) AS avga from t; binder_error: |- Feature is not yet implemented: aggregation function in filter clause No tracking issue yet. Feel free to submit a feature request at https://github.com/risingwavelabs/risingwave/issues/new?labels=type%2Ffeature&template=feature_request.yml -- sql: | - /* filter clause + non-boolean function */ +- name: filter clause + non-boolean function + sql: | create table t(a int, b int); select abs(a) FILTER (WHERE a > 0) AS avga from t; binder_error: 'Invalid input syntax: DISTINCT, ORDER BY or FILTER is only allowed in aggregation functions, but `abs` is not an aggregation function' -- sql: | - /* prune column before filter */ +- name: prune column before filter + sql: | create table t(v1 int, v2 int); with sub(a, b) as (select min(v1), sum(v2) filter (where v2 < 5) from t) select b from sub; batch_plan: | @@ -583,8 +585,8 @@ └─StreamExchange { dist: Single } └─StreamStatelessLocalSimpleAgg { aggs: [count, sum(t.v2) filter((t.v2 < 5:Int32))] } └─StreamTableScan { table: t, columns: [t.v2, t._row_id], pk: [t._row_id], distribution: UpstreamHashShard(t._row_id) } -- sql: | - /* only distinct agg */ +- name: only distinct agg + sql: | create table t(a int, b int, c int); select a, count(distinct b) as distinct_b_num, sum(distinct c) filter(where c < 100) as distinct_c_sum from t group by a; optimized_logical_plan: | @@ -593,8 +595,8 @@ └─LogicalProject { exprs: [t.a, t.b, t.c, t.c, flag] } └─LogicalExpand { column_subsets: [[t.a, t.b], [t.a, t.c]] } └─LogicalScan { table: t, columns: [t.a, t.b, t.c] } -- sql: | - /* distinct agg and non-disintct agg */ +- name: distinct agg and non-disintct agg + sql: | create table t(a int, b int, c int); select a, count(distinct b) as distinct_b_num, sum(c) as sum_c from t group by a; optimized_logical_plan: | @@ -610,24 +612,24 @@ └─StreamHashAgg { group_key: [t.a, t.b], aggs: [count, sum(t.c)] } └─StreamExchange { dist: HashShard(t.a, t.b) } └─StreamTableScan { table: t, columns: [t.a, t.b, t.c, t._row_id], pk: [t._row_id], distribution: UpstreamHashShard(t._row_id) } -- sql: | - /* distinct agg with filter */ +- name: distinct agg with filter + sql: | create table t(a int, b int, c int); select a, count(distinct b) filter(where b < 100), sum(c) from t group by a; optimized_logical_plan: | LogicalAgg { group_key: [t.a], aggs: [count(t.b) filter((count filter((t.b < 100:Int32)) > 0:Int64)), sum(sum(t.c))] } └─LogicalAgg { group_key: [t.a, t.b], aggs: [count filter((t.b < 100:Int32)), sum(t.c)] } └─LogicalScan { table: t, columns: [t.a, t.b, t.c] } -- sql: | - /* non-distinct agg with filter */ +- name: non-distinct agg with filter + sql: | create table t(a int, b int, c int); select a, count(distinct b), sum(c) filter(where b < 100) from t group by a; optimized_logical_plan: | LogicalAgg { group_key: [t.a], aggs: [count(t.b), sum(sum(t.c) filter((t.b < 100:Int32)))] } └─LogicalAgg { group_key: [t.a, t.b], aggs: [sum(t.c) filter((t.b < 100:Int32))] } └─LogicalScan { table: t, columns: [t.a, t.b, t.c] } -- sql: | - /* combined order by & filter clauses */ +- name: combined order by & filter clauses + sql: | create table t(a varchar, b int); select sum(length(a) * b order by length(a) + b) filter (where b < 100 AND b * 2 > 10) as s1 from t; logical_plan: | @@ -659,8 +661,8 @@ LogicalAgg { aggs: [count(t.v1)] } └─LogicalAgg { group_key: [t.v1], aggs: [] } └─LogicalScan { table: t, columns: [t.v1] } -- sql: | - /* input is sharded by group key */ +- name: input is sharded by group key + sql: | create table t(x int); create index i on t(x); select count(*) as cnt from i group by x; @@ -674,8 +676,8 @@ └─StreamProject { exprs: [count, i.x] } └─StreamHashAgg { group_key: [i.x], aggs: [count, count] } └─StreamTableScan { table: i, columns: [i.x, i.t._row_id], pk: [i.t._row_id], distribution: UpstreamHashShard(i.x) } -- sql: | - /* distinct aggregates only have one distinct argument doesn't need expand */ +- name: distinct aggregates only have one distinct argument doesn't need expand + sql: | create table t(x int, y int); select count(x), sum(distinct y), sum(distinct y) from t; optimized_logical_plan: | @@ -706,23 +708,23 @@ planner_error: |- Feature is not yet implemented: Non-distinct string_agg can't appear with distinct aggregates No tracking issue yet. Feel free to submit a feature request at https://github.com/risingwavelabs/risingwave/issues/new?labels=type%2Ffeature&template=feature_request.yml -- sql: | - /* remove unnecessary distinct for max and min */ +- name: remove unnecessary distinct for max and min + sql: | create table t(x int, y int); select max(distinct x), min(distinct y) from t; optimized_logical_plan: | LogicalAgg { aggs: [max(t.x), min(t.y)] } └─LogicalScan { table: t, columns: [t.x, t.y] } -- sql: | - /* agg filter: subquery */ +- name: agg filter - subquery + sql: | /* This case is valid in PostgreSQL */ create table a (a1 int, a2 int); select count(a1) filter (where (select true)) from a; binder_error: |- Feature is not yet implemented: subquery in filter clause No tracking issue yet. Feel free to submit a feature request at https://github.com/risingwavelabs/risingwave/issues/new?labels=type%2Ffeature&template=feature_request.yml -- sql: | - /* agg filter: agg */ +- name: agg filter - agg + sql: | /* This case is valid in PostgreSQL */ create table a (a1 int, a2 int); create table b (b1 int, b2 int); @@ -732,24 +734,24 @@ binder_error: |- Feature is not yet implemented: aggregation function in filter clause No tracking issue yet. Feel free to submit a feature request at https://github.com/risingwavelabs/risingwave/issues/new?labels=type%2Ffeature&template=feature_request.yml -- sql: | - /* agg filter: table function */ +- name: agg filter - table function + sql: | /* This case is NOT valid in PostgreSQL */ create table a (a1 int, a2 int); select count(a1) filter (where unnest(array[1]) < 1) from a; binder_error: |- Feature is not yet implemented: table function in filter clause No tracking issue yet. Feel free to submit a feature request at https://github.com/risingwavelabs/risingwave/issues/new?labels=type%2Ffeature&template=feature_request.yml -- sql: | - /* agg order by: subquery */ +- name: agg order by - subquery + sql: | /* This case is valid in PostgreSQL */ create table a (a1 int, a2 int); select string_agg('', '' order by (select true)) from a; planner_error: |- Feature is not yet implemented: subquery inside aggregation calls order by No tracking issue yet. Feel free to submit a feature request at https://github.com/risingwavelabs/risingwave/issues/new?labels=type%2Ffeature&template=feature_request.yml -- sql: | - /* agg order by: agg */ +- name: agg order by - agg + sql: | create table a (a1 int, a2 int); create table sb (b1 varchar, b2 varchar); select 1 from a having exists( @@ -759,24 +761,24 @@ planner_error: |- Feature is not yet implemented: aggregate function inside aggregation calls order by No tracking issue yet. Feel free to submit a feature request at https://github.com/risingwavelabs/risingwave/issues/new?labels=type%2Ffeature&template=feature_request.yml -- sql: | - /* agg order by: table function */ +- name: agg order by - table function + sql: | /* This case is NOT valid in PostgreSQL */ create table a (a1 int, a2 int); select string_agg('', '' order by unnest(array[1])) from a; planner_error: |- Feature is not yet implemented: table function inside aggregation calls order by No tracking issue yet. Feel free to submit a feature request at https://github.com/risingwavelabs/risingwave/issues/new?labels=type%2Ffeature&template=feature_request.yml -- sql: | - /* agg input: subquery */ +- name: agg input - subquery + sql: | /* This case is valid in PostgreSQL */ create table a (a1 int, a2 int); select count(a1 + (select 1)) from a; planner_error: |- Feature is not yet implemented: subquery inside aggregation calls No tracking issue yet. Feel free to submit a feature request at https://github.com/risingwavelabs/risingwave/issues/new?labels=type%2Ffeature&template=feature_request.yml -- sql: | - /* agg input: agg */ +- name: agg input - agg + sql: | /* This case is valid in PostgreSQL */ create table a (a1 int, a2 int); create table b (b1 int, b2 int); @@ -786,24 +788,24 @@ planner_error: |- Feature is not yet implemented: correlated subquery in HAVING or SELECT with agg Tracking issue: https://github.com/risingwavelabs/risingwave/issues/2275 -- sql: | - /* agg input: table function */ +- name: agg input - table function + sql: | /* This case is NOT valid in PostgreSQL */ create table a (a1 int, a2 int); select count(a1 + unnest(array[1])) from a; planner_error: |- Feature is not yet implemented: Table functions in agg call or group by is not supported yet Tracking issue: https://github.com/risingwavelabs/risingwave/issues/3814 -- sql: | - /* group by: subquery */ +- name: group by - subquery + sql: | /* This case is valid in PostgreSQL */ create table a (a1 int, a2 int); select count(a1) from a group by (select true); planner_error: |- Feature is not yet implemented: subquery inside GROUP BY No tracking issue yet. Feel free to submit a feature request at https://github.com/risingwavelabs/risingwave/issues/new?labels=type%2Ffeature&template=feature_request.yml -- sql: | - /* group by: agg */ +- name: group by - agg + sql: | /* This case is valid in PostgreSQL */ create table a (a1 int, a2 int); create table b (b1 int, b2 int); @@ -813,8 +815,8 @@ planner_error: |- Feature is not yet implemented: correlated subquery in HAVING or SELECT with agg Tracking issue: https://github.com/risingwavelabs/risingwave/issues/2275 -- sql: | - /* group by: table function */ +- name: group by - table function + sql: | /* This case is valid in PostgreSQL */ create table a (a1 int, a2 int); select count(a1) from a group by unnest(array[1]); diff --git a/src/frontend/planner_test/tests/testdata/array.yaml b/src/frontend/planner_test/tests/testdata/array.yaml index 59c0c31a5fb40..d7d2e6baffa2e 100644 --- a/src/frontend/planner_test/tests/testdata/array.yaml +++ b/src/frontend/planner_test/tests/testdata/array.yaml @@ -107,49 +107,49 @@ - sql: | select array_prepend(array[233], array[array[66]]); binder_error: 'Bind error: Cannot prepend integer[] to integer[][]' -- sql: | - /* string from/to varchar[] in implicit context */ +- name: string from/to varchar[] in implicit context + sql: | values (array['a', 'b']), ('{c,' || 'd}'); binder_error: 'Bind error: types List { datatype: Varchar } and Varchar cannot be matched' -- sql: | - /* string to varchar[] in assign context */ +- name: string to varchar[] in assign context + sql: | create table t (v1 varchar[]); insert into t values ('{c,' || 'd}'); binder_error: 'Bind error: cannot cast type "varchar" to "varchar[]" in Assign context' -- sql: | - /* string to varchar[] in explicit context */ +- name: string to varchar[] in explicit context + sql: | select ('{c,' || 'd}')::varchar[]; logical_plan: | LogicalProject { exprs: [ConcatOp('{c,':Varchar, 'd}':Varchar)::List { datatype: Varchar }] } └─LogicalValues { rows: [[]], schema: Schema { fields: [] } } -- sql: | - /* unknown to varchar[] in implicit context */ +- name: unknown to varchar[] in implicit context + sql: | values (array['a', 'b']), ('{c,d}'); logical_plan: | LogicalValues { rows: [[Array('a':Varchar, 'b':Varchar)], ['{c,d}':Varchar::List { datatype: Varchar }]], schema: Schema { fields: [*VALUES*_0.column_0:List { datatype: Varchar }] } } -- sql: | - /* unknown to varchar[] in assign context */ +- name: unknown to varchar[] in assign context + sql: | create table t (v1 varchar[]); insert into t values ('{c,d}'); logical_plan: | LogicalInsert { table: t } └─LogicalValues { rows: [['{c,d}':Varchar::List { datatype: Varchar }]], schema: Schema { fields: [*VALUES*_0.column_0:List { datatype: Varchar }] } } -- sql: | - /* unknown to varchar[] in explicit context */ +- name: unknown to varchar[] in explicit context + sql: | select ('{c,d}')::varchar[]; logical_plan: | LogicalProject { exprs: ['{c,d}':Varchar::List { datatype: Varchar }] } └─LogicalValues { rows: [[]], schema: Schema { fields: [] } } -- sql: | - /* varchar[] to string in assign context */ +- name: varchar[] to string in assign context + sql: | create table t (v1 varchar); insert into t values (array['a', 'b']); logical_plan: | LogicalInsert { table: t } └─LogicalValues { rows: [[Array('a':Varchar, 'b':Varchar)::Varchar]], schema: Schema { fields: [*VALUES*_0.column_0:Varchar] } } -- sql: | - /* varchar[] to string in explicit context */ +- name: varchar[] to string in explicit context + sql: | select array['a', 'b']::varchar; logical_plan: | LogicalProject { exprs: [Array('a':Varchar, 'b':Varchar)::Varchar] } diff --git a/src/frontend/planner_test/tests/testdata/basic_query.yaml b/src/frontend/planner_test/tests/testdata/basic_query.yaml index 22c1f2e3a17f6..6cd2cb50c80c7 100644 --- a/src/frontend/planner_test/tests/testdata/basic_query.yaml +++ b/src/frontend/planner_test/tests/testdata/basic_query.yaml @@ -39,48 +39,48 @@ StreamMaterialize { columns: [v1, t._row_id(hidden)], pk_columns: [t._row_id] } └─StreamFilter { predicate: (t.v1 < 1:Int32) } └─StreamTableScan { table: t, columns: [t.v1, t._row_id], pk: [t._row_id], distribution: UpstreamHashShard(t._row_id) } -- sql: | - /* test boolean expression common factor extraction */ +- name: test boolean expression common factor extraction + sql: | create table t (v1 Boolean, v2 Boolean, v3 Boolean); select * from t where v1 AND v2 AND ((v1 AND v2) OR (v2 AND v3)); batch_plan: | BatchExchange { order: [], dist: Single } └─BatchFilter { predicate: t.v1 AND t.v2 AND (t.v1 OR t.v3) } └─BatchScan { table: t, columns: [t.v1, t.v2, t.v3], distribution: SomeShard } -- sql: | - /* test boolean expression simplification */ +- name: test boolean expression simplification + sql: | create table t (v1 Boolean, v2 Boolean, v3 Boolean); select * from t where v1 AND NOT(v1 OR v2 Or NOT(v1 AND v2 AND true)); batch_plan: | BatchExchange { order: [], dist: Single } └─BatchFilter { predicate: t.v1 AND Not(t.v1) AND Not(t.v2) AND t.v2 } └─BatchScan { table: t, columns: [t.v1, t.v2, t.v3], distribution: SomeShard } -- sql: | - /* test boolean expression simplification */ +- name: test boolean expression simplification + sql: | create table t (v1 Boolean, v2 Boolean); select * from t where (v1 AND v2) OR (v1 AND v2); batch_plan: | BatchExchange { order: [], dist: Single } └─BatchFilter { predicate: t.v1 AND t.v2 } └─BatchScan { table: t, columns: [t.v1, t.v2], distribution: SomeShard } -- sql: | - /* constant folding for IS TRUE, IS FALSE, IS NULL*/ +- name: constant folding for IS TRUE, IS FALSE, IS NULL + sql: | create table t(a Boolean); select * from t where (NULL IS NULL) IS TRUE AND FALSE IS FALSE AND a; logical_plan: | LogicalProject { exprs: [t.a] } └─LogicalFilter { predicate: t.a } └─LogicalScan { table: t, columns: [t.a, t._row_id] } -- sql: | - /* constant folding for IS NOT TRUE, IS NOT FALSE */ +- name: constant folding for IS NOT TRUE, IS NOT FALSE + sql: | create table t(a Boolean); select * from t where (NULL IS NOT TRUE) IS NOT FALSE AND a IS NOT TRUE; logical_plan: | LogicalProject { exprs: [t.a] } └─LogicalFilter { predicate: IsNotTrue(t.a) } └─LogicalScan { table: t, columns: [t.a, t._row_id] } -- sql: | - /* constant folding IS NOT NULL */ +- name: constant folding IS NOT NULL + sql: | create table t(a double precision); select * from t where (a IS NOT NULL AND 3.14 IS NOT NULL) OR (NULL IS NOT NULL); logical_plan: | @@ -151,14 +151,14 @@ logical_plan: | LogicalProject { exprs: [] } └─LogicalScan { table: t, columns: [t._row_id] } -- sql: | - /* disallow subquery in values */ +- name: disallow subquery in values + sql: | values(1, (select 1)); binder_error: |- Feature is not yet implemented: Subquery in VALUES No tracking issue yet. Feel free to submit a feature request at https://github.com/risingwavelabs/risingwave/issues/new?labels=type%2Ffeature&template=feature_request.yml -- sql: | - /* disallow correlated_input_ref in values */ +- name: disallow correlated_input_ref in values + sql: | create table t(v1 int); select v1 from t where exists (values(v1)); binder_error: |- diff --git a/src/frontend/planner_test/tests/testdata/column_pruning.yaml b/src/frontend/planner_test/tests/testdata/column_pruning.yaml index bcff809839f03..4db81e9a00f77 100644 --- a/src/frontend/planner_test/tests/testdata/column_pruning.yaml +++ b/src/frontend/planner_test/tests/testdata/column_pruning.yaml @@ -7,8 +7,8 @@ └─LogicalScan { table: t, columns: [t.v1, t.v2, t._row_id] } optimized_logical_plan: | LogicalScan { table: t, columns: [t.v1] } -- sql: | - /* filter */ +- name: filter + sql: | create table t (v1 bigint, v2 double precision, v3 int); select v1 from t where v2 > 2 logical_plan: | @@ -17,8 +17,8 @@ └─LogicalScan { table: t, columns: [t.v1, t.v2, t.v3, t._row_id] } optimized_logical_plan: | LogicalScan { table: t, output_columns: [t.v1], required_columns: [v1, v2], predicate: (t.v2 > 2:Int32) } -- sql: | - /* join */ +- name: join + sql: | create table t1 (v1 int, v2 int, v3 int); create table t2 (v1 int, v2 int, v3 int); select t1.v1, t2.v1 from t1 join t2 on t1.v2 = t2.v2; @@ -31,8 +31,8 @@ LogicalJoin { type: Inner, on: (t1.v2 = t2.v2), output: [t1.v1, t2.v1] } ├─LogicalScan { table: t1, columns: [t1.v1, t1.v2] } └─LogicalScan { table: t2, columns: [t2.v1, t2.v2] } -- sql: | - /* agg */ +- name: agg + sql: | create table t (v1 bigint, v2 double precision, v3 int); select count(v1) from t where v2 > 2 logical_plan: | @@ -44,8 +44,8 @@ optimized_logical_plan: | LogicalAgg { aggs: [count(t.v1)] } └─LogicalScan { table: t, output_columns: [t.v1], required_columns: [v1, v2], predicate: (t.v2 > 2:Int32) } -- sql: | - /* top n */ +- name: top n + sql: | create table t (v1 int, v2 int, v3 int); select v3 from (select * from t order by v3, v2 limit 2) as s; logical_plan: | @@ -57,8 +57,8 @@ LogicalProject { exprs: [t.v3] } └─LogicalTopN { order: "[t.v3 ASC, t.v2 ASC]", limit: 2, offset: 0 } └─LogicalScan { table: t, columns: [t.v2, t.v3] } -- sql: | - /* constant */ +- name: constant + sql: | create table t (v1 bigint, v2 double precision, v3 int); select 1 from t logical_plan: | @@ -67,8 +67,8 @@ optimized_logical_plan: | LogicalProject { exprs: [1:Int32] } └─LogicalScan { table: t, columns: [] } -- sql: | - /* constant + filter */ +- name: constant + filter + sql: | create table t (v1 bigint, v2 double precision, v3 int); select 1 from t where v2>1 logical_plan: | @@ -78,8 +78,8 @@ optimized_logical_plan: | LogicalProject { exprs: [1:Int32] } └─LogicalScan { table: t, output_columns: [], required_columns: [v2], predicate: (t.v2 > 1:Int32) } -- sql: | - /* constant agg */ +- name: constant agg + sql: | create table t (v1 bigint, v2 double precision, v3 int); select count(1) from t logical_plan: | @@ -91,8 +91,8 @@ LogicalAgg { aggs: [count(1:Int32)] } └─LogicalProject { exprs: [1:Int32] } └─LogicalScan { table: t, columns: [] } -- sql: | - /* constant agg + filter */ +- name: constant agg + filter + sql: | create table t (v1 bigint, v2 double precision, v3 int); select count(1) from t where v2>1 logical_plan: | @@ -105,8 +105,8 @@ LogicalAgg { aggs: [count(1:Int32)] } └─LogicalProject { exprs: [1:Int32] } └─LogicalScan { table: t, output_columns: [], required_columns: [v2], predicate: (t.v2 > 1:Int32) } -- sql: | - /* join + filter */ +- name: join + filter + sql: | create table t1 (v1 int, v2 int, v3 int); create table t2 (v1 int, v2 int, v3 int); select t1.v1, t2.v1 from t1 join t2 on t1.v2 = t2.v2 where t1.v3 < 1; @@ -120,8 +120,8 @@ LogicalJoin { type: Inner, on: (t1.v2 = t2.v2), output: [t1.v1, t2.v1] } ├─LogicalScan { table: t1, output_columns: [t1.v1, t1.v2], required_columns: [v1, v2, v3], predicate: (t1.v3 < 1:Int32) } └─LogicalScan { table: t2, columns: [t2.v1, t2.v2] } -- sql: | - /* mixed */ +- name: mixed + sql: | create table t (v1 bigint, v2 double precision, v3 int); select count(1), count(v1) from t where v2>1 logical_plan: | @@ -134,8 +134,8 @@ LogicalAgg { aggs: [count(1:Int32), count(t.v1)] } └─LogicalProject { exprs: [1:Int32, t.v1] } └─LogicalScan { table: t, output_columns: [t.v1], required_columns: [v1, v2], predicate: (t.v2 > 1:Int32) } -- sql: | - /* hop window, time_col not selected */ +- name: hop window, time_col not selected + sql: | create table t1 (a int, b int, created_at timestamp); select a, window_end from hop(t1, created_at, interval '15' minute, interval '30' minute) logical_plan: | diff --git a/src/frontend/planner_test/tests/testdata/common_table_expressions.yaml b/src/frontend/planner_test/tests/testdata/common_table_expressions.yaml index 3fdffa1ecbeaf..b856215e8c532 100644 --- a/src/frontend/planner_test/tests/testdata/common_table_expressions.yaml +++ b/src/frontend/planner_test/tests/testdata/common_table_expressions.yaml @@ -50,8 +50,8 @@ | └─LogicalScan { table: t1, columns: [t1.x, t1._row_id] } └─LogicalProject { exprs: [0.1:Decimal] } └─LogicalValues { rows: [[]], schema: Schema { fields: [] } } -- sql: | - /* Ensure we can bind CTE with aliases in both table name and columns */ +- name: Ensure we can bind CTE with aliases in both table name and columns + sql: | create table t1 (x int, y int); with cte (cost) as (select * from t1) select * from cte as t2 (outflow, profit) join cte on (outflow = cost); logical_plan: | diff --git a/src/frontend/planner_test/tests/testdata/expr.yaml b/src/frontend/planner_test/tests/testdata/expr.yaml index c3819f8d1264b..8ec1b2f31f422 100644 --- a/src/frontend/planner_test/tests/testdata/expr.yaml +++ b/src/frontend/planner_test/tests/testdata/expr.yaml @@ -1,12 +1,12 @@ # This file is automatically generated. See `src/frontend/planner_test/README.md` for more information. -- sql: | - /* bind typed literal */ +- name: bind typed literal - int + sql: | select int '1'; logical_plan: | LogicalProject { exprs: ['1':Varchar::Int32] } └─LogicalValues { rows: [[]], schema: Schema { fields: [] } } -- sql: | - /* bind typed literal */ +- name: bind typed literal - bool + sql: | SELECT bool 't' logical_plan: | LogicalProject { exprs: ['t':Varchar::Boolean] } @@ -31,42 +31,42 @@ BatchExchange { order: [], dist: Single } └─BatchProject { exprs: [IsNull(IsNotNull(IsFalse(IsNotFalse(IsTrue(IsNotTrue(false:Boolean))))))] } └─BatchScan { table: t, columns: [], distribution: SomeShard } -- sql: | - /* bind between */ +- name: bind between + sql: | SELECT 1 between 2 and 3 logical_plan: | LogicalProject { exprs: [((1:Int32 >= 2:Int32) AND (1:Int32 <= 3:Int32))] } └─LogicalValues { rows: [[]], schema: Schema { fields: [] } } -- sql: | - /* bind is distinct from */ +- name: bind is distinct from + sql: | SELECT 1 IS DISTINCT FROM 2 logical_plan: | LogicalProject { exprs: [IsDistinctFrom(1:Int32, 2:Int32)] } └─LogicalValues { rows: [[]], schema: Schema { fields: [] } } -- sql: | - /* bind is not distinct from */ +- name: bind is not distinct from + sql: | SELECT 1 IS NOT DISTINCT FROM 2 logical_plan: | LogicalProject { exprs: [IsNotDistinctFrom(1:Int32, 2:Int32)] } └─LogicalValues { rows: [[]], schema: Schema { fields: [] } } -- sql: | - /* in-list with aligned types */ +- name: in-list with aligned types + sql: | SELECT 1::real in (3, 1.0, 2); batch_plan: | BatchProject { exprs: [In(1:Int32::Float32, 3:Int32::Float32, 1.0:Decimal::Float32, 2:Int32::Float32)] } └─BatchValues { rows: [[]] } -- sql: | - /* not in-list with aligned types */ +- name: not in-list with aligned types + sql: | SELECT 1::real not in (3, 1.0, 2); batch_plan: | BatchProject { exprs: [Not(In(1:Int32::Float32, 3:Int32::Float32, 1.0:Decimal::Float32, 2:Int32::Float32))] } └─BatchValues { rows: [[]] } -- sql: | - /* in-list with misaligned types */ +- name: in-list with misaligned types + sql: | SELECT true in (3, 1.0, 2); binder_error: 'Bind error: types Boolean and Int32 cannot be matched' -- sql: | - /* in-list with non-const: agg */ +- name: in-list with non-const - agg + sql: | create table t (v1 int); SELECT 1 in (3, 0.5*2, min(v1)) from t; batch_plan: | @@ -75,8 +75,8 @@ └─BatchExchange { order: [], dist: Single } └─BatchSimpleAgg { aggs: [min(t.v1)] } └─BatchScan { table: t, columns: [t.v1], distribution: SomeShard } -- sql: | - /* in-list with non-const: scalar subquery */ +- name: in-list with non-const - scalar subquery + sql: | create table t (v1 int); create table b (b1 int, b2 int); SELECT b2 from b where 1 in (3, 1.0, (select min(v1) from t)); @@ -90,8 +90,8 @@ └─BatchExchange { order: [], dist: Single } └─BatchSimpleAgg { aggs: [min(t.v1)] } └─BatchScan { table: t, columns: [t.v1], distribution: SomeShard } -- sql: | - /* in-list with non-const: correlated ref */ +- name: in-list with non-const - correlated ref + sql: | create table t (v1 int); create table b (b1 int, b2 int); SELECT b2 from b where exists (select 2 from t where v1 in (3, 1.0, b1)); @@ -159,8 +159,8 @@ BatchProject { exprs: [Position(Replace('1':Varchar, '1':Varchar, '2':Varchar), '123':Varchar)] } └─BatchFilter { predicate: Like('12':Varchar, '%1':Varchar) } └─BatchValues { rows: [[]] } -- sql: | - /* case searched form with else */ +- name: case searched form with else + sql: | create table t (v1 int); select (case when v1=1 then 1 when v1=2 then 2 else 0.0 end) as expr from t; batch_plan: | @@ -171,29 +171,29 @@ StreamMaterialize { columns: [expr, t._row_id(hidden)], pk_columns: [t._row_id] } └─StreamProject { exprs: [Case((t.v1 = 1:Int32), 1:Int32::Decimal, (t.v1 = 2:Int32), 2:Int32::Decimal, 0.0:Decimal), t._row_id] } └─StreamTableScan { table: t, columns: [t.v1, t._row_id], pk: [t._row_id], distribution: UpstreamHashShard(t._row_id) } -- sql: | - /* case searched form without else */ +- name: case searched form without else + sql: | create table t (v1 int); select (case when v1=1 then 1 when v1=2 then 2.1 end) from t; batch_plan: | BatchExchange { order: [], dist: Single } └─BatchProject { exprs: [Case((t.v1 = 1:Int32), 1:Int32::Decimal, (t.v1 = 2:Int32), 2.1:Decimal)] } └─BatchScan { table: t, columns: [t.v1], distribution: SomeShard } -- sql: | - /* case simple form */ +- name: case simple form + sql: | create table t (v1 int); select (case v1 when 1 then 1 when 2.0 then 2 else 0.0 end) from t; batch_plan: | BatchExchange { order: [], dist: Single } └─BatchProject { exprs: [Case((t.v1 = 1:Int32), 1:Int32::Decimal, (t.v1 = 2.0:Decimal), 2:Int32::Decimal, 0.0:Decimal)] } └─BatchScan { table: t, columns: [t.v1], distribution: SomeShard } -- sql: | - /* case misaligned result types */ +- name: case misaligned result types + sql: | create table t (v1 int); select (case when v1=1 then 1 when v1=2 then 2 else true end) from t; binder_error: 'Bind error: types Int32 and Boolean cannot be matched' -- sql: | - /* case misaligned value types */ +- name: case misaligned value types + sql: | create table t (v1 int); select (case v1 when 1 then 1 when true then 2 else 0.0 end) from t; binder_error: |- diff --git a/src/frontend/planner_test/tests/testdata/insert.yaml b/src/frontend/planner_test/tests/testdata/insert.yaml index b61d1829041d4..b2f09609a4243 100644 --- a/src/frontend/planner_test/tests/testdata/insert.yaml +++ b/src/frontend/planner_test/tests/testdata/insert.yaml @@ -1,72 +1,72 @@ # This file is automatically generated. See `src/frontend/planner_test/README.md` for more information. -- sql: | - /* insert values on matching types */ +- name: insert values on matching types + sql: | create table t (v1 int, v2 int); insert into t values (22, 33), (44, 55); batch_plan: | BatchExchange { order: [], dist: Single } └─BatchInsert { table: t } └─BatchValues { rows: [[22:Int32, 33:Int32], [44:Int32, 55:Int32]] } -- sql: | - /* insert values on assign-castable types */ +- name: insert values on assign-castable types + sql: | create table t (v1 real, v2 int); insert into t values (22.33, '33'), (44, 55.0); batch_plan: | BatchExchange { order: [], dist: Single } └─BatchInsert { table: t } └─BatchValues { rows: [[22.33:Decimal::Float32, '33':Varchar::Int32], [44:Int32::Float32, 55.0:Decimal::Int32]] } -- sql: | - /* insert values on non-assign-castable types */ +- name: insert values on non-assign-castable types + sql: | create table t (v1 real, v2 int); insert into t values (22.33, true); binder_error: 'Bind error: cannot cast type "boolean" to "integer" in Assign context' -- sql: | - /* insert values mismatch columns length */ +- name: insert values mismatch columns length + sql: | create table t (v1 real, v2 int, v3 varchar); insert into t values (1, 2), (3, 4); binder_error: 'Bind error: INSERT has more target columns than expressions' -- sql: | - /* insert literal null */ +- name: insert literal null + sql: | create table t(v1 int); insert into t values(NULL); batch_plan: | BatchExchange { order: [], dist: Single } └─BatchInsert { table: t } └─BatchValues { rows: [[null:Int32]] } -- sql: | - /* insert values cast each expr rather than whole `VALUES` (compare with below) */ +- name: insert values cast each expr rather than whole `VALUES` (compare with below) + sql: | create table t (v1 time); insert into t values (timestamp '2020-01-01 01:02:03'), (time '03:04:05'); batch_plan: | BatchExchange { order: [], dist: Single } └─BatchInsert { table: t } └─BatchValues { rows: [['2020-01-01 01:02:03':Varchar::Timestamp::Time], ['03:04:05':Varchar::Time]] } -- sql: | - /* a `VALUES` without insert context may be invalid on its own (compare with above) */ +- name: a `VALUES` without insert context may be invalid on its own (compare with above) + sql: | create table t (v1 time); values (timestamp '2020-01-01 01:02:03'), (time '03:04:05'); binder_error: 'Bind error: types Timestamp and Time cannot be matched' -- sql: | - /* a `VALUES` with `limit` loses insert context (compare with 2 cases above) */ +- name: a `VALUES` with `limit` loses insert context (compare with 2 cases above) + sql: | create table t (v1 time); insert into t values (timestamp '2020-01-01 01:02:03'), (time '03:04:05') limit 1; binder_error: 'Bind error: types Timestamp and Time cannot be matched' -- sql: | - /* null in first row without insert context */ +- name: null in first row without insert context + sql: | values (null), (1); batch_plan: | BatchValues { rows: [[null:Int32], [1:Int32]] } -- sql: | - /* null in later rows without insert context */ +- name: null in later rows without insert context + sql: | values (1), (null), (2.3); batch_plan: | BatchValues { rows: [[1:Int32::Decimal], [null:Decimal], [2.3:Decimal]] } -- sql: | - /* rows of different number of columns */ +- name: rows of different number of columns + sql: | values (1), (2, 3); binder_error: 'Bind error: VALUES lists must all be the same length' -- sql: | - /* insert into select without cast */ +- name: insert into select without cast + sql: | create table t (v1 time); insert into t select v1 from t; batch_plan: | @@ -74,8 +74,8 @@ └─BatchInsert { table: t } └─BatchExchange { order: [], dist: Single } └─BatchScan { table: t, columns: [t.v1], distribution: SomeShard } -- sql: | - /* insert into select with cast */ +- name: insert into select with cast + sql: | create table t (v1 time, v2 int, v3 real); insert into t select timestamp '2020-01-01 01:02:03', 11, 4.5 from t; batch_plan: | @@ -84,19 +84,19 @@ └─BatchExchange { order: [], dist: Single } └─BatchProject { exprs: ['2020-01-01 01:02:03':Varchar::Timestamp::Time, 11:Int32, 4.5:Decimal::Float32] } └─BatchScan { table: t, columns: [], distribution: SomeShard } -- sql: | - /* insert into select with cast error */ +- name: insert into select with cast error + sql: | create table t (v1 timestamp, v2 real); insert into t select time '01:02:03', 4.5 from t; binder_error: 'Bind error: cannot cast type "time without time zone" to "timestamp without time zone" in Assign context' -- sql: | - /* insert into select mismatch columns length */ +- name: insert into select mismatch columns length + sql: | create table t (v1 int, v2 real); insert into t select 2, 3, 4.5 from t; binder_error: 'Bind error: INSERT has more expressions than target columns' -- sql: | - /* insert with join */ +- name: insert with join + sql: | create table t1 (a int, b int); create table t2 (c int, d int); create table t3 (e int, f int); diff --git a/src/frontend/planner_test/tests/testdata/join.yaml b/src/frontend/planner_test/tests/testdata/join.yaml index 326f4a30c49c0..eaa290c29b7c6 100644 --- a/src/frontend/planner_test/tests/testdata/join.yaml +++ b/src/frontend/planner_test/tests/testdata/join.yaml @@ -22,8 +22,8 @@ | └─StreamTableScan { table: t2, columns: [t2.v3, t2.v4, t2._row_id], pk: [t2._row_id], distribution: UpstreamHashShard(t2._row_id) } └─StreamExchange { dist: HashShard(t3.v5) } └─StreamTableScan { table: t3, columns: [t3.v5, t3.v6, t3._row_id], pk: [t3._row_id], distribution: UpstreamHashShard(t3._row_id) } -- sql: | - /* self join */ +- name: self join + sql: | create table t (v1 int, v2 int); select t1.v1 as t1v1, t2.v1 as t2v1 from t t1 join t t2 on t1.v1 = t2.v1; logical_plan: | @@ -143,8 +143,8 @@ | └─BatchScan { table: bc, columns: [bc.b, bc.c], distribution: SomeShard } └─BatchExchange { order: [], dist: HashShard(ca.c) } └─BatchScan { table: ca, columns: [ca.c, ca.a], distribution: SomeShard } -- sql: | - /* Only push to left */ +- name: Only push to left + sql: | create table t1 (v1 int, v2 int); create table t2 (v1 int, v2 int); select * from t1 left join t2 where t1.v2 > 100; @@ -152,8 +152,8 @@ LogicalJoin { type: LeftOuter, on: true, output: all } ├─LogicalScan { table: t1, output_columns: [t1.v1, t1.v2], required_columns: [v1, v2], predicate: (t1.v2 > 100:Int32) } └─LogicalScan { table: t2, columns: [t2.v1, t2.v2] } -- sql: | - /* Only push to right */ +- name: Only push to right + sql: | create table t1 (v1 int, v2 int); create table t2 (v1 int, v2 int); select * from t1 right join t2 where t2.v2 > 100; @@ -161,8 +161,8 @@ LogicalJoin { type: LeftOuter, on: true, output: [t1.v1, t1.v2, t2.v1, t2.v2] } ├─LogicalScan { table: t2, output_columns: [t2.v1, t2.v2], required_columns: [v1, v2], predicate: (t2.v2 > 100:Int32) } └─LogicalScan { table: t1, columns: [t1.v1, t1.v2] } -- sql: | - /* Push to left, right and on */ +- name: Push to left, right and on + sql: | create table t1 (v1 int, v2 int); create table t2 (v1 int, v2 int); select * from t1, t2 where t1.v1 > 100 and t2.v1 < 1000 and t1.v2 = t2.v2; @@ -170,8 +170,8 @@ LogicalJoin { type: Inner, on: (t1.v2 = t2.v2), output: all } ├─LogicalScan { table: t1, output_columns: [t1.v1, t1.v2], required_columns: [v1, v2], predicate: (t1.v1 > 100:Int32) } └─LogicalScan { table: t2, output_columns: [t2.v1, t2.v2], required_columns: [v1, v2], predicate: (t2.v1 < 1000:Int32) } -- sql: | - /* Left & right has same SomeShard distribution. There should still be exchanges below hash join */ +- name: Left & right has same SomeShard distribution. There should still be exchanges below hash join + sql: | create table t(x int); create index i on t(x); select i.x as ix, ii.x as iix from i join i as ii on i.x=ii.x; @@ -189,8 +189,8 @@ | └─StreamTableScan { table: i, columns: [i.x, i.t._row_id], pk: [i.t._row_id], distribution: UpstreamHashShard(i.x) } └─StreamExchange { dist: HashShard(i.x) } └─StreamTableScan { table: i, columns: [i.x, i.t._row_id], pk: [i.t._row_id], distribution: UpstreamHashShard(i.x) } -- sql: | - /* Left & right has same SomeShard distribution. There should still be exchanges below hash join */ +- name: Left & right has same SomeShard distribution. There should still be exchanges below hash join + sql: | create table t(x int); create index i on t(x); select i.x as ix, t.x as tx from i join t on i.x=t.x; @@ -208,8 +208,8 @@ | └─StreamTableScan { table: i, columns: [i.x, i.t._row_id], pk: [i.t._row_id], distribution: UpstreamHashShard(i.x) } └─StreamExchange { dist: HashShard(t.x) } └─StreamTableScan { table: t, columns: [t.x, t._row_id], pk: [t._row_id], distribution: UpstreamHashShard(t._row_id) } -- sql: | - /* Left & right has same HashShard distribution. There should be no exchange below hash join */ +- name: Left & right has same HashShard distribution. There should be no exchange below hash join + sql: | create table t(x int); create index i on t(x); select * from @@ -246,8 +246,8 @@ | └─StreamTableScan { table: i, columns: [i.x, i.t._row_id], pk: [i.t._row_id], distribution: UpstreamHashShard(i.x) } └─StreamExchange { dist: HashShard(i.x) } └─StreamTableScan { table: i, columns: [i.x, i.t._row_id], pk: [i.t._row_id], distribution: UpstreamHashShard(i.x) } -- sql: | - /* Use lookup join */ +- name: Use lookup join + sql: | create table t1 (v1 int, v2 int); create table t2 (v1 int, v2 int); create materialized view t3 as select v1, count(v2) as v2 from t2 group by v1; @@ -259,8 +259,8 @@ with_config_map: QUERY_MODE: local RW_BATCH_ENABLE_LOOKUP_JOIN: 'true' -- sql: | - /* Ensure correct binding of join with USING clause */ +- name: Ensure correct binding of join with USING clause + sql: | create table t1(v1 varchar); create table t2(v1 varchar); create table t3(v2 varchar); @@ -272,8 +272,8 @@ └─LogicalJoin { type: Inner, on: (t1.v1 = t2.v1), output: all } ├─LogicalScan { table: t1, columns: [t1.v1, t1._row_id] } └─LogicalScan { table: t2, columns: [t2.v1, t2._row_id] } -- sql: | - /* Ensure correct binding of join with ON clause */ +- name: Ensure correct binding of join with ON clause + sql: | create table t1(v1 varchar); create table t2(v2 varchar); create table t3(v3 varchar); @@ -285,8 +285,8 @@ └─LogicalJoin { type: Inner, on: (t1.v1 = t2.v2), output: all } ├─LogicalScan { table: t1, columns: [t1.v1, t1._row_id] } └─LogicalScan { table: t2, columns: [t2.v2, t2._row_id] } -- sql: | - /* Ensure correct binding with USING clause with left outer join */ +- name: Ensure correct binding with USING clause with left outer join + sql: | create table t1(v1 varchar); create table t2(v1 varchar); create table t3(v2 varchar); @@ -298,8 +298,8 @@ └─LogicalJoin { type: LeftOuter, on: (t1.v1 = t2.v1), output: all } ├─LogicalScan { table: t1, columns: [t1.v1, t1._row_id] } └─LogicalScan { table: t2, columns: [t2.v1, t2._row_id] } -- sql: | - /* Ensure correct binding with ON clause with left outer join */ +- name: Ensure correct binding with ON clause with left outer join + sql: | create table t1(v1 varchar); create table t2(v2 varchar); create table t3(v3 varchar); @@ -311,8 +311,8 @@ └─LogicalJoin { type: LeftOuter, on: (t1.v1 = t2.v2), output: all } ├─LogicalScan { table: t1, columns: [t1.v1, t1._row_id] } └─LogicalScan { table: t2, columns: [t2.v2, t2._row_id] } -- sql: | - /* Ensure that ON clause cannot reference correlated columns */ +- name: Ensure that ON clause cannot reference correlated columns + sql: | create table a(a1 int); create table b(b1 int); create table c(c1 int); @@ -325,8 +325,8 @@ binder_error: |- Feature is not yet implemented: lateral subqueries are not yet supported Tracking issue: https://github.com/risingwavelabs/risingwave/issues/3815 -- sql: | - /* Ensure that natural joins bind the correct columns */ +- name: Ensure that natural joins bind the correct columns + sql: | create table a(x int); create table b(x int); create table c(y int); @@ -338,8 +338,8 @@ | ├─LogicalScan { table: a, columns: [a.x, a._row_id] } | └─LogicalScan { table: b, columns: [b.x, b._row_id] } └─LogicalScan { table: c, columns: [c.y, c._row_id] } -- sql: | - /* Ensure that natural joins can disambiguate columns */ +- name: Ensure that natural joins can disambiguate columns + sql: | create table a(x int); create table b(x int); select x, a.x, b.x from a natural join b; @@ -348,8 +348,8 @@ └─LogicalJoin { type: Inner, on: (a.x = b.x), output: all } ├─LogicalScan { table: a, columns: [a.x, a._row_id] } └─LogicalScan { table: b, columns: [b.x, b._row_id] } -- sql: | - /* Ensure that natural joins bind the correct columns */ +- name: Ensure that natural joins bind the correct columns + sql: | create table a(x int); create table b(x int); create table c(y int); @@ -361,8 +361,8 @@ | ├─LogicalScan { table: a, columns: [a.x, a._row_id] } | └─LogicalScan { table: b, columns: [b.x, b._row_id] } └─LogicalScan { table: c, columns: [c.y, c._row_id] } -- sql: | - /* Ensure that natural joins can disambiguate columns */ +- name: Ensure that natural joins can disambiguate columns + sql: | create table a(x int); create table b(x int); select x, a.x, b.x from a natural join b; @@ -371,8 +371,8 @@ └─LogicalJoin { type: Inner, on: (a.x = b.x), output: all } ├─LogicalScan { table: a, columns: [a.x, a._row_id] } └─LogicalScan { table: b, columns: [b.x, b._row_id] } -- sql: | - /* Ensure that natural joins bind the correct columns */ +- name: Ensure that natural joins bind the correct columns + sql: | create table a(x int); create table b(x int); create table c(y int); @@ -384,8 +384,8 @@ | ├─LogicalScan { table: a, columns: [a.x, a._row_id] } | └─LogicalScan { table: b, columns: [b.x, b._row_id] } └─LogicalScan { table: c, columns: [c.y, c._row_id] } -- sql: | - /* Ensure that natural joins bind the correct columns */ +- name: Ensure that natural joins bind the correct columns + sql: | create table a(x int); create table b(x int); select x from a natural join b; @@ -394,8 +394,8 @@ └─LogicalJoin { type: Inner, on: (a.x = b.x), output: all } ├─LogicalScan { table: a, columns: [a.x, a._row_id] } └─LogicalScan { table: b, columns: [b.x, b._row_id] } -- sql: | - /* Ensure that natural joins bind the correct columns */ +- name: Ensure that natural joins bind the correct columns + sql: | create table a(x int); create table b(x int); select x from a natural left join b; @@ -404,8 +404,8 @@ └─LogicalJoin { type: LeftOuter, on: (a.x = b.x), output: all } ├─LogicalScan { table: a, columns: [a.x, a._row_id] } └─LogicalScan { table: b, columns: [b.x, b._row_id] } -- sql: | - /* Ensure that natural joins bind the correct columns */ +- name: Ensure that natural joins bind the correct columns + sql: | create table a(x int); create table b(x int); select x, a.x, b.x from a natural right join b; @@ -414,8 +414,8 @@ └─LogicalJoin { type: RightOuter, on: (a.x = b.x), output: all } ├─LogicalScan { table: a, columns: [a.x, a._row_id] } └─LogicalScan { table: b, columns: [b.x, b._row_id] } -- sql: | - /* Ensure that natural joins bind the correct columns */ +- name: Ensure that natural joins bind the correct columns + sql: | create table a(x int); create table b(x int); select x, a.x, b.x from a natural full join b; @@ -424,8 +424,8 @@ └─LogicalJoin { type: FullOuter, on: (a.x = b.x), output: all } ├─LogicalScan { table: a, columns: [a.x, a._row_id] } └─LogicalScan { table: b, columns: [b.x, b._row_id] } -- sql: | - /* Ensure that nested natural joins bind and disambiguate columns */ +- name: Ensure that nested natural joins bind and disambiguate columns + sql: | create table a(x int, y int); create table b(x int, z int); create table c(x int, a int); @@ -437,8 +437,8 @@ | ├─LogicalScan { table: a, columns: [a.x, a.y, a._row_id] } | └─LogicalScan { table: b, columns: [b.x, b.z, b._row_id] } └─LogicalScan { table: c, columns: [c.x, c.a, c._row_id] } -- sql: | - /* Ensure that nested natural joins bind and disambiguate columns */ +- name: Ensure that nested natural joins bind and disambiguate columns + sql: | create table a(x int, y int); create table b(x int, z int); create table c(x int, a int); @@ -459,8 +459,8 @@ | └─LogicalScan { table: b, columns: [b.x] } └─LogicalProject { exprs: [c.x, c.x] } └─LogicalScan { table: c, columns: [c.x] } -- sql: | - /* Ensure that nested natural joins bind and disambiguate columns */ +- name: Ensure that nested natural joins bind and disambiguate columns + sql: | create table a(a int, y int); create table b(x int, z int); create table c(x int, a int); @@ -472,22 +472,22 @@ | ├─LogicalScan { table: a, columns: [a.a, a.y, a._row_id] } | └─LogicalScan { table: b, columns: [b.x, b.z, b._row_id] } └─LogicalScan { table: c, columns: [c.x, c.a, c._row_id] } -- sql: | - /* Ensure error on non-existent USING col */ +- name: Ensure error on non-existent USING col + sql: | create table t1(v1 int, v2 int); create table t2(v1 int, v3 int); select * from t1 join t2 using (v2); binder_error: 'Item not found: column "v2" specified in USING clause does not exist in right table' -- sql: | - /* Ensure error on non-existent USING col */ +- name: Ensure error on non-existent USING col + sql: | create table t1(v1 int, v2 int); create table t2(v1 int, v3 int); select * from t1 join t2 using (v3); binder_error: 'Item not found: column "v3" specified in USING clause does not exist in left table' -- sql: | - /* Ensure that we can correctly bind nested joins */ +- name: Ensure that we can correctly bind nested joins + sql: | create table t1(v1 int, v2 int); create table t2(v3 int, v4 int); create table t3(v5 int, v6 int); @@ -502,8 +502,8 @@ └─LogicalJoin { type: Inner, on: (t3.v5 = t4.v7), output: all } ├─LogicalScan { table: t3, columns: [t3.v5, t3.v6, t3._row_id] } └─LogicalScan { table: t4, columns: [t4.v7, t4.v8, t4._row_id] } -- sql: | - /* Ensure that we can correctly bind nested joins with ambiguous column names */ +- name: Ensure that we can correctly bind nested joins with ambiguous column names + sql: | create table t1(x int); create table t2(x int); create table t3(x int); @@ -515,8 +515,8 @@ └─LogicalJoin { type: FullOuter, on: (t2.x = t3.x), output: all } ├─LogicalScan { table: t2, columns: [t2.x, t2._row_id] } └─LogicalScan { table: t3, columns: [t3.x, t3._row_id] } -- sql: | - /* Ensure that non-trivial ambiguous references can be resolved */ +- name: Ensure that non-trivial ambiguous references can be resolved + sql: | create table a(x int); create table b(x int); select 2 * x as Y, x + x as Z from a natural full join b where 2 * x < 10 order by x + x; @@ -574,8 +574,8 @@ | └─BatchScan { table: test, columns: [test.a, test.b], distribution: SomeShard } └─BatchExchange { order: [], dist: HashShard(test2.a) } └─BatchScan { table: test2, columns: [test2.a, test2.c], distribution: SomeShard } -- sql: | - /* Use lookup join with predicate */ +- name: Use lookup join with predicate + sql: | create table t1 (v1 int, v2 int); create table t2 (v1 int, v2 int); create materialized view t3 as select v1, count(v2) as v2 from t2 group by v1; @@ -591,8 +591,8 @@ with_config_map: QUERY_MODE: local RW_BATCH_ENABLE_LOOKUP_JOIN: 'true' -- sql: | - /* Use project to do the calculation */ +- name: Use project to do the calculation + sql: | create table t1(x int, y int); create table t2(x int, y int); select * from t1, t2 where t1.x + t1.y = t2.x + t2.y; @@ -602,8 +602,8 @@ | └─LogicalScan { table: t1, columns: [t1.x, t1.y] } └─LogicalProject { exprs: [t2.x, t2.y, (t2.x + t2.y)] } └─LogicalScan { table: t2, columns: [t2.x, t2.y] } -- sql: | - /* Use project to align return types */ +- name: Use project to align return types + sql: | create table t1(x int, y int); create table t2(x int, y decimal); select * from t1, t2 where t1.x = t2.y; diff --git a/src/frontend/planner_test/tests/testdata/order_by.yaml b/src/frontend/planner_test/tests/testdata/order_by.yaml index 91c772f08d55c..aaea153de073f 100644 --- a/src/frontend/planner_test/tests/testdata/order_by.yaml +++ b/src/frontend/planner_test/tests/testdata/order_by.yaml @@ -1,6 +1,6 @@ # This file is automatically generated. See `src/frontend/planner_test/README.md` for more information. -- sql: | - /* desc */ +- name: desc + sql: | create table t (v1 bigint, v2 double precision); select * from t order by v1 desc; batch_plan: | @@ -10,8 +10,8 @@ stream_plan: | StreamMaterialize { columns: [v1, v2, t._row_id(hidden)], pk_columns: [t._row_id], order_descs: [v1, t._row_id] } └─StreamTableScan { table: t, columns: [t.v1, t.v2, t._row_id], pk: [t._row_id], distribution: UpstreamHashShard(t._row_id) } -- sql: | - /* output names are not qualified after table names */ +- name: output names are not qualified after table names + sql: | create table t (v1 bigint, v2 double precision); select t.* from t order by v1; batch_plan: | @@ -33,21 +33,21 @@ BatchExchange { order: [t.v1 ASC], dist: Single } └─BatchSort { order: [t.v1 ASC] } └─BatchScan { table: t, columns: [t.v1], distribution: SomeShard } -- sql: | - /* order by output alias */ +- name: order by output alias + sql: | create table t (v1 bigint, v2 double precision); select v1 as a1 from t order by a1; batch_plan: | BatchExchange { order: [t.v1 ASC], dist: Single } └─BatchSort { order: [t.v1 ASC] } └─BatchScan { table: t, columns: [t.v1], distribution: SomeShard } -- sql: | - /* order by ambiguous */ +- name: order by ambiguous + sql: | create table t (v1 bigint, v2 double precision); select v1 as a, v2 as a from t order by a; binder_error: 'Bind error: ORDER BY "a" is ambiguous' -- sql: | - /* ambiguous output name is okay as long as not used in order by */ +- name: ambiguous output name is okay as long as not used in order by + sql: | create table t (v1 bigint, v2 double precision); select v1 as a, v2 as a from t order by 2; batch_plan: | @@ -119,8 +119,8 @@ └─StreamGroupTopN { order: "[t.v1 DESC]", limit: 12, offset: 0, group_key: [3] } └─StreamProject { exprs: [t.v1, t.v2, t._row_id, Vnode(t._row_id)] } └─StreamTableScan { table: t, columns: [t.v1, t.v2, t._row_id], pk: [t._row_id], distribution: UpstreamHashShard(t._row_id) } -- sql: | - /* order by expression that would be valid in select list */ +- name: order by expression that would be valid in select list + sql: | create table t (x int, y int, z int); select x, y from t order by x + y, z; optimized_logical_plan: | @@ -136,8 +136,8 @@ StreamMaterialize { columns: [x, y, (t.x + t.y)(hidden), t.z(hidden), t._row_id(hidden)], pk_columns: [t._row_id], order_descs: [(t.x + t.y), t.z, t._row_id] } └─StreamProject { exprs: [t.x, t.y, (t.x + t.y), t.z, t._row_id] } └─StreamTableScan { table: t, columns: [t.x, t.y, t.z, t._row_id], pk: [t._row_id], distribution: UpstreamHashShard(t._row_id) } -- sql: | - /* order by the number of an output column */ +- name: order by the number of an output column + sql: | create table t (x int, y int); select x, y from t order by 2; optimized_logical_plan: | @@ -146,32 +146,32 @@ BatchExchange { order: [t.y ASC], dist: Single } └─BatchSort { order: [t.y ASC] } └─BatchScan { table: t, columns: [t.x, t.y], distribution: SomeShard } -- sql: | - /* index exceeds the number of select items */ +- name: index exceeds the number of select items + sql: | create table t (x int, y int); select x from t order by 2; binder_error: 'Invalid input syntax: Invalid value in ORDER BY: 2' -- sql: | - /* an output column name cannot be used in an expression */ +- name: an output column name cannot be used in an expression + sql: | create table t (x int, y int); select x + y as sum from t order by sum + 1; binder_error: 'Item not found: Invalid column: sum' -- sql: | - /* select distinct with order by expressions not appear in select list */ +- name: select distinct with order by expressions not appear in select list + sql: | create table t (x int, y int); select distinct x from t order by y; planner_error: 'Invalid input syntax: for SELECT DISTINCT, ORDER BY expressions must appear in select list' -- sql: | - /* No BatchSort needed, when input is already sorted */ +- name: No BatchSort needed, when input is already sorted + sql: | create table t(v int); create materialized view mv as select * from t order by v asc; select * from mv order by v asc; batch_plan: | BatchExchange { order: [mv.v ASC], dist: Single } └─BatchScan { table: mv, columns: [mv.v], distribution: SomeShard } -- sql: | - /* BatchSort needed, when input is sorted in wrong order */ +- name: BatchSort needed, when input is sorted in wrong order + sql: | create table t(v int); create materialized view mv as select * from t order by v asc; select * from mv order by v desc; @@ -179,16 +179,16 @@ BatchExchange { order: [mv.v DESC], dist: Single } └─BatchSort { order: [mv.v DESC] } └─BatchScan { table: mv, columns: [mv.v], distribution: SomeShard } -- sql: | - /* No BatchSort needed, when input is already sorted */ +- name: No BatchSort needed, when input is already sorted + sql: | create table t(v int); create materialized view mv as select * from t order by v desc; select * from mv order by v desc; batch_plan: | BatchExchange { order: [mv.v DESC], dist: Single } └─BatchScan { table: mv, columns: [mv.v], distribution: SomeShard } -- sql: | - /* BatchSort needed, when input is sorted in wrong order */ +- name: BatchSort needed, when input is sorted in wrong order + sql: | create table t(v int); create materialized view mv as select * from t order by v desc; select * from mv order by v asc; diff --git a/src/frontend/planner_test/tests/testdata/over_window_function.yaml b/src/frontend/planner_test/tests/testdata/over_window_function.yaml index 71472ead29d42..00e651b092c5b 100644 --- a/src/frontend/planner_test/tests/testdata/over_window_function.yaml +++ b/src/frontend/planner_test/tests/testdata/over_window_function.yaml @@ -63,8 +63,8 @@ create table t(x int); select sum(x) filter (where row_number() over () > 1) from t; binder_error: 'Invalid input syntax: window functions are not allowed in FILTER' -- sql: | - /* TopN with rank output */ +- name: TopN with rank output + sql: | create table t(x int); select * from (select *, row_number() over(PARTITION BY x ORDER BY x) rank from t) @@ -81,8 +81,8 @@ └─LogicalFilter { predicate: (ROW_NUMBER < 3:Int32) } └─LogicalOverAgg { window_function: ROW_NUMBER() OVER(PARTITION BY t.x ORDER BY t.x ASC NULLS LAST) } └─LogicalScan { table: t, columns: [t.x, t._row_id] } -- sql: | - /* TopN without rank output */ +- name: TopN without rank output + sql: | create table t(x int, y int); select x, y from (select *, row_number() over(PARTITION BY y ORDER BY x) rank from t) @@ -220,8 +220,8 @@ └─StreamExchange { dist: HashShard(TumbleStart(bid.bidtime, '00:10:00':Interval), (TumbleStart(bid.bidtime, '00:10:00':Interval) + '00:10:00':Interval)) } └─StreamProject { exprs: [bid.bidtime, bid.price, bid.item, bid.supplier_id, bid._row_id, TumbleStart(bid.bidtime, '00:10:00':Interval), (TumbleStart(bid.bidtime, '00:10:00':Interval) + '00:10:00':Interval)] } └─StreamTableScan { table: bid, columns: [bid.bidtime, bid.price, bid.item, bid.supplier_id, bid._row_id], pk: [bid._row_id], distribution: UpstreamHashShard(bid._row_id) } -- sql: | - /* Deduplication */ +- name: Deduplication + sql: | create table t(x int, y int); select x, y from (select *, row_number() over(PARTITION BY x ORDER BY y) rank from t) diff --git a/src/frontend/planner_test/tests/testdata/predicate_pushdown.yaml b/src/frontend/planner_test/tests/testdata/predicate_pushdown.yaml index 003ba092c40d8..0e07dd171c6a0 100644 --- a/src/frontend/planner_test/tests/testdata/predicate_pushdown.yaml +++ b/src/frontend/planner_test/tests/testdata/predicate_pushdown.yaml @@ -58,8 +58,8 @@ LogicalFilter { predicate: (min(t.v2) > 1:Int32) AND (t.v1 > min(t.v2)) } └─LogicalAgg { group_key: [t.v1], aggs: [min(t.v2)] } └─LogicalScan { table: t, output_columns: [t.v1, t.v2], required_columns: [v1, v2], predicate: (t.v1 > 1:Int32) AND (1:Int32 > 0:Int32) } -- sql: | - /* Always false should not be pushed below SimpleAgg */ +- name: Always false should not be pushed below SimpleAgg + sql: | create table t(v1 int, v2 int, v3 int, v4 int); select min(v1) from t having false; optimized_logical_plan: | diff --git a/src/frontend/planner_test/tests/testdata/project_set.yaml b/src/frontend/planner_test/tests/testdata/project_set.yaml index 4cabacf9f5fd1..0986aac924eb0 100644 --- a/src/frontend/planner_test/tests/testdata/project_set.yaml +++ b/src/frontend/planner_test/tests/testdata/project_set.yaml @@ -29,8 +29,8 @@ StreamMaterialize { columns: [projected_row_id(hidden), unnest, t._row_id(hidden)], pk_columns: [t._row_id, projected_row_id] } └─StreamProjectSet { select_list: [Unnest($0), $1] } └─StreamTableScan { table: t, columns: [t.x, t._row_id], pk: [t._row_id], distribution: UpstreamHashShard(t._row_id) } -- sql: | - /* table functions used with usual expressions */ +- name: table functions used with usual expressions + sql: | create table t(x int[]); select unnest(x), 1 from t; batch_plan: | @@ -38,8 +38,8 @@ └─BatchExchange { order: [], dist: Single } └─BatchProjectSet { select_list: [Unnest($0), 1:Int32] } └─BatchScan { table: t, columns: [t.x, t._row_id], distribution: UpstreamHashShard(t._row_id) } -- sql: | - /* multiple table functions */ +- name: multiple table functions + sql: | create table t(x int[]); select unnest(x), unnest(Array[1,2]) from t; batch_plan: | @@ -47,8 +47,8 @@ └─BatchExchange { order: [], dist: Single } └─BatchProjectSet { select_list: [Unnest($0), Unnest(Array(1:Int32, 2:Int32))] } └─BatchScan { table: t, columns: [t.x, t._row_id], distribution: UpstreamHashShard(t._row_id) } -- sql: | - /* table functions as parameters of usual functions */ +- name: table functions as parameters of usual functions + sql: | create table t(x int); select -generate_series(x,x,x) from t; batch_plan: | @@ -56,8 +56,8 @@ └─BatchProject { exprs: [Neg(Generate($0, $0, $0))] } └─BatchProjectSet { select_list: [$0, $1, Generate($0, $0, $0)] } └─BatchScan { table: t, columns: [t.x, t._row_id], distribution: UpstreamHashShard(t._row_id) } -- sql: | - /* table functions as parameters of usual functions */ +- name: table functions as parameters of usual functions + sql: | create table t(x int[]); select unnest(x) * unnest(x) as a, unnest(x) as b from t; batch_plan: | @@ -71,8 +71,8 @@ └─StreamProjectSet { select_list: [($3 * $4), Unnest($1), $2, $0] } └─StreamProjectSet { select_list: [$0, $1, Unnest($0), Unnest($0)] } └─StreamTableScan { table: t, columns: [t.x, t._row_id], pk: [t._row_id], distribution: UpstreamHashShard(t._row_id) } -- sql: | - /* table functions as parameters of table functions */ +- name: table functions as parameters of table functions + sql: | create table t(x int[]); select generate_series(unnest(x),100,1) from t; batch_plan: | diff --git a/src/frontend/planner_test/tests/testdata/range_scan.yaml b/src/frontend/planner_test/tests/testdata/range_scan.yaml index dc90b1b49208a..a6cd9605a2634 100644 --- a/src/frontend/planner_test/tests/testdata/range_scan.yaml +++ b/src/frontend/planner_test/tests/testdata/range_scan.yaml @@ -113,8 +113,8 @@ └─BatchScan { table: orders_count_by_user, columns: [orders_count_by_user.user_id, orders_count_by_user.date, orders_count_by_user.orders_count], scan_ranges: [orders_count_by_user.user_id = Int64(43)], distribution: UpstreamHashShard(orders_count_by_user.user_id, orders_count_by_user.date) } - before: - create_table_and_mv + name: If the IN list has a larger type than the column, the InputRef is casted. Currently this case is not converted to scan range yet. sql: | - /* If the IN list has a larger type than the column, the InputRef is casted. Currently this case is not converted to scan range yet. */ SELECT * FROM orders_count_by_user WHERE user_id in (42.0, 43.0) batch_plan: | BatchExchange { order: [], dist: Single } @@ -149,47 +149,47 @@ └─BatchScan { table: orders_count_by_user, columns: [orders_count_by_user.user_id, orders_count_by_user.date, orders_count_by_user.orders_count], scan_ranges: [orders_count_by_user.user_id = Int64(42), orders_count_by_user.date = Int32(2222) OR orders_count_by_user.user_id = Int64(42), orders_count_by_user.date = Int32(3333)], distribution: UpstreamHashShard(orders_count_by_user.user_id, orders_count_by_user.date) } - before: - create_table_and_mv + name: test duplicate value in in-list sql: | - /* test duplicate value in in-list */ SELECT * FROM orders_count_by_user WHERE user_id = 42 AND date in (2222, 2222) batch_plan: | BatchExchange { order: [], dist: Single } └─BatchScan { table: orders_count_by_user, columns: [orders_count_by_user.user_id, orders_count_by_user.date, orders_count_by_user.orders_count], scan_ranges: [orders_count_by_user.user_id = Int64(42), orders_count_by_user.date = Int32(2222)], distribution: UpstreamHashShard(orders_count_by_user.user_id, orders_count_by_user.date) } - before: - create_table_and_mv + name: test NULL in in-list sql: | - /* test NULL in in-list */ SELECT * FROM orders_count_by_user WHERE user_id = 42 AND date in (2222, NULL) batch_plan: | BatchExchange { order: [], dist: Single } └─BatchScan { table: orders_count_by_user, columns: [orders_count_by_user.user_id, orders_count_by_user.date, orders_count_by_user.orders_count], scan_ranges: [orders_count_by_user.user_id = Int64(42), orders_count_by_user.date = Int32(2222)], distribution: UpstreamHashShard(orders_count_by_user.user_id, orders_count_by_user.date) } - before: - create_table_and_mv + name: test NULL in in-list sql: | - /* test NULL in in-list */ SELECT * FROM orders_count_by_user WHERE user_id = 42 AND date in (NULL) batch_plan: | BatchValues { rows: [] } - before: - create_table_and_mv + name: test multiple in-list sql: | - /* test multiple in-list */ SELECT * FROM orders_count_by_user WHERE user_id = 42 AND date in (2222, 3333) AND date in (4444, 3333) batch_plan: | BatchExchange { order: [], dist: Single } └─BatchScan { table: orders_count_by_user, columns: [orders_count_by_user.user_id, orders_count_by_user.date, orders_count_by_user.orders_count], scan_ranges: [orders_count_by_user.user_id = Int64(42), orders_count_by_user.date = Int32(3333)], distribution: UpstreamHashShard(orders_count_by_user.user_id, orders_count_by_user.date) } - before: - create_table_and_mv + name: test eq & in-list sql: | - /* test eq & in-list */ SELECT * FROM orders_count_by_user WHERE user_id = 42 AND date in (2222, 3333) AND date = 3333 batch_plan: | BatchExchange { order: [], dist: Single } └─BatchScan { table: orders_count_by_user, columns: [orders_count_by_user.user_id, orders_count_by_user.date, orders_count_by_user.orders_count], scan_ranges: [orders_count_by_user.user_id = Int64(42), orders_count_by_user.date = Int32(3333)], distribution: UpstreamHashShard(orders_count_by_user.user_id, orders_count_by_user.date) } - before: - create_table_and_mv + name: test eq & in-list sql: | - /* test eq & in-list */ SELECT * FROM orders_count_by_user WHERE user_id = 42 AND date in (2222, 3333) AND date = 4444 batch_plan: | BatchValues { rows: [] } @@ -240,8 +240,8 @@ SELECT x from t group by x; - before: - create_small + name: When the constant has a larger type and cannot be casted to the column's type, we can't convert it to scan range yet. sql: | - /* When the constant has a larger type and cannot be casted to the column's type, we can't convert it to scan range yet. */ SELECT * FROM mv WHERE x = 60000; batch_plan: | BatchExchange { order: [], dist: Single } @@ -249,8 +249,8 @@ └─BatchScan { table: mv, columns: [mv.x], distribution: UpstreamHashShard(mv.x) } - before: - create_small + name: When the constant has a larger type and cannot be casted to the column's type, we can't convert it to scan range yet. sql: | - /* When the constant has a larger type and cannot be casted to the column's type, we can't convert it to scan range yet. */ SELECT * FROM mv WHERE x < 60000; batch_plan: | BatchExchange { order: [], dist: Single } @@ -279,8 +279,8 @@ └─BatchScan { table: orders_count_by_user, columns: [orders_count_by_user.user_id, orders_count_by_user.date, orders_count_by_user.orders_count], scan_ranges: [orders_count_by_user.user_id = Int64(1) OR orders_count_by_user.user_id = Int64(2), orders_count_by_user.date = Int32(1111) OR orders_count_by_user.user_id = Int64(2), orders_count_by_user.date = Int32(2222)], distribution: UpstreamHashShard(orders_count_by_user.user_id, orders_count_by_user.date) } - before: - create_table_and_mv + name: When one arm of or clause contains other conditions, we can't convert it to scan range yet. sql: | - /* When one arm of or clause contains other conditions, we can't convert it to scan range yet. */ SELECT * FROM orders_count_by_user WHERE (user_id = 1) or (user_id = 2 and date in (1111, 2222)) or (user_id != 3); batch_plan: | BatchExchange { order: [], dist: Single } @@ -288,8 +288,8 @@ └─BatchScan { table: orders_count_by_user, columns: [orders_count_by_user.user_id, orders_count_by_user.date, orders_count_by_user.orders_count], distribution: UpstreamHashShard(orders_count_by_user.user_id, orders_count_by_user.date) } - before: - create_table_and_mv + name: When any arm of or clause is not equal type, we can't convert it to scan range yet. sql: | - /* When any arm of or clause is not equal type, we can't convert it to scan range yet. */ SELECT * FROM orders_count_by_user WHERE user_id > 1 or user_id < 10 batch_plan: | BatchExchange { order: [], dist: Single } diff --git a/src/frontend/planner_test/tests/testdata/subquery.yaml b/src/frontend/planner_test/tests/testdata/subquery.yaml index 07facfdc04941..6679fdc08ee9e 100644 --- a/src/frontend/planner_test/tests/testdata/subquery.yaml +++ b/src/frontend/planner_test/tests/testdata/subquery.yaml @@ -7,8 +7,8 @@ └─LogicalFilter { predicate: (t.v2 > 1:Int32) } └─LogicalProject { exprs: [t.v1, t.v2] } └─LogicalScan { table: t, columns: [t.v1, t.v2, t._row_id] } -- sql: | - /* merge and then eliminate */ +- name: merge and then eliminate + sql: | create table t (v1 bigint, v2 double precision); select a1 as v1, a2 as v2 from (select v1 as a1, v2 as a2 from t); logical_plan: | @@ -29,8 +29,8 @@ └─LogicalFilter { predicate: (t.v2 > 1:Int32) } └─LogicalProject { exprs: [t.v2, t.v1] } └─LogicalScan { table: t, columns: [t.v1, t.v2, t._row_id] } -- sql: | - /* consecutive projects are merged */ +- name: consecutive projects are merged + sql: | create table t (v1 bigint, v2 double precision); select v1, 2 from (select v1, v2, 1 from t); logical_plan: | @@ -49,8 +49,8 @@ └─LogicalScan { table: t, columns: [t.v1, t.v2, t._row_id] } optimized_logical_plan: | LogicalScan { table: t, columns: [t.v1, t.v2] } -- sql: | - /* joins */ +- name: joins + sql: | create table t (v1 bigint, v2 double precision); select * from (select * from t), t; logical_plan: | @@ -59,8 +59,8 @@ ├─LogicalProject { exprs: [t.v1, t.v2] } | └─LogicalScan { table: t, columns: [t.v1, t.v2, t._row_id] } └─LogicalScan { table: t, columns: [t.v1, t.v2, t._row_id] } -- sql: | - /* table alias */ +- name: table alias + sql: | create table t (v1 bigint, v2 double precision); select * from (select * from t) as tt join t on tt.v1=t.v1; logical_plan: | @@ -69,8 +69,8 @@ ├─LogicalProject { exprs: [t.v1, t.v2] } | └─LogicalScan { table: t, columns: [t.v1, t.v2, t._row_id] } └─LogicalScan { table: t, columns: [t.v1, t.v2, t._row_id] } -- sql: | - /* alias less columns than available */ +- name: alias less columns than available + sql: | create table t (v1 bigint, v2 double precision); select * from (select * from t) as tt(a) join t on a=v1; logical_plan: | @@ -79,8 +79,8 @@ ├─LogicalProject { exprs: [t.v1, t.v2] } | └─LogicalScan { table: t, columns: [t.v1, t.v2, t._row_id] } └─LogicalScan { table: t, columns: [t.v1, t.v2, t._row_id] } -- sql: | - /* alias more columns than available */ +- name: alias more columns than available + sql: | create table t (v1 bigint, v2 double precision); select * from (select * from t) as tt(a, b, c) join t on a=v1; binder_error: 'Bind error: table "tt" has 2 columns available but 3 column aliases @@ -112,8 +112,8 @@ └─LogicalJoin { type: Inner, on: true, output: all } ├─LogicalScan { table: bc, columns: [bc.b] } └─LogicalScan { table: t, output_columns: [], required_columns: [v1], predicate: IsNotNull(t.v1) } -- sql: | - /* We cannot reference columns in left table if not lateral */ +- name: We cannot reference columns in left table if not lateral + sql: | create table ab (a int, b int); create table bc (b int, c int); create table t (v1 int, v2 varchar); @@ -123,8 +123,8 @@ ) as t0 ); binder_error: 'Item not found: Invalid column: c' -- sql: | - /* We need to ensure doubly nested reference to a left table is not permitted */ +- name: We need to ensure doubly nested reference to a left table is not permitted + sql: | create table ab (a int, b int); create table bc (b int, c int); create table t (v1 int, v2 int); diff --git a/src/frontend/planner_test/tests/testdata/subquery_expr_correlated.yaml b/src/frontend/planner_test/tests/testdata/subquery_expr_correlated.yaml index 6f15da1e1153e..02a6ec42c4307 100644 --- a/src/frontend/planner_test/tests/testdata/subquery_expr_correlated.yaml +++ b/src/frontend/planner_test/tests/testdata/subquery_expr_correlated.yaml @@ -208,8 +208,8 @@ create table t2(x int, y int); select x from t1 where y in (select y, x from t2 where t1.x > t2.x + 1000); binder_error: 'Bind error: Subquery must return only one column' -- sql: | - /* correlated outer subquery with an uncorrelated inner subquery */ +- name: correlated outer subquery with an uncorrelated inner subquery + sql: | create table t1(x int, y int); create table t2(x int, y int); create table t3(x int, y int); @@ -233,8 +233,8 @@ ├─LogicalScan { table: t2, columns: [t2.x, t2.y] } └─LogicalAgg { aggs: [min(t3.x)] } └─LogicalScan { table: t3, columns: [t3.x] } -- sql: | - /* correlated inner subquery with depth = 2 */ +- name: correlated inner subquery with depth = 2 + sql: | create table t1(x int, y int); create table t2(x int, y int); create table t3(x int, y int); @@ -249,8 +249,8 @@ └─LogicalProject { exprs: [t3.y] } └─LogicalFilter { predicate: (CorrelatedInputRef { index: 1, correlated_id: 1 } = t3.y) } └─LogicalScan { table: t3, columns: [t3.x, t3.y, t3._row_id] } -- sql: | - /* uncorrelated outer subquery with a correlated inner subquery */ +- name: uncorrelated outer subquery with a correlated inner subquery + sql: | create table t1(x int, y int); create table t2(x int, y int); create table t3(x int, y int); @@ -272,50 +272,50 @@ ├─LogicalScan { table: t2, columns: [t2.x, t2.y] } └─LogicalProject { exprs: [t3.y, t3.y] } └─LogicalScan { table: t3, columns: [t3.y] } -- sql: | - /* correlated agg column in SELECT */ +- name: correlated agg column in SELECT + sql: | create table t (v1 int, v2 int); select min(v1), (select max(v2)) from t; planner_error: |- Feature is not yet implemented: correlated subquery in HAVING or SELECT with agg Tracking issue: https://github.com/risingwavelabs/risingwave/issues/2275 -- sql: | - /* correlated group column in SELECT */ +- name: correlated group column in SELECT + sql: | create table t (v1 int, v2 int); select min(v1), (select v2) from t group by v2; planner_error: |- Feature is not yet implemented: correlated subquery in HAVING or SELECT with agg Tracking issue: https://github.com/risingwavelabs/risingwave/issues/2275 -- sql: | - /* correlated non-group column in SELECT */ +- name: correlated non-group column in SELECT + sql: | create table t (v1 int, v2 int); select min(v1), (select v2) from t; planner_error: |- Feature is not yet implemented: correlated subquery in HAVING or SELECT with agg Tracking issue: https://github.com/risingwavelabs/risingwave/issues/2275 -- sql: | - /* correlated agg column in HAVING */ +- name: correlated agg column in HAVING + sql: | create table t (v1 int, v2 int); select 1 from t having min(v1) > (select max(v2)); planner_error: |- Feature is not yet implemented: correlated subquery in HAVING or SELECT with agg Tracking issue: https://github.com/risingwavelabs/risingwave/issues/2275 -- sql: | - /* correlated group column in HAVING */ +- name: correlated group column in HAVING + sql: | create table t (v1 int, v2 int); select 1 from t group by v2 having min(v1) > (select v2); planner_error: |- Feature is not yet implemented: correlated subquery in HAVING or SELECT with agg Tracking issue: https://github.com/risingwavelabs/risingwave/issues/2275 -- sql: | - /* correlated non-group column in HAVING */ +- name: correlated non-group column in HAVING + sql: | create table t (v1 int, v2 int); select 1 from t having min(v1) > (select v2); planner_error: |- Feature is not yet implemented: correlated subquery in HAVING or SELECT with agg Tracking issue: https://github.com/risingwavelabs/risingwave/issues/2275 -- sql: | - /* correlated agg column belongs to outer query */ +- name: correlated agg column belongs to outer query + sql: | create table t (v1 int, v2 int); create table t2 (v3 int, v4 int); select @@ -325,8 +325,8 @@ planner_error: |- Feature is not yet implemented: correlated subquery in HAVING or SELECT with agg Tracking issue: https://github.com/risingwavelabs/risingwave/issues/2275 -- sql: | - /* uncorrelated subquery in HAVING */ +- name: uncorrelated subquery in HAVING + sql: | create table a (a1 int, a2 int); create table b (b1 int, b2 int); create table c (c1 int, c2 int); @@ -346,8 +346,8 @@ ├─LogicalScan { table: b, columns: [b.b1, b.b2, b._row_id] } └─LogicalProject { exprs: [CorrelatedInputRef { index: 0, correlated_id: 2 }] } └─LogicalScan { table: c, columns: [c.c1, c.c2, c._row_id] } -- sql: | - /* correlated column with depth=2 in HAVING */ +- name: correlated column with depth=2 in HAVING + sql: | create table a (a1 int, a2 int); create table b (b1 int, b2 int); create table c (c1 int, c2 int); @@ -359,8 +359,8 @@ planner_error: |- Feature is not yet implemented: correlated subquery in HAVING or SELECT with agg Tracking issue: https://github.com/risingwavelabs/risingwave/issues/2275 -- sql: | - /* correlated column with depth>1 in HAVING */ +- name: correlated column with depth>1 in HAVING + sql: | create table a (a1 int, a2 int); create table b (b1 int, b2 int); create table c (c1 int, c2 int); diff --git a/src/frontend/planner_test/tests/testdata/table_primary_key.yaml b/src/frontend/planner_test/tests/testdata/table_primary_key.yaml index ba8bac1503b50..cf87dd7739a9f 100644 --- a/src/frontend/planner_test/tests/testdata/table_primary_key.yaml +++ b/src/frontend/planner_test/tests/testdata/table_primary_key.yaml @@ -21,8 +21,8 @@ └─BatchScan { table: t1, columns: [t1.a, t1.b, t1.c], distribution: SomeShard } - before: - create_table_t1 + name: _row_id column is inserted if no pk is specified sql: | - /* _row_id column is inserted if no pk is specified */ select _row_id from t1; batch_plan: | BatchExchange { order: [], dist: Single } @@ -34,8 +34,8 @@ binder_error: 'Item not found: Invalid column: _row_id' - before: - create_table_t2 + name: selecting on pk should generate range scan sql: | - /* selecting on pk should generate range scan */ select * from t2 where a > 1; batch_plan: | BatchExchange { order: [], dist: Single }