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 @@ -26,6 +26,7 @@
import org.apache.paimon.utils.InternalRowPartitionComputer;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

Expand All @@ -48,9 +49,12 @@ public void open() {
String defaultPartitionName = Options.fromMap(table.options()).get(PARTITION_DEFAULT_NAME);
InternalRowSerializer serializer = new InternalRowSerializer(partitionType);
for (Map<String, String> spec : scanPartitions) {
Map<String, String> completedSpec = new LinkedHashMap<>(spec);
table.partitionKeys()
.forEach(key -> completedSpec.putIfAbsent(key, defaultPartitionName));
GenericRow row =
InternalRowPartitionComputer.convertSpecToInternalRow(
spec, partitionType, defaultPartitionName);
completedSpec, partitionType, defaultPartitionName);
partitions.add(serializer.toBinaryRow(row).copy());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,16 @@ public void testScanWithSpecifiedPartitions() {
assertThat(sql(query)).containsExactly(Row.of(1, 11), Row.of(1, 12), Row.of(2, 22));
}

@Test
public void testScanWithPartialSpecifiedPartition() {
sql("CREATE TABLE P (dt STRING, hh INT, v INT) PARTITIONED BY (dt, hh)");
sql(
"INSERT INTO P VALUES ('20260814', CAST(NULL AS INT), 1), ('20260814', 10, 2), ('20260815', CAST(NULL AS INT), 3)");

assertThat(sql("SELECT COUNT(*) FROM P /*+ OPTIONS('scan.partitions' = 'dt=20260814') */"))
.containsExactly(Row.of(1L));
}

@Test
public void testScanWithSpecifiedPartitionsWithFieldMapping() {
sql("CREATE TABLE P (id INT, v INT, pt STRING) PARTITIONED BY (pt)");
Expand Down
Loading