branch-2.1: [opt](paimon) Optimize error prompt #47593 (#47790)

Cherry-picked from #47593

Co-authored-by: wuwenchi <wuwenchi@selectdb.com>
This commit is contained in:
github-actions[bot]
2025-02-13 16:49:41 +08:00
committed by GitHub
parent 13c8b1797d
commit 8fb10b0fa0
2 changed files with 47 additions and 12 deletions

View File

@ -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);
}
}

View File

@ -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<String, String> 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"));
}
}
}