Skip to content
Closed
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ class SQLQueryTestSuite extends QueryTest with SharedSQLContext {
private val inputFilePath = new File(baseResourcePath, "inputs").getAbsolutePath
private val goldenFilePath = new File(baseResourcePath, "results").getAbsolutePath

private val validTestFileExtensionsRegEx = ".*\\.sql"

/** 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.
".DS_Store" // A meta-file that may be created on Mac by Finder App.
// We should ignore this file from processing.
"blacklist.sql" // Do NOT remove this one. It is here to test the blacklist functionality.
)

// Create all the test cases.
Expand Down Expand Up @@ -329,7 +329,8 @@ class SQLQueryTestSuite extends QueryTest with SharedSQLContext {
/** Returns all the files (not directories) in a directory, recursively. */
private def listFilesRecursively(path: File): Seq[File] = {
val (dirs, files) = path.listFiles().partition(_.isDirectory)
files ++ dirs.flatMap(listFilesRecursively)
val filteredFiles = files.filter (_.getName matches validTestFileExtensionsRegEx)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's avoid postfix syntax.
Not that it matters, but it is probably a little more efficient to make the regex a regex above with .r and then match with that pattern here.

Copy link
Contributor Author

@dilipbiswal dilipbiswal Apr 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@srowen Thanks.. Sure... I will make the change. I wanted to confirm one thing.. so initially i had it as a regex as i thought, it may be easier for us to add more extensions o than just .sql in the future. But if we are going to stay with .sql, should we just do a endsWith check instead ? WDYT ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All sounds fine. The regex could match more patterns later, or could be many regexes. Or could indeed just check for suffixes for now for simplicity and make it more complicated later.

filteredFiles ++ dirs.flatMap(listFilesRecursively)
}

/** Load built-in test tables into the SparkSession. */
Expand Down