[ 
https://issues.apache.org/jira/browse/FLINK-35663?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17862503#comment-17862503
 ] 

Ferenc Csaky commented on FLINK-35663:
--------------------------------------

h2. 0. Setup
* Build Flink on branch {{release-1.20}}:
{code:sh}
$ mvn clean install -DskipTests -Dfast
{code}
* Start SQL Client:
{code:sh}
$ ./build-target/bin/sql-client.sh
{code}

h2. 1. DDL statements
{code:java}
Flink SQL> create catalog c1 comment 'comment for ''c1''' with 
('type'='generic_in_memory', 'default-database'='db1');
[INFO] Execute statement succeeded.

Flink SQL> create catalog if not exists c1 comment 'new' with 
('type'='generic_in_memory');
[INFO] Execute statement succeeded.

Flink SQL> create catalog if not exists c2 with ('type'='generic_in_memory');
[INFO] Execute statement succeeded.

Flink SQL> create catalog c2 with ('type'='generic_in_memory', 
'default-database'='db2');
[ERROR] Could not execute SQL statement. Reason:
org.apache.flink.table.catalog.exceptions.CatalogException: Catalog c2 already 
exists.
{code}

h2. 2. Check saved state via show/describe
{code:java}
Flink SQL> show create catalog c1;
+--------------------------------------------------------------------------------------+
|                                                                               
result |
+--------------------------------------------------------------------------------------+
| CREATE CATALOG `c1` COMMENT 'comment for ''c1''' WITH (
  'default-database' = 'db1',
  'type' = 'generic_in_memory'
)
 |
+--------------------------------------------------------------------------------------+
1 row in set

Flink SQL> desc catalog c1;
+-----------+-------------------+
| info name |        info value |
+-----------+-------------------+
|      name |                c1 |
|      type | generic_in_memory |
|   comment |  comment for 'c1' |
+-----------+-------------------+
3 rows in set

Flink SQL> desc catalog extended c1;
+-------------------------+-------------------+
|               info name |        info value |
+-------------------------+-------------------+
|                    name |                c1 |
|                    type | generic_in_memory |
|                 comment |  comment for 'c1' |
| option:default-database |               db1 |
+-------------------------+-------------------+
4 rows in set

Flink SQL> show create catalog c2;
+--------------------------------------------------------------+
|                                                       result |
+--------------------------------------------------------------+
| CREATE CATALOG `c2` WITH (
  'type' = 'generic_in_memory'
)
 |
+--------------------------------------------------------------+
1 row in set

Flink SQL> desc catalog c2;
+-----------+-------------------+
| info name |        info value |
+-----------+-------------------+
|      name |                c2 |
|      type | generic_in_memory |
|   comment |                   |
+-----------+-------------------+
3 rows in set

Flink SQL> desc catalog extended c2;
+-----------+-------------------+
| info name |        info value |
+-----------+-------------------+
|      name |                c2 |
|      type | generic_in_memory |
|   comment |                   |
+-----------+-------------------+
3 rows in set
{code}

h2. 3. Alter statements
{code:java}
Flink SQL> alter catalog c1 reset ('default-database');
[INFO] Execute statement succeeded.

Flink SQL> alter catalog c1 comment '';
[INFO] Execute statement succeeded.

Flink SQL> alter catalog c2 set ('default-database'='db2');
[INFO] Execute statement succeeded.

Flink SQL> alter catalog c2 reset ('type');
[ERROR] Could not execute SQL statement. Reason:
org.apache.flink.table.api.ValidationException: ALTER CATALOG RESET does not 
support changing 'type'

Flink SQL> alter catalog c2 reset ();
[ERROR] Could not execute SQL statement. Reason:
org.apache.flink.table.api.ValidationException: ALTER CATALOG RESET does not 
support empty key

Flink SQL> alter catalog c2 comment 'hello catalog ''c2''';
[INFO] Execute statement succeeded.
{code}

h2. 4. Check saved state after altering via show/describe
{code:java}
Flink SQL> show create catalog c1;
+--------------------------------------------------------------+
|                                                       result |
+--------------------------------------------------------------+
| CREATE CATALOG `c1` WITH (
  'type' = 'generic_in_memory'
)
 |
+--------------------------------------------------------------+
1 row in set

Flink SQL> desc catalog c1;
+-----------+-------------------+
| info name |        info value |
+-----------+-------------------+
|      name |                c1 |
|      type | generic_in_memory |
|   comment |                   |
+-----------+-------------------+
3 rows in set

Flink SQL> desc catalog extended c1;
+-----------+-------------------+
| info name |        info value |
+-----------+-------------------+
|      name |                c1 |
|      type | generic_in_memory |
|   comment |                   |
+-----------+-------------------+
3 rows in set

Flink SQL> show create catalog c2;
+--------------------------------------------------------------------------------------+
|                                                                               
result |
+--------------------------------------------------------------------------------------+
| CREATE CATALOG `c2` COMMENT 'hello catalog ''c2''' WITH (
  'default-database' = 'db2',
  'type' = 'generic_in_memory'
)
 |
+--------------------------------------------------------------------------------------+
1 row in set

Flink SQL> desc catalog c2;
+-----------+--------------------+
| info name |         info value |
+-----------+--------------------+
|      name |                 c2 |
|      type |  generic_in_memory |
|   comment | hello catalog 'c2' |
+-----------+--------------------+
3 rows in set

Flink SQL> desc catalog extended c2;
+-------------------------+--------------------+
|               info name |         info value |
+-------------------------+--------------------+
|                    name |                 c2 |
|                    type |  generic_in_memory |
|                 comment | hello catalog 'c2' |
| option:default-database |                db2 |
+-------------------------+--------------------+
4 rows in set
{code}

h2. 5. Results
All of the executed statements gave back the expected result, the feature LGTM.

> Release Testing: FLIP-436: Introduce Catalog-related Syntax
> -----------------------------------------------------------
>
>                 Key: FLINK-35663
>                 URL: https://issues.apache.org/jira/browse/FLINK-35663
>             Project: Flink
>          Issue Type: Sub-task
>          Components: Table SQL / API
>    Affects Versions: 1.20.0
>            Reporter: Yubin Li
>            Assignee: Ferenc Csaky
>            Priority: Blocker
>         Attachments: image-2024-06-21-09-43-47-391.png, 
> image-2024-06-21-09-43-58-460.png, image-2024-06-21-09-44-26-213.png, 
> image-2024-06-21-09-45-43-807.png
>
>
> This describes how to verify FLINK-34914 FLIP-436: Introduce Catalog-related 
> Syntax.
> The verification steps are as follows.
> h3. 1. Start the sql client.
> bin/sql-client.sh
> h3. 2. Execute the following DDL statements.
> {code:java}
> create catalog c1 comment 'comment for ''c1''' with 
> ('type'='generic_in_memory', 'default-database'='db1');
> create catalog if not exists c1 comment 'new' with 
> ('type'='generic_in_memory'); 
> create catalog if not exists c2 with ('type'='generic_in_memory'); 
> create catalog c2 with ('type'='generic_in_memory', 
> 'default-database'='db2'); {code}
> Verify whether only the last statement is supposed to throw an exception and 
> messages such as `Catalog c2 already exists.`
> h3. 3. Execute the following statements.
> {code:java}
> show catalogs;
> show create catalog c1;
> describe catalog c1;
> desc catalog extended c1;
> show create catalog c2;
> describe catalog c2;
> desc catalog extended c2; {code}
> Verify whether they are the same as the given results.
> !image-2024-06-21-09-45-43-807.png|width=795,height=933!
> h3. 4. Execute the following DDL statements.
> {code:java}
> alter catalog c1 reset ('default-database');
> alter catalog c1 comment '';
> alter catalog c2 set ('default-database'='db2');
> alter catalog c2 reset ('type');
> alter catalog c2 reset ();
> alter catalog c2 comment 'hello catalog ''c2''';{code}
> Verify whether the forth statement is supposed to throw an exception and 
> messages such as `ALTER CATALOG RESET does not support changing 'type'`.
> Verify whether the fifth statement is supposed to throw an exception and 
> messages such as `ALTER CATALOG RESET does not support empty key`.
> h3. 5. Execute the following statements.
> {code:java}
> show create catalog c1;
> describe catalog c1;
> desc catalog extended c1;
> show create catalog c2;
> describe catalog c2;
> desc catalog extended c2;  {code}
> Verify whether they are the same as the given results.
> !image-2024-06-21-09-44-26-213.png|width=792,height=792!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to