Skip to content

Commit 5e4634c

Browse files
kyleconroyclaude
andcommitted
Add FROM clause parsing for ATTACH TABLE
- Add FromPath field to AttachQuery AST - Parse FROM 'path' after table name in ATTACH TABLE Fixes 01721_engine_file_truncate_on_insert/stmt3 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e471e45 commit 5e4634c

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

ast/ast.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,7 @@ type AttachQuery struct {
767767
Database string `json:"database,omitempty"`
768768
Table string `json:"table,omitempty"`
769769
Dictionary string `json:"dictionary,omitempty"`
770+
FromPath string `json:"from_path,omitempty"` // FROM 'path' clause
770771
Columns []*ColumnDeclaration `json:"columns,omitempty"`
771772
ColumnsPrimaryKey []Expression `json:"columns_primary_key,omitempty"` // PRIMARY KEY in column list
772773
HasEmptyColumnsPrimaryKey bool `json:"has_empty_columns_primary_key,omitempty"` // TRUE if PRIMARY KEY () was seen with empty parens

parser/parser.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7275,6 +7275,15 @@ func (p *Parser) parseAttach() *ast.AttachQuery {
72757275

72767276
_ = isMaterializedView
72777277

7278+
// Parse FROM clause: ATTACH TABLE name FROM 'path'
7279+
if p.currentIs(token.FROM) {
7280+
p.nextToken() // skip FROM
7281+
if p.currentIs(token.STRING) {
7282+
attach.FromPath = p.current.Value
7283+
p.nextToken()
7284+
}
7285+
}
7286+
72787287
// Parse column definitions for ATTACH TABLE name(col1 type, ...)
72797288
if !isDatabase && p.currentIs(token.LPAREN) {
72807289
p.nextToken()
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt3": true
4-
}
5-
}
1+
{}

0 commit comments

Comments
 (0)