zhengruifeng opened a new pull request, #42775:
URL: https://github.com/apache/spark/pull/42775

   ### What changes were proposed in this pull request?
   for SQL function aliases (with `setAlias=true`) added in 3.5, using replace 
expression construction with `call_function` to make the output column name 
consistent with SQL
   
   ### Why are the changes needed?
   before this PR
   
   ```
   scala> val df = spark.range(0, 10)
   df: org.apache.spark.sql.Dataset[Long] = [id: bigint]
   
   scala> df.createOrReplaceTempView("t")
   
   scala> spark.sql("SELECT TRY_SUM(id), TRY_AVG(id) FROM t")
   res1: org.apache.spark.sql.DataFrame = [try_sum(id): bigint, try_avg(id): 
double]
   
   scala> df.select(try_sum(col("id")), try_avg(col("id")))
   res2: org.apache.spark.sql.DataFrame = [sum(id): bigint, avg(id): double]
   
   scala> 
   
   scala> spark.sql("SELECT sign(-1), signum(-1)")
   res3: org.apache.spark.sql.DataFrame = [sign(-1): double, SIGNUM(-1): double]
   
   scala> spark.range(1).select(sign(lit(-1)), signum(lit(-1)))
   res4: org.apache.spark.sql.DataFrame = [SIGNUM(-1): double, SIGNUM(-1): 
double]
   ```
   
   
   
   after this PR
   
   ```
   scala> spark.sql("SELECT TRY_SUM(id), TRY_AVG(id) FROM t")
   res9: org.apache.spark.sql.DataFrame = [try_sum(id): bigint, try_avg(id): 
double]
   
   scala> df.select(try_sum(col("id")), try_avg(col("id")))
   res10: org.apache.spark.sql.DataFrame = [try_sum(id): bigint, try_avg(id): 
double]
   
   scala> 
   
   scala> spark.sql("SELECT sign(-1), signum(-1)")
   res11: org.apache.spark.sql.DataFrame = [sign(-1): double, SIGNUM(-1): 
double]
   
   scala> spark.range(1).select(sign(lit(-1)), signum(lit(-1)))
   res12: org.apache.spark.sql.DataFrame = [sign(-1): double, SIGNUM(-1): 
double]
   ```
   
   
   
   ### Does this PR introduce _any_ user-facing change?
   yes
   
   
   ### How was this patch tested?
   updated UT
   
   ### Was this patch authored or co-authored using generative AI tooling?
   no
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to