GitHub user HyukjinKwon opened a pull request:

    https://github.com/apache/spark/pull/18590

    [SPARK-21365][PYTHON] Deduplicate logics parsing DDL type/schema definition

    ## What changes were proposed in this pull request?
    
    This PR deals with three points as below:
    
    - Reuse existing DDL parser APIs rather than reimplementing within PySpark
    
    - Support DDL formatted string, `field type, field type`.
    
    - Support nested data types as below:
    
      **Before**
      ```
      >>> spark.createDataFrame([[[1]]], "struct<a: struct<b: int>>").show()
      ...
      ValueError: The strcut field string format is: 'field_name:field_type', 
but got: a: struct<b: int>
      ```
    
      ```
      >>> spark.createDataFrame([[[1]]], "a: struct<b: int>").show()
      ...
      ValueError: The strcut field string format is: 'field_name:field_type', 
but got: a: struct<b: int>
      ```
    
      ```
      >>> spark.createDataFrame([[[1]]], "a int").show()
      ...
      ValueError: Could not parse datatype: a int
      ```
    
      **After**
      ```
      >>> spark.createDataFrame([[[1]]], "struct<a: struct<b: int>>").show()
      +---+
      |  a|
      +---+
      |[1]|
      +---+
      ```
    
      ```
      >>> spark.createDataFrame([[[1]]], "a: struct<b: int>").show()
      +---+
      |  a|
      +---+
      |[1]|
      +---+
      ```
    
      ```
      >>> spark.createDataFrame([[1]], "a int").show()
      +---+
      |  a|
      +---+
      |  1|
      +---+
      ```
    
    ## How was this patch tested?
    


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/HyukjinKwon/spark deduplicate-python-ddl

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/18590.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #18590
    
----
commit 3472873768aa6227c3fe15a035efd6ca112f88f9
Author: hyukjinkwon <[email protected]>
Date:   2017-07-10T17:02:06Z

    Deduplicate logics parsing DDL-like type definition

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to