Skip to content

Commit f2f73ed

Browse files
wangyumHyukjinKwon
authored andcommitted
[SPARK-39401][SQL][TESTS] Replace withView with withTempView in CTEInlineSuite
### What changes were proposed in this pull request? This PR replaces `withView` with `withTempView` in `CTEInlineSuite`. ### Why are the changes needed? To use correct API. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Manual testing. Closes apache#36788 from wangyum/SPARK-39401. Authored-by: Yuming Wang <[email protected]> Signed-off-by: Hyukjin Kwon <[email protected]>
1 parent e1ae760 commit f2f73ed

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

sql/core/src/test/scala/org/apache/spark/sql/CTEInlineSuite.scala

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ abstract class CTEInlineSuiteBase
3232
import testImplicits._
3333

3434
test("SPARK-36447: non-deterministic CTE dedup") {
35-
withView("t") {
35+
withTempView("t") {
3636
Seq((0, 1), (1, 2)).toDF("c1", "c2").createOrReplaceTempView("t")
3737
val df = sql(
3838
s"""with
@@ -49,7 +49,7 @@ abstract class CTEInlineSuiteBase
4949
}
5050

5151
test("SPARK-36447: non-deterministic CTE in subquery") {
52-
withView("t") {
52+
withTempView("t") {
5353
Seq((0, 1), (1, 2)).toDF("c1", "c2").createOrReplaceTempView("t")
5454
val df = sql(
5555
s"""with
@@ -66,7 +66,7 @@ abstract class CTEInlineSuiteBase
6666
}
6767

6868
test("SPARK-36447: non-deterministic CTE with one reference should be inlined") {
69-
withView("t") {
69+
withTempView("t") {
7070
Seq((0, 1), (1, 2)).toDF("c1", "c2").createOrReplaceTempView("t")
7171
val df = sql(
7272
s"""with
@@ -86,7 +86,7 @@ abstract class CTEInlineSuiteBase
8686
}
8787

8888
test("SPARK-36447: nested non-deterministic CTEs referenced more than once are not inlined") {
89-
withView("t") {
89+
withTempView("t") {
9090
Seq((0, 1), (1, 2)).toDF("c1", "c2").createOrReplaceTempView("t")
9191
val df = sql(
9292
s"""with
@@ -115,7 +115,7 @@ abstract class CTEInlineSuiteBase
115115
}
116116

117117
test("SPARK-36447: nested CTEs only the deterministic is inlined") {
118-
withView("t") {
118+
withTempView("t") {
119119
Seq((0, 1), (1, 2)).toDF("c1", "c2").createOrReplaceTempView("t")
120120
val df = sql(
121121
s"""with
@@ -144,7 +144,7 @@ abstract class CTEInlineSuiteBase
144144
}
145145

146146
test("SPARK-36447: nested non-deterministic CTEs referenced only once are inlined") {
147-
withView("t") {
147+
withTempView("t") {
148148
Seq((0, 1), (1, 2)).toDF("c1", "c2").createOrReplaceTempView("t")
149149
val df = sql(
150150
s"""with
@@ -173,7 +173,7 @@ abstract class CTEInlineSuiteBase
173173
test("SPARK-36447: With in subquery of main query") {
174174
withSQLConf(
175175
SQLConf.ADAPTIVE_OPTIMIZER_EXCLUDED_RULES.key -> AQEPropagateEmptyRelation.ruleName) {
176-
withView("t") {
176+
withTempView("t") {
177177
Seq((2, 1), (2, 2)).toDF("c1", "c2").createOrReplaceTempView("t")
178178
val df = sql(
179179
s"""with v as (
@@ -200,7 +200,7 @@ abstract class CTEInlineSuiteBase
200200
}
201201

202202
test("SPARK-36447: With in subquery of CTE def") {
203-
withView("t") {
203+
withTempView("t") {
204204
Seq((2, 1), (2, 2)).toDF("c1", "c2").createOrReplaceTempView("t")
205205
val df = sql(
206206
s"""with v as (
@@ -227,7 +227,7 @@ abstract class CTEInlineSuiteBase
227227
}
228228

229229
test("SPARK-36447: nested deterministic CTEs are inlined") {
230-
withView("t") {
230+
withTempView("t") {
231231
Seq((0, 1), (1, 2)).toDF("c1", "c2").createOrReplaceTempView("t")
232232
val df = sql(
233233
s"""with
@@ -256,7 +256,7 @@ abstract class CTEInlineSuiteBase
256256
}
257257

258258
test("SPARK-36447: invalid nested CTEs") {
259-
withView("t") {
259+
withTempView("t") {
260260
Seq((0, 1), (1, 2)).toDF("c1", "c2").createOrReplaceTempView("t")
261261
val ex = intercept[AnalysisException](sql(
262262
s"""with
@@ -275,7 +275,7 @@ abstract class CTEInlineSuiteBase
275275
}
276276

277277
test("CTE Predicate push-down and column pruning") {
278-
withView("t") {
278+
withTempView("t") {
279279
Seq((0, 1), (1, 2)).toDF("c1", "c2").createOrReplaceTempView("t")
280280
val df = sql(
281281
s"""with
@@ -325,7 +325,7 @@ abstract class CTEInlineSuiteBase
325325
}
326326

327327
test("CTE Predicate push-down and column pruning - combined predicate") {
328-
withView("t") {
328+
withTempView("t") {
329329
Seq((0, 1, 2), (1, 2, 3)).toDF("c1", "c2", "c3").createOrReplaceTempView("t")
330330
val df = sql(
331331
s"""with
@@ -378,7 +378,7 @@ abstract class CTEInlineSuiteBase
378378
}
379379

380380
test("Views with CTEs - 1 temp view") {
381-
withView("t", "t2") {
381+
withTempView("t", "t2") {
382382
Seq((0, 1), (1, 2)).toDF("c1", "c2").createOrReplaceTempView("t")
383383
sql(
384384
s"""with
@@ -399,7 +399,7 @@ abstract class CTEInlineSuiteBase
399399
}
400400

401401
test("Views with CTEs - 2 temp views") {
402-
withView("t", "t2", "t3") {
402+
withTempView("t", "t2", "t3") {
403403
Seq((0, 1), (1, 2)).toDF("c1", "c2").createOrReplaceTempView("t")
404404
sql(
405405
s"""with
@@ -422,7 +422,7 @@ abstract class CTEInlineSuiteBase
422422

423423
test("Views with CTEs - temp view + sql view") {
424424
withTable("t") {
425-
withView ("t2", "t3") {
425+
withTempView ("t2", "t3") {
426426
Seq((0, 1), (1, 2)).toDF("c1", "c2").write.saveAsTable("t")
427427
sql(
428428
s"""with
@@ -453,7 +453,7 @@ abstract class CTEInlineSuiteBase
453453
}
454454

455455
test("CTE definitions out of original order when not inlined") {
456-
withView("t1", "t2") {
456+
withTempView("issue_current") {
457457
Seq((1, 2, 10, 100), (2, 3, 20, 200)).toDF("workspace_id", "issue_id", "shard_id", "field_id")
458458
.createOrReplaceTempView("issue_current")
459459
withSQLConf(SQLConf.OPTIMIZER_EXCLUDED_RULES.key ->

0 commit comments

Comments
 (0)