Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.apache.doris.catalog.external.HMSExternalTable;
import org.apache.doris.common.Config;
import org.apache.doris.datasource.CacheException;
import org.apache.doris.datasource.HMSExternalCatalog;
import org.apache.doris.planner.external.TablePartitionValues;
import org.apache.doris.planner.external.TablePartitionValues.TablePartitionKey;

Expand All @@ -31,6 +32,8 @@
import org.apache.hudi.common.table.timeline.HoodieInstant;
import org.apache.hudi.common.table.timeline.HoodieTimeline;
import org.apache.hudi.common.util.Option;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Arrays;
import java.util.List;
Expand All @@ -39,6 +42,7 @@
import java.util.stream.Collectors;

public class HudiCachedPartitionProcessor extends HudiPartitionProcessor {
private static final Logger LOG = LoggerFactory.getLogger(HudiCachedPartitionProcessor.class);
private final long catalogId;
private final Executor executor;
private final LoadingCache<TablePartitionKey, TablePartitionValues> partitionCache;
Expand Down Expand Up @@ -137,7 +141,17 @@ public TablePartitionValues getPartitionValues(HMSExternalTable table, HoodieTab
if (lastTimestamp <= lastUpdateTimestamp) {
return partitionValues;
}
List<String> partitionNames = getAllPartitionNames(tableMetaClient);
HMSExternalCatalog catalog = (HMSExternalCatalog) table.getCatalog();
List<String> partitionNames;
// When a Hudi table is synchronized to HMS, the partition information is also synchronized,
// so even if the metastore is not enabled in the Hudi table
// (for example, if the Metastore is false for a Hudi table created with Flink),
// we can still obtain the partition information through the HMS API.
partitionNames = catalog.getClient().listPartitionNames(table.getDbName(), table.getName());
if (partitionNames.size() == 0) {
LOG.warn("Failed to get partitions from hms api, switch it from hudi api.");
partitionNames = getAllPartitionNames(tableMetaClient);
}
List<String> partitionColumnsList = Arrays.asList(partitionColumns.get());
partitionValues.cleanPartitions();
partitionValues.addPartitions(partitionNames,
Expand Down