Repository: spark
Updated Branches:
  refs/heads/master 89608cf26 -> 68f2142cf


[SQL] Duplicate test exception in SQLQueryTestSuite due to meta 
files(.DS_Store) on Mac

## What changes were proposed in this pull request?
After adding the tests for subquery, we now have multiple level of directories 
under "sql-tests/inputs".  Some times on Mac while using Finder application it 
creates the meta data files called ".DS_Store". When these files are present at 
different levels in directory hierarchy, we get duplicate test exception while 
running the tests  as we just use the file name as the test case name. In this 
PR, we use the relative file path from the base directory along with the test 
file as the test name. Also after this change, we can have the same test file 
name under different directory like exists/basic.sql , in/basic.sql. Here is 
the truncated output of the test run after the change.

```SQL
info] SQLQueryTestSuite:
[info] - arithmetic.sql (5 seconds, 235 milliseconds)
[info] - array.sql (536 milliseconds)
[info] - blacklist.sql !!! IGNORED !!!
[info] - cast.sql (550 milliseconds)
....
....
....
[info] - union.sql (315 milliseconds)
[info] - subquery/.DS_Store !!! IGNORED !!!
[info] - subquery/exists-subquery/.DS_Store !!! IGNORED !!!
[info] - subquery/exists-subquery/exists-aggregate.sql (2 seconds, 451 
milliseconds)
....
....
[info] - subquery/in-subquery/in-group-by.sql (12 seconds, 264 milliseconds)
....
....
[info] - subquery/scalar-subquery/scalar-subquery-predicate.sql (7 seconds, 769 
milliseconds)
[info] - subquery/scalar-subquery/scalar-subquery-select.sql (4 seconds, 119 
milliseconds)
```
Since this is a simple change, i haven't created a JIRA for it.
## How was this patch tested?
Manually verified. This is change to test infrastructure

Author: Dilip Biswal <dbis...@us.ibm.com>

Closes #17060 from dilipbiswal/sqlquerytestsuite.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/68f2142c
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/68f2142c
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/68f2142c

Branch: refs/heads/master
Commit: 68f2142cfd2ca632a4afb0cc29cc358edbb21f8d
Parents: 89608cf
Author: Dilip Biswal <dbis...@us.ibm.com>
Authored: Sat Feb 25 23:56:57 2017 -0800
Committer: Xiao Li <gatorsm...@gmail.com>
Committed: Sat Feb 25 23:56:57 2017 -0800

----------------------------------------------------------------------
 .../scala/org/apache/spark/sql/SQLQueryTestSuite.scala    | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/68f2142c/sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala
----------------------------------------------------------------------
diff --git 
a/sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala 
b/sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala
index 91aecca..0b3da9a 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala
@@ -98,7 +98,9 @@ class SQLQueryTestSuite extends QueryTest with 
SharedSQLContext {
 
   /** List of test cases to ignore, in lower cases. */
   private val blackList = Set(
-    "blacklist.sql"  // Do NOT remove this one. It is here to test the 
blacklist functionality.
+    "blacklist.sql",  // Do NOT remove this one. It is here to test the 
blacklist functionality.
+    ".DS_Store"       // A meta-file that may be created on Mac by Finder App.
+                      // We should ignore this file from processing.
   )
 
   // Create all the test cases.
@@ -121,7 +123,7 @@ class SQLQueryTestSuite extends QueryTest with 
SharedSQLContext {
   }
 
   private def createScalaTestCase(testCase: TestCase): Unit = {
-    if (blackList.contains(testCase.name.toLowerCase)) {
+    if (blackList.exists(t => 
testCase.name.toLowerCase.contains(t.toLowerCase))) {
       // Create a test case to ignore this case.
       ignore(testCase.name) { /* Do nothing */ }
     } else {
@@ -241,7 +243,9 @@ class SQLQueryTestSuite extends QueryTest with 
SharedSQLContext {
   private def listTestCases(): Seq[TestCase] = {
     listFilesRecursively(new File(inputFilePath)).map { file =>
       val resultFile = file.getAbsolutePath.replace(inputFilePath, 
goldenFilePath) + ".out"
-      TestCase(file.getName, file.getAbsolutePath, resultFile)
+      val absPath = file.getAbsolutePath
+      val testCaseName = 
absPath.stripPrefix(inputFilePath).stripPrefix(File.separator)
+      TestCase(testCaseName, absPath, resultFile)
     }
   }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to