-
- Downloads
[SPARK-14402][SQL] initcap UDF doesn't match Hive/Oracle behavior in lowercasing rest of string
## What changes were proposed in this pull request? Current, SparkSQL `initCap` is using `toTitleCase` function. However, `UTF8String.toTitleCase` implementation changes only the first letter and just copy the other letters: e.g. sParK --> SParK. This is the correct implementation `toTitleCase`. ``` hive> select initcap('sParK'); Spark ``` ``` scala> sql("select initcap('sParK')").head res0: org.apache.spark.sql.Row = [SParK] ``` This PR updates the implementation of `initcap` using `toLowerCase` and `toTitleCase`. ## How was this patch tested? Pass the Jenkins tests (including new testcase). Author: Dongjoon Hyun <dongjoon@apache.org> Closes #12175 from dongjoon-hyun/SPARK-14402.
Showing
- sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala 8 additions, 3 deletions...he/spark/sql/catalyst/expressions/stringExpressions.scala
- sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/StringExpressionsSuite.scala 1 addition, 0 deletions...ark/sql/catalyst/expressions/StringExpressionsSuite.scala
- sql/core/src/test/scala/org/apache/spark/sql/StringFunctionsSuite.scala 3 additions, 3 deletions...est/scala/org/apache/spark/sql/StringFunctionsSuite.scala
Please register or sign in to comment