This is an automated email from the ASF dual-hosted git repository.
maxgekk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 49da438ece8 [SPARK-44868][SQL][FOLLOWUP] Invoke the `to_varchar`
function in Scala API
49da438ece8 is described below
commit 49da438ece84391db22f9c56e747d555d9b01969
Author: Max Gekk <[email protected]>
AuthorDate: Mon Aug 28 20:57:27 2023 +0300
[SPARK-44868][SQL][FOLLOWUP] Invoke the `to_varchar` function in Scala API
### What changes were proposed in this pull request?
In the PR, I propose to invoke the `to_varchar` function instead of
`to_char` in `to_varchar` of Scala/Java API.
### Why are the changes needed?
1. To show correct function name in error messages and in `explain`.
2. To be consistent to other API: PySpark and the previous Spark SQL
version 3.5.0.
### Does this PR introduce _any_ user-facing change?
Yes.
### How was this patch tested?
By running the modified test:
```
$ build/sbt "test:testOnly *.StringFunctionsSuite"
```
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes #42703 from MaxGekk/fix-to_varchar-call.
Authored-by: Max Gekk <[email protected]>
Signed-off-by: Max Gekk <[email protected]>
---
sql/core/src/main/scala/org/apache/spark/sql/functions.scala | 2 +-
.../src/test/scala/org/apache/spark/sql/StringFunctionsSuite.scala | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/functions.scala
b/sql/core/src/main/scala/org/apache/spark/sql/functions.scala
index f6699b66af9..6b474c84cdb 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/functions.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/functions.scala
@@ -4431,7 +4431,7 @@ object functions {
* @group string_funcs
* @since 3.5.0
*/
- def to_varchar(e: Column, format: Column): Column = to_char(e, format)
+ def to_varchar(e: Column, format: Column): Column =
call_function("to_varchar", e, format)
/**
* Convert string 'e' to a number based on the string format 'format'.
diff --git
a/sql/core/src/test/scala/org/apache/spark/sql/StringFunctionsSuite.scala
b/sql/core/src/test/scala/org/apache/spark/sql/StringFunctionsSuite.scala
index 12881f4a22a..03b9053c71a 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/StringFunctionsSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/StringFunctionsSuite.scala
@@ -878,7 +878,7 @@ class StringFunctionsSuite extends QueryTest with
SharedSparkSession {
errorClass = "_LEGACY_ERROR_TEMP_1100",
parameters = Map(
"argName" -> "format",
- "funcName" -> "to_char",
+ "funcName" -> funcName,
"requiredType" -> "string"))
checkError(
exception = intercept[AnalysisException] {
@@ -887,7 +887,7 @@ class StringFunctionsSuite extends QueryTest with
SharedSparkSession {
errorClass = "INVALID_PARAMETER_VALUE.BINARY_FORMAT",
parameters = Map(
"parameter" -> "`format`",
- "functionName" -> "`to_char`",
+ "functionName" -> s"`$funcName`",
"invalidFormat" -> "'invalid_format'"))
checkError(
exception = intercept[AnalysisException] {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]