Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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 @@ -100,7 +100,9 @@ trait CrossDbmsQueryTestSuite extends DockerJDBCIntegrationSuite with SQLQueryTe
val conn = getConnection()
val stmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY)

val outputs: Seq[QueryTestOutput] = queries.map { sql =>
val outputs: Seq[QueryTestOutput] = queries.zipWithIndex.map { case (sql, queryIdx) =>
log.debug(s"[${testCase.name}] Executing query #$queryIdx against $DATABASE_NAME: " +

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

are these very useful? (asking if its better to remove)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hm, I think it's harmless.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Was concerned it will spam the logs, but will leave you to.

s"${sql.take(120).replace('\n', ' ')}${if (sql.length > 120) "..." else ""}")
val output = {
try {
val sparkDf = localSparkSession.sql(sql)
Expand All @@ -122,14 +124,19 @@ trait CrossDbmsQueryTestSuite extends DockerJDBCIntegrationSuite with SQLQueryTe
}
}
val output = rows.map(_.mkString("\t")).toSeq
log.debug(s"[${testCase.name}] Query #$queryIdx returned ${output.size} rows from " +
s"$DATABASE_NAME")
if (isSemanticallySorted(sparkDf.queryExecution.analyzed)) {
output
} else {
// Sort the answer manually if it isn't sorted.
output.sorted
}
} catch {
case NonFatal(e) => Seq(e.getClass.getName, e.getMessage)
case NonFatal(e) =>
log.warn(s"[${testCase.name}] Query #$queryIdx threw ${e.getClass.getName} " +
s"against $DATABASE_NAME: ${Option(e.getMessage).getOrElse("(no message)")}")
Seq(e.getClass.getName, e.getMessage)
}
}

Expand Down Expand Up @@ -164,9 +171,19 @@ trait CrossDbmsQueryTestSuite extends DockerJDBCIntegrationSuite with SQLQueryTe
}

outputs.zip(expectedOutputs).zipWithIndex.foreach { case ((output, expected), i) =>
if (output.sql != expected.sql) {
log.error(s"[${testCase.name}] SQL text mismatch for query #$i:\n" +
s" Expected (golden): ${expected.sql.take(200)}\n" +
s" Actual (input): ${output.sql.take(200)}")
}
assertResult(expected.sql, s"SQL query did not match for query #$i\n${expected.sql}") {
output.sql
}
if (output.output != expected.output) {
log.error(s"[${testCase.name}] Output mismatch for query #$i (${output.sql.take(80)}):\n" +
s" Expected (Spark golden):\n${expected.output.take(500)}\n" +
s" Actual ($DATABASE_NAME):\n${output.output.take(500)}")
}
assertResult(expected.output, s"Result did not match" +
s" for query #$i\n${expected.sql}") {
output.output
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading