Skip to content
Merged
Show file tree
Hide file tree
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 @@ -23,6 +23,7 @@
import org.apache.fluss.exception.PartitionNotExistException;
import org.apache.fluss.metadata.PhysicalTablePath;
import org.apache.fluss.metadata.ResolvedPartitionSpec;
import org.apache.fluss.metadata.TableInfo;
import org.apache.fluss.metadata.TablePath;
import org.apache.fluss.utils.AutoPartitionStrategy;
import org.apache.fluss.utils.ExceptionUtils;
Expand Down Expand Up @@ -66,9 +67,7 @@ public DynamicPartitionCreator(
}

public void checkAndCreatePartitionAsync(
PhysicalTablePath physicalTablePath,
List<String> partitionKeys,
AutoPartitionStrategy autoPartitionStrategy) {
PhysicalTablePath physicalTablePath, TableInfo tableInfo) {
String partitionName = physicalTablePath.getPartitionName();
if (partitionName == null) {
// no need to check and create partition
Expand All @@ -87,7 +86,11 @@ public void checkAndCreatePartitionAsync(
// if the partition exists, we should skip creating it.
LOG.debug("Partition {} already exists, skipping.", physicalTablePath);
} else {
// Validate early, before touching any state.
// Validate early, before touching any state. The strategy is only resolved here,
// on the partition-creation path, not on the common "already exists" path.
List<String> partitionKeys = tableInfo.getPartitionKeys();
AutoPartitionStrategy autoPartitionStrategy =
tableInfo.getTableConfig().getAutoPartitionStrategy();
ResolvedPartitionSpec resolvedPartitionSpec =
ResolvedPartitionSpec.fromPartitionName(partitionKeys, partitionName);
validateAutoPartitionTime(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ private void doSend(WriteRecord record, WriteCallback callback) {

TableInfo tableInfo = record.getTableInfo();
PhysicalTablePath physicalTablePath = record.getPhysicalTablePath();
dynamicPartitionCreator.checkAndCreatePartitionAsync(
physicalTablePath,
tableInfo.getPartitionKeys(),
tableInfo.getTableConfig().getAutoPartitionStrategy());
// Skip the call entirely on non-partitioned tables; there is no partition to create.
if (tableInfo.isPartitioned()) {
dynamicPartitionCreator.checkAndCreatePartitionAsync(physicalTablePath, tableInfo);
}

// maybe create bucket assigner.
Cluster cluster = metadataUpdater.getCluster();
Expand Down
Loading