You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "beliefer (via GitHub)" <gi...@apache.org> on 2023/06/19 12:24:05 UTC

[GitHub] [spark] beliefer commented on a diff in pull request #41659: [SPARK-43944][SQL][CONNECT][PYTHON][FOLLOW-UP] Make `startswith` & `endswith` support binary type

beliefer commented on code in PR #41659:
URL: https://github.com/apache/spark/pull/41659#discussion_r1233981865


##########
connector/connect/client/jvm/src/main/scala/org/apache/spark/sql/functions.scala:
##########
@@ -3947,10 +3947,6 @@ object functions {
    * Returns a boolean. The value is True if str ends with suffix. Returns NULL if either input
    * expression is NULL. Otherwise, returns False. Both str or suffix must be of STRING type.

Review Comment:
   The comment need update now.



##########
sql/core/src/main/scala/org/apache/spark/sql/functions.scala:
##########
@@ -4048,31 +4048,27 @@ object functions {
    * Returns NULL if either input expression is NULL. Otherwise, returns False.
    * Both str or suffix must be of STRING type.
    *
-   * @note
-   *   Only STRING type is supported in this function, while `endswith` in SQL supports both
-   *   STRING and BINARY.
-   *
    * @group string_funcs
    * @since 3.5.0
    */
-  def endswith(str: Column, suffix: Column): Column = withExpr {
-    EndsWith(str.expr, suffix.expr)
+  def endswith(str: Column, suffix: Column): Column = {
+    // 'EndsWith' expression only supports StringType,
+    // use 'call_udf' to support both StringType and BinaryType.
+    call_udf("endswith", str, suffix)

Review Comment:
   I see the usage for call_udf.



##########
sql/core/src/main/scala/org/apache/spark/sql/functions.scala:
##########
@@ -4048,31 +4048,27 @@ object functions {
    * Returns NULL if either input expression is NULL. Otherwise, returns False.
    * Both str or suffix must be of STRING type.

Review Comment:
   ditto.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org