[ 
https://issues.apache.org/jira/browse/FLINK-41412?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ASF GitHub Bot updated FLINK-41412:
-----------------------------------
    Labels: pull-request-available  (was: )

> Support IF EXISTS for ALTER VIEW, DATABASE, CATALOG and MATERIALIZED TABLE
> --------------------------------------------------------------------------
>
>                 Key: FLINK-41412
>                 URL: https://issues.apache.org/jira/browse/FLINK-41412
>             Project: Flink
>          Issue Type: Improvement
>          Components: Table SQL / API
>    Affects Versions: 2.4.0
>            Reporter: sepuri sai krishna
>            Priority: Minor
>              Labels: pull-request-available
>
> Every {{DROP}} statement takes {{IF EXISTS}}. {{ALTER}} takes it for three of 
> the seven object
> kinds.
> ||object||documented DROP||documented ALTER||
> |{{TABLE}}|{{DROP [TEMPORARY] TABLE [IF EXISTS] ...}}|{{ALTER TABLE [IF 
> EXISTS] table_name ...}}|
> |{{FUNCTION}}|{{DROP [TEMPORARY\|TEMPORARY SYSTEM] FUNCTION [IF EXISTS] 
> ...}}|{{ALTER [TEMPORARY\|TEMPORARY SYSTEM] FUNCTION [IF EXISTS] ...}}|
> |{{MODEL}}|{{DROP [TEMPORARY] MODEL [IF EXISTS] ...}}|{{ALTER MODEL [IF 
> EXISTS] ...}}|
> |{{VIEW}}|{{DROP [TEMPORARY] VIEW [IF EXISTS] ...}}|{{ALTER VIEW 
> [catalog_name.][db_name.]view_name ...}}|
> |{{DATABASE}}|{{DROP DATABASE [IF EXISTS] ...}}|{{ALTER DATABASE 
> [catalog_name.]db_name SET (key1=val1, key2=val2, ...)}}|
> |{{CATALOG}}|{{DROP CATALOG [IF EXISTS] catalog_name}}|{{ALTER CATALOG 
> catalog_name SET (key1=val1, ...)}}|
> |{{MATERIALIZED TABLE}}|{{DROP MATERIALIZED TABLE [IF EXISTS] ...}}|{{ALTER 
> MATERIALIZED TABLE [catalog_name.][db_name.]table_name ...}}|
> The four missing forms are parse errors on master:
> {code:sql}
> ALTER VIEW IF EXISTS v RENAME TO v2;
> ALTER VIEW IF EXISTS v AS SELECT 1;
> ALTER DATABASE IF EXISTS d SET ('k' = 'v');
> ALTER CATALOG IF EXISTS c SET ('k' = 'v');
> ALTER MATERIALIZED TABLE IF EXISTS mt SUSPEND;
> {code}
> {code}
> Encountered "EXISTS" at line 1, column 15. Was expecting one of: "AS" ... 
> "RENAME" ... "." ...
> Encountered "EXISTS" at line 1, column 19. Was expecting one of: "SET" ... 
> "." ...
> Encountered "EXISTS" at line 1, column 18. Was expecting one of: "RESET" ... 
> "SET" ... "COMMENT" ...
> Encountered "EXISTS" at line 1, column 29. Was expecting one of: "ADD" ... 
> "AS" ... "DROP" ...
> {code}
> Without the guard the statement fails on a missing object, for example
> {{ALTER MATERIALIZED TABLE mt SUSPEND}} gives
> {{Cannot find table '`default_catalog`.`default_database`.`mt`'}}.
> The motivation is the one FLINK-41363 gives for columns: re-running a SQL 
> script should not fail
> on the statements that have already been applied. {{ALTER TABLE IF EXISTS}} 
> gives tables that
> property, so the same script becomes order dependent as soon as it touches a 
> view, a database, a
> catalog or a materialized table.
> Three of the four already have the capability underneath, so the gap is in 
> what SQL can express.
> {{Catalog#alterDatabase}}, {{Catalog#renameTable}} and 
> {{CatalogManager#alterTable}} all take an
> {{ignoreIfNotExists}} flag, and the operations pass a literal {{false}}:
> {{AlterDatabaseOperation}}, {{AlterViewAsOperation}}, 
> {{AlterViewRenameOperation}} and
> {{AlterMaterializedTableChangeOperation}}. {{CatalogManager#alterCatalog}} 
> has no such
> parameter, so {{CATALOG}} needs more than the grammar and may be worth 
> splitting out.
> Checked on master, built from source, JDK 17.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to