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


##########
python/pyspark/sql/functions/builtin.py:
##########
@@ -16308,6 +16308,53 @@ def try_parse_json(
     return _invoke_function("try_parse_json", _to_java_column(col))
 
 
+@_try_remote_functions
+def to_variant_object(
+    col: "ColumnOrName",
+) -> Column:
+    """
+    Converts a column containing nested inputs (array/map/struct) into a 
variants where maps and
+    structs are converted to variant objects which are unordered unlike SQL 
structs. Input maps can
+    only have string keys.
+
+    .. versionadded:: 4.0.0
+
+    Parameters
+    ----------
+    col : :class:`~pyspark.sql.Column` or str
+        a column with a nested schema or column name
+
+    Returns
+    -------
+    :class:`~pyspark.sql.Column`
+        a new column of VariantType.
+
+    Examples
+    --------
+    >>> from pyspark.sql.types import ArrayType, StructType, StructField, 
StringType, MapType
+    >>> from pyspark.sql.functions.builtin import to_variant_object

Review Comment:
   ```suggestion
       >>> from pyspark.sql import functions as sf
       >>> from pyspark.sql.types import ArrayType, StructType, StructField, 
StringType, MapType
   ```



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