Skip to content

Commit efaa4d0

Browse files
committed
Address comments.
1 parent a9a1b00 commit efaa4d0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

sql/hive/src/test/scala/org/apache/spark/sql/catalyst/LogicalPlanToSQLSuite.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ class LogicalPlanToSQLSuite extends SQLBuilderTest with SQLTestUtils {
4040
import testImplicits._
4141

4242
// Used for generating new query answer files by saving
43-
private val saveQuery = System.getenv("SPARK_GENERATE_GOLDEN_FILES") != null
43+
private val regenerateGoldenFiles =
44+
Option(System.getenv("SPARK_GENERATE_GOLDEN_FILES")).contains("1")
4445
private val goldenSQLPath = "src/test/resources/sqlgen/"
4546

4647
protected override def beforeAll(): Unit = {
@@ -102,7 +103,7 @@ class LogicalPlanToSQLSuite extends SQLBuilderTest with SQLTestUtils {
102103
val normalizedGenSQL = convertedSQL.replaceAll("`gen_attr_\\d+`", "`gen_attr`")
103104
if (answerFile != null) {
104105
val separator = "-" * 80
105-
if (saveQuery) {
106+
if (regenerateGoldenFiles) {
106107
val path = Paths.get(s"$goldenSQLPath/$answerFile.sql")
107108
val header = "-- This file is automatically generated by LogicalPlanToSQLSuite."
108109
val answerText = s"$header\n${originalSQL.trim()}\n${separator}\n$normalizedGenSQL\n"
@@ -166,7 +167,7 @@ class LogicalPlanToSQLSuite extends SQLBuilderTest with SQLTestUtils {
166167
}
167168

168169
// When saving golden files, these tests should be ignored to prevent making files.
169-
if (!saveQuery) {
170+
if (!regenerateGoldenFiles) {
170171
test("Test should fail if the SQL query cannot be parsed") {
171172
val m = intercept[ParseException] {
172173
checkSQL("SELE", "NOT_A_FILE")

0 commit comments

Comments
 (0)