Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-48355][SQL][TESTS][FOLLOWUP] Enable a SQL Scripting test in ANSI and non-ANSI modes #48194

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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 @@ -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