diff --git a/sql/connect/client/jvm/src/test/scala/org/apache/spark/sql/connect/DataFrameSuite.scala b/sql/connect/client/jvm/src/test/scala/org/apache/spark/sql/connect/DataFrameSuite.scala index 890245fdd2fba..57b8080c4b137 100644 --- a/sql/connect/client/jvm/src/test/scala/org/apache/spark/sql/connect/DataFrameSuite.scala +++ b/sql/connect/client/jvm/src/test/scala/org/apache/spark/sql/connect/DataFrameSuite.scala @@ -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") + } } }