@@ -43,6 +43,8 @@ object IcebergReflection extends Logging {
4343 schemaClass : Class [_],
4444 partitionSpecParserClass : Class [_],
4545 partitionSpecClass : Class [_],
46+ structLikeClass : Class [_],
47+ nestedFieldClass : Class [_],
4648 // ContentScanTask methods
4749 fileMethod : java.lang.reflect.Method ,
4850 startMethod : java.lang.reflect.Method ,
@@ -62,7 +64,17 @@ object IcebergReflection extends Logging {
6264 // Schema methods
6365 schemaToJsonMethod : java.lang.reflect.Method ,
6466 // PartitionSpec methods
65- partitionSpecToJsonMethod : java.lang.reflect.Method )
67+ partitionSpecToJsonMethod : java.lang.reflect.Method ,
68+ partitionTypeMethod : java.lang.reflect.Method ,
69+ // StructType methods
70+ structTypeFieldsMethod : java.lang.reflect.Method ,
71+ // NestedField methods
72+ nestedFieldTypeMethod : java.lang.reflect.Method ,
73+ nestedFieldIdMethod : java.lang.reflect.Method ,
74+ nestedFieldNameMethod : java.lang.reflect.Method ,
75+ nestedFieldIsOptionalMethod : java.lang.reflect.Method ,
76+ // StructLike methods
77+ structLikeGetMethod : java.lang.reflect.Method )
6678
6779 /**
6880 * Creates a ReflectionCache by loading all classes and methods once.
@@ -77,6 +89,9 @@ object IcebergReflection extends Logging {
7789 val schemaClass = Class .forName(ClassNames .SCHEMA )
7890 val partitionSpecParserClass = Class .forName(ClassNames .PARTITION_SPEC_PARSER )
7991 val partitionSpecClass = Class .forName(ClassNames .PARTITION_SPEC )
92+ val structTypeClass = Class .forName(ClassNames .STRUCT_TYPE )
93+ val nestedFieldClass = Class .forName(ClassNames .NESTED_FIELD )
94+ val structLikeClass = Class .forName(ClassNames .STRUCT_LIKE )
8095 // scalastyle:on classforname
8196
8297 // ContentScanTask methods
@@ -108,9 +123,22 @@ object IcebergReflection extends Logging {
108123 val schemaToJsonMethod = schemaParserClass.getMethod(" toJson" , schemaClass)
109124 schemaToJsonMethod.setAccessible(true )
110125
111- // PartitionSpec serialization
126+ // PartitionSpec methods
112127 val partitionSpecToJsonMethod =
113128 partitionSpecParserClass.getMethod(" toJson" , partitionSpecClass)
129+ val partitionTypeMethod = partitionSpecClass.getMethod(" partitionType" )
130+
131+ // StructType methods
132+ val structTypeFieldsMethod = structTypeClass.getMethod(" fields" )
133+
134+ // NestedField methods
135+ val nestedFieldTypeMethod = nestedFieldClass.getMethod(" type" )
136+ val nestedFieldIdMethod = nestedFieldClass.getMethod(" fieldId" )
137+ val nestedFieldNameMethod = nestedFieldClass.getMethod(" name" )
138+ val nestedFieldIsOptionalMethod = nestedFieldClass.getMethod(" isOptional" )
139+
140+ // StructLike methods
141+ val structLikeGetMethod = structLikeClass.getMethod(" get" , classOf [Int ], classOf [Class [_]])
114142
115143 ReflectionCache (
116144 contentScanTaskClass = contentScanTaskClass,
@@ -121,6 +149,8 @@ object IcebergReflection extends Logging {
121149 schemaClass = schemaClass,
122150 partitionSpecParserClass = partitionSpecParserClass,
123151 partitionSpecClass = partitionSpecClass,
152+ structLikeClass = structLikeClass,
153+ nestedFieldClass = nestedFieldClass,
124154 fileMethod = fileMethod,
125155 startMethod = startMethod,
126156 lengthMethod = lengthMethod,
@@ -134,7 +164,14 @@ object IcebergReflection extends Logging {
134164 deleteSpecIdMethod = deleteSpecIdMethod,
135165 deleteEqualityIdsMethod = deleteEqualityIdsMethod,
136166 schemaToJsonMethod = schemaToJsonMethod,
137- partitionSpecToJsonMethod = partitionSpecToJsonMethod)
167+ partitionSpecToJsonMethod = partitionSpecToJsonMethod,
168+ partitionTypeMethod = partitionTypeMethod,
169+ structTypeFieldsMethod = structTypeFieldsMethod,
170+ nestedFieldTypeMethod = nestedFieldTypeMethod,
171+ nestedFieldIdMethod = nestedFieldIdMethod,
172+ nestedFieldNameMethod = nestedFieldNameMethod,
173+ nestedFieldIsOptionalMethod = nestedFieldIsOptionalMethod,
174+ structLikeGetMethod = structLikeGetMethod)
138175 }
139176
140177 /**
@@ -154,6 +191,8 @@ object IcebergReflection extends Logging {
154191 val PARTITION_SPEC = " org.apache.iceberg.PartitionSpec"
155192 val PARTITION_FIELD = " org.apache.iceberg.PartitionField"
156193 val UNBOUND_PREDICATE = " org.apache.iceberg.expressions.UnboundPredicate"
194+ val STRUCT_TYPE = " org.apache.iceberg.types.Types$StructType"
195+ val NESTED_FIELD = " org.apache.iceberg.types.Types$NestedField"
157196 }
158197
159198 /**
0 commit comments