[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.
This commit is contained in:
Tiewei Fang
2024-04-22 23:39:30 +08:00
committed by yiguolei
parent 2a1fbfd72c
commit a11ae2cd51

View File

@ -229,7 +229,7 @@ public class PostgreSQLJdbcHMSCachedClient extends JdbcHMSCachedClient {
private List<String> 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);
}
@ -366,7 +366,7 @@ public class PostgreSQLJdbcHMSCachedClient extends JdbcHMSCachedClient {
private List<FieldSchema> 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);
}