Skip to content

Commit d0496a0

Browse files
kyleconroyclaude
andcommitted
Support old-style table hints after TABLESAMPLE clause
Handle syntax like: SELECT * FROM t1 tablesample (1000 rows)(nolock) where table hints appear in parentheses without WITH keyword after the TABLESAMPLE clause. Enables: FromClauseTests90 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 20815bf commit d0496a0

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

parser/parse_select.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2922,6 +2922,31 @@ func (p *Parser) parseNamedTableReferenceWithName(son *ast.SchemaObjectName) (*a
29222922
ref.TableSampleClause = tableSample
29232923
}
29242924

2925+
// Check for old-style hints after TABLESAMPLE (without WITH keyword): alias TABLESAMPLE (...)(nolock)
2926+
if p.curTok.Type == TokenLParen && p.peekIsTableHint() {
2927+
p.nextToken() // consume (
2928+
for p.curTok.Type != TokenRParen && p.curTok.Type != TokenEOF {
2929+
hint, err := p.parseTableHint()
2930+
if err != nil {
2931+
return nil, err
2932+
}
2933+
if hint != nil {
2934+
ref.TableHints = append(ref.TableHints, hint)
2935+
}
2936+
if p.curTok.Type == TokenComma {
2937+
p.nextToken()
2938+
} else if p.curTok.Type != TokenRParen {
2939+
if p.isTableHintToken() {
2940+
continue
2941+
}
2942+
break
2943+
}
2944+
}
2945+
if p.curTok.Type == TokenRParen {
2946+
p.nextToken()
2947+
}
2948+
}
2949+
29252950
// Check for new-style hints (with WITH keyword): alias WITH (hints)
29262951
if p.curTok.Type == TokenWith && p.peekTok.Type == TokenLParen {
29272952
p.nextToken() // consume WITH
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"todo": true}
1+
{}

0 commit comments

Comments
 (0)