This is an automated email from the ASF dual-hosted git repository.

dongjoon 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 1bd2a975ba8 [SPARK-46172][SQL][DOCS] Describe arguments of `encode()`
1bd2a975ba8 is described below

commit 1bd2a975ba86f80edbb377b18774075ab4c0d22d
Author: Max Gekk <max.g...@gmail.com>
AuthorDate: Wed Nov 29 12:49:59 2023 -0800

    [SPARK-46172][SQL][DOCS] Describe arguments of `encode()`
    
    ### What changes were proposed in this pull request?
    In the PR, I propose to update the description of the `Encode` expression 
and apparently the `encode()` function by describing the arguments `str` and 
`charset`. Also, renamed the parameter `value` to `str` according to the docs.
    
    #### The updated docs:
    <img width="724" alt="Screenshot 2023-11-29 at 12 04 17" 
src="https://github.com/apache/spark/assets/1580697/69339147-554b-412e-ae19-0f68991be40b";>
    
    ### Why are the changes needed?
    To improve user experience with Spark SQL by documenting the public 
function.
    
    ### Does this PR introduce _any_ user-facing change?
    No.
    
    ### How was this patch tested?
    By manually checking the generated docs.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    No.
    
    Closes #44078 from MaxGekk/doc-encode-params.
    
    Lead-authored-by: Max Gekk <max.g...@gmail.com>
    Co-authored-by: Maxim Gekk <max.g...@gmail.com>
    Signed-off-by: Dongjoon Hyun <dh...@apple.com>
---
 .../sql/catalyst/expressions/stringExpressions.scala    | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala
 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala
index 90cfd13875d..412422f4da4 100755
--- 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala
+++ 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala
@@ -2670,13 +2670,16 @@ case class StringDecode(bin: Expression, charset: 
Expression)
 }
 
 /**
- * Encodes the first argument into a BINARY using the provided character set
- * (one of 'US-ASCII', 'ISO-8859-1', 'UTF-8', 'UTF-16BE', 'UTF-16LE', 
'UTF-16').
- * If either argument is null, the result will also be null.
+ * Encode the given string to a binary using the provided charset.
  */
 // scalastyle:off line.size.limit
 @ExpressionDescription(
-  usage = "_FUNC_(str, charset) - Encodes the first argument using the second 
argument character set.",
+  usage = "_FUNC_(str, charset) - Encodes the first argument using the second 
argument character set. If either argument is null, the result will also be 
null.",
+  arguments = """
+    Arguments:
+      * str - a string expression
+      * charset - one of the charsets 'US-ASCII', 'ISO-8859-1', 'UTF-8', 
'UTF-16BE', 'UTF-16LE', 'UTF-16' to encode `str` into a BINARY. It is case 
insensitive.
+  """,
   examples = """
     Examples:
       > SELECT _FUNC_('abc', 'utf-8');
@@ -2685,13 +2688,13 @@ case class StringDecode(bin: Expression, charset: 
Expression)
   since = "1.5.0",
   group = "string_funcs")
 // scalastyle:on line.size.limit
-case class Encode(value: Expression, charset: Expression, legacyCharsets: 
Boolean)
+case class Encode(str: Expression, charset: Expression, legacyCharsets: 
Boolean)
   extends BinaryExpression with ImplicitCastInputTypes with NullIntolerant {
 
   def this(value: Expression, charset: Expression) =
     this(value, charset, SQLConf.get.legacyJavaCharsets)
 
-  override def left: Expression = value
+  override def left: Expression = str
   override def right: Expression = charset
   override def dataType: DataType = BinaryType
   override def inputTypes: Seq[DataType] = Seq(StringType, StringType)
@@ -2732,7 +2735,7 @@ case class Encode(value: Expression, charset: Expression, 
legacyCharsets: Boolea
   }
 
   override protected def withNewChildrenInternal(
-    newLeft: Expression, newRight: Expression): Encode = copy(value = newLeft, 
charset = newRight)
+    newLeft: Expression, newRight: Expression): Encode = copy(str = newLeft, 
charset = newRight)
 }
 
 object Encode {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to