bowenli86 commented on a change in pull request #8703: [FLINK-12807][hive]Support Hive table columnstats related operations in HiveCatalog URL: https://github.com/apache/flink/pull/8703#discussion_r293542867
########## File path: flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveCatalog.java ########## @@ -1079,7 +1100,27 @@ public void alterPartitionStatistics(ObjectPath tablePath, CatalogPartitionSpec @Override public void alterPartitionColumnStatistics(ObjectPath tablePath, CatalogPartitionSpec partitionSpec, CatalogColumnStatistics columnStatistics, boolean ignoreIfNotExists) throws PartitionNotExistException, CatalogException { + try { + Partition hivePartition = getHivePartition(tablePath, partitionSpec); + Table hiveTable = getHiveTable(tablePath); + String partName = getPartitionName(tablePath, partitionSpec, hiveTable); + client.updatePartitionColumnStatistics(HiveCatalogUtil.createPartitionColumnStats(hivePartition, partName, columnStatistics.getColumnStatisticsData())); + } catch (TableNotExistException | PartitionSpecInvalidException e) { + throw new PartitionNotExistException(getName(), tablePath, partitionSpec, e); + } catch (TException e) { + throw new CatalogException(String.format("Failed to alter table column stats of table %s 's partition %s", + tablePath.getFullName(), String.valueOf(partitionSpec)), e); + } + } + private String getPartitionName(ObjectPath tablePath, CatalogPartitionSpec partitionSpec, Table hiveTable) throws PartitionSpecInvalidException { + List<String> partitionCols = getFieldNames(hiveTable.getPartitionKeys()); + List<String> partitionVals = getOrderedFullPartitionValues(partitionSpec, partitionCols, tablePath); + List<String> partKVs = new ArrayList<>(); + for (int i = 0; i < partitionCols.size(); i++) { + partKVs.add(partitionCols.get(i) + "=" + partitionVals.get(i)); + } + return org.apache.commons.lang3.StringUtils.join(partKVs, "/"); Review comment: we'd better not use commons lang3 and introduce unnecessary dependency on it ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services