Skip to content

Commit 80fbc38

Browse files
committed
Revert "[SPARK-29462] The data type of "array()" should be array<null>"
This reverts commit 0dcd739.
1 parent eb79af8 commit 80fbc38

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

docs/sql-migration-guide.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,6 @@ license: |
217217
For example `SELECT timestamp 'tomorrow';`.
218218

219219
- Since Spark 3.0, the `size` function returns `NULL` for the `NULL` input. In Spark version 2.4 and earlier, this function gives `-1` for the same input. To restore the behavior before Spark 3.0, you can set `spark.sql.legacy.sizeOfNull` to `true`.
220-
221-
- Since Spark 3.0, when `array` function is called without parameters, it returns an empty array with `NullType` data type. In Spark version 2.4 and earlier, the data type of the result is `StringType`.
222220

223221
- Since Spark 3.0, the interval literal syntax does not allow multiple from-to units anymore. For example, `SELECT INTERVAL '1-1' YEAR TO MONTH '2-2' YEAR TO MONTH'` throws parser exception.
224222

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypeCreator.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ case class CreateArray(children: Seq[Expression]) extends Expression {
4747
override def dataType: ArrayType = {
4848
ArrayType(
4949
TypeCoercion.findCommonTypeDifferentOnlyInNullFlags(children.map(_.dataType))
50-
.getOrElse(NullType),
50+
.getOrElse(StringType),
5151
containsNull = children.exists(_.nullable))
5252
}
5353

sql/core/src/test/scala/org/apache/spark/sql/DataFrameFunctionsSuite.scala

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3400,9 +3400,12 @@ class DataFrameFunctionsSuite extends QueryTest with SharedSparkSession {
34003400
).foreach(assertValuesDoNotChangeAfterCoalesceOrUnion(_))
34013401
}
34023402

3403-
test("SPARK-21281 use string types by default if map have no argument") {
3403+
test("SPARK-21281 use string types by default if array and map have no argument") {
34043404
val ds = spark.range(1)
34053405
var expectedSchema = new StructType()
3406+
.add("x", ArrayType(StringType, containsNull = false), nullable = false)
3407+
assert(ds.select(array().as("x")).schema == expectedSchema)
3408+
expectedSchema = new StructType()
34063409
.add("x", MapType(StringType, StringType, valueContainsNull = false), nullable = false)
34073410
assert(ds.select(map().as("x")).schema == expectedSchema)
34083411
}
@@ -3460,13 +3463,6 @@ class DataFrameFunctionsSuite extends QueryTest with SharedSparkSession {
34603463
checkAnswer(df.select("x").filter("exists(i, x -> x % d == 0)"),
34613464
Seq(Row(1)))
34623465
}
3463-
3464-
test("SPARK-29462: Use null type by default if array have no argument") {
3465-
val ds = spark.range(1)
3466-
var expectedSchema = new StructType()
3467-
.add("x", ArrayType(NullType, containsNull = false), nullable = false)
3468-
assert(ds.select(array().as("x")).schema == expectedSchema)
3469-
}
34703466
}
34713467

34723468
object DataFrameFunctionsSuite {

0 commit comments

Comments
 (0)