Github user davies commented on a diff in the pull request:

    https://github.com/apache/spark/pull/6686#discussion_r32656949
  
    --- Diff: python/pyspark/sql/types.py ---
    @@ -368,8 +367,49 @@ def __init__(self, fields):
             >>> struct1 == struct2
             False
             """
    -        assert all(isinstance(f, DataType) for f in fields), "fields 
should be a list of DataType"
    -        self.fields = fields
    +        if not fields:
    +            self.fields = []
    +        else:
    +            self.fields = fields
    +            assert all(isinstance(f, StructField) for f in fields),\
    +                "fields should be a list of StructField"
    +
    +    def add(self, name_or_struct_field, data_type=NullType(), 
nullable=True, metadata=None):
    --- End diff --
    
    I think you could use `None` as default value of `dataType`, and raise an 
exception if `name_or_struct_field ` is string and `dataType` is None


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to