Skip to content

Commit 9bc32ab

Browse files
committed
address comments
1 parent 9722230 commit 9bc32ab

File tree

2 files changed

+37
-24
lines changed

2 files changed

+37
-24
lines changed

sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveParquetSourceSuite.scala

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,11 @@ class HiveParquetSourceSuite extends ParquetPartitioningTest {
249249
|LOCATION '${s"${path.getCanonicalPath}"}'""".stripMargin
250250
sql(topDirStatement)
251251
if (parquetConversion == "true") {
252-
checkAnswer(sql("select * from tbl1"), Nil)
252+
checkAnswer(sql("SELECT * FROM tbl1"), Nil)
253253
} else {
254-
intercept[IOException](sql("select * from tbl1").show())
254+
val msg = intercept[IOException] {sql("SELECT * FROM tbl1").show()
255+
}.getMessage
256+
assert(msg.contains("Not a file:"))
255257
}
256258

257259
val l1DirStatement =
@@ -264,10 +266,13 @@ class HiveParquetSourceSuite extends ParquetPartitioningTest {
264266
|LOCATION '${s"${path.getCanonicalPath}/l1/"}'""".stripMargin
265267
sql(l1DirStatement)
266268
if (parquetConversion == "true") {
267-
checkAnswer(sql("select * from tbl2"),
269+
checkAnswer(sql("SELECT * FROM tbl2"),
268270
(1 to 2).map(i => Row(i, i, s"parq$i")))
269271
} else {
270-
intercept[IOException](sql("select * from tbl2").show())
272+
val msg = intercept[IOException] {
273+
sql("SELECT * FROM tbl2").show()
274+
}.getMessage
275+
assert(msg.contains("Not a file:"))
271276
}
272277

273278
val l2DirStatement =
@@ -280,10 +285,12 @@ class HiveParquetSourceSuite extends ParquetPartitioningTest {
280285
|LOCATION '${s"${path.getCanonicalPath}/l1/l2/"}'""".stripMargin
281286
sql(l2DirStatement)
282287
if (parquetConversion == "true") {
283-
checkAnswer(sql("select * from tbl3"),
288+
checkAnswer(sql("SELECT * FROM tbl3"),
284289
(3 to 4).map(i => Row(i, i, s"parq$i")))
285290
} else {
286-
intercept[IOException](sql("select * from tbl3").show())
291+
val msg = intercept[IOException] {sql("SELECT * FROM tbl3").show()
292+
}.getMessage
293+
assert(msg.contains("Not a file:"))
287294
}
288295

289296
val wildcardTopDirStatement =
@@ -296,10 +303,13 @@ class HiveParquetSourceSuite extends ParquetPartitioningTest {
296303
|LOCATION '${new File(s"${path}/*").toURI}'""".stripMargin
297304
sql(wildcardTopDirStatement)
298305
if (parquetConversion == "true") {
299-
checkAnswer(sql("select * from tbl4"),
306+
checkAnswer(sql("SELECT * FROM tbl4"),
300307
(1 to 2).map(i => Row(i, i, s"parq$i")))
301308
} else {
302-
intercept[IOException](sql("select * from tbl4").show())
309+
val msg = intercept[IOException] {
310+
sql("SELECT * FROM tbl4").show()
311+
}.getMessage
312+
assert(msg.contains("Not a file:"))
303313
}
304314

305315
val wildcardL1DirStatement =
@@ -312,10 +322,12 @@ class HiveParquetSourceSuite extends ParquetPartitioningTest {
312322
|LOCATION '${new File(s"${path}/l1/*").toURI}'""".stripMargin
313323
sql(wildcardL1DirStatement)
314324
if (parquetConversion == "true") {
315-
checkAnswer(sql("select * from tbl5"),
325+
checkAnswer(sql("SELECT * FROM tbl5"),
316326
(1 to 4).map(i => Row(i, i, s"parq$i")))
317327
} else {
318-
intercept[IOException](sql("select * from tbl5").show())
328+
val msg = intercept[IOException] {sql("SELECT * FROM tbl5").show()
329+
}.getMessage
330+
assert(msg.contains("Not a file:"))
319331
}
320332

321333
val wildcardL2DirStatement =
@@ -327,7 +339,7 @@ class HiveParquetSourceSuite extends ParquetPartitioningTest {
327339
|STORED AS parquet
328340
|LOCATION '${new File(s"${path}/l1/l2/*").toURI}'""".stripMargin
329341
sql(wildcardL2DirStatement)
330-
checkAnswer(sql("select * from tbl6"),
342+
checkAnswer(sql("SELECT * FROM tbl6"),
331343
(3 to 6).map(i => Row(i, i, s"parq$i")))
332344
}
333345
}

sql/hive/src/test/scala/org/apache/spark/sql/hive/orc/HiveOrcSourceSuite.scala

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -176,32 +176,33 @@ class HiveOrcSourceSuite extends OrcSuite with TestHiveSingleton {
176176
withSQLConf(HiveUtils.CONVERT_METASTORE_ORC.key -> s"$convertMetastore") {
177177
withTempDir { dir =>
178178
try {
179-
hiveClient.runSqlHive("USE default")
180-
hiveClient.runSqlHive(
179+
sql("USE default")
180+
sql(
181181
"""
182182
|CREATE EXTERNAL TABLE hive_orc(
183183
| C1 INT,
184184
| C2 INT,
185185
| C3 STRING)
186-
|STORED AS orc""".stripMargin)
186+
|STORED AS orc
187+
|LOCATION '${new File(s"${dir.getCanonicalPath}").toURI}'""".stripMargin)
188+
187189
// Hive throws an exception if I assign the location in the create table statement.
188-
hiveClient.runSqlHive(
189-
s"ALTER TABLE hive_orc SET LOCATION " +
190+
sql(s"ALTER TABLE hive_orc SET LOCATION " +
190191
s"'${new File(s"${dir.getCanonicalPath}/l1/").toURI}'")
191192
hiveClient.runSqlHive(
192193
"""
193194
|INSERT INTO TABLE hive_orc
194195
|VALUES (1, 1, 'orc1'), (2, 2, 'orc2')""".stripMargin)
195196

196-
hiveClient.runSqlHive(
197+
sql(
197198
s"ALTER TABLE hive_orc SET LOCATION " +
198199
s"'${new File(s"${dir.getCanonicalPath}/l1/l2/").toURI}'")
199200
hiveClient.runSqlHive(
200201
"""
201202
|INSERT INTO TABLE hive_orc
202203
|VALUES (3, 3, 'orc3'), (4, 4, 'orc4')""".stripMargin)
203204

204-
hiveClient.runSqlHive(
205+
sql(
205206
s"ALTER TABLE hive_orc SET LOCATION " +
206207
s"'${new File(s"${dir.getCanonicalPath}/l1/l2/l3/").toURI}'")
207208
hiveClient.runSqlHive(
@@ -219,7 +220,7 @@ class HiveOrcSourceSuite extends OrcSuite with TestHiveSingleton {
219220
|STORED AS orc
220221
|LOCATION '${s"${dir.getCanonicalPath}"}'""".stripMargin
221222
sql(topDirStatement)
222-
val topDirSqlStatement = s"select * from tbl1"
223+
val topDirSqlStatement = s"SELECT * FROM tbl1"
223224
if (convertMetastore) {
224225
checkAnswer(sql(topDirSqlStatement), Nil)
225226
} else {
@@ -236,7 +237,7 @@ class HiveOrcSourceSuite extends OrcSuite with TestHiveSingleton {
236237
|STORED AS orc
237238
|LOCATION '${s"${dir.getCanonicalPath}/l1/"}'""".stripMargin
238239
sql(l1DirStatement)
239-
val l1DirSqlStatement = s"select * from tbl2"
240+
val l1DirSqlStatement = s"SELECT * FROM tbl2"
240241
if (convertMetastore) {
241242
checkAnswer(sql(l1DirSqlStatement),
242243
(1 to 2).map(i => Row(i, i, s"orc$i")))
@@ -254,7 +255,7 @@ class HiveOrcSourceSuite extends OrcSuite with TestHiveSingleton {
254255
|STORED AS orc
255256
|LOCATION '${s"${dir.getCanonicalPath}/l1/l2/"}'""".stripMargin
256257
sql(l2DirStatement)
257-
val l2DirSqlStatement = s"select * from tbl3"
258+
val l2DirSqlStatement = s"SELECT * FROM tbl3"
258259
if (convertMetastore) {
259260
checkAnswer(sql(l2DirSqlStatement),
260261
(3 to 4).map(i => Row(i, i, s"orc$i")))
@@ -272,7 +273,7 @@ class HiveOrcSourceSuite extends OrcSuite with TestHiveSingleton {
272273
|STORED AS orc
273274
|LOCATION '${new File(s"${dir}/*").toURI}'""".stripMargin
274275
sql(wildcardTopDirStatement)
275-
val wildcardTopDirSqlStatement = s"select * from tbl4"
276+
val wildcardTopDirSqlStatement = s"SELECT * FROM tbl4"
276277
if (convertMetastore) {
277278
checkAnswer(sql(wildcardTopDirSqlStatement),
278279
(1 to 2).map(i => Row(i, i, s"orc$i")))
@@ -289,7 +290,7 @@ class HiveOrcSourceSuite extends OrcSuite with TestHiveSingleton {
289290
|STORED AS orc
290291
|LOCATION '${new File(s"${dir}/l1/*").toURI}'""".stripMargin
291292
sql(wildcardL1DirStatement)
292-
val wildcardL1DirSqlStatement = s"select * from tbl5"
293+
val wildcardL1DirSqlStatement = s"SELECT * FROM tbl5"
293294
if (convertMetastore) {
294295
checkAnswer(sql(wildcardL1DirSqlStatement),
295296
(1 to 4).map(i => Row(i, i, s"orc$i")))
@@ -306,7 +307,7 @@ class HiveOrcSourceSuite extends OrcSuite with TestHiveSingleton {
306307
|STORED AS orc
307308
|LOCATION '${new File(s"${dir}/l1/l2/*").toURI}'""".stripMargin
308309
sql(wildcardL2Statement)
309-
val wildcardL2SqlStatement = s"select * from tbl6"
310+
val wildcardL2SqlStatement = s"SELECT * FROM tbl6"
310311
if (convertMetastore) {
311312
checkAnswer(sql(wildcardL2SqlStatement),
312313
(3 to 6).map(i => Row(i, i, s"orc$i")))

0 commit comments

Comments
 (0)