-
Notifications
You must be signed in to change notification settings - Fork 29k
[Spark-25993][SQL][TEST]Add test cases for CREATE EXTERNAL TABLE with subdirectories #23108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
4e45ef9
e238764
e731746
d6e582b
39ebcf8
d75b923
fe472c8
51d1d78
d851169
fef8c68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2370,4 +2370,51 @@ class HiveDDLSuite | |
| )) | ||
| } | ||
| } | ||
|
|
||
| test("SPARK-25993 Add test cases for resolution of Parquet table location") { | ||
|
||
| withTempPath { path => | ||
| val someDF1 = Seq((1, 1, "parq1"), (2, 2, "parq2")).toDF("c1", "c2", "c3").repartition(1) | ||
|
||
| withTable("tbl1", "tbl2", "tbl3") { | ||
| val dataDir = s"${path.getCanonicalPath}/l3/l2/l1/" | ||
|
||
| val parentDir = s"${path.getCanonicalPath}/l3/l2/" | ||
| val l3Dir = s"${path.getCanonicalPath}/l3/" | ||
| val wildcardParentDir = new File(s"${path}/l3/l2/*").toURI | ||
| val wildcardL3Dir = new File(s"${path}/l3/*").toURI | ||
| someDF1.write.parquet(dataDir) | ||
| val parentDirStatement = | ||
| s""" | ||
| |CREATE EXTERNAL TABLE tbl1( | ||
| | c1 int, | ||
| | c2 int, | ||
| | c3 string) | ||
| |STORED AS parquet | ||
| |LOCATION '${parentDir}'""".stripMargin | ||
| sql(parentDirStatement) | ||
| checkAnswer(sql("select * from tbl1"), Nil) | ||
|
|
||
| val wildcardStatement = | ||
| s""" | ||
| |CREATE EXTERNAL TABLE tbl2( | ||
| | c1 int, | ||
| | c2 int, | ||
| | c3 string) | ||
| |STORED AS parquet | ||
| |LOCATION '${wildcardParentDir}'""".stripMargin | ||
| sql(wildcardStatement) | ||
| checkAnswer(sql("select * from tbl2"), | ||
| (1 to 2).map(i => Row(i, i, s"parq$i"))) | ||
|
|
||
| val wildcardL3Statement = | ||
| s""" | ||
|
||
| |CREATE EXTERNAL TABLE tbl3( | ||
| | c1 int, | ||
| | c2 int, | ||
| | c3 string) | ||
| |STORED AS parquet | ||
| |LOCATION '${wildcardL3Dir}'""".stripMargin | ||
| sql(wildcardL3Statement) | ||
| checkAnswer(sql("select * from tbl3"), Nil) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -190,4 +190,12 @@ class HiveOrcSourceSuite extends OrcSuite with TestHiveSingleton { | |
| } | ||
| } | ||
| } | ||
|
|
||
| test("SPARK-25993 Add test cases for resolution of ORC table location") { | ||
|
||
| Seq(true, false).foreach { convertMetastore => | ||
| withSQLConf(HiveUtils.CONVERT_METASTORE_ORC.key -> s"$convertMetastore") { | ||
| testORCTableLocation(convertMetastore) | ||
| } | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this test helper function is only used in
HiveOrcSourceSuite, can we move this intoHiveOrcSourceSuite?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I moved.