Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Reenabled file-based tests
  • Loading branch information
DaveDeCaprio committed Nov 18, 2018
commit 42e4fcfb5678e83018013f7181c5bafc96c8136e
Original file line number Diff line number Diff line change
Expand Up @@ -42,74 +42,74 @@ class QueryExecutionSuite extends SharedSQLContext {
s"*(1) Range (0, $expected, step=1, splits=2)",
""))
}
// test("dumping query execution info to a file") {
// withTempDir { dir =>
// val path = dir.getCanonicalPath + "/plans.txt"
// val df = spark.range(0, 10)
// df.queryExecution.debug.toFile(path)
//
// checkDumpedPlans(path, expected = 10)
// }
// }
//
// test("dumping query execution info to an existing file") {
// withTempDir { dir =>
// val path = dir.getCanonicalPath + "/plans.txt"
// val df = spark.range(0, 10)
// df.queryExecution.debug.toFile(path)
//
// val df2 = spark.range(0, 1)
// df2.queryExecution.debug.toFile(path)
// checkDumpedPlans(path, expected = 1)
// }
// }
//
// test("dumping query execution info to non-existing folder") {
// withTempDir { dir =>
// val path = dir.getCanonicalPath + "/newfolder/plans.txt"
// val df = spark.range(0, 100)
// df.queryExecution.debug.toFile(path)
// checkDumpedPlans(path, expected = 100)
// }
// }
//
// test("dumping query execution info by invalid path") {
// val path = "1234567890://plans.txt"
// val exception = intercept[IllegalArgumentException] {
// spark.range(0, 100).queryExecution.debug.toFile(path)
// }
//
// assert(exception.getMessage.contains("Illegal character in scheme name"))
// }
//
// test("toString() exception/error handling") {
// spark.experimental.extraStrategies = Seq(
// new SparkStrategy {
// override def apply(plan: LogicalPlan): Seq[SparkPlan] = Nil
// })
//
// def qe: QueryExecution = new QueryExecution(spark, OneRowRelation())
//
// // Nothing!
// assert(qe.toString.contains("OneRowRelation"))
//
// // Throw an AnalysisException - this should be captured.
// spark.experimental.extraStrategies = Seq(
// new SparkStrategy {
// override def apply(plan: LogicalPlan): Seq[SparkPlan] =
// throw new AnalysisException("exception")
// })
// assert(qe.toString.contains("org.apache.spark.sql.AnalysisException"))
//
// // Throw an Error - this should not be captured.
// spark.experimental.extraStrategies = Seq(
// new SparkStrategy {
// override def apply(plan: LogicalPlan): Seq[SparkPlan] =
// throw new Error("error")
// })
// val error = intercept[Error](qe.toString)
// assert(error.getMessage.contains("error"))
// }
test("dumping query execution info to a file") {
withTempDir { dir =>
val path = dir.getCanonicalPath + "/plans.txt"
val df = spark.range(0, 10)
df.queryExecution.debug.toFile(path)

checkDumpedPlans(path, expected = 10)
}
}

test("dumping query execution info to an existing file") {
withTempDir { dir =>
val path = dir.getCanonicalPath + "/plans.txt"
val df = spark.range(0, 10)
df.queryExecution.debug.toFile(path)

val df2 = spark.range(0, 1)
df2.queryExecution.debug.toFile(path)
checkDumpedPlans(path, expected = 1)
}
}

test("dumping query execution info to non-existing folder") {
withTempDir { dir =>
val path = dir.getCanonicalPath + "/newfolder/plans.txt"
val df = spark.range(0, 100)
df.queryExecution.debug.toFile(path)
checkDumpedPlans(path, expected = 100)
}
}

test("dumping query execution info by invalid path") {
val path = "1234567890://plans.txt"
val exception = intercept[IllegalArgumentException] {
spark.range(0, 100).queryExecution.debug.toFile(path)
}

assert(exception.getMessage.contains("Illegal character in scheme name"))
}

test("toString() exception/error handling") {
spark.experimental.extraStrategies = Seq(
new SparkStrategy {
override def apply(plan: LogicalPlan): Seq[SparkPlan] = Nil
})

def qe: QueryExecution = new QueryExecution(spark, OneRowRelation())

// Nothing!
assert(qe.toString.contains("OneRowRelation"))

// Throw an AnalysisException - this should be captured.
spark.experimental.extraStrategies = Seq(
new SparkStrategy {
override def apply(plan: LogicalPlan): Seq[SparkPlan] =
throw new AnalysisException("exception")
})
assert(qe.toString.contains("org.apache.spark.sql.AnalysisException"))

// Throw an Error - this should not be captured.
spark.experimental.extraStrategies = Seq(
new SparkStrategy {
override def apply(plan: LogicalPlan): Seq[SparkPlan] =
throw new Error("error")
})
val error = intercept[Error](qe.toString)
assert(error.getMessage.contains("error"))
}

test("toString() tree depth") {
import testImplicits._
Expand Down