spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From HyukjinKwon <>
Subject [GitHub] spark pull request #18926: [SPARK-21712] [PySpark] Clarify type error for Co...
Date Sun, 13 Aug 2017 10:27:46 GMT
Github user HyukjinKwon commented on a diff in the pull request:
    --- Diff: python/pyspark/sql/ ---
    @@ -406,7 +406,13 @@ def substr(self, startPos, length):
             [Row(col=u'Ali'), Row(col=u'Bob')]
             if type(startPos) != type(length):
    -            raise TypeError("Can not mix the type")
    +            raise TypeError(
    +                "startPos and length must be the same type. "
    +                "Got {startPos_t} and {length_t}, respectively."
    +                .format(
    +                    startPos_t=type(startPos),
    +                    length_t=type(length),
    +                ))
             if isinstance(startPos, (int, long)):
    --- End diff --
    @nchammas, supporting `long` with Python 2 is not documented in the docstring and looks
we throw unexpected exception by `long` with Python 2 as below:
    from pyspark.sql import Row
    df = spark.createDataFrame([Row(name=u'Tom', height=80), Row(name=u'Alice', height=None)]), long(3)).alias("col")).collect()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File ".../spark/python/pyspark/sql/", line 411, in substr
        jc = self._jc.substr(startPos, length)
      File ".../spark/python/lib/", line 1160, in
      File ".../spark/python/pyspark/sql/", line 63, in deco
        return f(*a, **kw)
      File ".../spark/python/lib/", line 324, in get_return_value
    py4j.protocol.Py4JError: An error occurred while calling o47.substr. Trace:
    py4j.Py4JException: Method substr([class java.lang.Long, class java.lang.Long]) does not
    	at py4j.reflection.ReflectionEngine.getMethod(
    	at py4j.reflection.ReflectionEngine.getMethod(
    	at py4j.Gateway.invoke(
    	at py4j.commands.AbstractCommand.invokeMethod(
    	at py4j.commands.CallCommand.execute(
    Would you mind double checking this and taking `long` out with a simple test with Python
2 as well? I think this will also address @gatorsmile's concern above as well.

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

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message