Skip to content
Open
Show file tree
Hide file tree
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 @@ -31,8 +31,8 @@ import org.apache.spark.sql.types._

class ResolveBinBySuite extends AnalysisTest {

// BIN BY is gated off by default; run the resolution tests with it enabled. The dedicated
// gate test below uses `super.test` to observe the default-off behavior.
// Run the resolution tests with the operator enabled. The dedicated gate test below uses
// `super.test` to escape this wrapper and pins the flag off.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: "uses super.test to escape this wrapper and pins the flag off" coordinates the infinitive "escape" with the finite "pins". Read it as "…to escape this wrapper and pin the flag off."

override protected def test(testName: String, testTags: Tag*)(testFun: => Any)
(implicit pos: Position): Unit = {
super.test(testName, testTags: _*) {
Expand Down Expand Up @@ -336,9 +336,10 @@ class ResolveBinBySuite extends AnalysisTest {
"appended BinBy attributes must have distinct exprIds across the two join sides")
}

// `super.test` escapes the suite-wide flag-on wrapper so this runs with the default (off).
super.test("BIN BY is gated off by default") {
assert(!SQLConf.get.getConf(SQLConf.BIN_BY_ENABLED))
expectError(unresolved(), "UNSUPPORTED_FEATURE.BIN_BY")
// `super.test` escapes the suite-wide flag-on wrapper; pin the flag off explicitly.
super.test("BIN BY is rejected when the operator is disabled") {
withSQLConf(SQLConf.BIN_BY_ENABLED.key -> "false") {
expectError(unresolved(), "UNSUPPORTED_FEATURE.BIN_BY")
}
}
}
24 changes: 13 additions & 11 deletions sql/core/src/test/scala/org/apache/spark/sql/BinBySuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,19 @@ class BinBySuite extends QueryTest with SharedSparkSession {
}
}

test("BIN BY is gated off by default") {
withTempView("metrics") {
createMetricsView()
// Gated off, the operator is rejected at analysis with the same UNSUPPORTED_FEATURE.BIN_BY
// condition the execution stub raises when enabled.
checkError(
exception = intercept[SparkThrowable] {
spark.sql(binByQuery).queryExecution.assertAnalyzed()
},
condition = "UNSUPPORTED_FEATURE.BIN_BY",
parameters = Map.empty[String, String])
test("BIN BY is rejected when the operator is disabled") {
withSQLConf(SQLConf.BIN_BY_ENABLED.key -> "false") {
withTempView("metrics") {
createMetricsView()
// Disabled, the operator is rejected at analysis with the same UNSUPPORTED_FEATURE.BIN_BY
// condition the execution stub raises when enabled.
checkError(
exception = intercept[SparkThrowable] {
spark.sql(binByQuery).queryExecution.assertAnalyzed()
},
condition = "UNSUPPORTED_FEATURE.BIN_BY",
parameters = Map.empty[String, String])
}
}
}

Expand Down