From 62db0318651b4c84d3abd298f15b65e8306d88e6 Mon Sep 17 00:00:00 2001 From: Tiewei Fang <43782773+BePPPower@users.noreply.github.com> Date: Mon, 22 Apr 2024 23:39:30 +0800 Subject: [PATCH] [Fix](Jdbc-Hive) fix the order of partition keys (#33963) The partition key information recorded in PARTITION_KEYS table is sorted according to the INTEGER_IDX field, so we need to add an 'order by' clause to ensure that the obtained partition names are ordered. --- .../doris/datasource/hive/PostgreSQLJdbcHMSCachedClient.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/PostgreSQLJdbcHMSCachedClient.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/PostgreSQLJdbcHMSCachedClient.java index 11cec91eb90da6..2d02e7753217e6 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/PostgreSQLJdbcHMSCachedClient.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/PostgreSQLJdbcHMSCachedClient.java @@ -228,7 +228,7 @@ private List getPartitionsByNames(String dbName, String tblName, List private List getPartitionValues(int partitionId) { String sql = String.format("SELECT \"PART_KEY_VAL\" FROM \"PARTITION_KEY_VALS\"" - + " WHERE \"PART_ID\" = " + partitionId); + + " WHERE \"PART_ID\" = " + partitionId + " ORDER BY \"INTEGER_IDX\""); if (LOG.isDebugEnabled()) { LOG.debug("getPartitionValues exec sql: {}", sql); } @@ -356,7 +356,7 @@ private Map getSerdeInfoParameters(int serdeId) { private List getTablePartitionKeys(int tableId) { String sql = "SELECT \"PKEY_NAME\", \"PKEY_TYPE\", \"PKEY_COMMENT\" from \"PARTITION_KEYS\"" - + " WHERE \"TBL_ID\"= " + tableId; + + " WHERE \"TBL_ID\"= " + tableId + " ORDER BY \"INTEGER_IDX\""; if (LOG.isDebugEnabled()) { LOG.debug("getTablePartitionKeys exec sql: {}", sql); }