dongjoon-hyun opened a new pull request, #489:
URL: https://github.com/apache/spark-connect-swift/pull/489
### What changes were proposed in this pull request?
This PR adds `SparkSession.parseDDL` which parses a DDL-formatted schema
string into the public `StructType` model using the server-side parser.
```swift
let schema = try await spark.parseDDL("id BIGINT NOT NULL, name STRING")
// StructType(fields: [
// StructField(name: "id", dataType: .long, nullable: false),
// StructField(name: "name", dataType: .string),
// ])
```
Internally, it reuses the existing `AnalyzePlan` `ddlParse` round-trip
(already used by `createDataFrame` and `DataFrameReader.schema`) and converts
the returned protobuf `DataType` via the `StructType` initializer added in
SPARK-58647. A non-struct top-level type (e.g. `array<int>`) throws
`SparkConnectError.InvalidType`, and an invalid DDL string throws
`SparkConnectError.ParseSyntaxError` through the existing `ErrorInfo`-based
error conversion.
Note that this follows the PySpark Connect behavior where `DataType.fromDDL`
delegates to the server-side parser (`SparkSession._parse_ddl` via the
`ddl_parse` analyze method), instead of implementing a client-local SQL type
parser.
### Why are the changes needed?
For feature parity with Scala (`StructType.fromDDL`) and PySpark
(`DataType.fromDDL`), so users can obtain a traversable `StructType` from a DDL
string. This is the missing inverse of `StructType.toDDL` added in SPARK-58648.
### Does this PR introduce _any_ user-facing change?
No. This adds a new API without changing existing behavior.
### How was this patch tested?
Pass the CIs with the newly added test cases .
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Fable 5
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]