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

    https://github.com/apache/spark/pull/11444#discussion_r54979708
  
    --- Diff: python/pyspark/sql/types.py ---
    @@ -681,6 +681,129 @@ def __eq__(self, other):
                               for v in [ArrayType, MapType, StructType])
     
     
    +_FIXED_DECIMAL = re.compile("decimal\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*\\)")
    +
    +
    +_BRACKETS = {'(': ')', '[': ']', '{': '}'}
    +
    +
    +def _parse_basic_datatype_string(s):
    +    if s in _all_atomic_types.keys():
    +        return _all_atomic_types[s]()
    +    elif s == "int":
    +        return IntegerType()
    +    elif _FIXED_DECIMAL.match(s):
    +        m = _FIXED_DECIMAL.match(s)
    +        return DecimalType(int(m.group(1)), int(m.group(2)))
    +    else:
    +        raise ValueError("Could not parse datatype: %s" % s)
    +
    +
    +def _ignore_brackets_split(s, separator):
    +    """
    +    Splits the given string by given separator, but ignore separators 
inside brackets pairs, e.g.
    +    given "a,b" and separator ",", it will return ["a", "b"], but given 
"a<b,c>, d", it will return
    +    ["a<b,c>", "d"].
    +    """
    +    parts = []
    +    buf = ""
    +    level = 0
    +    for c in s:
    +        if c in _BRACKETS.keys():
    +            level += 1
    +            buf += c
    +        elif c in _BRACKETS.values():
    +            if level == 0:
    +                raise ValueError("Brackets are not correctly paired: %s" % 
s)
    +            level -= 1
    +            buf += c
    +        elif c == separator and level > 0:
    +            buf += c
    +        elif c == separator:
    +            parts.append(buf)
    +            buf = ""
    +        else:
    +            buf += c
    +
    +    if len(buf) == 0:
    +        raise ValueError("The %s cannot be the last char: %s" % 
(separator, s))
    +    parts.append(buf)
    +    return parts
    +
    +
    +def _parse_struct_type_string(s):
    --- End diff --
    
    Does this support StructType?


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