Skip to content

Commit 76f3e3b

Browse files
committed
Support qualified identifiers starting with keywords
When a keyword like SYSTEM is used as the start of a qualified name (e.g., system.one.*), parseKeywordAsIdentifier was returning just the keyword as a single-part identifier. Now it continues to parse DOT sequences to build qualified identifiers and handle qualified asterisks. Fixes tests: - 00467_qualified_names (stmt19, stmt21) - 00502_custom_partitioning_local (stmt17)
1 parent dc5e91b commit 76f3e3b

3 files changed

Lines changed: 22 additions & 12 deletions

File tree

parser/expression.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2749,9 +2749,28 @@ func (p *Parser) parseKeywordAsIdentifier() ast.Expression {
27492749
name := p.current.Value
27502750
p.nextToken()
27512751

2752+
// Check for qualified identifier (system.one.* or system.one.col)
2753+
parts := []string{name}
2754+
for p.currentIs(token.DOT) {
2755+
p.nextToken()
2756+
if p.currentIs(token.IDENT) || p.current.Token.IsKeyword() {
2757+
parts = append(parts, p.current.Value)
2758+
p.nextToken()
2759+
} else if p.currentIs(token.ASTERISK) {
2760+
// table.*
2761+
p.nextToken()
2762+
return &ast.Asterisk{
2763+
Position: pos,
2764+
Table: strings.Join(parts, "."),
2765+
}
2766+
} else {
2767+
break
2768+
}
2769+
}
2770+
27522771
return &ast.Identifier{
27532772
Position: pos,
2754-
Parts: []string{name},
2773+
Parts: parts,
27552774
}
27562775
}
27572776

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt19": true,
4-
"stmt21": true
5-
}
6-
}
1+
{}
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt17": true
4-
}
5-
}
1+
{}

0 commit comments

Comments
 (0)