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

Paul Lin updated FLINK-28685:
-----------------------------
    Description: 
Currently, Catalog#getTable(ObjectPath) might be abused in CatalogManager. 
CatalogManager gets an ObjectPath directly, instead of checking the existence 
of the table first, which could surprise Catalog developers and may get 
unexpected exceptions other than TableNotFoundExceptions.
{code:java}
private Optional<CatalogBaseTable> getUnresolvedTable(ObjectIdentifier 
objectIdentifier) {
Catalog currentCatalog = catalogs.get(objectIdentifier.getCatalogName());
ObjectPath objectPath = objectIdentifier.toObjectPath();
if (currentCatalog != null) {
try
{ final CatalogBaseTable table = currentCatalog.getTable(objectPath); return 
Optional.of(table); }
catch (TableNotExistException e)
{ // Ignore. }
}
return Optional.empty();
}{code}

  was:
Currently, Catalog#getTable(ObjectPath) might be abused in CatalogManager. 
CatalogManager gets an ObjectPath directly, instead of checking the existence 
of the table first, which could surprise Catalog developers and may get 
unexpected exceptions other than TableNotFoundExceptions. 

```
    private Optional<CatalogBaseTable> getUnresolvedTable(ObjectIdentifier 
objectIdentifier) {
        Catalog currentCatalog = 
catalogs.get(objectIdentifier.getCatalogName());
        ObjectPath objectPath = objectIdentifier.toObjectPath();
        if (currentCatalog != null) {
            try {
                final CatalogBaseTable table = 
currentCatalog.getTable(objectPath);
                return Optional.of(table);
            } catch (TableNotExistException e) {
                // Ignore.
            }
        }
        return Optional.empty();
    }
```


> Optimize CatalogManager getTable implementation
> -----------------------------------------------
>
>                 Key: FLINK-28685
>                 URL: https://issues.apache.org/jira/browse/FLINK-28685
>             Project: Flink
>          Issue Type: Improvement
>          Components: Table SQL / API
>    Affects Versions: 1.16.0
>            Reporter: Paul Lin
>            Priority: Major
>
> Currently, Catalog#getTable(ObjectPath) might be abused in CatalogManager. 
> CatalogManager gets an ObjectPath directly, instead of checking the existence 
> of the table first, which could surprise Catalog developers and may get 
> unexpected exceptions other than TableNotFoundExceptions.
> {code:java}
> private Optional<CatalogBaseTable> getUnresolvedTable(ObjectIdentifier 
> objectIdentifier) {
> Catalog currentCatalog = catalogs.get(objectIdentifier.getCatalogName());
> ObjectPath objectPath = objectIdentifier.toObjectPath();
> if (currentCatalog != null) {
> try
> { final CatalogBaseTable table = currentCatalog.getTable(objectPath); return 
> Optional.of(table); }
> catch (TableNotExistException e)
> { // Ignore. }
> }
> return Optional.empty();
> }{code}



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

Reply via email to