diff --git a/.github/.licenserc.yaml b/.github/.licenserc.yaml index 0fb34a3..2ab49a4 100644 --- a/.github/.licenserc.yaml +++ b/.github/.licenserc.yaml @@ -14,5 +14,6 @@ header: - 'NOTICE' - '.asf.yaml' - '.nojekyll' + - 'Package.swift' comment: on-failure diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 169bc39..1cfdfbf 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -38,3 +38,19 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: config: .github/.licenserc.yaml + + build: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + - macos-15 + steps: + - uses: actions/checkout@v4 + - uses: swift-actions/setup-swift@v2.2.0 + with: + swift-version: "6" + - name: Build + run: swift build -v diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5ed8585 --- /dev/null +++ b/.gitignore @@ -0,0 +1,66 @@ +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## Swift Package Manager +Package.resolved +.swiftpm/ + +## User settings +xcuserdata/ + +## Obj-C/Swift specific +*.hmap + +## App packaging +*.ipa +*.dSYM.zip +*.dSYM + +## Playgrounds +timeline.xctimeline +playground.xcworkspace + +# Swift Package Manager +# +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +# Package.pins +# Package.resolved +# *.xcodeproj +# +# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata +# hence it is not needed unless you have added a package configuration file to your project +# .swiftpm + +.build/ + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# Pods/ +# +# Add this line if you want to avoid checking in source code from the Xcode workspace +# *.xcworkspace + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build/ + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. +# Instead, use fastlane to re-generate the screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/#source-control + +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots/**/*.png +fastlane/test_output diff --git a/LICENSE b/LICENSE index 9b1e96a..261eeb9 100644 --- a/LICENSE +++ b/LICENSE @@ -199,68 +199,3 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - - ------------------------------------------------------------------------------------- -This product bundles various third-party components under other open source licenses. -This section summarizes those components and their licenses. See licenses/ -for text of these licenses. - - -Apache Software Foundation License 2.0 --------------------------------------- - -common/network-common/src/main/java/org/apache/spark/network/util/LimitedInputStream.java -core/src/main/java/org/apache/spark/util/collection/TimSort.java -core/src/main/resources/org/apache/spark/ui/static/bootstrap* -core/src/main/resources/org/apache/spark/ui/static/vis* -connector/spark-ganglia-lgpl/src/main/java/com/codahale/metrics/ganglia/GangliaReporter.java -core/src/main/resources/org/apache/spark/ui/static/d3-flamegraph.min.js -core/src/main/resources/org/apache/spark/ui/static/d3-flamegraph.css - -Python Software Foundation License ----------------------------------- - -python/pyspark/loose_version.py - -BSD 3-Clause ------------- - -python/lib/py4j-*-src.zip -python/pyspark/cloudpickle/*.py -python/pyspark/join.py - -The CSS style for the navigation sidebar of the documentation was originally -submitted by Óscar Nájera for the scikit-learn project. The scikit-learn project -is distributed under the 3-Clause BSD license. - - -MIT License ------------ - -core/src/main/resources/org/apache/spark/ui/static/dagre-d3.min.js -core/src/main/resources/org/apache/spark/ui/static/*dataTables* -core/src/main/resources/org/apache/spark/ui/static/graphlib-dot.min.js -core/src/main/resources/org/apache/spark/ui/static/jquery* -core/src/main/resources/org/apache/spark/ui/static/sorttable.js -docs/js/vendor/bootstrap* -docs/js/vendor/anchor.min.js -docs/js/vendor/jquery* -docs/js/vendor/modernizer* -docs/js/vendor/docsearch.min.js - -ISC License ------------ - -core/src/main/resources/org/apache/spark/ui/static/d3.min.js - - -Creative Commons CC0 1.0 Universal Public Domain Dedication ------------------------------------------------------------ -(see LICENSE-CC0.txt) - -data/mllib/images/kittens/29.5.a_b_EGDP022204.jpg -data/mllib/images/kittens/54893.jpg -data/mllib/images/kittens/DP153539.jpg -data/mllib/images/kittens/DP802813.jpg -data/mllib/images/multi-channel/chr30.4.184.jpg diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..b110e07 --- /dev/null +++ b/NOTICE @@ -0,0 +1,5 @@ +Apache Spark +Copyright 2014 and onwards The Apache Software Foundation. + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..58aa421 --- /dev/null +++ b/Package.swift @@ -0,0 +1,59 @@ +// swift-tools-version: 6.0 +// The swift-tools-version declares the minimum version of Swift required to build this package. +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +import PackageDescription + +let package = Package( + name: "SparkConnect", + platforms: [ + .macOS(.v15), + .iOS(.v18), + .watchOS(.v11), + .tvOS(.v18), + ], + products: [ + .library( + name: "SparkConnect", + targets: ["SparkConnect"]) + ], + dependencies: [ + .package(url: "https://github.com/grpc/grpc-swift.git", from: "2.1.0"), + .package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "1.1.0"), + .package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", from: "1.0.1"), + .package(url: "https://github.com/scottrhoyt/SwiftyTextTable.git", from: "0.9.0"), + .package(url: "https://github.com/google/flatbuffers.git", branch: "v24.3.7"), + ], + targets: [ + .target( + name: "SparkConnect", + dependencies: [ + .product(name: "GRPCCore", package: "grpc-swift"), + .product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"), + .product(name: "GRPCNIOTransportHTTP2", package: "grpc-swift-nio-transport"), + .product(name: "SwiftyTextTable", package: "SwiftyTextTable"), + .product(name: "FlatBuffers", package: "flatbuffers"), + ] + ), + .testTarget( + name: "SparkConnectTests", + dependencies: ["SparkConnect"] + ), + ] +) diff --git a/README.md b/README.md index 1e23370..f7cfb41 100644 --- a/README.md +++ b/README.md @@ -1 +1,15 @@ -# Apache Spark Connect Client for Swift language +# Apache Spark Connect Client for Swift + +[![GitHub Actions Build](https://github.com/apache/spark-connect-swift/actions/workflows/build_and_test.yml/badge.svg)](https://github.com/apache/spark-connect-swift/blob/main/.github/workflows/build_and_test.yml) + +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 like the [Apache Spark](https://spark.apache.org) 4.0.0 RC2 release and [Apache Arrow](https://arrow.apache.org) project's Swift-support. + +## Requirement +- [Apache Spark 4.0.0 RC2 (March 2025)](https://dist.apache.org/repos/dist/dev/spark/v4.0.0-rc2-bin/) +- [Swift 6.0 (2024)](https://swift.org) +- [gRPC Swift 2.1 (March 2025)](https://github.com/grpc/grpc-swift/releases/tag/2.1.0) +- [gRPC Swift Protobuf 1.0 (March 2025)](https://github.com/grpc/grpc-swift-protobuf/releases/tag/1.1.0) +- [gRPC Swift NIO Transport 1.0 (March 2025)](https://github.com/grpc/grpc-swift-nio-transport/releases/tag/1.0.1) +- [Apache Arrow Swift](https://github.com/apache/arrow/tree/main/swift) diff --git a/Sources/SparkConnect/SparkConnectError.swift b/Sources/SparkConnect/SparkConnectError.swift new file mode 100644 index 0000000..5dda8cf --- /dev/null +++ b/Sources/SparkConnect/SparkConnectError.swift @@ -0,0 +1,23 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +/// A enum for ``SparkConnect`` package errors +enum SparkConnectError: Error { + case UnsupportedOperationException +} diff --git a/Tests/SparkConnectTests/BuilderTests.swift b/Tests/SparkConnectTests/BuilderTests.swift new file mode 100644 index 0000000..f264525 --- /dev/null +++ b/Tests/SparkConnectTests/BuilderTests.swift @@ -0,0 +1,38 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +import Testing + +@testable import SparkConnect + +/// A test suite for `SparkSession.Builder` +@Suite(.serialized) +struct BuilderTests { + @Test + func builderDefault() async throws { + } + + @Test + func remote() async throws { + } + + @Test + func appName() async throws { + } +}