This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new f868aa9d4a [Enhancement](multi-catalog) Add some checks for
ShowPartitionsStmt. (#21446)
f868aa9d4a is described below
commit f868aa9d4a3d53532b467093cd989c5e7766e59f
Author: Xiangyu Wang <[email protected]>
AuthorDate: Wed Jul 5 16:28:05 2023 +0800
[Enhancement](multi-catalog) Add some checks for ShowPartitionsStmt.
(#21446)
1. Add some validations for ShowPartitionsStmt with hive tables
2. Make the behavior consistently with hive
---
.../org/apache/doris/analysis/ShowPartitionsStmt.java | 17 ++++++++++++++---
.../main/java/org/apache/doris/catalog/DatabaseIf.java | 4 ++--
.../src/main/java/org/apache/doris/qe/ShowExecutor.java | 5 ++---
3 files changed, 18 insertions(+), 8 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowPartitionsStmt.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowPartitionsStmt.java
index d7de6ee560..f6e9b06e0b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowPartitionsStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowPartitionsStmt.java
@@ -25,6 +25,7 @@ import org.apache.doris.catalog.Table;
import org.apache.doris.catalog.TableIf;
import org.apache.doris.catalog.TableIf.TableType;
import org.apache.doris.catalog.Type;
+import org.apache.doris.catalog.external.HMSExternalTable;
import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.ErrorCode;
import org.apache.doris.common.ErrorReport;
@@ -41,6 +42,7 @@ import org.apache.doris.qe.ConnectContext;
import org.apache.doris.qe.ShowResultSetMetaData;
import com.google.common.base.Strings;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -121,12 +123,21 @@ public class ShowPartitionsStmt extends ShowStmt {
ConnectContext.get().getRemoteIP(),
dbName + ": " + tblName);
}
- if (!catalog.isInternalCatalog()) {
+
+ DatabaseIf db = catalog.getDbOrAnalysisException(dbName);
+ TableIf table = db.getTableOrMetaException(tblName,
Table.TableType.OLAP, TableType.MATERIALIZED_VIEW,
+ TableType.HMS_EXTERNAL_TABLE);
+
+ if (table instanceof HMSExternalTable) {
+ if (((HMSExternalTable) table).isView()) {
+ throw new AnalysisException("Table " + tblName + " is not a
partitioned table");
+ }
+ if (CollectionUtils.isEmpty(((HMSExternalTable)
table).getPartitionColumns())) {
+ throw new AnalysisException("Table " + tblName + " is not a
partitioned table");
+ }
return;
}
- DatabaseIf db = catalog.getDbOrAnalysisException(dbName);
- TableIf table = db.getTableOrMetaException(tblName,
Table.TableType.OLAP, TableType.MATERIALIZED_VIEW);
table.readLock();
try {
// build proc path
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/DatabaseIf.java
b/fe/fe-core/src/main/java/org/apache/doris/catalog/DatabaseIf.java
index 4c696b9ef9..7672b8b76d 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/DatabaseIf.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/DatabaseIf.java
@@ -169,7 +169,7 @@ public interface DatabaseIf<T extends TableIf> {
T table = getTableOrMetaException(tableName);
if (!tableTypes.contains(table.getType())) {
throw new MetaNotFoundException(
- "Tye type of " + tableName + " doesn't match, expected
data tables=" + tableTypes);
+ "Type of " + tableName + " doesn't match, expected data
tables=" + tableTypes);
}
return table;
}
@@ -193,7 +193,7 @@ public interface DatabaseIf<T extends TableIf> {
T table = getTableOrMetaException(tableId);
if (!tableTypes.contains(table.getType())) {
throw new MetaNotFoundException(
- "Tye type of " + tableId + " doesn't match, expected data
tables=" + tableTypes);
+ "Type of " + tableId + " doesn't match, expected data
tables=" + tableTypes);
}
return table;
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java
b/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java
index 06aa997695..7f5d197723 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java
@@ -1583,6 +1583,7 @@ public class ShowExecutor {
HMSExternalCatalog catalog = (HMSExternalCatalog)
(showStmt.getCatalog());
List<List<String>> rows = new ArrayList<>();
String dbName =
ClusterNamespace.getNameFromFullName(showStmt.getTableName().getDb());
+
List<String> partitionNames =
catalog.getClient().listPartitionNames(dbName,
showStmt.getTableName().getTbl());
for (String partition : partitionNames) {
@@ -1592,9 +1593,7 @@ public class ShowExecutor {
}
// sort by partition name
- rows.sort((x, y) -> {
- return x.get(0).compareTo(y.get(0));
- });
+ rows.sort(Comparator.comparing(x -> x.get(0)));
resultSet = new ShowResultSet(showStmt.getMetaData(), rows);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]