Skip to content

Commit edcc83c

Browse files
authored
[iceberg] Make Iceberg partition a required field, as specified in Iceberg spec (#5386)
1 parent a4effef commit edcc83c

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

paimon-core/src/main/java/org/apache/paimon/iceberg/manifest/IcebergDataFileMeta.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public static RowType schema(RowType partitionType) {
218218
fields.add(new DataField(134, "content", DataTypes.INT().notNull()));
219219
fields.add(new DataField(100, "file_path", DataTypes.STRING().notNull()));
220220
fields.add(new DataField(101, "file_format", DataTypes.STRING().notNull()));
221-
fields.add(new DataField(102, "partition", partitionType));
221+
fields.add(new DataField(102, "partition", partitionType.notNull()));
222222
fields.add(new DataField(103, "record_count", DataTypes.BIGINT().notNull()));
223223
fields.add(new DataField(104, "file_size_in_bytes", DataTypes.BIGINT().notNull()));
224224
fields.add(
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.paimon.iceberg.manifest;
20+
21+
import org.apache.paimon.TestKeyValueGenerator;
22+
import org.apache.paimon.types.DataField;
23+
import org.apache.paimon.types.RowType;
24+
25+
import org.junit.jupiter.api.DisplayName;
26+
import org.junit.jupiter.api.Test;
27+
28+
import java.util.List;
29+
import java.util.Optional;
30+
31+
import static org.assertj.core.api.Assertions.assertThat;
32+
33+
class IcebergDataFileMetaTest {
34+
35+
@Test
36+
@DisplayName("Test partition is a required field")
37+
void testPartitionIsNotNull() {
38+
RowType partitionType = TestKeyValueGenerator.SINGLE_PARTITIONED_PART_TYPE;
39+
RowType schema = IcebergDataFileMeta.schema(partitionType);
40+
List<DataField> fields = schema.getFields();
41+
42+
Optional<DataField> partitionField = fields.stream().filter(f -> f.id() == 102).findFirst();
43+
44+
assertThat(partitionField).isPresent();
45+
assertThat(partitionField.get().name()).isEqualTo("partition");
46+
assertThat(partitionField.get().type()).isEqualTo(partitionType.notNull());
47+
}
48+
}

0 commit comments

Comments
 (0)