Skip to content
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 @@ -380,7 +380,6 @@ hint

hintStatement
: hintName=identifier
| hintName=identifier '(' parameters+=identifier parameters+=identifier ')'
| hintName=identifier '(' parameters+=identifier (',' parameters+=identifier)* ')'
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,13 @@ class PlanParserSuite extends PlanTest {
val m2 = intercept[ParseException] {
parsePlan("SELECT /*+ MAPJOIN(default.t) */ * from default.t")
}.getMessage
assert(m2.contains("no viable alternative at input"))
assert(m2.contains("mismatched input '.' expecting {')', ','}"))

// Disallow space as the delimiter.
val m3 = intercept[ParseException] {
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: You can use the PlanParserSuite.intercept method. That saves some typing.

parsePlan("SELECT /*+ INDEX(a b c) */ * from default.t")
}.getMessage
assert(m3.contains("mismatched input 'b' expecting {')', ','}"))

comparePlans(
parsePlan("SELECT /*+ HINT */ * FROM t"),
Expand All @@ -524,7 +530,7 @@ class PlanParserSuite extends PlanTest {
Hint("STREAMTABLE", Seq("a", "b", "c"), table("t").select(star())))

comparePlans(
parsePlan("SELECT /*+ INDEX(t emp_job_ix) */ * FROM t"),
parsePlan("SELECT /*+ INDEX(t, emp_job_ix) */ * FROM t"),
Copy link
Contributor

Choose a reason for hiding this comment

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

we can remove this test now, as it's duplicated if we use , as delimiter

Copy link
Member

Choose a reason for hiding this comment

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

Hi, @viirya and @cloud-fan @hvanhovell @rxin @gatorsmile .

Just for explanation, it was originally designed to support other syntax like the followings. Except query block parts (which we don't support), this case means tableSpec and indexSpec.

https://docs.oracle.com/cd/B12037_01/server.101/b10752/hintsref.htm#21629

At that time, there was a request to provide more general syntax to prevent future changes on SqlBase.g4 layer.

Anyway, I have no objection on the current approach since I also read the comments between @rxin and @viirya on the previous @rxin 's commit.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea we can generalize it later.

Copy link
Member Author

Choose a reason for hiding this comment

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

@dongjoon-hyun Thanks for explanation. Looks like the syntax you referred only supports space as the delimiter?

Hint("INDEX", Seq("t", "emp_job_ix"), table("t").select(star())))

comparePlans(
Expand Down