Skip to content

Commit 38ffbd3

Browse files
committed
[SPARK-52629] Remove ArrowReaderHelper.isNestedType
### What changes were proposed in this pull request? This PR aims to remove `ArrowReaderHelper.isNestedType` method in order to make `loadField` more flexible. ### Why are the changes needed? This is a preparation to support more complex types. `switch` pattern is more flexible to extend `loadField` method. In addition, `isNestedType` is used once. ### Does this PR introduce _any_ user-facing change? No, this is an internal refactoring. ### How was this patch tested? Pass the CIs. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #204 from dongjoon-hyun/SPARK-52629. Authored-by: Dongjoon Hyun <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent bfa92ae commit 38ffbd3

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

Sources/SparkConnect/ArrowReader.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,15 @@ public class ArrowReader { // swiftlint:disable:this type_body_length
201201
)
202202
-> Result<ArrowArrayHolder, ArrowError>
203203
{
204-
if isNestedType(field.typeType) {
204+
switch field.typeType {
205+
case .struct_:
205206
return loadStructData(loadInfo, field: field)
206-
} else if isFixedPrimitive(field.typeType) {
207-
return loadPrimitiveData(loadInfo, field: field)
208-
} else {
209-
return loadVariableData(loadInfo, field: field)
207+
default:
208+
if isFixedPrimitive(field.typeType) {
209+
return loadPrimitiveData(loadInfo, field: field)
210+
} else {
211+
return loadVariableData(loadInfo, field: field)
212+
}
210213
}
211214
}
212215

Sources/SparkConnect/ArrowReaderHelper.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -262,15 +262,6 @@ func isFixedPrimitive(_ type: org_apache_arrow_flatbuf_Type_) -> Bool {
262262
}
263263
}
264264

265-
func isNestedType(_ type: org_apache_arrow_flatbuf_Type_) -> Bool {
266-
switch type {
267-
case .struct_:
268-
return true
269-
default:
270-
return false
271-
}
272-
}
273-
274265
func findArrowType( // swiftlint:disable:this cyclomatic_complexity function_body_length
275266
_ field: org_apache_arrow_flatbuf_Field
276267
) -> ArrowType {

0 commit comments

Comments
 (0)