Github user liancheng commented on a diff in the pull request:
https://github.com/apache/spark/pull/15951#discussion_r89262935
--- Diff:
sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLSuite.scala
---
@@ -274,7 +274,7 @@ class DDLSuite extends QueryTest with SharedSQLContext
with BeforeAndAfterEach {
pathToPartitionedTable,
userSpecifiedSchema = Option("num int, str string"),
userSpecifiedPartitionCols = partitionCols,
- expectedSchema = new StructType().add("num",
IntegerType).add("str", StringType),
+ expectedSchema = new StructType().add("str",
StringType).add("num", IntegerType),
--- End diff --
I believe the original test case was incorrect. Although the schema check
passes, if you really read rows out of the Dataset, you'll hit an exception, as
shown in the following Spark shell session:
```scala
import org.apache.spark.sql.types._
val df0 = spark.range(10).select(
('id % 4) cast StringType as "part",
'id cast StringType as "data"
)
val path = "/tmp/part.parquet"
df0.write.mode("overwrite").partitionBy("part").parquet(path)
val df1 = spark.read.schema(
new StructType()
.add("part", StringType, nullable = true)
.add("data", StringType, nullable = true)
).parquet(path)
df1.printSchema()
// root
// |-- part: string (nullable = true)
// |-- data: string (nullable = true)
df1.show()
// 16/11/22 22:52:21 ERROR Executor: Exception in task 0.0 in stage 10.0
(TID 34)
// java.lang.NullPointerException
// at
org.apache.spark.sql.execution.vectorized.OnHeapColumnVector.getArrayLength(OnHeapColumnVector.java:375)
// at
org.apache.spark.sql.execution.vectorized.ColumnVector.getArray(ColumnVector.java:554)
// at
org.apache.spark.sql.execution.vectorized.ColumnVector.getByteArray(ColumnVector.java:576)
// [...]
```
---
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]