Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/18086#discussion_r119762455
--- Diff:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/PlanParserSuite.scala
---
@@ -527,47 +527,117 @@ class PlanParserSuite extends PlanTest {
val m = intercept[ParseException] {
parsePlan("SELECT /*+ HINT() */ * FROM t")
}.getMessage
- assert(m.contains("no viable alternative at input"))
-
- // Hive compatibility: No database.
- val m2 = intercept[ParseException] {
- parsePlan("SELECT /*+ MAPJOIN(default.t) */ * from default.t")
- }.getMessage
- assert(m2.contains("mismatched input '.' expecting {')', ','}"))
+ assert(m.contains("mismatched input"))
// Disallow space as the delimiter.
val m3 = intercept[ParseException] {
parsePlan("SELECT /*+ INDEX(a b c) */ * from default.t")
}.getMessage
- assert(m3.contains("mismatched input 'b' expecting {')', ','}"))
+ assert(m3.contains("mismatched input 'b' expecting"))
comparePlans(
parsePlan("SELECT /*+ HINT */ * FROM t"),
UnresolvedHint("HINT", Seq.empty, table("t").select(star())))
comparePlans(
parsePlan("SELECT /*+ BROADCASTJOIN(u) */ * FROM t"),
- UnresolvedHint("BROADCASTJOIN", Seq("u"), table("t").select(star())))
+ UnresolvedHint("BROADCASTJOIN", Seq($"u"),
table("t").select(star())))
comparePlans(
parsePlan("SELECT /*+ MAPJOIN(u) */ * FROM t"),
- UnresolvedHint("MAPJOIN", Seq("u"), table("t").select(star())))
+ UnresolvedHint("MAPJOIN", Seq($"u"), table("t").select(star())))
comparePlans(
parsePlan("SELECT /*+ STREAMTABLE(a,b,c) */ * FROM t"),
- UnresolvedHint("STREAMTABLE", Seq("a", "b", "c"),
table("t").select(star())))
+ UnresolvedHint("STREAMTABLE", Seq($"a", $"b", $"c"),
table("t").select(star())))
comparePlans(
parsePlan("SELECT /*+ INDEX(t, emp_job_ix) */ * FROM t"),
- UnresolvedHint("INDEX", Seq("t", "emp_job_ix"),
table("t").select(star())))
+ UnresolvedHint("INDEX", Seq($"t", $"emp_job_ix"),
table("t").select(star())))
comparePlans(
parsePlan("SELECT /*+ MAPJOIN(`default.t`) */ * from `default.t`"),
- UnresolvedHint("MAPJOIN", Seq("default.t"),
table("default.t").select(star())))
+ UnresolvedHint("MAPJOIN",
Seq(UnresolvedAttribute.quoted("default.t")),
+ table("default.t").select(star())))
comparePlans(
parsePlan("SELECT /*+ MAPJOIN(t) */ a from t where true group by a
order by a"),
- UnresolvedHint("MAPJOIN", Seq("t"),
+ UnresolvedHint("MAPJOIN", Seq($"t"),
table("t").where(Literal(true)).groupBy('a)('a)).orderBy('a.asc))
}
+
+ test("SPARK-20854: select hint syntax with expressions") {
+ comparePlans(
+ parsePlan("SELECT /*+ HINT1(a, array(1, 2, 3)) */ * from t"),
+ UnresolvedHint("HINT1", Seq($"a",
+ UnresolvedFunction("array", Literal(1) :: Literal(2) :: Literal(3)
:: Nil, false)),
+ table("t").select(star())
+ )
+ )
+
+ comparePlans(
+ parsePlan("SELECT /*+ HINT1(a, array(1, 2, 3)) */ * from t"),
--- End diff --
yea, @bogdanrdc can you send a follow-up PR to clean it up?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]