Skip to content

Commit

Permalink
[Fix](Jdbc-Hive) fix the order of partition keys (#33963)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
BePPPower authored Apr 22, 2024
1 parent 5c3a650 commit d84b35c
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ private List<Partition> getPartitionsByNames(String dbName, String tblName, List

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);
}
Expand Down Expand Up @@ -366,7 +366,7 @@ private Map<String, String> getSerdeInfoParameters(int serdeId) {

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);
}
Expand Down

0 comments on commit d84b35c

Please sign in to comment.