Skip to content

Commit

Permalink
[SPARK-48355][SQL][TESTS][FOLLOWUP] Enable a SQL Scripting test in AN…
Browse files Browse the repository at this point in the history
…SI and non-ANSI modes

### What changes were proposed in this pull request?
In the PR, I propose to enable the test which #48115 turned off, and run in the ANSI and non-ANSI modes.

### Why are the changes needed?
To make this test stable, and don't depend on the default setting for ANSI mode.

### Does this PR introduce _any_ user-facing change?
No.

### How was this patch tested?
By running the modified test locally:
```
$ PYSPARK_PYTHON=python3 build/sbt "sql/testOnly org.apache.spark.sql.scripting.SqlScriptingInterpreterSuite"
```

### Was this patch authored or co-authored using generative AI tooling?
No.

Closes #48194 from MaxGekk/enable-sqlscript-test-ansi.

Authored-by: Max Gekk <max.gekk@gmail.com>
Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
  • Loading branch information
MaxGekk authored and HyukjinKwon committed Sep 22, 2024
1 parent b642096 commit 067f8f1
Showing 1 changed file with 22 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import org.apache.spark.{SparkException, SparkNumberFormatException}
import org.apache.spark.sql.{AnalysisException, DataFrame, Dataset, QueryTest, Row}
import org.apache.spark.sql.catalyst.QueryPlanningTracker
import org.apache.spark.sql.exceptions.SqlScriptingException
import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.test.SharedSparkSession

/**
Expand Down Expand Up @@ -701,8 +702,7 @@ class SqlScriptingInterpreterSuite extends QueryTest with SharedSparkSession {
verifySqlScriptResult(commands, expected)
}

// This is disabled because it fails in non-ANSI mode
ignore("simple case mismatched types") {
test("simple case mismatched types") {
val commands =
"""
|BEGIN
Expand All @@ -712,18 +712,26 @@ class SqlScriptingInterpreterSuite extends QueryTest with SharedSparkSession {
| END CASE;
|END
|""".stripMargin

checkError(
exception = intercept[SparkNumberFormatException] (
runSqlScript(commands)
),
condition = "CAST_INVALID_INPUT",
parameters = Map(
"expression" -> "'one'",
"sourceType" -> "\"STRING\"",
"targetType" -> "\"BIGINT\""),
context = ExpectedContext(fragment = "\"one\"", start = 23, stop = 27)
)
withSQLConf(SQLConf.ANSI_ENABLED.key -> "true") {
checkError(
exception = intercept[SparkNumberFormatException](
runSqlScript(commands)
),
condition = "CAST_INVALID_INPUT",
parameters = Map(
"expression" -> "'one'",
"sourceType" -> "\"STRING\"",
"targetType" -> "\"BIGINT\""),
context = ExpectedContext(fragment = "\"one\"", start = 23, stop = 27))
}
withSQLConf(SQLConf.ANSI_ENABLED.key -> "false") {
checkError(
exception = intercept[SqlScriptingException](
runSqlScript(commands)
),
condition = "BOOLEAN_STATEMENT_WITH_EMPTY_ROW",
parameters = Map("invalidStatement" -> "\"ONE\""))
}
}

test("simple case compare with null") {
Expand Down

0 comments on commit 067f8f1

Please sign in to comment.