You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "dongjoon-hyun (via GitHub)" <gi...@apache.org> on 2026/09/14 03:58:26 UTC

[PR] [SPARK-59484] Use `value` as the output column name of `DataFrame.toJSON` [spark-connect-swift]

dongjoon-hyun opened a new pull request, #565:
URL: https://github.com/apache/spark-connect-swift/pull/565

   ### What changes were proposed in this pull request?
   
   This PR aims to make `DataFrame.toJSON()` return a single column named `value`, like the Scala Spark Connect client.
   
   ```swift
   -    return selectExpr("to_json(struct(*))")
   +    return selectExpr("to_json(struct(*)) AS value")
   ```
   
   ### Why are the changes needed?
   
   The Scala Spark Connect client names the `toJSON` output column `value`.
   
   - [Apache Spark 4.2.0 (2026-07-11) `Dataset.toJSON`](https://github.com/apache/spark/blob/v4.2.0/sql/connect/common/src/main/scala/org/apache/spark/sql/connect/Dataset.scala#L1277-L1279)
   
   ```scala
   def toJSON: Dataset[String] = {
     select(to_json(struct(col("*"))).as("value")).as(StringEncoder)
   }
   ```
   
   The Swift client currently names the column after the expression, such as `to_json(struct(id))`. So the column name depends on the input schema, and code ported from Scala that refers to `value` fails.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. The output column is renamed from `to_json(struct(...))` to `value`, matching the Scala Spark Connect client. The JSON content is unchanged.
   
   **BEFORE**
   
   ```swift
   try await spark.range(2).toJSON().columns  // ["to_json(struct(id))"]
   ```
   
   **AFTER**
   
   ```swift
   try await spark.range(2).toJSON().columns  // ["value"]
   try await spark.range(2).toJSON().schema   // value STRING (nullable)
   ```
   
   ### How was this patch tested?
   
   Pass the CIs with the updated test case. It checks the column name, the schema (`value STRING`, nullable), unchanged JSON content, a multi-column DataFrame, and a nested struct column.
   
   I also tested manually with an Apache Spark 4.2.0 Spark Connect server.
   
   ```
   $ swift test --no-parallel --filter DataFrameTests
   ...
   Test run with 152 tests in 2 suites passed after 22.965 seconds.
   ```
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Opus 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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-59484] Use `value` as the output column name of `DataFrame.toJSON` [spark-connect-swift]

Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun closed pull request #565: [SPARK-59484] Use `value` as the output column name of `DataFrame.toJSON`
URL: https://github.com/apache/spark-connect-swift/pull/565


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-59484] Use `value` as the output column name of `DataFrame.toJSON` [spark-connect-swift]

Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #565:
URL: https://github.com/apache/spark-connect-swift/pull/565#issuecomment-5660030542

   Thank you, @viirya ~


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-59484] Use `value` as the output column name of `DataFrame.toJSON` [spark-connect-swift]

Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #565:
URL: https://github.com/apache/spark-connect-swift/pull/565#issuecomment-5660037100

   Merged to main


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org