From 8cd982baa4315522c514613628633f0431e51a5d Mon Sep 17 00:00:00 2001 From: morningman Date: Wed, 9 Oct 2024 18:31:02 +0800 Subject: [PATCH] 1 --- .../java/org/apache/doris/analysis/Analyzer.java | 8 ++++++-- .../main/java/org/apache/doris/common/ErrorCode.java | 2 +- .../doris/datasource/hive/HMSExternalTable.java | 12 +++++------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/Analyzer.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/Analyzer.java index b1b0d66b585c25..8a3aa47fc17e25 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/Analyzer.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/Analyzer.java @@ -41,6 +41,7 @@ import org.apache.doris.common.UserException; import org.apache.doris.common.util.TimeUtils; import org.apache.doris.datasource.hive.HMSExternalTable; +import org.apache.doris.nereids.exceptions.NotSupportedException; import org.apache.doris.planner.AggregationNode; import org.apache.doris.planner.AnalyticEvalNode; import org.apache.doris.planner.PlanNode; @@ -846,11 +847,14 @@ public TableRef resolveTableRef(TableRef tableRef) throws AnalysisException { // Now hms table only support a bit of table kinds in the whole hive system. // So Add this strong checker here to avoid some undefine behaviour in doris. if (table.getType() == TableType.HMS_EXTERNAL_TABLE) { - if (!((HMSExternalTable) table).isSupportedHmsTable()) { + try { + ((HMSExternalTable) table).isSupportedHmsTable(); + } catch (NotSupportedException e) { ErrorReport.reportAnalysisException(ErrorCode.ERR_NONSUPPORT_HMS_TABLE, table.getName(), ((HMSExternalTable) table).getDbName(), - tableName.getCtl()); + tableName.getCtl(), + e.getMessage()); } if (Config.enable_query_hive_views) { if (((HMSExternalTable) table).isView() diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/ErrorCode.java b/fe/fe-core/src/main/java/org/apache/doris/common/ErrorCode.java index 68e15e7ee46e81..2d98f36ad8a2ce 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/common/ErrorCode.java +++ b/fe/fe-core/src/main/java/org/apache/doris/common/ErrorCode.java @@ -1199,7 +1199,7 @@ public enum ErrorCode { ERR_CATALOG_ACCESS_DENIED(5087, new byte[]{'4', '2', '0', '0', '0'}, "Access denied for user '%s' to catalog '%s'"), ERR_NONSUPPORT_HMS_TABLE(5088, new byte[]{'4', '2', '0', '0', '0'}, - "Nonsupport hive metastore table named '%s' in database '%s' with catalog '%s'."), + "Nonsupport hive metastore table named '%s' in database '%s' with catalog '%s'. %s"), ERR_TABLE_NAME_LENGTH_LIMIT(5089, new byte[]{'4', '2', '0', '0', '0'}, "Table name length exceeds limit, " + "the length of table name '%s' is %d which is greater than the configuration 'table_name_length_limit' (%d)."), diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HMSExternalTable.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HMSExternalTable.java index 6179bf5f19ced7..a215cba3f9cee6 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HMSExternalTable.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HMSExternalTable.java @@ -167,14 +167,11 @@ public HMSExternalTable(long id, String name, String dbName, HMSExternalCatalog super(id, name, catalog, dbName, TableType.HMS_EXTERNAL_TABLE); } + // Will throw NotSupportedException if not supported hms table. + // Otherwise, return true. public boolean isSupportedHmsTable() { - try { - makeSureInitialized(); - return true; - } catch (NotSupportedException e) { - LOG.warn("Not supported hms table, message: {}", e.getMessage()); - return false; - } + makeSureInitialized(); + return true; } protected synchronized void makeSureInitialized() { @@ -191,6 +188,7 @@ protected synchronized void makeSureInitialized() { } else if (supportedHiveTable()) { dlaType = DLAType.HIVE; } else { + // Should not reach here. Because `supportedHiveTable` will throw exception if not return true. throw new NotSupportedException("Unsupported dlaType for table: " + getNameWithFullQualifiers()); } }