Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Add more test cases
  • Loading branch information
dongjoon-hyun committed Nov 4, 2020
commit b7367d71d02d1938ea0bf74c42db50b10fda1fab
12 changes: 12 additions & 0 deletions sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3706,6 +3706,18 @@ class SQLQuerySuite extends QueryTest with SharedSparkSession with AdaptiveSpark
}
}
}

test("SPARK-33338: GROUP BY using literal map should not fail") {
withTempDir { dir =>
sql(s"CREATE TABLE t USING ORC LOCATION '${dir.toURI}' AS SELECT map('k1', 'v1') m, 'k1' k")
Seq(
"SELECT map('k1', 'v1')[k] FROM t GROUP BY 1",
"SELECT map('k1', 'v1')[k] FROM t GROUP BY map('k1', 'v1')[k]",
Copy link
Contributor

Choose a reason for hiding this comment

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

how about SELECT map('k1', 'v1', 'k2', 'v2')[k] FROM t GROUP BY map('k2', 'v2', 'k1', 'v1')[k]?

Copy link
Member Author

Choose a reason for hiding this comment

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

Since we don't normalize the literal maps, they are not the same maps, @cloud-fan . We should not handle it here, @cloud-fan .

"SELECT map('k1', 'v1')[k] a FROM t GROUP BY a").foreach { statement =>
checkAnswer(sql(statement), Row("v1"))
}
}
}
}

case class Foo(bar: Option[String])