cloud-fan commented on code in PR #43465:
URL: https://github.com/apache/spark/pull/43465#discussion_r1366907577
##########
connector/connect/client/jvm/src/test/scala/org/apache/spark/sql/ClientE2ETestSuite.scala:
##########
@@ -872,6 +872,68 @@ class ClientE2ETestSuite extends RemoteSparkSession with
SQLHelper with PrivateM
assert(joined2.schema.catalogString === "struct<id:bigint,a:double>")
}
+ test("SPARK-45509: ambiguous column reference") {
+ val session = spark
+ import session.implicits._
+ val df1 = Seq(1 -> "a").toDF("i", "j")
+ val df1_filter = df1.filter(df1("i") > 0)
+ val df2 = Seq(2 -> "b").toDF("i", "y")
+
+ checkSameResult(
+ Seq(Row(1)),
+ // df1("i") is not ambiguous, and it's still valid in the filtered df.
+ df1_filter.select(df1("i"))
+ )
+
+ val e1 = intercept[AnalysisException] {
+ // df1("i") is not ambiguous, but it's not valid in the projected df.
+ df1.select((df1("i") + 1).as("plus")).select(df1("i")).collect()
+ }
+
assert(e1.getMessage.contains("MISSING_ATTRIBUTES.RESOLVED_ATTRIBUTE_MISSING_FROM_INPUT"))
+
+ checkSameResult(
+ Seq(Row(1, "a")),
+ // All these column references are not ambiguous and are still valid
after join.
+ df1.join(df2, df1("i") + 1 ===
df2("i")).sort(df1("i").desc).select(df1("i"), df1("j"))
+ )
+
+ val e2 = intercept[AnalysisException] {
+ // df1("i") is ambiguous as df1 appears in both join sides.
+ df1.join(df1, df1("i") === 1).collect()
Review Comment:
classic spark sql thinks this is not ambiguous. It's probably a bug and I'll
fix later.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]