SparkConnect

0.4.0

Apache Spark Connect Client for Swift
apache/spark-connect-swift

What's New

0.4.0

2025-10-01T16:34:50Z

Apache Sparkā„¢ Connect Client for Swift language is a subproject of Apache Spark and aims to provide Swift implementation of Spark Connect. 0.4.0 is the fourth release of Apache Spark Connect for Swift client. This is still experimental.

Website

https://apache.github.io/spark-connect-swift/

Swift Package Index

https://swiftpackageindex.com/apache/spark-connect-swift

Documentation

https://swiftpackageindex.com/apache/spark-connect-swift/0.4.0/documentation/sparkconnect

Full Changelog

0.3.0...0.4.0

Resolved Issues

  • [SPARK-52390] Upgrade gRPC Swift libraries to grpc-swift-2-based ones
  • [SPARK-52436] Update CIs to use actions/checkout@v4 consistently
  • [SPARK-52465] Update .asf.yaml with new README.md link
  • [SPARK-52472] Regenerate Spark Connect-generated Swift source code with protoc-gen-grpc-swift-2
  • [SPARK-52473] Limit GHA job execution time to up to 20 minutes
  • [SPARK-52522] Reapply swift format
  • [SPARK-52523] Update arrow-swift code for Timestamp
  • [SPARK-52524] Support Timestamp type
  • [SPARK-52627] Improve SQLTests to handle userName
  • [SPARK-52629] Remove ArrowReaderHelper.isNestedType
  • [SPARK-52631] Update Spark Connect-generated Swift source code
  • [SPARK-52658] Add Swift 6.2 build test CI
  • [SPARK-52678] Update ArrowReader.swift with GH-54
  • [SPARK-52742] Support createDataflowGraph
  • [SPARK-52743] Support startRun
  • [SPARK-52744] Add MacOS integration test with Apache Spark 4.1.0-preview1 RC1
  • [SPARK-52748] Support defineDataset
  • [SPARK-52756] Support defineFlow
  • [SPARK-52758] Support defineSqlGraphElements
  • [SPARK-52775] Add time SQL test and answer file
  • [SPARK-52847] Add ConstraintTests
  • [SPARK-52913] Upgrade grpc-swift-2 to 2.1.0
  • [SPARK-53370] Upgrade gRPC Swift Protobuf to 2.1.1
  • [SPARK-53371] Upgrade gRPC Swift NIO Transport to 2.1.0
  • [SPARK-53373] Use nightly-6.2-amazonlinux2 for Swift 6.2 CI
  • [SPARK-53374] Use release build in Apache Spark 4.1.0-preview1 testing
  • [SPARK-53375] Remove downloaded tgz files
  • [SPARK-53376] Run Swift build first before running test
  • [SPARK-53379] Add integration-test-ubuntu GitHub Action job
  • [SPARK-53380] Add SPARK_LOCAL_IP env variable to MacOS-based integration test jobs
  • [SPARK-53404] Make Build step to verify test compilation too
  • [SPARK-53463] Upgrade actions/checkout to v5
  • [SPARK-53465] Use 4.1.0-preview1 instead of RC1
  • [SPARK-53466] Use Spark 4.0.1 instead of 4.0.0
  • [SPARK-53467] Improve merge_spark_pr.py to accept PR numbers as a CLI argument
  • [SPARK-53477] Add integration-test-ubuntu-spark41 GitHub Action job
  • [SPARK-53569] Use Iceberg 1.10 for Spark 3-based Iceberg integration test
  • [SPARK-53570] Update integration-test-token to use Spark 4.1.0-preview1
  • [SPARK-53571] Add integration-test-mac-spark4-iceberg GitHub Action job
  • [SPARK-53683] Use Spark 3.5.7 for Spark 3 integration tests
  • [SPARK-53685] Upgrade gRPC Swift NIO Transport to 2.1.1
  • [SPARK-53697] Use 4.1.0-preview2 for integration-test-(mac-spark41|token) GitHub Action jobs
  • [SPARK-53698] Support Swift 6.2
  • [SPARK-53699] Add MacOS 26 GitHub Action job
  • [SPARK-53724] Update Examples and documentations to use 4.0.1
  • [MINOR] Update gRPC Swift-related library links in README.md

Apache Spark Connect Client for Swift

GitHub Actions Build Swift Version Compatibility Platform Compatibility

This is an experimental Swift library to show how to connect to a remote Apache Spark Connect Server and run SQL statements to manipulate remote data.

So far, this library project is tracking the upstream changes of Apache Arrow project's Swift-support.

Resources

Requirement

How to use in your apps

Create a Swift project.

mkdir SparkConnectSwiftApp
cd SparkConnectSwiftApp
swift package init --name SparkConnectSwiftApp --type executable

Add SparkConnect package to the dependency like the following

$ cat Package.swift
import PackageDescription

let package = Package(
  name: "SparkConnectSwiftApp",
  platforms: [
    .macOS(.v15)
  ],
  dependencies: [
    .package(url: "https://github.com/apache/spark-connect-swift.git", branch: "main")
  ],
  targets: [
    .executableTarget(
      name: "SparkConnectSwiftApp",
      dependencies: [.product(name: "SparkConnect", package: "spark-connect-swift")]
    )
  ]
)

Use SparkSession of SparkConnect module in Swift.

$ cat Sources/main.swift

import SparkConnect

let spark = try await SparkSession.builder.getOrCreate()
print("Connected to Apache Spark \(await spark.version) Server")

let statements = [
  "DROP TABLE IF EXISTS t",
  "CREATE TABLE IF NOT EXISTS t(a INT) USING ORC",
  "INSERT INTO t VALUES (1), (2), (3)",
]

for s in statements {
  print("EXECUTE: \(s)")
  _ = try await spark.sql(s).count()
}
print("SELECT * FROM t")
try await spark.sql("SELECT * FROM t").cache().show()

try await spark.range(10).filter("id % 2 == 0").write.mode("overwrite").orc("/tmp/orc")
try await spark.read.orc("/tmp/orc").show()

await spark.stop()

Run your Swift application.

$ swift run
...
Connected to Apache Spark 4.0.1 Server
EXECUTE: DROP TABLE IF EXISTS t
EXECUTE: CREATE TABLE IF NOT EXISTS t(a INT)
EXECUTE: INSERT INTO t VALUES (1), (2), (3)
SELECT * FROM t
+---+
| a |
+---+
| 2 |
| 1 |
| 3 |
+---+
+----+
| id |
+----+
| 2  |
| 6  |
| 0  |
| 8  |
| 4  |
+----+

You can find more complete examples including Spark SQL REPL, Web Server and Streaming applications in the Examples directory.

This library also supports SPARK_REMOTE environment variable to specify the Spark Connect connection string in order to provide more options.

Description

  • Swift Tools 6.0.0
View More Packages from this Author

Dependencies

Last updated: Fri Oct 31 2025 03:40:37 GMT-0900 (Hawaii-Aleutian Daylight Time)