You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Hyukjin Kwon (JIRA)" <ji...@apache.org> on 2018/07/31 08:07:00 UTC

[jira] [Resolved] (SPARK-24949) pyspark.sql.Column breaks the iterable contract

     [ https://issues.apache.org/jira/browse/SPARK-24949?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Hyukjin Kwon resolved SPARK-24949.
----------------------------------
    Resolution: Won't Fix

Let me leave this resolved. Seems difficult to fix but I wonder if it's worth. Please reopen and go ahead if a PR is ready. Let me leave this resolve till then.

> pyspark.sql.Column breaks the iterable contract
> -----------------------------------------------
>
>                 Key: SPARK-24949
>                 URL: https://issues.apache.org/jira/browse/SPARK-24949
>             Project: Spark
>          Issue Type: Bug
>          Components: PySpark
>    Affects Versions: 2.3.1
>            Reporter: Daniel Shields
>            Priority: Minor
>
> pyspark.sql.Column implements __iter__ just to raise a TypeError:
> {code:java}
> def __iter__(self):
>     raise TypeError("Column is not iterable")
> {code}
> This makes column look iterable even when it isn't:
> {code:java}
> isinstance(mycolumn, collections.Iterable) # Evaluates to True{code}
> This function should be removed from Column completely so it behaves like every other non-iterable class.
> For further motivation of why this should be fixed, consider the below example, which currently requires listing Column explicitly:
> {code:java}
> def listlike(value):
>     # Column unfortunately implements __iter__ just to raise a TypeError.
>     # This breaks the iterable contract and should be fixed in Spark proper.
>     return isinstance(value, collections.Iterable) and not isinstance(value, (str, bytes, pyspark.sql.Column))
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org