diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonExternalCatalog.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonExternalCatalog.java index eb25336ab0..46ee79166b 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonExternalCatalog.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonExternalCatalog.java @@ -121,18 +121,10 @@ public abstract class PaimonExternalCatalog extends ExternalCatalog { public org.apache.paimon.table.Table getPaimonTable(String dbName, String tblName) { makeSureInitialized(); try { - return hadoopAuthenticator.doAs(() -> { - org.apache.paimon.table.Table table = null; - try { - table = catalog.getTable(Identifier.create(dbName, tblName)); - } catch (Catalog.TableNotExistException e) { - LOG.warn("TableNotExistException", e); - } - return table; - }); - } catch (IOException e) { - throw new RuntimeException("Failed to get Paimon table, catalog name: " + getName() + ", db: " - + dbName + ", table: " + tblName, e); + return hadoopAuthenticator.doAs(() -> catalog.getTable(Identifier.create(dbName, tblName))); + } catch (Exception e) { + throw new RuntimeException("Failed to get Paimon table:" + getName() + "." + + dbName + "." + tblName + ", because " + e.getMessage(), e); } } diff --git a/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/PaimonExternalCatalogTest.java b/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/PaimonExternalCatalogTest.java new file mode 100644 index 0000000000..35dd64515b --- /dev/null +++ b/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/PaimonExternalCatalogTest.java @@ -0,0 +1,43 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.doris.datasource.paimon; + +import org.junit.Assert; +import org.junit.Test; + +import java.util.HashMap; + + +public class PaimonExternalCatalogTest { + + @Test + public void testGetPaimonTable() { + + HashMap props = new HashMap<>(); + props.put("warehouse", "not_exist"); + PaimonExternalCatalog catalog = new PaimonFileExternalCatalog(1, "name", "resource", props, "comment"); + catalog.setInitialized(true); + + try { + catalog.getPaimonTable("dbName", "tblName"); + Assert.fail(); + } catch (Exception e) { + Assert.assertTrue(e.getMessage().contains("Failed to get Paimon table")); + } + } +}