Skip to content

Commit 9e7ec64

Browse files
Query hints fix to support bigquery hints
1 parent 652113f commit 9e7ec64

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

operand.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ func expectOperand(cursor *parsly.Cursor) (node.Node, error) {
146146
return nil, cursor.NewError(selectorMatcher)
147147
}
148148
return unary, nil
149-
case asKeyword, orderByKeyword, onKeyword, fromKeyword, whereKeyword, joinToken, groupByKeyword, havingKeyword, windowTokenCode, nextCode, commentBlock:
149+
case commentBlock:
150+
return expectOperand(cursor)
151+
case asKeyword, orderByKeyword, onKeyword, fromKeyword, whereKeyword, joinToken, groupByKeyword, havingKeyword, windowTokenCode, nextCode:
150152
cursor.Pos = pos
151153
}
152154
return nil, nil

query_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,19 @@ func TestParseSelect(t *testing.T) {
105105
SQL: `SELECT user.* FROM (SELECT t.* FROM USER t ) user /* {"Self":{"Holder":"Team", "Child":"ID", "Parent":"MGR_ID" }} */ `,
106106
expect: `SELECT user.* FROM (SELECT t.* FROM USER t ) user /* {"Self":{"Holder":"Team", "Child":"ID", "Parent":"MGR_ID" }} */`,
107107
},
108+
{
109+
description: "legacy-sql hint in subquery",
110+
SQL: `SELECT
111+
a.*
112+
FROM (
113+
SELECT /*+ {\"UseLegacySql\": true} +*/
114+
'' AS a
115+
) a`,
116+
expect: `SELECT a.* FROM (
117+
SELECT /*+ {\"UseLegacySql\": true} +*/
118+
'' AS a
119+
) a`,
120+
},
108121

109122
{
110123
description: "bq table select",

0 commit comments

Comments
 (0)