This is an automated email from the ASF dual-hosted git repository.

raulcd pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-swift.git

commit aecb1e3c4f7bf31102a72ad38eb5a59143c2176d
Author: abandy <[email protected]>
AuthorDate: Fri Jun 21 18:16:57 2024 -0400

    GH-42243: [Swift] Update isValidBuilderType to not required instance of 
type (#42244)
    
    ### Rationale for this change
    isValidBuilderType should take a Type and not require an instance of a type 
in order to validate.
    
    ### What changes are included in this PR?
    Updated isValidBuilderType to take a Type instead of an instance.
    
    ### Are these changes tested?
    Yes
    
    * GitHub Issue: #42243
    
    Authored-by: Alva Bandy <[email protected]>
    Signed-off-by: Sutou Kouhei <[email protected]>
---
 Arrow/Sources/Arrow/ArrowArrayBuilder.swift   |  3 +-
 Arrow/Tests/ArrowTests/ArrayBuilderTest.swift | 56 +++++++++++++--------------
 2 files changed, 29 insertions(+), 30 deletions(-)

diff --git a/Arrow/Sources/Arrow/ArrowArrayBuilder.swift 
b/Arrow/Sources/Arrow/ArrowArrayBuilder.swift
index 38e6e45..dc80f52 100644
--- a/Arrow/Sources/Arrow/ArrowArrayBuilder.swift
+++ b/Arrow/Sources/Arrow/ArrowArrayBuilder.swift
@@ -152,8 +152,7 @@ public class ArrowArrayBuilders {
         }
     }
 
-    public static func isValidBuilderType<T>(_: T) -> Bool {
-        let type = T.self
+    public static func isValidBuilderType<T>(_ type: T.Type) -> Bool {
         return type == Int8?.self || type == Int16?.self ||
             type == Int32?.self || type == Int64?.self ||
             type == UInt8?.self || type == UInt16?.self ||
diff --git a/Arrow/Tests/ArrowTests/ArrayBuilderTest.swift 
b/Arrow/Tests/ArrowTests/ArrayBuilderTest.swift
index 965e4ed..42e167f 100644
--- a/Arrow/Tests/ArrowTests/ArrayBuilderTest.swift
+++ b/Arrow/Tests/ArrowTests/ArrayBuilderTest.swift
@@ -20,35 +20,35 @@ import XCTest
 
 final class ArrayBuilderTests: XCTestCase {
     func testIsValidTypeForBuilder() throws {
-        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Int8(0)))
-        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Int16(0)))
-        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Int32(0)))
-        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Int64(0)))
-        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(UInt8(0)))
-        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(UInt16(0)))
-        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(UInt32(0)))
-        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(UInt64(0)))
-        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Float(0)))
-        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Double(0)))
-        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Date.now))
-        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(true))
-        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Int8?(0)))
-        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Int16?(0)))
-        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Int32?(0)))
-        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Int64?(0)))
-        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(UInt8?(0)))
-        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(UInt16?(0)))
-        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(UInt32?(0)))
-        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(UInt64?(0)))
-        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Float?(0)))
-        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Double?(0)))
-        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Date?(Date.now)))
-        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Bool?(true)))
+        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(UInt8.self))
+        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Int16.self))
+        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Int32.self))
+        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Int64.self))
+        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(UInt8.self))
+        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(UInt16.self))
+        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(UInt32.self))
+        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(UInt64.self))
+        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Float.self))
+        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Double.self))
+        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Date.self))
+        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Bool.self))
+        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Int8?.self))
+        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Int16?.self))
+        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Int32?.self))
+        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Int64?.self))
+        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(UInt8?.self))
+        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(UInt16?.self))
+        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(UInt32?.self))
+        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(UInt64?.self))
+        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Float?.self))
+        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Double?.self))
+        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Date?.self))
+        XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Bool?.self))
 
-        XCTAssertFalse(ArrowArrayBuilders.isValidBuilderType(Int(0)))
-        XCTAssertFalse(ArrowArrayBuilders.isValidBuilderType(UInt(0)))
-        XCTAssertFalse(ArrowArrayBuilders.isValidBuilderType(Int?(0)))
-        XCTAssertFalse(ArrowArrayBuilders.isValidBuilderType(UInt?(0)))
+        XCTAssertFalse(ArrowArrayBuilders.isValidBuilderType(Int.self))
+        XCTAssertFalse(ArrowArrayBuilders.isValidBuilderType(UInt.self))
+        XCTAssertFalse(ArrowArrayBuilders.isValidBuilderType(Int?.self))
+        XCTAssertFalse(ArrowArrayBuilders.isValidBuilderType(UInt?.self))
     }
 
     func testLoadArrayBuilders() throws {

Reply via email to