Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2154,8 +2154,8 @@ object SQLConf {

val LEGACY_SIZE_OF_NULL = buildConf("spark.sql.legacy.sizeOfNull")
.internal()
.doc("If it is set to true, size of null returns -1. This behavior was inherited from Hive. " +
"The size function returns null for null input if the flag is disabled.")
.doc(s"If it is set to false, or ${ANSI_ENABLED.key} is true, then size of null returns " +
"null. Otherwise, it returns -1, which was inherited from Hive.")
.version("2.4.0")
.booleanConf
.createWithDefault(true)
Expand Down Expand Up @@ -3014,7 +3014,10 @@ class SQLConf extends Serializable with Logging {

def csvColumnPruning: Boolean = getConf(SQLConf.CSV_PARSER_COLUMN_PRUNING)

def legacySizeOfNull: Boolean = getConf(SQLConf.LEGACY_SIZE_OF_NULL)
def legacySizeOfNull: Boolean = {
// size(null) should return null under ansi mode.
getConf(SQLConf.LEGACY_SIZE_OF_NULL) && !getConf(ANSI_ENABLED)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, ansi conf overrides legacy conf ? Do we have another legacy conf like this? Is it consistent with the other legacy? Could you update the migration guide and conf document to be consistent, too?

cc @gatorsmile

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the first one, and I don't think we need a migration guide as the behavior doesn't change by default.

I'll update the config doc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

}

def isReplEagerEvalEnabled: Boolean = getConf(SQLConf.REPL_EAGER_EVAL_ENABLED)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ class CollectionExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper
withSQLConf(SQLConf.LEGACY_SIZE_OF_NULL.key -> "false") {
testSize(sizeOfNull = null)
}
// size(null) should return null under ansi mode.
withSQLConf(
SQLConf.LEGACY_SIZE_OF_NULL.key -> "true",
SQLConf.ANSI_ENABLED.key -> "true") {
testSize(sizeOfNull = null)
}
}

test("MapKeys/MapValues") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,12 @@ class DataFrameFunctionsSuite extends QueryTest with SharedSparkSession {
withSQLConf(SQLConf.LEGACY_SIZE_OF_NULL.key -> "false") {
testSizeOfArray(sizeOfNull = null)
}
// size(null) should return null under ansi mode.
withSQLConf(
SQLConf.LEGACY_SIZE_OF_NULL.key -> "true",
SQLConf.ANSI_ENABLED.key -> "true") {
testSizeOfArray(sizeOfNull = null)
}
}

test("dataframe arrays_zip function") {
Expand Down Expand Up @@ -569,6 +575,12 @@ class DataFrameFunctionsSuite extends QueryTest with SharedSparkSession {
withSQLConf(SQLConf.LEGACY_SIZE_OF_NULL.key -> "false") {
testSizeOfMap(sizeOfNull = null)
}
// size(null) should return null under ansi mode.
withSQLConf(
SQLConf.LEGACY_SIZE_OF_NULL.key -> "true",
SQLConf.ANSI_ENABLED.key -> "true") {
testSizeOfMap(sizeOfNull = null)
}
}

test("map_keys/map_values function") {
Expand Down