Skip to content

[SPARK-42655][SQL] Incorrect ambiguous column reference error #40258

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

Closed
wants to merge 1 commit into from
Closed
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 @@ -342,7 +342,7 @@ package object expressions {
// attribute metadata to indicate that they are from metadata columns, but they should not
// keep any restrictions that may break column resolution for normal attributes.
// See SPARK-42084 for more details.
prunedCandidates.map(_.markAsAllowAnyAccess()) match {
prunedCandidates.distinct.map(_.markAsAllowAnyAccess()) match {
case Seq(a) if nestedFields.nonEmpty =>
// One match, but we also need to extract the requested nested field.
// The foldLeft adds ExtractValues for every remaining parts of the identifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2768,6 +2768,15 @@ class DataFrameSuite extends QueryTest
checkAnswer(swappedDf.filter($"key"($"map") > "a"), Row(2, Map(2 -> "b")))
}

test("SPARK-42655 Fix ambiguous column reference error") {
val df1 = sparkContext.parallelize(List((1, 2, 3, 4, 5))).toDF("id", "col2", "col3",
"col4", "col5")
val op_cols_mixed_case = List("id", "col2", "col3", "col4", "col5", "ID")
val df2 = df1.select(op_cols_mixed_case.head, op_cols_mixed_case.tail: _*)
// should not throw any error.
checkAnswer(df2.select("id"), Row(1))
}

test("SPARK-26057: attribute deduplication on already analyzed plans") {
withTempView("a", "b", "v") {
val df1 = Seq(("1-1", 6)).toDF("id", "n")
Expand Down