spark-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Arttu Voutilainen (JIRA)" <>
Subject [jira] [Created] (SPARK-26810) Fixing SPARK-25072 broke existing code and fails to show error message
Date Fri, 01 Feb 2019 19:51:00 GMT
Arttu Voutilainen created SPARK-26810:

             Summary: Fixing SPARK-25072 broke existing code and fails to show error message
                 Key: SPARK-26810
             Project: Spark
          Issue Type: Bug
          Components: PySpark
    Affects Versions: 2.4.0
            Reporter: Arttu Voutilainen


We upgraded Spark recently, and caused our
pipeline to fail after the upgrade. Annoyingly, the error message formatting also threw an
exception itself, thus hiding the message we should have seen.

Repro using gettyimages/docker-spark, on 2.4.0:
from pyspark.sql import Row
r = Row(['a','b'])
r('1', '2')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/spark-2.4.0/python/pyspark/sql/", line 1505, in __call__
    "but got %s" % (self, len(self), args))
  File "/usr/spark-2.4.0/python/pyspark/sql/", line 1552, in __repr__
    return "<Row(%s)>" % ", ".join(self)
TypeError: sequence item 0: expected str instance, list found
On 2.3.1, and also showing how this was used:
from pyspark.sql import Row, types as T

r = Row(['a','b'])
df = spark.createDataFrame([Row(col='doesntmatter')])
rdd = df.rdd.mapPartitions(lambda p: [r('a1','b2')])
spark.createDataFrame(rdd, T.StructType([T.StructField('a', T.StringType()), T.StructField('b',
[Row(a='a1', b='b2'), Row(a='a1', b='b2')]
While I do think the code we had was quite horrible, it used to work. The unexpected error
came from __repr__ as it assumes that the arguments given to Row constructor are strings.
That sounds like a reasonable assumption, should the Row constructor validate that it holds
true maybe? (I guess that might be another potentially breaking change though, if someone
has as weird code as this one...)

This message was sent by Atlassian JIRA

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

View raw message