Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
01e4cdf
Merge remote-tracking branch 'upstream/master'
gatorsmile Nov 13, 2015
6835704
Merge remote-tracking branch 'upstream/master'
gatorsmile Nov 14, 2015
9180687
Merge remote-tracking branch 'upstream/master'
gatorsmile Nov 14, 2015
b38a21e
SPARK-11633
gatorsmile Nov 17, 2015
d2b84af
Merge remote-tracking branch 'upstream/master' into joinMakeCopy
gatorsmile Nov 17, 2015
fda8025
Merge remote-tracking branch 'upstream/master'
gatorspark Nov 17, 2015
ac0dccd
Merge branch 'master' of https://github.com/gatorsmile/spark
gatorspark Nov 17, 2015
6e0018b
Merge remote-tracking branch 'upstream/master'
Nov 20, 2015
0546772
converge
gatorsmile Nov 20, 2015
b37a64f
converge
gatorsmile Nov 20, 2015
c2a872c
Merge remote-tracking branch 'upstream/master'
gatorsmile Jan 6, 2016
ab6dbd7
Merge remote-tracking branch 'upstream/master'
gatorsmile Jan 6, 2016
4276356
Merge remote-tracking branch 'upstream/master'
gatorsmile Jan 6, 2016
2dab708
Merge remote-tracking branch 'upstream/master'
gatorsmile Jan 7, 2016
0458770
Merge remote-tracking branch 'upstream/master'
gatorsmile Jan 8, 2016
1debdfa
Merge remote-tracking branch 'upstream/master'
gatorsmile Jan 9, 2016
763706d
Merge remote-tracking branch 'upstream/master'
gatorsmile Jan 14, 2016
4de6ec1
Merge remote-tracking branch 'upstream/master'
gatorsmile Jan 18, 2016
9422a4f
Merge remote-tracking branch 'upstream/master'
gatorsmile Jan 19, 2016
52bdf48
Merge remote-tracking branch 'upstream/master'
gatorsmile Jan 20, 2016
1e95df3
Merge remote-tracking branch 'upstream/master'
gatorsmile Jan 23, 2016
fab24cf
Merge remote-tracking branch 'upstream/master'
gatorsmile Feb 1, 2016
8b2e33b
Merge remote-tracking branch 'upstream/master'
gatorsmile Feb 5, 2016
2ee1876
Merge remote-tracking branch 'upstream/master'
gatorsmile Feb 11, 2016
b9f0090
Merge remote-tracking branch 'upstream/master'
gatorsmile Feb 12, 2016
ade6f7e
Merge remote-tracking branch 'upstream/master'
gatorsmile Feb 15, 2016
9fd63d2
Merge remote-tracking branch 'upstream/master'
gatorsmile Feb 19, 2016
5199d49
Merge remote-tracking branch 'upstream/master'
gatorsmile Feb 22, 2016
404214c
Merge remote-tracking branch 'upstream/master'
gatorsmile Feb 23, 2016
c001dd9
Merge remote-tracking branch 'upstream/master'
gatorsmile Feb 25, 2016
59daa48
Merge remote-tracking branch 'upstream/master'
gatorsmile Mar 5, 2016
41d5f64
Merge remote-tracking branch 'upstream/master'
gatorsmile Mar 7, 2016
472a6e3
Merge remote-tracking branch 'upstream/master'
gatorsmile Mar 10, 2016
458f7be
ppd for window
gatorsmile Mar 10, 2016
92136dd
Merge remote-tracking branch 'upstream/master' into pushPredicateThro…
gatorsmile Mar 10, 2016
f401d8b
only partitioning key
gatorsmile Mar 10, 2016
0fba10a
Merge remote-tracking branch 'upstream/master'
gatorsmile Mar 12, 2016
3aea1da
Merge branch 'pushPredicateThroughWindow' into pushPredicateThroughWi…
gatorsmile Mar 12, 2016
d420246
add windowExpr and windowSpec to DSL
gatorsmile Mar 12, 2016
c05b4ae
remove useless import
gatorsmile Mar 12, 2016
6db1940
added more test cases
gatorsmile Mar 14, 2016
8fa0294
added two more test case.
gatorsmile Mar 21, 2016
cbf73b3
Merge remote-tracking branch 'upstream/master'
gatorsmile Mar 21, 2016
c08f561
Merge remote-tracking branch 'upstream/master'
gatorsmile Mar 22, 2016
474df88
Merge remote-tracking branch 'upstream/master'
gatorsmile Mar 22, 2016
3d9828d
Merge remote-tracking branch 'upstream/master'
gatorsmile Mar 24, 2016
72d2361
Merge remote-tracking branch 'upstream/master'
gatorsmile Mar 26, 2016
07afea5
Merge remote-tracking branch 'upstream/master'
gatorsmile Mar 29, 2016
8bf2007
Merge remote-tracking branch 'upstream/master'
gatorsmile Mar 30, 2016
87a165b
Merge remote-tracking branch 'upstream/master'
gatorsmile Mar 31, 2016
b9359cd
Merge remote-tracking branch 'upstream/master'
gatorsmile Apr 1, 2016
b0d7b3b
Merge branch 'pushPredicateThroughWindowNew' into pushPredicateThroug…
gatorsmile Apr 1, 2016
65bd090
Merge remote-tracking branch 'upstream/master'
gatorsmile Apr 5, 2016
babf2da
Merge remote-tracking branch 'upstream/master'
gatorsmile Apr 5, 2016
9e09469
Merge remote-tracking branch 'upstream/master'
gatorsmile Apr 6, 2016
50a8e4a
Merge remote-tracking branch 'upstream/master'
gatorsmile Apr 6, 2016
f3337fa
Merge remote-tracking branch 'upstream/master'
gatorsmile Apr 10, 2016
09cc36d
Merge remote-tracking branch 'upstream/master'
gatorsmile Apr 12, 2016
83a1915
Merge remote-tracking branch 'upstream/master'
gatorsmile Apr 14, 2016
0483145
Merge remote-tracking branch 'upstream/master'
gatorsmile Apr 19, 2016
236a5f4
Merge remote-tracking branch 'upstream/master'
gatorsmile Apr 20, 2016
417bdb4
merge
gatorsmile Apr 20, 2016
cc5f0bd
merge
gatorsmile Apr 20, 2016
436359f
style fix.
gatorsmile Apr 20, 2016
fae2694
address comments.
gatorsmile Apr 20, 2016
875d6b6
style fix.
gatorsmile Apr 20, 2016
0469923
style fix
gatorsmile Apr 20, 2016
5c4f4d3
address comments.
gatorsmile Apr 20, 2016
c4dedd2
address comments and added more test cases.
gatorsmile Apr 20, 2016
3eaeaa5
Merge remote-tracking branch 'upstream/master' into pushPredicateThro…
gatorsmile Apr 25, 2016
e427ce9
address comments.
gatorsmile Apr 25, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
address comments and added more test cases.
  • Loading branch information
gatorsmile committed Apr 20, 2016
commit c4dedd21fd6a7986814d2da970e22762e8292aed
Original file line number Diff line number Diff line change
Expand Up @@ -959,15 +959,18 @@ object PushDownPredicate extends Rule[LogicalPlan] with PredicateHelper {
project.copy(child = Filter(replaceAlias(condition, aliasMap), grandChild))

// Push [[Filter]] operators through [[Window]] operators. Parts of the predicate that can be
// pushed beneath must satisfy three conditions:
// 1. All the columns are part of window partitioning key.
// 2. Window partitioning key should be just a sequence of [[AttributeReference]].
// 3. Deterministic
// pushed beneath must satisfy the following two conditions:
// 1. All the expressions are part of window partitioning key. The expressions can be compound.
// 2. Deterministic
case filter @ Filter(condition, w: Window)
if w.partitionSpec.forall(_.isInstanceOf[AttributeReference]) =>
val partitionAttrs = AttributeSet(w.partitionSpec.flatMap(_.references))
val (pushDown, stayUp) = splitConjunctivePredicates(condition).partition { cond =>
cond.references.subsetOf(partitionAttrs) && cond.deterministic
cond.references.subsetOf(partitionAttrs) && cond.deterministic &&
// This is for ensuring all the partitioning expressions have been converted to alias
// in Analyzer. Thus, we do not need to check if the expressions in conditions are
// the same as the expressions used in partitioning columns.
partitionAttrs.forall(_.isInstanceOf[Attribute])
}
if (pushDown.nonEmpty) {
val pushDownPredicate = pushDown.reduce(And)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -871,10 +871,39 @@ class FilterPushdownSuite extends PlanTest {
comparePlans(Optimize.execute(originalQuery.analyze), correctAnswer)
}

// complex predicates with the same references but the same expressions
// Todo: in Analyzer, to enable it, we need to convert the expression in conditions
// to the alias that is defined as the same expression
ignore("Window: predicate push down -- complex predicate with the same expressions") {
val winSpec = windowSpec(
partitionSpec = 'a.attr + 'b.attr :: Nil,
orderSpec = 'b.asc :: Nil,
UnspecifiedFrame)
val winExpr = windowExpr(count('b), winSpec)

val winSpecAnalyzed = windowSpec(
partitionSpec = '_w0.attr :: Nil,
orderSpec = 'b.asc :: Nil,
UnspecifiedFrame)
val winExprAnalyzed = windowExpr(count('b), winSpecAnalyzed)

val originalQuery = testRelation.select('a, 'b, 'c, winExpr.as('window)).where('a + 'b > 1)
val correctAnswer = testRelation
.where('a + 'b > 1).select('a, 'b, 'c, ('a + 'b).as("_w0"))
.window(winExprAnalyzed.as('window) :: Nil, '_w0 :: Nil, 'b.asc :: Nil)
.select('a, 'b, 'c, 'window).analyze

comparePlans(Optimize.execute(originalQuery.analyze), correctAnswer)
}

test("Window: no predicate push down -- predicates are not from partitioning keys") {
val winExpr =
windowExpr(count('b), windowSpec('a.attr :: 'b.attr :: Nil, 'b.asc :: Nil, UnspecifiedFrame))
val winSpec = windowSpec(
partitionSpec = 'a.attr :: 'b.attr :: Nil,
orderSpec = 'b.asc :: Nil,
UnspecifiedFrame)
val winExpr = windowExpr(count('b), winSpec)

// No push down: the predicate is c > 1, but the partitioning key is (a, b).
val originalQuery = testRelation.select('a, 'b, 'c, winExpr.as('window)).where('c > 1)
val correctAnswer = testRelation.select('a, 'b, 'c)
.window(winExpr.as('window) :: Nil, 'a.attr :: 'b.attr :: Nil, 'b.asc :: Nil)
Expand All @@ -883,17 +912,63 @@ class FilterPushdownSuite extends PlanTest {
comparePlans(Optimize.execute(originalQuery.analyze), correctAnswer)
}

test("Window: no predicate push down -- compound partition key") {
val winSpec = windowSpec('a.attr + 'b.attr :: 'b.attr :: Nil, 'b.asc :: Nil, UnspecifiedFrame)
test("Window: no predicate push down -- partial compound partition key") {
val winSpec = windowSpec(
partitionSpec = 'a.attr + 'b.attr :: 'b.attr :: Nil,
orderSpec = 'b.asc :: Nil,
UnspecifiedFrame)
val winExpr = windowExpr(count('b), winSpec)

// No push down: the predicate is a > 1, but the partitioning key is (a + b, b)
val originalQuery = testRelation.select('a, 'b, 'c, winExpr.as('window)).where('a > 1)

val winSpecAnalyzed = windowSpec('_w0.attr :: 'b.attr :: Nil, 'b.asc :: Nil, UnspecifiedFrame)
val winSpecAnalyzed = windowSpec(
partitionSpec = '_w0.attr :: 'b.attr :: Nil,
orderSpec = 'b.asc :: Nil,
UnspecifiedFrame)
val winExprAnalyzed = windowExpr(count('b), winSpecAnalyzed)
val correctAnswer = testRelation.select('a, 'b, 'c, ('a + 'b).as("_w0"))
.window(winExprAnalyzed.as('window) :: Nil, '_w0 :: 'b.attr :: Nil, 'b.asc :: Nil)
.where('a > 1).select('a, 'b, 'c, 'window).analyze

comparePlans(Optimize.execute(originalQuery.analyze), correctAnswer)
}

test("Window: no predicate push down -- complex predicates containing non partitioning columns") {
val winSpec =
windowSpec(partitionSpec = 'b.attr :: Nil, orderSpec = 'b.asc :: Nil, UnspecifiedFrame)
val winExpr = windowExpr(count('b), winSpec)

// No push down: the predicate is a + b > 1, but the partitioning key is b.
val originalQuery = testRelation.select('a, 'b, 'c, winExpr.as('window)).where('a + 'b > 1)
val correctAnswer = testRelation
.select('a, 'b, 'c)
.window(winExpr.as('window) :: Nil, 'b.attr :: Nil, 'b.asc :: Nil)
.where('a + 'b > 1).select('a, 'b, 'c, 'window).analyze

comparePlans(Optimize.execute(originalQuery.analyze), correctAnswer)
}

// complex predicates with the same references but different expressions
test("Window: no predicate push down -- complex predicate with different expressions") {
val winSpec = windowSpec(
partitionSpec = 'a.attr + 'b.attr :: Nil,
orderSpec = 'b.asc :: Nil,
UnspecifiedFrame)
val winExpr = windowExpr(count('b), winSpec)

val winSpecAnalyzed = windowSpec(
partitionSpec = '_w0.attr :: Nil,
orderSpec = 'b.asc :: Nil,
UnspecifiedFrame)
val winExprAnalyzed = windowExpr(count('b), winSpecAnalyzed)

// No push down: the predicate is a + b > 1, but the partitioning key is a + b.
val originalQuery = testRelation.select('a, 'b, 'c, winExpr.as('window)).where('a - 'b > 1)
val correctAnswer = testRelation.select('a, 'b, 'c, ('a + 'b).as("_w0"))
.window(winExprAnalyzed.as('window) :: Nil, '_w0 :: Nil, 'b.asc :: Nil)
.where('a - 'b > 1).select('a, 'b, 'c, 'window).analyze

comparePlans(Optimize.execute(originalQuery.analyze), correctAnswer)
}
}