Skip to content

Commit b601a93

Browse files
committed
Fix comments
1 parent 3a7559b commit b601a93

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

python/pyspark/sql/functions.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2115,7 +2115,7 @@ def json_tuple(col, *fields):
21152115
def from_json(col, schema, options={}):
21162116
"""
21172117
Parses a column containing a JSON string into a :class:`MapType` with :class:`StringType`
2118-
as keys type, :class:`StructType` or :class:`ArrayType` of :class:`StructType`\\s with
2118+
as keys type, :class:`StructType` or :class:`ArrayType` with
21192119
the specified schema. Returns `null`, in the case of an unparseable string.
21202120
21212121
:param col: string column in json format
@@ -2141,6 +2141,11 @@ def from_json(col, schema, options={}):
21412141
>>> df = spark.createDataFrame(data, ("key", "value"))
21422142
>>> df.select(from_json(df.value, schema).alias("json")).collect()
21432143
[Row(json=[Row(a=1)])]
2144+
>>> data = [(1, '''[1, 2, 3]''')]
2145+
>>> schema = ArrayType(IntegerType())
2146+
>>> df = spark.createDataFrame(data, ("key", "value"))
2147+
>>> df.select(from_json(df.value, schema).alias("json")).collect()
2148+
[Row(json=[1, 2, 3])]
21442149
"""
21452150

21462151
sc = SparkContext._active_spark_context

sql/core/src/main/scala/org/apache/spark/sql/functions.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3243,7 +3243,7 @@ object functions {
32433243

32443244
/**
32453245
* (Scala-specific) Parses a column containing a JSON string into a `MapType` with `StringType`
3246-
* as keys type, `StructType` or `ArrayType` of `StructType`s with the specified schema.
3246+
* as keys type, `StructType` or `ArrayType` with the specified schema.
32473247
* Returns `null`, in the case of an unparseable string.
32483248
*
32493249
* @param e a string column containing JSON data.
@@ -3275,7 +3275,7 @@ object functions {
32753275

32763276
/**
32773277
* (Java-specific) Parses a column containing a JSON string into a `MapType` with `StringType`
3278-
* as keys type, `StructType` or `ArrayType` of `StructType`s with the specified schema.
3278+
* as keys type, `StructType` or `ArrayType` with the specified schema.
32793279
* Returns `null`, in the case of an unparseable string.
32803280
*
32813281
* @param e a string column containing JSON data.
@@ -3304,7 +3304,7 @@ object functions {
33043304

33053305
/**
33063306
* Parses a column containing a JSON string into a `MapType` with `StringType` as keys type,
3307-
* `StructType` or `ArrayType` of `StructType`s with the specified schema.
3307+
* `StructType` or `ArrayType` with the specified schema.
33083308
* Returns `null`, in the case of an unparseable string.
33093309
*
33103310
* @param e a string column containing JSON data.
@@ -3318,7 +3318,7 @@ object functions {
33183318

33193319
/**
33203320
* (Java-specific) Parses a column containing a JSON string into a `MapType` with `StringType`
3321-
* as keys type, `StructType` or `ArrayType` of `StructType`s with the specified schema.
3321+
* as keys type, `StructType` or `ArrayType` with the specified schema.
33223322
* Returns `null`, in the case of an unparseable string.
33233323
*
33243324
* @param e a string column containing JSON data.
@@ -3335,7 +3335,7 @@ object functions {
33353335

33363336
/**
33373337
* (Scala-specific) Parses a column containing a JSON string into a `MapType` with `StringType`
3338-
* as keys type, `StructType` or `ArrayType` of `StructType`s with the specified schema.
3338+
* as keys type, `StructType` or `ArrayType` with the specified schema.
33393339
* Returns `null`, in the case of an unparseable string.
33403340
*
33413341
* @param e a string column containing JSON data.

0 commit comments

Comments
 (0)