Skip to content
Closed
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 @@ -68,14 +68,24 @@ class DataFrameSuite extends QueryTest with RemoteSparkSession {
}

test("lazy column validation") {
val session = spark
import session.implicits._

val df1 = Seq(1 -> "y").toDF("a", "y")
val df2 = Seq(1 -> "x").toDF("a", "x")
val df3 = df1.join(df2, df1("a") === df2("a"))
val df4 = df3.select(df1("x")) // <- No exception here

intercept[AnalysisException] { df4.schema }
// The test relies on strict plan-id-based resolution: with the name-based fallback
// enabled, df1("x") would resolve to df2.x via the join output and df4.schema would
// succeed. Pin the config directly via spark.conf.set/unset; the lazy SQLConf entry
// trips withSQLConf's isModifiable check on the Connect server, so we cannot use that
// helper here.
spark.conf.set("spark.sql.analyzer.strictDataFrameColumnResolution", "true")
try {
val session = spark
import session.implicits._

val df1 = Seq(1 -> "y").toDF("a", "y")
val df2 = Seq(1 -> "x").toDF("a", "x")
val df3 = df1.join(df2, df1("a") === df2("a"))
val df4 = df3.select(df1("x")) // <- No exception here

intercept[AnalysisException] { df4.schema }
} finally {
spark.conf.unset("spark.sql.analyzer.strictDataFrameColumnResolution")
}
}
}