Skip to content

Commit 81a0375

Browse files
authored
[mosaic] Support ARRAY and MAP type validation (#8178)
- Remove `UnsupportedOperationException` for ARRAY and MAP types in `MosaicRowTypeVisitor`, allowing these types to pass schema validation - Recursively validate child types (element type for ARRAY, key/value types for MAP) - Once paimon-mosaic upstream releases 0.2.0 (which includes ARRAY/MAP support in the native library), we only need to bump the mosaic dependency version
1 parent 773f942 commit 81a0375

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

paimon-mosaic/src/main/java/org/apache/paimon/format/mosaic/MosaicFileFormat.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ public Void visit(BlobType blobType) {
209209

210210
@Override
211211
public Void visit(ArrayType arrayType) {
212-
throw new UnsupportedOperationException(
213-
"Mosaic file format does not support type ARRAY");
212+
arrayType.getElementType().accept(this);
213+
return null;
214214
}
215215

216216
@Override
@@ -227,7 +227,9 @@ public Void visit(MultisetType multisetType) {
227227

228228
@Override
229229
public Void visit(MapType mapType) {
230-
throw new UnsupportedOperationException("Mosaic file format does not support type MAP");
230+
mapType.getKeyType().accept(this);
231+
mapType.getValueType().accept(this);
232+
return null;
231233
}
232234

233235
@Override

paimon-mosaic/src/test/java/org/apache/paimon/format/mosaic/MosaicFileFormatTest.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,17 @@ void testValidateDataFieldsSupported() {
8585
}
8686

8787
@Test
88-
void testValidateDataFieldsMapUnsupported() {
88+
void testValidateDataFieldsArraySupported() {
89+
MosaicFileFormat format = createFormat();
90+
RowType rowType = DataTypes.ROW(DataTypes.ARRAY(DataTypes.INT()));
91+
format.validateDataFields(rowType);
92+
}
93+
94+
@Test
95+
void testValidateDataFieldsMapSupported() {
8996
MosaicFileFormat format = createFormat();
9097
RowType rowType = DataTypes.ROW(DataTypes.MAP(DataTypes.STRING(), DataTypes.INT()));
91-
assertThatThrownBy(() -> format.validateDataFields(rowType))
92-
.isInstanceOf(UnsupportedOperationException.class)
93-
.hasMessageContaining("MAP");
98+
format.validateDataFields(rowType);
9499
}
95100

96101
@Test

0 commit comments

Comments
 (0)