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_r293549259
##########
File path:
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveCatalog.java
##########
@@ -1099,7 +1153,28 @@ public CatalogTableStatistics
getPartitionStatistics(ObjectPath tablePath, Catal
@Override
public CatalogColumnStatistics getPartitionColumnStatistics(ObjectPath
tablePath, CatalogPartitionSpec partitionSpec) throws
PartitionNotExistException, CatalogException {
- throw new UnsupportedOperationException();
+ try {
+ Partition partition = getHivePartition(tablePath,
partitionSpec);
+ Table hiveTable = getHiveTable(tablePath);
+ String partName = getPartitionName(tablePath,
partitionSpec, hiveTable);
+ List<String> partNames = new ArrayList<>();
+ partNames.add(partName);
+ Map<String, List<ColumnStatisticsObj>>
partitionColumnStatistics =
+
client.getPartitionColumnStatistics(partition.getDbName(),
partition.getTableName(), partNames,
+
getFieldNames(partition.getSd().getCols()));
+ if (partitionColumnStatistics.containsKey(partName)) {
+ List<ColumnStatisticsObj> columnStatisticsObjs
= partitionColumnStatistics.get(partName);
+ return new
CatalogColumnStatistics(HiveCatalogUtil.createCatalogColumnStats(columnStatisticsObjs));
+ } else {
+ throw new
CatalogException(String.format("Failed to get table stats of table %s 's
partition %s",
Review comment:
I wonder if we should just return an unknown stats here to be consistent
with other APIs, e.g. `getTableColumnStatistics()` returns unknown stats when
table columns don't exist (the table is not partitioned).
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services