You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Apache Spark (JIRA)" <ji...@apache.org> on 2016/06/19 07:30:05 UTC
[jira] [Commented] (SPARK-13748) createDataFrame and rows with
omitted fields
[ https://issues.apache.org/jira/browse/SPARK-13748?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15338417#comment-15338417 ]
Apache Spark commented on SPARK-13748:
--------------------------------------
User 'HyukjinKwon' has created a pull request for this issue:
https://github.com/apache/spark/pull/13771
> createDataFrame and rows with omitted fields
> --------------------------------------------
>
> Key: SPARK-13748
> URL: https://issues.apache.org/jira/browse/SPARK-13748
> Project: Spark
> Issue Type: Improvement
> Components: Documentation, PySpark, SQL
> Affects Versions: 1.6.0
> Reporter: Ethan Aubin
> Priority: Minor
>
> I found it confusing that a Row with an omitted field is different from a row with field present but value missing. This was originally problematic for json files will varying fields, but it's comes down to something like:
> def test(rows):
> ds = sc.parallelize(rows)
> df = sqlContext.createDataFrame(ds,None,1)
> print df[['y']].collect()
> test([Row(x=1,y=None),Row(x=2, y='asdf')]) # Works
> test([Row(x=1),Row(x=2, y='asdf')]) # Fails with an ArrayIndexOutOfBoundsException.
> maybe more could be said in the documentation for createDataFrame or Row about what's expected. Validation or correction would be helpful, as would a function creating a well formed row from a structtype and dictionary.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org