1717
1818package org .apache .spark .sql .catalyst .optimizer
1919
20+ import org .apache .spark .sql .catalyst .SimpleCatalystConf
21+ import org .apache .spark .sql .catalyst .analysis .{Analyzer , EmptyFunctionRegistry }
22+ import org .apache .spark .sql .catalyst .catalog .{InMemoryCatalog , SessionCatalog }
2023import org .apache .spark .sql .catalyst .dsl .expressions ._
2124import org .apache .spark .sql .catalyst .dsl .plans ._
2225import org .apache .spark .sql .catalyst .expressions .Literal
@@ -25,6 +28,9 @@ import org.apache.spark.sql.catalyst.plans.logical.{LocalRelation, LogicalPlan}
2528import org .apache .spark .sql .catalyst .rules .RuleExecutor
2629
2730class AggregateOptimizeSuite extends PlanTest {
31+ val conf = new SimpleCatalystConf (caseSensitiveAnalysis = false )
32+ val catalog = new SessionCatalog (new InMemoryCatalog , EmptyFunctionRegistry , conf)
33+ val analyzer = new Analyzer (catalog, conf)
2834
2935 object Optimize extends RuleExecutor [LogicalPlan ] {
3036 val batches = Batch (" Aggregate" , FixedPoint (100 ),
@@ -47,10 +53,10 @@ class AggregateOptimizeSuite extends PlanTest {
4753 test(" remove repetition in grouping expression" ) {
4854 val input = LocalRelation (' a .int, ' b .int, ' c .int)
4955
50- val query = input.groupBy(' a , ' b , ' b , ' a )(sum(' c ))
51- val optimized = Optimize .execute(query)
56+ val query = input.groupBy(' a + 1 , ' b + 2 , Literal ( 1 ) + ' A , Literal ( 2 ) + ' B )(sum(' c ))
57+ val optimized = Optimize .execute(analyzer.execute( query) )
5258
53- val correctAnswer = input.groupBy(' a , ' b )(sum(' c ))
59+ val correctAnswer = analyzer.execute( input.groupBy(' a + 1 , ' b + 2 )(sum(' c ) ))
5460
5561 comparePlans(optimized, correctAnswer)
5662 }
0 commit comments