HyukjinKwon commented on code in PR #57079:
URL: https://github.com/apache/spark/pull/57079#discussion_r3550697174


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/numberFormatExpressions.scala:
##########
@@ -223,6 +237,13 @@ case class TryToNumber(left: Expression, right: Expression)
         'hex': a string in the hexadecimal format.
         'utf-8': the input binary is decoded to UTF-8 string.
   """,
+  arguments = """
+    Arguments:
+      * expr - The expression to convert to a string.
+        An expression that evaluates to a numeric, datetime, or binary.

Review Comment:
   `to_char`/`to_varchar` accept datetime and binary as well as numeric — 
`ToCharacterBuilder.build` dispatches `DatetimeType` to `DateFormatClass` and 
`BinaryType` to `Base64`/`Hex`/`Decode`. The examples below use 
`date'2016-04-08'` and `x'537061726b2053514c'`, so "decimal" is too narrow.
   ```suggestion
           An expression that evaluates to a numeric, datetime, or binary.
   ```



##########
python/pyspark/sql/functions/builtin.py:
##########
@@ -17310,8 +17799,10 @@ def to_char(col: "ColumnOrName", format: 
"ColumnOrName") -> Column:
     ----------
     col : :class:`~pyspark.sql.Column` or str
         Input column or strings.
+        A column that evaluates to a numeric, datetime, or binary.

Review Comment:
   Same as the Scala side: `to_char` accepts numeric, datetime, or binary (the 
docstring itself says "If `col` is a datetime ..." and "If `col` is a binary 
...").
   ```suggestion
           A column that evaluates to a numeric, datetime, or binary.
   ```



##########
python/pyspark/sql/functions/builtin.py:
##########
@@ -17356,8 +17847,10 @@ def to_varchar(col: "ColumnOrName", format: 
"ColumnOrName") -> Column:
     ----------
     col : :class:`~pyspark.sql.Column` or str
         Input column or strings.
+        A column that evaluates to a numeric, datetime, or binary.

Review Comment:
   Same as `to_char`: `to_varchar` accepts numeric, datetime, or binary.
   ```suggestion
           A column that evaluates to a numeric, datetime, or binary.
   ```



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/TryEval.scala:
##########
@@ -58,6 +58,13 @@ case class TryEval(child: Expression) extends 
UnaryExpression {
 @ExpressionDescription(
   usage = "_FUNC_(expr1, expr2) - Returns the sum of `expr1`and `expr2` and 
the result is null on overflow. " +
     "The acceptable input types are the same with the `+` operator.",
+  arguments = """
+    Arguments:
+      * expr1 - The first addend.
+        An expression that evaluates to a numeric or interval.

Review Comment:
   `try_add` also accepts date/timestamp operands (date arithmetic) — the 
examples below use `try_add(date'2021-01-01', 1)` and 
`try_add(date'2021-01-01', interval 1 year)`. Non-blocking, but "numeric or 
interval" omits the date/timestamp case the examples show. Same on `expr2` (66).
   ```suggestion
           An expression that evaluates to a numeric, date, timestamp, or 
interval.
   ```



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/TryEval.scala:
##########
@@ -177,6 +198,13 @@ case class TryMod(left: Expression, right: Expression, 
replacement: Expression)
 @ExpressionDescription(
   usage = "_FUNC_(expr1, expr2) - Returns `expr1`-`expr2` and the result is 
null on overflow. " +
     "The acceptable input types are the same with the `-` operator.",
+  arguments = """
+    Arguments:
+      * expr1 - The minuend to subtract from.
+        An expression that evaluates to a numeric or interval.

Review Comment:
   Same as `try_add`: `try_subtract` accepts date/timestamp operands too. Same 
on `expr2` (206).
   ```suggestion
           An expression that evaluates to a numeric, date, timestamp, or 
interval.
   ```



##########
python/pyspark/sql/functions/builtin.py:
##########
@@ -867,7 +878,9 @@ def try_subtract(left: "ColumnOrName", right: 
"ColumnOrName") -> Column:
     Parameters
     ----------
     left : :class:`~pyspark.sql.Column` or column name
+        A column that evaluates to a numeric or interval.

Review Comment:
   Same: `try_subtract`'s example uses a date operand.
   ```suggestion
           A column that evaluates to a numeric, date, timestamp, or interval.
   ```



##########
python/pyspark/sql/functions/builtin.py:
##########
@@ -553,7 +555,9 @@ def try_add(left: "ColumnOrName", right: "ColumnOrName") -> 
Column:
     Parameters
     ----------
     left : :class:`~pyspark.sql.Column` or column name
+        A column that evaluates to a numeric or interval.

Review Comment:
   Same as the Scala side: the example uses `try_add("date", sf.lit(1))`, so 
date/timestamp operands should be reflected here. Non-blocking.
   ```suggestion
           A column that evaluates to a numeric, date, timestamp, or interval.
   ```



-- 
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