Skip to content

Commit 7782b61

Browse files
srowendongjoon-hyun
authored andcommitted
[SPARK-29392][CORE][SQL][FOLLOWUP] Avoid deprecated (in 2.13) Symbol syntax 'foo in favor of simpler expression, where it generated deprecation warnings
TL;DR - this is more of the same change in apache#26748 I told you it'd be iterative! Closes apache#26765 from srowen/SPARK-29392.3. Authored-by: Sean Owen <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent 5892bbf commit 7782b61

13 files changed

+183
-176
lines changed

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/DistributionSuite.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class DistributionSuite extends SparkFunSuite {
221221

222222
checkSatisfied(
223223
RangePartitioning(Seq($"a".asc, $"b".asc, $"c".asc), 10),
224-
OrderedDistribution(Seq($"a".asc, $"b".asc, $"c".asc, 'd.desc)),
224+
OrderedDistribution(Seq($"a".asc, $"b".asc, $"c".asc, $"d".desc)),
225225
true)
226226

227227
// TODO: We can have an optimization to first sort the dataset
@@ -240,7 +240,7 @@ class DistributionSuite extends SparkFunSuite {
240240

241241
checkSatisfied(
242242
RangePartitioning(Seq($"a".asc, $"b".asc, $"c".asc), 10),
243-
OrderedDistribution(Seq($"a".asc, $"b".asc, 'd.desc)),
243+
OrderedDistribution(Seq($"a".asc, $"b".asc, $"d".desc)),
244244
false)
245245

246246
// RangePartitioning can satisfy ClusteredDistribution iff its ordering expressions are a subset

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/AnalysisErrorSuite.scala

+28-28
Original file line numberDiff line numberDiff line change
@@ -112,32 +112,32 @@ class AnalysisErrorSuite extends AnalysisTest {
112112
errorTest(
113113
"scalar subquery with 2 columns",
114114
testRelation.select(
115-
(ScalarSubquery(testRelation.select('a, dateLit.as('b))) + Literal(1)).as('a)),
115+
(ScalarSubquery(testRelation.select($"a", dateLit.as("b"))) + Literal(1)).as("a")),
116116
"Scalar subquery must return only one column, but got 2" :: Nil)
117117

118118
errorTest(
119119
"scalar subquery with no column",
120-
testRelation.select(ScalarSubquery(LocalRelation()).as('a)),
120+
testRelation.select(ScalarSubquery(LocalRelation()).as("a")),
121121
"Scalar subquery must return only one column, but got 0" :: Nil)
122122

123123
errorTest(
124124
"single invalid type, single arg",
125-
testRelation.select(TestFunction(dateLit :: Nil, IntegerType :: Nil).as('a)),
125+
testRelation.select(TestFunction(dateLit :: Nil, IntegerType :: Nil).as("a")),
126126
"cannot resolve" :: "testfunction(CAST(NULL AS DATE))" :: "argument 1" :: "requires int type" ::
127127
"'CAST(NULL AS DATE)' is of date type" :: Nil)
128128

129129
errorTest(
130130
"single invalid type, second arg",
131131
testRelation.select(
132-
TestFunction(dateLit :: dateLit :: Nil, DateType :: IntegerType :: Nil).as('a)),
132+
TestFunction(dateLit :: dateLit :: Nil, DateType :: IntegerType :: Nil).as("a")),
133133
"cannot resolve" :: "testfunction(CAST(NULL AS DATE), CAST(NULL AS DATE))" ::
134134
"argument 2" :: "requires int type" ::
135135
"'CAST(NULL AS DATE)' is of date type" :: Nil)
136136

137137
errorTest(
138138
"multiple invalid type",
139139
testRelation.select(
140-
TestFunction(dateLit :: dateLit :: Nil, IntegerType :: IntegerType :: Nil).as('a)),
140+
TestFunction(dateLit :: dateLit :: Nil, IntegerType :: IntegerType :: Nil).as("a")),
141141
"cannot resolve" :: "testfunction(CAST(NULL AS DATE), CAST(NULL AS DATE))" ::
142142
"argument 1" :: "argument 2" :: "requires int type" ::
143143
"'CAST(NULL AS DATE)' is of date type" :: Nil)
@@ -150,7 +150,7 @@ class AnalysisErrorSuite extends AnalysisTest {
150150
WindowSpecDefinition(
151151
UnresolvedAttribute("a") :: Nil,
152152
SortOrder(UnresolvedAttribute("b"), Ascending) :: Nil,
153-
UnspecifiedFrame)).as('window)),
153+
UnspecifiedFrame)).as("window")),
154154
"not supported within a window function" :: Nil)
155155

156156
errorTest(
@@ -161,7 +161,7 @@ class AnalysisErrorSuite extends AnalysisTest {
161161
WindowSpecDefinition(
162162
UnresolvedAttribute("a") :: Nil,
163163
SortOrder(UnresolvedAttribute("b"), Ascending) :: Nil,
164-
UnspecifiedFrame)).as('window)),
164+
UnspecifiedFrame)).as("window")),
165165
"Distinct window functions are not supported" :: Nil)
166166

167167
errorTest(
@@ -176,7 +176,7 @@ class AnalysisErrorSuite extends AnalysisTest {
176176

177177
errorTest(
178178
"nested aggregate functions",
179-
testRelation.groupBy('a)(
179+
testRelation.groupBy($"a")(
180180
AggregateExpression(
181181
Max(AggregateExpression(Count(Literal(1)), Complete, isDistinct = false)),
182182
Complete,
@@ -192,39 +192,39 @@ class AnalysisErrorSuite extends AnalysisTest {
192192
WindowSpecDefinition(
193193
UnresolvedAttribute("a") :: Nil,
194194
SortOrder(UnresolvedAttribute("b"), Ascending) :: Nil,
195-
SpecifiedWindowFrame(RangeFrame, Literal(1), Literal(2)))).as('window)),
195+
SpecifiedWindowFrame(RangeFrame, Literal(1), Literal(2)))).as("window")),
196196
"window frame" :: "must match the required frame" :: Nil)
197197

198198
errorTest(
199199
"too many generators",
200-
listRelation.select(Explode('list).as('a), Explode('list).as('b)),
200+
listRelation.select(Explode($"list").as("a"), Explode($"list").as("b")),
201201
"only one generator" :: "explode" :: Nil)
202202

203203
errorTest(
204204
"unresolved attributes",
205-
testRelation.select('abcd),
205+
testRelation.select($"abcd"),
206206
"cannot resolve" :: "abcd" :: Nil)
207207

208208
errorTest(
209209
"unresolved attributes with a generated name",
210-
testRelation2.groupBy('a)(max('b))
211-
.where(sum('b) > 0)
212-
.orderBy('havingCondition.asc),
210+
testRelation2.groupBy($"a")(max($"b"))
211+
.where(sum($"b") > 0)
212+
.orderBy($"havingCondition".asc),
213213
"cannot resolve" :: "havingCondition" :: Nil)
214214

215215
errorTest(
216216
"unresolved star expansion in max",
217-
testRelation2.groupBy('a)(sum(UnresolvedStar(None))),
217+
testRelation2.groupBy($"a")(sum(UnresolvedStar(None))),
218218
"Invalid usage of '*'" :: "in expression 'sum'" :: Nil)
219219

220220
errorTest(
221221
"sorting by unsupported column types",
222-
mapRelation.orderBy('map.asc),
222+
mapRelation.orderBy($"map".asc),
223223
"sort" :: "type" :: "map<int,int>" :: Nil)
224224

225225
errorTest(
226226
"sorting by attributes are not from grouping expressions",
227-
testRelation2.groupBy('a, 'c)('a, 'c, count('a).as("a3")).orderBy('b.asc),
227+
testRelation2.groupBy($"a", $"c")($"a", $"c", count($"a").as("a3")).orderBy($"b".asc),
228228
"cannot resolve" :: "'`b`'" :: "given input columns" :: "[a, a3, c]" :: Nil)
229229

230230
errorTest(
@@ -239,7 +239,7 @@ class AnalysisErrorSuite extends AnalysisTest {
239239

240240
errorTest(
241241
"missing group by",
242-
testRelation2.groupBy('a)('b),
242+
testRelation2.groupBy($"a")($"b"),
243243
"'`b`'" :: "group by" :: Nil
244244
)
245245

@@ -317,7 +317,7 @@ class AnalysisErrorSuite extends AnalysisTest {
317317
errorTest(
318318
"SPARK-9955: correct error message for aggregate",
319319
// When parse SQL string, we will wrap aggregate expressions with UnresolvedAlias.
320-
testRelation2.where('bad_column > 1).groupBy('a)(UnresolvedAlias(max('b))),
320+
testRelation2.where($"bad_column" > 1).groupBy($"a")(UnresolvedAlias(max($"b"))),
321321
"cannot resolve '`bad_column`'" :: Nil)
322322

323323
errorTest(
@@ -385,14 +385,14 @@ class AnalysisErrorSuite extends AnalysisTest {
385385

386386
errorTest(
387387
"generator nested in expressions",
388-
listRelation.select(Explode('list) + 1),
388+
listRelation.select(Explode($"list") + 1),
389389
"Generators are not supported when it's nested in expressions, but got: (explode(list) + 1)"
390390
:: Nil
391391
)
392392

393393
errorTest(
394394
"generator appears in operator which is not Project",
395-
listRelation.sortBy(Explode('list).asc),
395+
listRelation.sortBy(Explode($"list").asc),
396396
"Generators are not supported outside the SELECT clause, but got: Sort" :: Nil
397397
)
398398

@@ -410,7 +410,7 @@ class AnalysisErrorSuite extends AnalysisTest {
410410

411411
errorTest(
412412
"more than one generators in SELECT",
413-
listRelation.select(Explode('list), Explode('list)),
413+
listRelation.select(Explode($"list"), Explode($"list")),
414414
"Only one generator allowed per select clause but found 2: explode(list), explode(list)" :: Nil
415415
)
416416

@@ -510,20 +510,20 @@ class AnalysisErrorSuite extends AnalysisTest {
510510
}
511511

512512
test("Join can work on binary types but can't work on map types") {
513-
val left = LocalRelation('a.binary, 'b.map(StringType, StringType))
514-
val right = LocalRelation('c.binary, 'd.map(StringType, StringType))
513+
val left = LocalRelation(Symbol("a").binary, Symbol("b").map(StringType, StringType))
514+
val right = LocalRelation(Symbol("c").binary, Symbol("d").map(StringType, StringType))
515515

516516
val plan1 = left.join(
517517
right,
518518
joinType = Cross,
519-
condition = Some('a === 'c))
519+
condition = Some(Symbol("a") === Symbol("c")))
520520

521521
assertAnalysisSuccess(plan1)
522522

523523
val plan2 = left.join(
524524
right,
525525
joinType = Cross,
526-
condition = Some('b === 'd))
526+
condition = Some(Symbol("b") === Symbol("d")))
527527
assertAnalysisError(plan2, "EqualTo does not support ordering on type map" :: Nil)
528528
}
529529

@@ -596,7 +596,7 @@ class AnalysisErrorSuite extends AnalysisTest {
596596
val plan5 = Filter(
597597
Exists(
598598
Sample(0.0, 0.5, false, 1L,
599-
Filter(EqualTo(UnresolvedAttribute("a"), b), LocalRelation(b))).select('b)
599+
Filter(EqualTo(UnresolvedAttribute("a"), b), LocalRelation(b))).select("b")
600600
),
601601
LocalRelation(a))
602602
assertAnalysisError(plan5,
@@ -606,7 +606,7 @@ class AnalysisErrorSuite extends AnalysisTest {
606606
test("Error on filter condition containing aggregate expressions") {
607607
val a = AttributeReference("a", IntegerType)()
608608
val b = AttributeReference("b", IntegerType)()
609-
val plan = Filter('a === UnresolvedFunction("max", Seq(b), true), LocalRelation(a, b))
609+
val plan = Filter(Symbol("a") === UnresolvedFunction("max", Seq(b), true), LocalRelation(a, b))
610610
assertAnalysisError(plan,
611611
"Aggregate/Window/Generate expressions are not valid in where clause of the query" :: Nil)
612612
}

0 commit comments

Comments
 (0)