You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/RemoveRedundantAliasAndProjectSuite.scala
+28-23Lines changed: 28 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -45,9 +45,10 @@ class RemoveRedundantAliasAndProjectSuite extends PlanTest with PredicateHelper
45
45
46
46
test("all expressions in project list are aliased child output but with different order") {
47
47
valrelation=LocalRelation('a.int, 'b.int)
48
-
valquery= relation.select('b, 'a).analyze
49
-
valoptimized=Optimize.execute(relation.select('b as 'b, 'a as 'a).analyze)
50
-
comparePlans(optimized, query)
48
+
valquery= relation.select('b as 'b, 'a as 'a).analyze
49
+
valoptimized=Optimize.execute(query)
50
+
valexpected= relation.select('b, 'a).analyze
51
+
comparePlans(optimized, expected)
51
52
}
52
53
53
54
test("some expressions in project list are aliased child output") {
@@ -59,16 +60,18 @@ class RemoveRedundantAliasAndProjectSuite extends PlanTest with PredicateHelper
59
60
60
61
test("some expressions in project list are aliased child output but with different order") {
61
62
valrelation=LocalRelation('a.int, 'b.int)
62
-
valquery= relation.select('b, 'a).analyze
63
-
valoptimized=Optimize.execute(relation.select('b as 'b, 'a).analyze)
64
-
comparePlans(optimized, query)
63
+
valquery= relation.select('b as 'b, 'a).analyze
64
+
valoptimized=Optimize.execute(query)
65
+
valexpected= relation.select('b, 'a).analyze
66
+
comparePlans(optimized, expected)
65
67
}
66
68
67
69
test("some expressions in project list are not Alias or Attribute") {
68
70
valrelation=LocalRelation('a.int, 'b.int)
69
-
valquery= relation.select('a, 'b+1).analyze
70
-
valoptimized=Optimize.execute(relation.select('a as 'a, 'b+1).analyze)
71
-
comparePlans(optimized, query)
71
+
valquery= relation.select('a as 'a, 'b+1).analyze
72
+
valoptimized=Optimize.execute(query)
73
+
valexpected= relation.select('a, 'b+1).analyze
74
+
comparePlans(optimized, expected)
72
75
}
73
76
74
77
test("some expressions in project list are aliased child output but with metadata") {
@@ -83,32 +86,34 @@ class RemoveRedundantAliasAndProjectSuite extends PlanTest with PredicateHelper
83
86
test("retain deduplicating alias in self-join") {
84
87
valrelation=LocalRelation('a.int)
85
88
valfragment= relation.select('a as 'a)
86
-
valquery=relation.join(relation.select('a as 'a)).analyze
87
-
valoptimized=Optimize.execute(
88
-
fragment.select('a as 'a).join(fragment.select('a as 'a)).analyze)
89
-
comparePlans(optimized, query)
89
+
valquery=fragment.select('a as 'a).join(fragment.select('a as 'a)).analyze
90
+
valoptimized=Optimize.execute(query)
91
+
valexpected= relation.join(relation.select('a as 'a)).analyze
92
+
comparePlans(optimized, expected)
90
93
}
91
94
92
95
test("alias removal should not break after push project through union") {
93
96
valr1=LocalRelation('a.int)
94
97
valr2=LocalRelation('b.int)
95
-
valoptimized=Optimize.execute(
96
-
r1.select('a as 'a).union(r2.select('b as 'b)).select('a).analyze)
97
-
valquery= r1.union(r2)
98
-
comparePlans(optimized, query)
98
+
valquery=r1.select('a as 'a).union(r2.select('b as 'b)).select('a).analyze
99
+
valoptimized=Optimize.execute(query)
100
+
valexpected= r1.union(r2)
101
+
comparePlans(optimized, expected)
99
102
}
100
103
101
104
test("remove redundant alias from aggregate") {
102
105
valrelation=LocalRelation('a.int, 'b.int)
103
-
valoptimized=Optimize.execute(relation.groupBy('a as 'a)('a as 'a, sum('b)).analyze)
0 commit comments