GitHub user maropu opened a pull request:
https://github.com/apache/spark/pull/20176
[SPARK-22981][SQL] Fix incorrect results of Casting Struct to String
## What changes were proposed in this pull request?
This pr fixed the issue when casting structs into strings;
```
scala> val df = Seq(((1, "a"), 0), ((2, "b"), 0)).toDF("a", "b")
scala> df.write.saveAsTable("t")
scala> sql("SELECT CAST(a AS STRING) FROM t").show
+-------------------+
| a|
+-------------------+
|[0,1,1800000001,61]|
|[0,2,1800000001,62]|
+-------------------+
```
This pr modified the result into;
```
+------+
| a|
+------+
|[1, a]|
|[2, b]|
+------+
```
## How was this patch tested?
Added tests in `CastSuite`.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/maropu/spark SPARK-22981
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/20176.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #20176
----
commit 10285d0ee8ba037809a9d15409a5c5055cd5be84
Author: Takeshi Yamamuro <yamamuro@...>
Date: 2018-01-06T09:58:20Z
Cast structs to strings
----
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]