Skip to content

Add IF NOT EXISTS to CREATE VIEW#29125

Open
liianghuang wants to merge 1 commit intotrinodb:masterfrom
liianghuang:support-view-if-not-exists
Open

Add IF NOT EXISTS to CREATE VIEW#29125
liianghuang wants to merge 1 commit intotrinodb:masterfrom
liianghuang:support-view-if-not-exists

Conversation

@liianghuang
Copy link
Copy Markdown

Description

Add IF NOT EXISTS to CREATE VIEW

Additional context and related issues

IF NOT EXISTS is supported in CREATE MATERIALIZED VIEW, we should be able to support it in CREATE VIEW as well.

Fixes #28076

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
(x) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text:

## SQL
* Add `CREATE VIEW IF NOT EXISTS`.

@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 15, 2026

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@github-actions github-actions Bot added the docs label Apr 15, 2026
@liianghuang liianghuang force-pushed the support-view-if-not-exists branch from 02ab2f7 to b61f917 Compare April 15, 2026 16:51
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 15, 2026

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

Comment thread core/trino-parser/src/main/java/io/trino/sql/parser/AstBuilder.java Outdated
Comment thread docs/src/main/sphinx/sql/create-view.md Outdated
Comment thread core/trino-main/src/test/java/io/trino/execution/TestCreateViewTask.java Outdated
Comment thread docs/src/main/sphinx/sql/create-view.md Outdated
Comment thread testing/trino-testing/src/main/java/io/trino/testing/BaseConnectorTest.java Outdated
Comment thread testing/trino-testing/src/main/java/io/trino/testing/BaseConnectorTest.java Outdated
Comment thread testing/trino-testing/src/main/java/io/trino/testing/BaseConnectorTest.java Outdated
@liianghuang liianghuang force-pushed the support-view-if-not-exists branch from b61f917 to 151596f Compare April 16, 2026 14:54
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 16, 2026

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should provide the save mode to connectors here.

@liianghuang liianghuang force-pushed the support-view-if-not-exists branch from 151596f to f8b90b2 Compare April 17, 2026 02:38
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 17, 2026

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@github-actions github-actions Bot added blackhole Blackhole connector memory Memory connector labels Apr 17, 2026
@liianghuang liianghuang force-pushed the support-view-if-not-exists branch from f8b90b2 to 9441cde Compare April 17, 2026 03:23
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 17, 2026

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@github-actions github-actions Bot added iceberg Iceberg connector delta-lake Delta Lake connector hive Hive connector lakehouse labels Apr 17, 2026
@liianghuang liianghuang force-pushed the support-view-if-not-exists branch from 9441cde to e056476 Compare April 17, 2026 03:47
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 17, 2026

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@liianghuang liianghuang force-pushed the support-view-if-not-exists branch from e056476 to d3eb848 Compare April 17, 2026 04:56
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 17, 2026

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@github-actions github-actions Bot added the faker Faker connector label Apr 17, 2026
@liianghuang liianghuang force-pushed the support-view-if-not-exists branch from d3eb848 to 6d1cc7a Compare April 17, 2026 06:31
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 17, 2026

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@liianghuang liianghuang force-pushed the support-view-if-not-exists branch from 6d1cc7a to 9191880 Compare April 19, 2026 05:48
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 19, 2026

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@liianghuang liianghuang marked this pull request as ready for review April 20, 2026 02:01
* be serialized by the connector for permanent storage.
*/
default void createView(ConnectorSession session, SchemaTableName viewName, ConnectorViewDefinition definition, Map<String, Object> viewProperties, boolean replace)
default void createView(ConnectorSession session, SchemaTableName viewName, ConnectorViewDefinition definition, Map<String, Object> viewProperties, SaveMode saveMode)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should give migration period by deprecating createView(ConnectorSession session, SchemaTableName viewName, ConnectorViewDefinition definition, Map<String, Object> viewProperties, boolean replace) and adding another createView(ConnectorSession session, SchemaTableName viewName, ConnectorViewDefinition definition, Map<String, Object> viewProperties, SaveMode saveMode)

You can refer to #13681

@liianghuang liianghuang force-pushed the support-view-if-not-exists branch from 9191880 to d1fa3d8 Compare April 20, 2026 12:40
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 20, 2026

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@liianghuang liianghuang force-pushed the support-view-if-not-exists branch from d1fa3d8 to d637135 Compare April 20, 2026 13:27
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 20, 2026

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@liianghuang liianghuang force-pushed the support-view-if-not-exists branch from d637135 to 9b53741 Compare April 20, 2026 14:33
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 20, 2026

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

Comment thread core/trino-spi/pom.xml Outdated
<old>method void io.trino.spi.connector.ConnectorMetadata::createView(io.trino.spi.connector.ConnectorSession, io.trino.spi.connector.SchemaTableName, io.trino.spi.connector.ConnectorViewDefinition, java.util.Map&lt;java.lang.String, java.lang.Object&gt;, boolean)</old>
<new>method void io.trino.spi.connector.ConnectorMetadata::createView(io.trino.spi.connector.ConnectorSession, io.trino.spi.connector.SchemaTableName, io.trino.spi.connector.ConnectorViewDefinition, java.util.Map&lt;java.lang.String, java.lang.Object&gt;, io.trino.spi.connector.SaveMode)</new>
<justification>Replace boolean parameter with SaveMode enum</justification>
</item>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this change. It's no longer needed.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed

@liianghuang liianghuang force-pushed the support-view-if-not-exists branch from 9b53741 to 7f93560 Compare April 20, 2026 22:32
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 20, 2026

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blackhole Blackhole connector delta-lake Delta Lake connector docs faker Faker connector hive Hive connector iceberg Iceberg connector lakehouse memory Memory connector

Development

Successfully merging this pull request may close these issues.

Support IF NOT EXISTS clause in CREATE VIEW statement.

2 participants