You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Sean Owen (JIRA)" <ji...@apache.org> on 2016/03/08 20:25:40 UTC
[jira] [Updated] (SPARK-13748) createDataFrame and rows with
omitted fields
[ https://issues.apache.org/jira/browse/SPARK-13748?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sean Owen updated SPARK-13748:
------------------------------
Component/s: Documentation
Issue Type: Improvement (was: Bug)
Sure, open a PR with proposed doc updates
> 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