Skip to content

Commit

Permalink
fix golden file find
Browse files Browse the repository at this point in the history
  • Loading branch information
zwangsheng committed Jan 24, 2024
1 parent 67b2a9d commit 1dc1f3d
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,20 @@ abstract class VeloxTPCHSuite extends VeloxTPCHTableSupport {
.trim
}

private def getGoldenFile(id: Int): String = {
val path = s"$rootPath/tpch-approved-plan/spark$formatSparkVersion/$id.txt"
formatMaterializedPlan(Source.fromFile(new File(path), "UTF-8").mkString)
private def getGoldenFile(path: String): String = {
val expect = Source.fromFile(new File(path), "UTF-8")
try {
formatMaterializedPlan(expect.mkString)
} finally {
expect.close()
}
}

private def checkGoldenFile(df: DataFrame, id: Int): Unit = {
val actual = formatMaterializedPlan(df.queryExecution.explainString(FormattedMode))
val path = s"$rootPath/tpch-approved-plan/spark$formatSparkVersion/$id.txt"
assert(
getGoldenFile(id) == formatMaterializedPlan(df.queryExecution.explainString(FormattedMode)))
getGoldenFile(path) == actual, s"Current plan:\n$actual, find diff in golden file in $path")
}

test("TPC-H q1") {
Expand Down

0 comments on commit 1dc1f3d

Please sign in to comment.