[
https://issues.apache.org/jira/browse/SPARK-11329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15024237#comment-15024237
]
Maciej BryĆski commented on SPARK-11329:
----------------------------------------
Is it OK that there is 'ConvertToSafe' part during this aggregation ?
{code}
sqlCtx.sql('select id, max(struct(data)) as max from table group by id
').collect()
== Physical Plan ==
SortBasedAggregate(key=[id#0],
functions=[(max(struct(data#2)),mode=Final,isDistinct=false)],
output=[id#0,max#39])
ConvertToSafe
Sort [id#0 ASC], false, 0
TungstenExchange hashpartitioning(id#0,400), None
ConvertToUnsafe
SortBasedAggregate(key=[id#0],
functions=[(max(struct(data#2)),mode=Partial,isDistinct=false)],
output=[id#0,max#42])
ConvertToSafe
Sort [id#0 ASC], false, 0
Scan ParquetRelation[file:] PushedFilter: [] [id#0,data#2]
{code}
But running count run only tungsten aggregation.
{code}
sqlCtx.sql('select id, max(struct(data)) as max from table group by id
').count()
== Physical Plan ==
TungstenAggregate(key=[], functions=[(count(1),mode=Final,isDistinct=false)],
output=[count#35L])
TungstenExchange SinglePartition, None
TungstenAggregate(key=[],
functions=[(count(1),mode=Partial,isDistinct=false)], output=[count#38L])
TungstenAggregate(key=[id#0], functions=[], output=[])
TungstenExchange hashpartitioning(id#0,400), None
TungstenAggregate(key=[id#0], functions=[], output=[id#0])
Scan ParquetRelation[file:] PushedFilter: [] [id#0]
{code}
> Expand Star when creating a struct
> ----------------------------------
>
> Key: SPARK-11329
> URL: https://issues.apache.org/jira/browse/SPARK-11329
> Project: Spark
> Issue Type: Improvement
> Components: SQL
> Reporter: Yin Huai
> Assignee: Nong Li
> Fix For: 1.6.0
>
>
> It is pretty common for customers to do regular extractions of update data
> from an external datasource (e.g. mysql or postgres). While this is possible
> today, the syntax is a little onerous. With some small improvements to the
> analyzer I think we could make this much easier.
> Goal: Allow users to execute the following two queries as well as their
> dataframe equivalents
> to find the most recent record for each key
> {{SELECT max(struct(timestamp, *)) as mostRecentRecord GROUP BY key}}
> to unnest the struct from above.
> {{SELECT mostRecentRecord.* FROM data}}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]