This is an automated email from the ASF dual-hosted git repository.
ruifengz 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 65fcb011b6f [SPARK-41473][CONNECT][PYTHON] Implement `format_number`
function
65fcb011b6f is described below
commit 65fcb011b6fa6b0072d37baf7d8dedd05615c5bd
Author: Ruifeng Zheng <[email protected]>
AuthorDate: Tue Dec 27 14:16:16 2022 +0800
[SPARK-41473][CONNECT][PYTHON] Implement `format_number` function
### What changes were proposed in this pull request?
Implement `format_number` function
### Why are the changes needed?
for API coverage
### Does this PR introduce _any_ user-facing change?
yes
### How was this patch tested?
added UT
Closes #39229 from zhengruifeng/connect_function_format_number.
Authored-by: Ruifeng Zheng <[email protected]>
Signed-off-by: Ruifeng Zheng <[email protected]>
---
python/pyspark/sql/connect/functions.py | 10 +++++-----
.../pyspark/sql/tests/connect/test_connect_function.py | 16 ++++++++--------
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/python/pyspark/sql/connect/functions.py
b/python/pyspark/sql/connect/functions.py
index 0ed3629751d..c35ca531540 100644
--- a/python/pyspark/sql/connect/functions.py
+++ b/python/pyspark/sql/connect/functions.py
@@ -1641,11 +1641,11 @@ def encode(col: "ColumnOrName", charset: str) -> Column:
encode.__doc__ = pysparkfuncs.encode.__doc__
-# TODO(SPARK-41473): Resolve the data type mismatch issue and enable the
function
-# def format_number(col: "ColumnOrName", d: int) -> Column:
-# return _invoke_function("format_number", _to_col(col), lit(d))
-#
-# format_number.__doc__ = pysparkfuncs.format_number.__doc__
+def format_number(col: "ColumnOrName", d: int) -> Column:
+ return _invoke_function("format_number", _to_col(col), lit(d))
+
+
+format_number.__doc__ = pysparkfuncs.format_number.__doc__
def format_string(format: str, *cols: "ColumnOrName") -> Column:
diff --git a/python/pyspark/sql/tests/connect/test_connect_function.py
b/python/pyspark/sql/tests/connect/test_connect_function.py
index 40d8c924f60..c3ff22cb1e1 100644
--- a/python/pyspark/sql/tests/connect/test_connect_function.py
+++ b/python/pyspark/sql/tests/connect/test_connect_function.py
@@ -1629,14 +1629,14 @@ class
SparkConnectFunctionTests(SparkConnectFuncTestCase):
cdf = self.connect.sql(query)
sdf = self.spark.sql(query)
- # TODO(SPARK-41473): Resolve the data type mismatch issue and enable
the
- # Disable the test because:
- # Cannot resolve "format_number(a, 2)" due to data type mismatch:
- # Parameter 2 requires the ("INT" or "STRING") type, however "2" has
the type "BIGINT"
- # self.assert_eq(
- # cdf.select(CF.format_number(cdf.a, 2)).toPandas(),
- # sdf.select(SF.format_number(sdf.a, 2)).toPandas(),
- # )
+ self.assert_eq(
+ cdf.select(CF.format_number(cdf.a, 2)).toPandas(),
+ sdf.select(SF.format_number(sdf.a, 2)).toPandas(),
+ )
+ self.assert_eq(
+ cdf.select(CF.format_number("a", 5)).toPandas(),
+ sdf.select(SF.format_number("a", 5)).toPandas(),
+ )
self.assert_eq(
cdf.select(CF.concat_ws("-", cdf.b, "c")).toPandas(),
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]