Yikun commented on code in PR #37465:
URL: https://github.com/apache/spark/pull/37465#discussion_r943080421


##########
python/pyspark/sql/types.py:
##########
@@ -684,6 +702,30 @@ class StructType(DataType):
     ...     StructField("f2", IntegerType(), False)])
     >>> struct1 == struct2
     False
+
+    The below example demonstrates how to create a struct using StructType & 
StructField on
+    DataFrame:
+
+    >>> data = [("Alice", ["Java", "Scala"]), ("Bob", ["Python", "Scala"])]
+    >>> schema = StructType([
+    ...     StructField("name", StringType()),
+    ...     StructField("languagesSkills", ArrayType(StringType())),
+    ... ])
+    >>> df = spark.createDataFrame(data=data, schema=schema)
+    >>> df.printSchema()
+    root
+     |-- name: string (nullable = true)
+     |-- languagesSkills: array (nullable = true)
+     |    |-- element: string (containsNull = true)
+    <BLANKLINE>

Review Comment:
   ah, good suggestion, it was copy from other existing code. Addressed!
   
   and I will also submit a PR to address other places
   
   ```
   spark git:(type) ✗ grep -r BLANKLINE **/*.py
   python/pyspark/ml/stat.py:    <BLANKLINE>
   python/pyspark/ml/stat.py:    <BLANKLINE>
   python/pyspark/ml/stat.py:    <BLANKLINE>
   python/pyspark/ml/stat.py:    <BLANKLINE>
   python/pyspark/mllib/tree.py:        <BLANKLINE>
   python/pyspark/mllib/tree.py:        <BLANKLINE>
   python/pyspark/mllib/tree.py:        <BLANKLINE>
   python/pyspark/mllib/tree.py:        <BLANKLINE>
   python/pyspark/mllib/tree.py:        <BLANKLINE>
   python/pyspark/pandas/frame.py:        <BLANKLINE>
   python/pyspark/pandas/series.py:        <BLANKLINE>
   python/pyspark/pandas/series.py:        <BLANKLINE>
   python/pyspark/pandas/series.py:        <BLANKLINE>
   python/pyspark/pandas/series.py:        <BLANKLINE>
   python/pyspark/sql/dataframe.py:        <BLANKLINE>
   ```



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