@@ -32,15 +32,19 @@ class Aggregate2Suite extends QueryTest with BeforeAndAfterAll {
3232 override def beforeAll (): Unit = {
3333 originalUseAggregate2 = ctx.conf.useSqlAggregate2
3434 ctx.sql(" set spark.sql.useAggregate2=true" )
35- val data = Seq [(Int , Integer )](
35+ val data = Seq [(Integer , Integer )](
3636 (1 , 10 ),
37+ (null , - 60 ),
3738 (1 , 20 ),
3839 (1 , 30 ),
3940 (2 , 0 ),
41+ (null , - 10 ),
4042 (2 , - 1 ),
4143 (2 , null ),
4244 (2 , null ),
45+ (null , 100 ),
4346 (3 , null ),
47+ (null , null ),
4448 (3 , null )).toDF(" key" , " value" )
4549
4650 data.write.saveAsTable(" agg2" )
@@ -54,7 +58,7 @@ class Aggregate2Suite extends QueryTest with BeforeAndAfterAll {
5458 |FROM agg2
5559 |GROUP BY key
5660 """ .stripMargin),
57- Row (- 0.5 ) :: Row (20.0 ) :: Row (null ) :: Nil )
61+ Row (- 0.5 ) :: Row (20.0 ) :: Row (null ) :: Row ( 10.0 ) :: Nil )
5862 }
5963
6064 test(" test average2" ) {
@@ -79,7 +83,7 @@ class Aggregate2Suite extends QueryTest with BeforeAndAfterAll {
7983 |FROM agg2
8084 |GROUP BY key
8185 """ .stripMargin),
82- Row (1 , 20.0 ) :: Row (2 , - 0.5 ) :: Row (3 , null ) :: Nil )
86+ Row (1 , 20.0 ) :: Row (2 , - 0.5 ) :: Row (3 , null ) :: Row ( null , 10.0 ) :: Nil )
8387
8488 checkAnswer(
8589 ctx.sql(
@@ -88,7 +92,7 @@ class Aggregate2Suite extends QueryTest with BeforeAndAfterAll {
8892 |FROM agg2
8993 |GROUP BY key
9094 """ .stripMargin),
91- Row (20.0 , 1 ) :: Row (- 0.5 , 2 ) :: Row (null , 3 ) :: Nil )
95+ Row (20.0 , 1 ) :: Row (- 0.5 , 2 ) :: Row (null , 3 ) :: Row ( 10.0 , null ) :: Nil )
9296
9397 checkAnswer(
9498 ctx.sql(
@@ -97,14 +101,14 @@ class Aggregate2Suite extends QueryTest with BeforeAndAfterAll {
97101 |FROM agg2
98102 |GROUP BY key + 10
99103 """ .stripMargin),
100- Row (21.5 , 11 ) :: Row (1.0 , 12 ) :: Row (null , 13 ) :: Nil )
104+ Row (21.5 , 11 ) :: Row (1.0 , 12 ) :: Row (null , 13 ) :: Row ( 11.5 , null ) :: Nil )
101105
102106 checkAnswer(
103107 ctx.sql(
104108 """
105109 |SELECT avg(value) FROM agg2
106110 """ .stripMargin),
107- Row (11.8 ) :: Nil )
111+ Row (11.125 ) :: Nil )
108112
109113 checkAnswer(
110114 ctx.sql(
@@ -137,14 +141,14 @@ class Aggregate2Suite extends QueryTest with BeforeAndAfterAll {
137141 |FROM agg2
138142 |GROUP BY key
139143 """ .stripMargin),
140- Row (60.0 , 1 ) :: Row (- 1.0 , 2 ) :: Row (null , 3 ) :: Nil )
144+ Row (60.0 , 1 ) :: Row (- 1.0 , 2 ) :: Row (null , 3 ) :: Row ( 30.0 , null ) :: Nil )
141145
142146 checkAnswer(
143147 ctx.sql(
144148 """
145149 |SELECT mydoublesum(cast(value as double)) FROM agg2
146150 """ .stripMargin),
147- Row (59 .0 ) :: Nil )
151+ Row (89 .0 ) :: Nil )
148152
149153 checkAnswer(
150154 ctx.sql(
@@ -163,7 +167,10 @@ class Aggregate2Suite extends QueryTest with BeforeAndAfterAll {
163167 |FROM agg2
164168 |GROUP BY key
165169 """ .stripMargin),
166- Row (60.0 , 1 , 20.0 ) :: Row (- 1.0 , 2 , - 0.5 ) :: Row (null , 3 , null ) :: Nil )
170+ Row (60.0 , 1 , 20.0 ) ::
171+ Row (- 1.0 , 2 , - 0.5 ) ::
172+ Row (null , 3 , null ) ::
173+ Row (30.0 , null , 10.0 ) :: Nil )
167174
168175 checkAnswer(
169176 ctx.sql(
@@ -179,7 +186,8 @@ class Aggregate2Suite extends QueryTest with BeforeAndAfterAll {
179186 """ .stripMargin),
180187 Row (64.5 , 19.0 , 1 , 55.5 , 20.0 ) ::
181188 Row (5.0 , - 2.5 , 2 , - 7.0 , - 0.5 ) ::
182- Row (null , null , 3 , null , null ) :: Nil )
189+ Row (null , null , 3 , null , null ) ::
190+ Row (null , null , null , null , 10.0 ) :: Nil )
183191 }
184192
185193 override def afterAll (): Unit = {
0 commit comments