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

Mingcan Wang edited comment on FLINK-37093 at 1/14/25 11:08 AM:
----------------------------------------------------------------

can anyone assign this issue to me ? thanks :)


was (Author: JIRAUSER302010):
can someone assign this issue to me ? thanks :)

> The catalog that failed validation due to no type still exists in 
> catalogStoreHolder
> ------------------------------------------------------------------------------------
>
>                 Key: FLINK-37093
>                 URL: https://issues.apache.org/jira/browse/FLINK-37093
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / API
>    Affects Versions: 1.20.0, 2.0-preview
>         Environment: mac os
>            Reporter: Mingcan Wang
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 2.0.0, 1.20.0
>
>
> here's sql-client (1.20 & 2.0-preview1):
>  
> *Flink SQL> create catalog cat1;*
> {color:#ff0000}[ERROR] Could not execute SQL statement. Reason:{color}
> {color:#ff0000}org.apache.flink.table.api.ValidationException: Catalog 
> options do not contain an option key 'type' for discovering a catalog.{color}
> *Flink SQL> show catalogs;*
> +-----------------+
> |   catalog name|
> +-----------------+
> |           cat1|
> |default_catalog|
> +-----------------+
> 2 rows in set
> *Flink SQL> use catalog cat1;*
> {color:#ff0000}[ERROR] Could not execute SQL statement. Reason:{color}
> {color:#ff0000}org.apache.flink.table.api.ValidationException: Catalog 
> options do not contain an option key 'type' for discovering a catalog.{color}
> *Flink SQL> alter catalog cat1 comment 'no type';*
> {color:#ff0000}[ERROR] Could not execute SQL statement. Reason:{color}
> {color:#ff0000}org.apache.flink.table.api.ValidationException: Catalog 
> options do not contain an option key 'type' for discovering a catalog.{color}
> *Flink SQL> create catalog cat1;*
> {color:#ff0000}[ERROR] Could not execute SQL statement. Reason:{color}
> {color:#ff0000}org.apache.flink.table.catalog.exceptions.CatalogException: 
> Catalog cat1 already exists.{color}
> *Flink SQL> drop catalog cat1;*
> [INFO] Execute statement succeeded.
> *Flink SQL> show catalogs;*
> +-----------------+
> |   catalog name|
> +-----------------+
> |default_catalog|
> +-----------------+
> 1 row in set
>  
> When I create a catalog without type , the sql will parsed successfully. 
> According to the code :
>  
> {code:java}
> public void createCatalog(
> String catalogName, CatalogDescriptor catalogDescriptor, boolean 
> ignoreIfExists)
> throws CatalogException {
> checkArgument(
> !StringUtils.isNullOrWhitespaceOnly(catalogName),
> "Catalog name cannot be null or empty.");
> checkNotNull(catalogDescriptor, "Catalog descriptor cannot be null");
> boolean catalogExistsInStore = 
> catalogStoreHolder.catalogStore().contains(catalogName);
> boolean catalogExistsInMemory = catalogs.containsKey(catalogName);
> if (catalogExistsInStore || catalogExistsInMemory) {
> if (!ignoreIfExists)
> { throw new CatalogException(format("Catalog %s already exists.", 
> catalogName)); }
> } else { 
> // Store the catalog in the catalog store 
> catalogStoreHolder.catalogStore().storeCatalog(catalogName, 
> catalogDescriptor); 
> // Initialize and store the catalog in memory 
> Catalog catalog = initCatalog(catalogName, catalogDescriptor); 
> catalog.open(); 
> catalogs.put(catalogName, catalog); 
> }
> }{code}
> the catalog will store in the catalog store first, then failed in 
> initCatalog() method.
> the result is the catalog still exists in catalogStoreHolder. And I cannot 
> use, alter or create it again.
> I noticed the alterCatalog() method, the proces is :
> {code:java}
> Catalog newCatalog = initCatalog(catalogName, newDescriptor);
> catalogStore.removeCatalog(catalogName, false);
> if (catalogs.containsKey(catalogName))
> { catalogs.get(catalogName).close(); }
> newCatalog.open();
> catalogs.put(catalogName, newCatalog);
> catalogStoreHolder.catalogStore().storeCatalog(catalogName, newDescriptor); 
> {code}
> store in catalogStoreHolder should after initCatalog() and open().



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

Reply via email to