[
https://issues.apache.org/jira/browse/SPARK-7548?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14538937#comment-14538937
]
Nicholas Chammas commented on SPARK-7548:
-----------------------------------------
To provide a motivating example for the record, consider a DataFrame that looks
like this:
{code}
>>> a = {
'test_name': 'abracadabra',
'results': [{'time': 14.7}, {'time': 22.3}]
}
>>> df = sqlContext.jsonRDD(sc.parallelize([json.dumps(a)]))
>>> df.printSchema()
root
|-- results: array (nullable = true)
| |-- element: struct (containsNull = true)
| | |-- time: double (nullable = true)
|-- test_name: string (nullable = true)
>>> print df.select('results.time').collect()
[Row(time=[14.7, 22.3])]
{code}
It is currently not possible to aggregate over the nested {{time}} field as
follows:
{code}
df.groupBy('test_name').avg('results.time')
{code}
An alternative to supporting this kind of aggregation would be to offer some
way to "promote" the nested column to a top-level column. Hence, {{explode()}}.
> Add explode expression
> ----------------------
>
> Key: SPARK-7548
> URL: https://issues.apache.org/jira/browse/SPARK-7548
> Project: Spark
> Issue Type: Sub-task
> Components: SQL
> Reporter: Reynold Xin
> Assignee: Michael Armbrust
> Priority: Blocker
>
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]