Skip to content

Instantly share code, notes, and snippets.

@liancheng
Last active March 14, 2016 03:31
Show Gist options
  • Save liancheng/97d18b4b06cd46b55211 to your computer and use it in GitHub Desktop.
Save liancheng/97d18b4b06cd46b55211 to your computer and use it in GitHub Desktop.
Scraper query plan explanation
@ context range 10 groupBy 'id agg count('id) having ('id > 0 and count('id) > 0) explain ()
# Logical plan
Filter: condition=$0 ==> [?output?]
├╴$0: ((`id` > 0:INT) AND (COUNT(`id`) > 0:INT))
╰╴UnresolvedAggregate: keys=[$0], projectList=[$1] ==> [?output?]
├╴$0: `id`
├╴$1: COUNT(`id`) AS ?alias?
╰╴LocalRelation: data=<local-data> ==> [`id`#0:BIGINT!]
# Analyzed plan
Project: projectList=[$0] ==> [`COUNT(id)`#1:BIGINT!]
├╴$0: `agg`#3:BIGINT! AS `COUNT(id)`#1
╰╴Filter: condition=$0 ==> [`group`#2:BIGINT!, `agg`#3:BIGINT!, `agg`#5:BIGINT!]
├╴$0: ((`group`#2:BIGINT! > CAST(0:INT AS BIGINT)) AND (`agg`#5:BIGINT! > CAST(0:INT AS BIGINT)))
╰╴Aggregate: keys=[$0], functions=[$1, $2] ==> [`group`#2:BIGINT!, `agg`#3:BIGINT!, `agg`#5:BIGINT!]
├╴$0: `id`#0:BIGINT! AS `group`#2
├╴$1: COUNT(`id`#0:BIGINT!) AS `agg`#3
├╴$2: COUNT(`id`#0:BIGINT!) AS `agg`#5
╰╴LocalRelation: data=<local-data> ==> [`id`#0:BIGINT!]
# Optimized plan
Project: projectList=[$0] ==> [`COUNT(id)`#1:BIGINT!]
├╴$0: `agg`#3:BIGINT! AS `COUNT(id)`#1
╰╴Filter: condition=$0 ==> [`group`#2:BIGINT!, `agg`#3:BIGINT!, `agg`#5:BIGINT!]
├╴$0: (`agg`#5:BIGINT! > 0:BIGINT)
╰╴Aggregate: keys=[$0], functions=[$1, $2] ==> [`group`#2:BIGINT!, `agg`#3:BIGINT!, `agg`#5:BIGINT!]
├╴$0: `id`#0:BIGINT! AS `group`#2
├╴$1: COUNT(`id`#0:BIGINT!) AS `agg`#3
├╴$2: COUNT(`id`#0:BIGINT!) AS `agg`#5
╰╴Filter: condition=$0 ==> [`id`#0:BIGINT!]
├╴$0: (`id`#0:BIGINT! > 0:BIGINT)
╰╴LocalRelation: data=<local-data> ==> [`id`#0:BIGINT!]
# Physical plan
Project: expressions=[$0] ==> [`COUNT(id)`#1:BIGINT!]
├╴$0: `agg`#3:BIGINT! AS `COUNT(id)`#1
╰╴Filter: condition=$0 ==> [`group`#2:BIGINT!, `agg`#3:BIGINT!, `agg`#5:BIGINT!]
├╴$0: (`agg`#5:BIGINT! > 0:BIGINT)
╰╴NotImplemented: logicalPlanName=Aggregate ==> [`group`#2:BIGINT!, `agg`#3:BIGINT!, `agg`#5:BIGINT!]
╰╴Filter: condition=$0 ==> [`id`#0:BIGINT!]
├╴$0: (`id`#0:BIGINT! > 0:BIGINT)
╰╴LocalRelation: data=<local-data> ==> [`id`#0:BIGINT!]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment