MaxGekk commented on code in PR #48499:
URL: https://github.com/apache/spark/pull/48499#discussion_r1803826795


##########
python/pyspark/sql/functions/builtin.py:
##########
@@ -7248,6 +7248,41 @@ def log2(col: "ColumnOrName") -> Column:
     return _invoke_function_over_columns("log2", col)
 
 
+@_try_remote_functions
+def try_conv(col: "ColumnOrName", fromBase: int, toBase: int) -> Column:
+    """
+    This is a special version of `conv` that performs the same operation, but 
returns a
+    NULL value instead of raising an error if the decoding cannot be performed.
+
+    .. versionadded:: 4.0.0
+
+    Parameters
+    ----------
+    col : :class:`~pyspark.sql.Column` or str
+        a column to convert base for.
+    fromBase: int
+        from base number.
+    toBase: int
+        to base number.
+
+    Returns
+    -------
+    :class:`~pyspark.sql.Column`
+        logariphm of given value.
+
+    Examples
+    --------
+    >>> df = spark.createDataFrame([("010101",)], ['n'])
+    >>> df.select(try_conv(df.n, 2, 16).alias('hex')).collect()
+    [Row(hex='15')]

Review Comment:
   can you show an example of NULL result?



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