Thanks for your prompt response.
Attached (assuming attachments actually work on this list) are three
explains:
1. original (with incorrect GROUP BY result)
2. with hive.app.aggr=false (no change, still getting incorrect result),
3. back to the default hive.app.aggr value, with my workaround of
presorting the inputs (result is correctly grouped)
If you'd like any other info, or if you'd like me to test with other
versions of Spark or whatever, please let me know.
/drm
On Tue, Nov 1, 2016 at 4:51 PM, Gopal Vijayaraghavan <[email protected]>
wrote:
>
> > I've run into a GROUP BY that does not work reliably in the newer
> version: the GROUP BY results are not always fully aggregated. Instead, I
> get lots of duplicate + triplicate sets of group values. Seems like a Hive
> bug to me
>
> That does sound like a bug, but this information is not enough to
> determine what's wrong.
>
> > This is not 100% repeatable.
>
> The output of "explain <query>" would be useful and along with it, I have
> put in a non-deterministic flush in Hive (for Tez) which might be messing
> with Spark.
>
> Can you run repros with - set hive.map.aggr=false;?
>
> Cheers,
> Gopal
>
>
>
1. First, an explain of the original query reproducing the issue.
Note that the input 'selfJoinedTemp' table has not been ordered.
Parsing command: EXPLAIN SELECT artid, artorsec, page, geo, ranks, pos, start,
finish, duration,
pageviews, redpageviews, videostarts, redvideostarts, thirtyinterval,
medianpctviewed, cumulativeprop,
pagevisitors, redpagevisitors, eyeballs, redeyeballs, viewrates, rviewrates,
vidviewrates, rvidviewrates,
COUNT(articleByLocation) as numarticles,
SUM(eyes_in_timeframe) as eyes_in_timeframe,
SUM(redeyes_in_timeframe) as redeyes_in_timeframe
FROM selfJoinedTemp
GROUP BY artid, artorsec, page, geo, ranks, pos, start, finish, duration,
pageviews, redpageviews, videostarts, redvideostarts, thirtyinterval,
medianpctviewed, cumulativeprop,
pagevisitors, redpagevisitors, eyeballs, redeyeballs, viewrates, rviewrates,
vidviewrates, rvidviewrates
Parse Completed
EXPLANATION<<<
== Physical Plan ==
TungstenAggregate(key=[artid#5,artorsec#0,page#11,geo#12,ranks#2,pos#4,start#13,finish#14,duration#15,pageviews#1064L,redpageviews#213L,videostarts#1065L,redvideostarts#1066L,thirtyinterval#7,medianpctviewed#115,cumulativeprop#418,pagevisitors#1067L,redpagevisitors#1068L,eyeballs#1249,redeyeballs#1250,viewrates#1251,rviewrates#1252,vidviewrates#1253,rvidviewrates#1254],
functions=[(count(articleByLocation#1630),mode=Final,isDistinct=false),(sum(eyes_in_timeframe#1631),mode=Final,isDistinct=false),(sum(redeyes_in_timeframe#1632),mode=Final,isDistinct=false)],
output=[artid#5,artorsec#0,page#11,geo#12,ranks#2,pos#4,start#13,finish#14,duration#15,pageviews#1064L,redpageviews#213L,videostarts#1065L,redvideostarts#1066L,thirtyinterval#7,medianpctviewed#115,cumulativeprop#418,pagevisitors#1067L,redpagevisitors#1068L,eyeballs#1249,redeyeballs#1250,viewrates#1251,rviewrates#1252,vidviewrates#1253,rvidviewrates#1254,numarticles#2135L,eyes_in_timeframe#2136,redeyes_in_timeframe#2137])
+-
TungstenAggregate(key=[artid#5,artorsec#0,page#11,geo#12,ranks#2,pos#4,start#13,finish#14,duration#15,pageviews#1064L,redpageviews#213L,videostarts#1065L,redvideostarts#1066L,thirtyinterval#7,medianpctviewed#115,cumulativeprop#418,pagevisitors#1067L,redpagevisitors#1068L,eyeballs#1249,redeyeballs#1250,viewrates#1251,rviewrates#1252,vidviewrates#1253,rvidviewrates#1254],
functions=[(count(articleByLocation#1630),mode=Partial,isDistinct=false),(sum(eyes_in_timeframe#1631),mode=Partial,isDistinct=false),(sum(redeyes_in_timeframe#1632),mode=Partial,isDistinct=false)],
output=[artid#5,artorsec#0,page#11,geo#12,ranks#2,pos#4,start#13,finish#14,duration#15,pageviews#1064L,redpageviews#213L,videostarts#1065L,redvideostarts#1066L,thirtyinterval#7,medianpctviewed#115,cumulativeprop#418,pagevisitors#1067L,redpagevisitors#1068L,eyeballs#1249,redeyeballs#1250,viewrates#1251,rviewrates#1252,vidviewrates#1253,rvidviewrates#1254,count#2280L,sum#2281,sum#2282])
+- InMemoryColumnarTableScan
[artid#5,artorsec#0,page#11,geo#12,ranks#2,pos#4,start#13,finish#14,duration#15,pageviews#1064L,redpageviews#213L,videostarts#1065L,redvideostarts#1066L,thirtyinterval#7,medianpctviewed#115,cumulativeprop#418,pagevisitors#1067L,redpagevisitors#1068L,eyeballs#1249,redeyeballs#1250,viewrates#1251,rviewrates#1252,vidviewrates#1253,rvidviewrates#1254,articleByLocation#1630,eyes_in_timeframe#1631,redeyes_in_timeframe#1632],
InMemoryRelation
[artid#5,artorsec#0,page#11,geo#12,ranks#2,pos#4,start#13,finish#14,duration#15,pageviews#1064L,redpageviews#213L,videostarts#1065L,redvideostarts#1066L,thirtyinterval#7,medianpctviewed#115,cumulativeprop#418,pagevisitors#1067L,redpagevisitors#1068L,eyeballs#1249,redeyeballs#1250,viewrates#1251,rviewrates#1252,vidviewrates#1253,rvidviewrates#1254,articleByLocation#1630,eyes_in_timeframe#1631,redeyes_in_timeframe#1632],
true, 10000, StorageLevel(true, true, false, true, 1), Project
[artid#5,artorsec#0,page#11,geo#12,ranks#2,pos#4,start#13,finish#14,duration#15,pageviews#1064L,redpageviews#213L,videostarts#1065L,redvideostarts#1066L,thirtyinterval#7,medianpctviewed#115,cumulativeprop#418,pagevisitors#1067L,redpagevisitors#1068L,eyeballs#1249,redeyeballs#1250,viewrates#1251,rviewrates#1252,vidviewrates#1253,rvidviewrates#1254,concat(artid#1670,artorsec#1665,page#1652,geo#1653)
AS articleByLocation#1630,eyeballs#1633 AS
eyes_in_timeframe#1631,redeyeballs#1634 AS redeyes_in_timeframe#1632], None
>>>EXPLANATION
_________________________________________
2. Second, when I simply add hiveContext.sql("set hive.map.aggr=false"), there
is no change to the output, I am still seeing the issue.
Here's an explain for that:
Parsing command: EXPLAIN SELECT artid, artorsec, page, geo, ranks, pos, start,
finish, duration,
pageviews, redpageviews, videostarts, redvideostarts, thirtyinterval,
medianpctviewed, cumulativeprop,
pagevisitors, redpagevisitors, eyeballs, redeyeballs, viewrates, rviewrates,
vidviewrates, rvidviewrates,
COUNT(articleByLocation) as numarticles,
SUM(eyes_in_timeframe) as eyes_in_timeframe,
SUM(redeyes_in_timeframe) as redeyes_in_timeframe
FROM selfJoinedTemp
GROUP BY artid, artorsec, page, geo, ranks, pos, start, finish, duration,
pageviews, redpageviews, videostarts, redvideostarts, thirtyinterval,
medianpctviewed, cumulativeprop,
pagevisitors, redpagevisitors, eyeballs, redeyeballs, viewrates, rviewrates,
vidviewrates, rvidviewrates
Parse Completed
EXPLANATION<<<
== Physical Plan ==
TungstenAggregate(key=[artid#8,artorsec#3,page#14,geo#15,ranks#5,pos#7,start#16,finish#17,duration#18,pageviews#1067L,redpageviews#216L,videostarts#1068L,redvideostarts#1069L,thirtyinterval#10,medianpctviewed#118,cumulativeprop#421,pagevisitors#1070L,redpagevisitors#1071L,eyeballs#1252,redeyeballs#1253,viewrates#1254,rviewrates#1255,vidviewrates#1256,rvidviewrates#1257],
functions=[(count(articleByLocation#1633),mode=Final,isDistinct=false),(sum(eyes_in_timeframe#1634),mode=Final,isDistinct=false),(sum(redeyes_in_timeframe#1635),mode=Final,isDistinct=false)],
output=[artid#8,artorsec#3,page#14,geo#15,ranks#5,pos#7,start#16,finish#17,duration#18,pageviews#1067L,redpageviews#216L,videostarts#1068L,redvideostarts#1069L,thirtyinterval#10,medianpctviewed#118,cumulativeprop#421,pagevisitors#1070L,redpagevisitors#1071L,eyeballs#1252,redeyeballs#1253,viewrates#1254,rviewrates#1255,vidviewrates#1256,rvidviewrates#1257,numarticles#2138L,eyes_in_timeframe#2139,redeyes_in_timeframe#2140])
+-
TungstenAggregate(key=[artid#8,artorsec#3,page#14,geo#15,ranks#5,pos#7,start#16,finish#17,duration#18,pageviews#1067L,redpageviews#216L,videostarts#1068L,redvideostarts#1069L,thirtyinterval#10,medianpctviewed#118,cumulativeprop#421,pagevisitors#1070L,redpagevisitors#1071L,eyeballs#1252,redeyeballs#1253,viewrates#1254,rviewrates#1255,vidviewrates#1256,rvidviewrates#1257],
functions=[(count(articleByLocation#1633),mode=Partial,isDistinct=false),(sum(eyes_in_timeframe#1634),mode=Partial,isDistinct=false),(sum(redeyes_in_timeframe#1635),mode=Partial,isDistinct=false)],
output=[artid#8,artorsec#3,page#14,geo#15,ranks#5,pos#7,start#16,finish#17,duration#18,pageviews#1067L,redpageviews#216L,videostarts#1068L,redvideostarts#1069L,thirtyinterval#10,medianpctviewed#118,cumulativeprop#421,pagevisitors#1070L,redpagevisitors#1071L,eyeballs#1252,redeyeballs#1253,viewrates#1254,rviewrates#1255,vidviewrates#1256,rvidviewrates#1257,count#2283L,sum#2284,sum#2285])
+- InMemoryColumnarTableScan
[artid#8,artorsec#3,page#14,geo#15,ranks#5,pos#7,start#16,finish#17,duration#18,pageviews#1067L,redpageviews#216L,videostarts#1068L,redvideostarts#1069L,thirtyinterval#10,medianpctviewed#118,cumulativeprop#421,pagevisitors#1070L,redpagevisitors#1071L,eyeballs#1252,redeyeballs#1253,viewrates#1254,rviewrates#1255,vidviewrates#1256,rvidviewrates#1257,articleByLocation#1633,eyes_in_timeframe#1634,redeyes_in_timeframe#1635],
InMemoryRelation
[artid#8,artorsec#3,page#14,geo#15,ranks#5,pos#7,start#16,finish#17,duration#18,pageviews#1067L,redpageviews#216L,videostarts#1068L,redvideostarts#1069L,thirtyinterval#10,medianpctviewed#118,cumulativeprop#421,pagevisitors#1070L,redpagevisitors#1071L,eyeballs#1252,redeyeballs#1253,viewrates#1254,rviewrates#1255,vidviewrates#1256,rvidviewrates#1257,articleByLocation#1633,eyes_in_timeframe#1634,redeyes_in_timeframe#1635],
true, 10000, StorageLevel(true, true, false, true, 1), Project
[artid#8,artorsec#3,page#14,geo#15,ranks#5,pos#7,start#16,finish#17,duration#18,pageviews#1067L,redpageviews#216L,videostarts#1068L,redvideostarts#1069L,thirtyinterval#10,medianpctviewed#118,cumulativeprop#421,pagevisitors#1070L,redpagevisitors#1071L,eyeballs#1252,redeyeballs#1253,viewrates#1254,rviewrates#1255,vidviewrates#1256,rvidviewrates#1257,concat(artid#1673,artorsec#1668,page#1655,geo#1656)
AS articleByLocation#1633,eyeballs#1636 AS
eyes_in_timeframe#1634,redeyeballs#1637 AS redeyes_in_timeframe#1635], None
>>>EXPLANATION
_________________________________________
3. Finally, when I remove that hiveContext.sql("set hive.map.aggr=false")
and instead sort that "selfJoinedTemp" input table (by artid, artorsec, page,
geo, ranks, pos, start) before running this GROUP BY query, the issue
disappears.
Here is an explain for that:
Parsing command: EXPLAIN SELECT artid, artorsec, page, geo, ranks, pos, start,
finish, duration,
pageviews, redpageviews, videostarts, redvideostarts, thirtyinterval,
medianpctviewed, cumulativeprop,
pagevisitors, redpagevisitors, eyeballs, redeyeballs, viewrates, rviewrates,
vidviewrates, rvidviewrates,
COUNT(articleByLocation) as numarticles,
SUM(eyes_in_timeframe) as eyes_in_timeframe,
SUM(redeyes_in_timeframe) as redeyes_in_timeframe
FROM selfJoinedTemp
GROUP BY artid, artorsec, page, geo, ranks, pos, start, finish, duration,
pageviews, redpageviews, videostarts, redvideostarts, thirtyinterval,
medianpctviewed, cumulativeprop,
pagevisitors, redpagevisitors, eyeballs, redeyeballs, viewrates, rviewrates,
vidviewrates, rvidviewrates
Parse Completed
EXPLANATION<<<
== Physical Plan ==
TungstenAggregate(key=[artid#5,artorsec#0,page#11,geo#12,ranks#2,pos#4,start#13,finish#14,duration#15,pageviews#1064L,redpageviews#213L,videostarts#1065L,redvideostarts#1066L,thirtyinterval#7,medianpctviewed#115,cumulativeprop#418,pagevisitors#1067L,redpagevisitors#1068L,eyeballs#1249,redeyeballs#1250,viewrates#1251,rviewrates#1252,vidviewrates#1253,rvidviewrates#1254],
functions=[(count(articleByLocation#1630),mode=Final,isDistinct=false),(sum(eyes_in_timeframe#1631),mode=Final,isDistinct=false),(sum(redeyes_in_timeframe#1632),mode=Final,isDistinct=false)],
output=[artid#5,artorsec#0,page#11,geo#12,ranks#2,pos#4,start#13,finish#14,duration#15,pageviews#1064L,redpageviews#213L,videostarts#1065L,redvideostarts#1066L,thirtyinterval#7,medianpctviewed#115,cumulativeprop#418,pagevisitors#1067L,redpagevisitors#1068L,eyeballs#1249,redeyeballs#1250,viewrates#1251,rviewrates#1252,vidviewrates#1253,rvidviewrates#1254,numarticles#2135L,eyes_in_timeframe#2136,redeyes_in_timeframe#2137])
+-
TungstenAggregate(key=[artid#5,artorsec#0,page#11,geo#12,ranks#2,pos#4,start#13,finish#14,duration#15,pageviews#1064L,redpageviews#213L,videostarts#1065L,redvideostarts#1066L,thirtyinterval#7,medianpctviewed#115,cumulativeprop#418,pagevisitors#1067L,redpagevisitors#1068L,eyeballs#1249,redeyeballs#1250,viewrates#1251,rviewrates#1252,vidviewrates#1253,rvidviewrates#1254],
functions=[(count(articleByLocation#1630),mode=Partial,isDistinct=false),(sum(eyes_in_timeframe#1631),mode=Partial,isDistinct=false),(sum(redeyes_in_timeframe#1632),mode=Partial,isDistinct=false)],
output=[artid#5,artorsec#0,page#11,geo#12,ranks#2,pos#4,start#13,finish#14,duration#15,pageviews#1064L,redpageviews#213L,videostarts#1065L,redvideostarts#1066L,thirtyinterval#7,medianpctviewed#115,cumulativeprop#418,pagevisitors#1067L,redpagevisitors#1068L,eyeballs#1249,redeyeballs#1250,viewrates#1251,rviewrates#1252,vidviewrates#1253,rvidviewrates#1254,count#2280L,sum#2281,sum#2282])
+- InMemoryColumnarTableScan
[artid#5,artorsec#0,page#11,geo#12,ranks#2,pos#4,start#13,finish#14,duration#15,pageviews#1064L,redpageviews#213L,videostarts#1065L,redvideostarts#1066L,thirtyinterval#7,medianpctviewed#115,cumulativeprop#418,pagevisitors#1067L,redpagevisitors#1068L,eyeballs#1249,redeyeballs#1250,viewrates#1251,rviewrates#1252,vidviewrates#1253,rvidviewrates#1254,articleByLocation#1630,eyes_in_timeframe#1631,redeyes_in_timeframe#1632],
InMemoryRelation
[artid#5,artorsec#0,page#11,geo#12,ranks#2,pos#4,start#13,finish#14,duration#15,pageviews#1064L,redpageviews#213L,videostarts#1065L,redvideostarts#1066L,thirtyinterval#7,medianpctviewed#115,cumulativeprop#418,pagevisitors#1067L,redpagevisitors#1068L,eyeballs#1249,redeyeballs#1250,viewrates#1251,rviewrates#1252,vidviewrates#1253,rvidviewrates#1254,articleByLocation#1630,eyes_in_timeframe#1631,redeyes_in_timeframe#1632],
true, 10000, StorageLevel(true, true, false, true, 1), Sort [artid#5
ASC,artorsec#0 ASC,page#11 ASC,geo#12 ASC,ranks#2 ASC,pos#4 ASC,start#13 ASC],
true, 0, None
>>>EXPLANATION