GitHub user clockfly opened a pull request:
https://github.com/apache/spark/pull/13632
[SPARK-15910][SQL] Check schema consistency when using Kryo encoder to
convert DataFrame to Dataset
## What changes were proposed in this pull request?
This PR enforces schema check when converting DataFrame to Dataset using
Kryo encoder. For example.
**Before the change:**
Schema is NOT checked when converting DataFrame to Dataset using kryo
encoder.
```
scala> case class B(b: Int)
scala> implicit val encoder = Encoders.kryo[B]
scala> val df = Seq((1)).toDF("b")
scala> val ds = df.as[B] // Schema compatibility is NOT checked
```
**After the change:**
Report AnalysisException since the schema is NOT compatible.
```
scala> val ds = Seq((1)).toDF("b").as[B]
org.apache.spark.sql.AnalysisException: cannot resolve 'CAST(`b` AS
BINARY)' due to data type mismatch: cannot cast IntegerType to BinaryType;
...
```
## How was this patch tested?
Unit test.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/clockfly/spark spark-15910
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/13632.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 #13632
----
commit 50bb48d6f2a59e2e88fe68699fceac308153e08a
Author: Sean Zhong <[email protected]>
Date: 2016-06-13T04:01:57Z
SPARK-15910: Check schema
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]