Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/backend/parser/gram.y
Original file line number Diff line number Diff line change
Expand Up @@ -7114,7 +7114,7 @@ CreateMatViewStmt:
ctas->into->distributedBy = $10;
$$ = (Node *) ctas;
}
| CREATE OptNoLog incremental MATERIALIZED VIEW IF_P NOT EXISTS create_mv_target AS SelectStmt opt_with_data
| CREATE OptNoLog incremental MATERIALIZED VIEW IF_P NOT EXISTS create_mv_target AS SelectStmt opt_with_data OptDistributedBy
{
CreateTableAsStmt *ctas = makeNode(CreateTableAsStmt);
ctas->query = $11;
Expand All @@ -7126,6 +7126,7 @@ CreateMatViewStmt:
$9->rel->relpersistence = $2;
$9->skipData = !($12);
$9->ivm = $3;
ctas->into->distributedBy = $13;
$$ = (Node *) ctas;
}
;
Expand Down
15 changes: 15 additions & 0 deletions src/test/regress/expected/matview.out
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,21 @@ DETAIL: drop cascades to materialized view mvtest_mv_v
drop cascades to materialized view mvtest_mv_v_2
drop cascades to materialized view mvtest_mv_v_3
drop cascades to materialized view mvtest_mv_v_4
-- Check that CREATE IF NOT EXISTS accept DISTRIBUTED BY
CREATE MATERIALIZED VIEW IF NOT EXISTS mv_ine_distr (a, b) AS
SELECT generate_series(1, 10) a, generate_series(1, 10) b DISTRIBUTED BY (b);
\d+ mv_ine_distr
Materialized view "public.mv_ine_distr"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+---------+-----------+----------+---------+---------+--------------+-------------
a | integer | | | | plain | |
b | integer | | | | plain | |
View definition:
SELECT generate_series(1, 10) AS a,
generate_series(1, 10) AS b;
Distributed by: (b)

DROP MATERIALIZED VIEW mv_ine_distr;
-- Check that unknown literals are converted to "text" in CREATE MATVIEW,
-- so that we don't end up with unknown-type columns.
CREATE MATERIALIZED VIEW mv_unspecified_types AS
Expand Down
15 changes: 15 additions & 0 deletions src/test/regress/expected/matview_optimizer.out
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,21 @@ DETAIL: drop cascades to materialized view mvtest_mv_v
drop cascades to materialized view mvtest_mv_v_2
drop cascades to materialized view mvtest_mv_v_3
drop cascades to materialized view mvtest_mv_v_4
-- Check that CREATE IF NOT EXISTS accept DISTRIBUTED BY
CREATE MATERIALIZED VIEW IF NOT EXISTS mv_ine_distr (a, b) AS
SELECT generate_series(1, 10) a, generate_series(1, 10) b DISTRIBUTED BY (b);
\d+ mv_ine_distr
Materialized view "public.mv_ine_distr"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+---------+-----------+----------+---------+---------+--------------+-------------
a | integer | | | | plain | |
b | integer | | | | plain | |
View definition:
SELECT generate_series(1, 10) AS a,
generate_series(1, 10) AS b;
Distributed by: (b)

DROP MATERIALIZED VIEW mv_ine_distr;
-- Check that unknown literals are converted to "text" in CREATE MATVIEW,
-- so that we don't end up with unknown-type columns.
CREATE MATERIALIZED VIEW mv_unspecified_types AS
Expand Down
6 changes: 6 additions & 0 deletions src/test/regress/sql/matview.sql
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ SELECT * FROM mvtest_mv_v_3;
SELECT * FROM mvtest_mv_v_4;
DROP TABLE mvtest_v CASCADE;

-- Check that CREATE IF NOT EXISTS accept DISTRIBUTED BY
CREATE MATERIALIZED VIEW IF NOT EXISTS mv_ine_distr (a, b) AS
SELECT generate_series(1, 10) a, generate_series(1, 10) b DISTRIBUTED BY (b);
\d+ mv_ine_distr
DROP MATERIALIZED VIEW mv_ine_distr;

-- Check that unknown literals are converted to "text" in CREATE MATVIEW,
-- so that we don't end up with unknown-type columns.
CREATE MATERIALIZED VIEW mv_unspecified_types AS
Expand Down