You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by do...@apache.org on 2025/05/22 21:34:06 UTC

(spark-connect-swift) branch main updated: [SPARK-52268] Add `variant` SQL test and answer file

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

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


The following commit(s) were added to refs/heads/main by this push:
     new 09b42e3  [SPARK-52268] Add `variant` SQL test and answer file
09b42e3 is described below

commit 09b42e39bacd25797d40eb96d48576d736ba5b0b
Author: Dongjoon Hyun <do...@apache.org>
AuthorDate: Thu May 22 14:33:57 2025 -0700

    [SPARK-52268] Add `variant` SQL test and answer file
    
    ### What changes were proposed in this pull request?
    
    This PR aims to add `variant` (SPARK-45891) SQL test and answer file with `parse_json` and `variant_get` methods.
    
    ### Why are the changes needed?
    
    To add a test coverage for Spark 4 feature.
    
    Note that this PR doesn't aim to cover `collect` with the serialization.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Pass the CIs.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    No.
    
    Closes #167 from dongjoon-hyun/SPARK-52268.
    
    Authored-by: Dongjoon Hyun <do...@apache.org>
    Signed-off-by: Dongjoon Hyun <do...@apache.org>
---
 Tests/SparkConnectTests/Resources/queries/variant.sql        | 5 +++++
 Tests/SparkConnectTests/Resources/queries/variant.sql.answer | 5 +++++
 Tests/SparkConnectTests/SQLTests.swift                       | 1 +
 3 files changed, 11 insertions(+)

diff --git a/Tests/SparkConnectTests/Resources/queries/variant.sql b/Tests/SparkConnectTests/Resources/queries/variant.sql
new file mode 100644
index 0000000..ae81f1e
--- /dev/null
+++ b/Tests/SparkConnectTests/Resources/queries/variant.sql
@@ -0,0 +1,5 @@
+FROM VALUES parse_json('{"a": true, "b": 1, "c": "swift"}') T(v)
+|> SELECT v,
+          variant_get(v, '$.a', 'boolean') as a,
+          variant_get(v, '$.b', 'int') as b,
+          variant_get(v, '$.c', 'string') as c
diff --git a/Tests/SparkConnectTests/Resources/queries/variant.sql.answer b/Tests/SparkConnectTests/Resources/queries/variant.sql.answer
new file mode 100644
index 0000000..c50602e
--- /dev/null
+++ b/Tests/SparkConnectTests/Resources/queries/variant.sql.answer
@@ -0,0 +1,5 @@
++----------------------------+----+---+-----+
+|                           v|   a|  b|    c|
++----------------------------+----+---+-----+
+|{"a":true,"b":1,"c":"swift"}|true|  1|swift|
++----------------------------+----+---+-----+
\ No newline at end of file
diff --git a/Tests/SparkConnectTests/SQLTests.swift b/Tests/SparkConnectTests/SQLTests.swift
index a9c6b71..1b9be5f 100644
--- a/Tests/SparkConnectTests/SQLTests.swift
+++ b/Tests/SparkConnectTests/SQLTests.swift
@@ -85,6 +85,7 @@ struct SQLTests {
     "create_table_function.sql",
     "pipesyntax.sql",
     "explain.sql",
+    "variant.sql",
   ]
 
 #if !os(Linux)


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