Skip to content

Commit

Permalink
[MINOR][PYTHON][DOCS] Refine the docstring of VariantVal
Browse files Browse the repository at this point in the history
### 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 <ruifengz@apache.org>
Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
  • Loading branch information
zhengruifeng authored and HyukjinKwon committed Feb 20, 2025
1 parent cecafac commit 948840b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions python/pyspark/sql/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1730,11 +1730,13 @@ class VariantVal:
Examples
--------
>>> from pyspark.sql.functions import *
>>> from pyspark.sql import functions as sf
>>> df = spark.createDataFrame([ {'json': '''{ "a" : 1 }'''} ])
>>> v = df.select(parse_json(df.json).alias("var")).collect()[0].var
>>> v = df.select(sf.parse_json(df.json).alias("var")).head().var
>>> v.toPython()
{'a': 1}
>>> v.toJson()
'{"a":1}'
"""

def __init__(self, value: bytes, metadata: bytes):
Expand Down

0 comments on commit 948840b

Please sign in to comment.