Skip to content

Commit 948840b

Browse files
zhengruifengHyukjinKwon
authored andcommitted
[MINOR][PYTHON][DOCS] Refine the docstring of VariantVal
### What changes were proposed in this pull request? Refine the docstring of `VariantVal` ### Why are the changes needed? avoid the wildcard import, which is not suggested ### Does this PR introduce _any_ user-facing change? doc-only change ### How was this patch tested? doctest ### Was this patch authored or co-authored using generative AI tooling? no Closes #50002 from zhengruifeng/py_doc_variantval. Authored-by: Ruifeng Zheng <[email protected]> Signed-off-by: Hyukjin Kwon <[email protected]>
1 parent cecafac commit 948840b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

python/pyspark/sql/types.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,11 +1730,13 @@ class VariantVal:
17301730
17311731
Examples
17321732
--------
1733-
>>> from pyspark.sql.functions import *
1733+
>>> from pyspark.sql import functions as sf
17341734
>>> df = spark.createDataFrame([ {'json': '''{ "a" : 1 }'''} ])
1735-
>>> v = df.select(parse_json(df.json).alias("var")).collect()[0].var
1735+
>>> v = df.select(sf.parse_json(df.json).alias("var")).head().var
17361736
>>> v.toPython()
17371737
{'a': 1}
1738+
>>> v.toJson()
1739+
'{"a":1}'
17381740
"""
17391741

17401742
def __init__(self, value: bytes, metadata: bytes):

0 commit comments

Comments
 (0)