Skip to content

Commit 39a6f51

Browse files
gatorsmiledongjoon-hyun
authored andcommitted
[SPARK-29554][SQL][FOLLOWUP] Update Auto-generated Alias Name for Version
### What changes were proposed in this pull request? The auto-generated alias name of built-in function `version()` is `sparkversion()`. After this PR, it is updated to `version()`. ### Why are the changes needed? Based on our auto-generated alias name convention for the built-in functions, the alias names should be consistent with the function names. This built-in function `version` is added in the upcoming Spark 3.0. Thus, we should fix it before the release. ### Does this PR introduce any user-facing change? Yes. Update the column name in schema if users do not specify the alias. ### How was this patch tested? Added a test case. Closes apache#28131 from gatorsmile/spark-29554followup. Authored-by: gatorsmile <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent 9f58f03 commit 39a6f51

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ case class SparkVersion() extends LeafExpression with CodegenFallback {
173173
override def nullable: Boolean = false
174174
override def foldable: Boolean = true
175175
override def dataType: DataType = StringType
176+
override def prettyName: String = "version"
176177
override def eval(input: InternalRow): Any = {
177178
UTF8String.fromString(SPARK_VERSION_SHORT + " " + SPARK_REVISION)
178179
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ class MiscFunctionsSuite extends QueryTest with SharedSparkSession {
3434
}
3535

3636
test("version") {
37+
val df = sql("SELECT version()")
3738
checkAnswer(
38-
Seq("").toDF("a").selectExpr("version()"),
39+
df,
3940
Row(SPARK_VERSION_SHORT + " " + SPARK_REVISION))
41+
assert(df.schema.fieldNames === Seq("version()"))
4042
}
4143
}
4244

0 commit comments

Comments
 (0)