Skip to content

Commit d0e66d1

Browse files
kyleconroyclaude
andcommitted
Add CTAS (CREATE TABLE AS SELECT) statement parsing support
- Add SelectStatement and CtasColumns fields to CreateTableStatement - Add TableDistributionPolicy interface with HASH, ROUND_ROBIN, REPLICATE policies - Add CLUSTERED COLUMNSTORE INDEX ORDER() parsing for ordered CCI - Add DISTRIBUTION, CLUSTERED INDEX, HEAP options to parseCreateTableOptions - Fix CTAS column list detection to use peekTok directly (avoids lexer state issues) - Enable Baselines130_CtasStatementTests and CtasStatementTests Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 873a35a commit d0e66d1

6 files changed

Lines changed: 351 additions & 82 deletions

File tree

ast/create_table_statement.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ type CreateTableStatement struct {
1212
FileStreamOn *IdentifierOrValueExpression
1313
Options []TableOption
1414
FederationScheme *FederationScheme
15+
SelectStatement *SelectStatement // For CTAS: CREATE TABLE ... AS SELECT
16+
CtasColumns []*Identifier // For CTAS with column names: CREATE TABLE (col1, col2) WITH ... AS SELECT
1517
}
1618

1719
// FederationScheme represents a FEDERATED ON clause

ast/table_distribution_option.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
package ast
22

3+
// TableDistributionPolicy is an interface for table distribution policies
4+
type TableDistributionPolicy interface {
5+
tableDistributionPolicy()
6+
}
7+
38
// TableDistributionOption represents DISTRIBUTION option for tables
49
type TableDistributionOption struct {
5-
Value *TableHashDistributionPolicy
10+
Value TableDistributionPolicy
611
OptionKind string // "Distribution"
712
}
813

@@ -15,4 +20,17 @@ type TableHashDistributionPolicy struct {
1520
DistributionColumns []*Identifier
1621
}
1722

18-
func (t *TableHashDistributionPolicy) node() {}
23+
func (t *TableHashDistributionPolicy) node() {}
24+
func (t *TableHashDistributionPolicy) tableDistributionPolicy() {}
25+
26+
// TableRoundRobinDistributionPolicy represents ROUND_ROBIN distribution for tables
27+
type TableRoundRobinDistributionPolicy struct{}
28+
29+
func (t *TableRoundRobinDistributionPolicy) node() {}
30+
func (t *TableRoundRobinDistributionPolicy) tableDistributionPolicy() {}
31+
32+
// TableReplicateDistributionPolicy represents REPLICATE distribution for tables
33+
type TableReplicateDistributionPolicy struct{}
34+
35+
func (t *TableReplicateDistributionPolicy) node() {}
36+
func (t *TableReplicateDistributionPolicy) tableDistributionPolicy() {}

ast/table_index_option.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ type TableIndexType interface {
1717

1818
// TableClusteredIndexType represents a clustered index type
1919
type TableClusteredIndexType struct {
20-
Columns []*ColumnWithSortOrder
21-
ColumnStore bool
20+
Columns []*ColumnWithSortOrder
21+
ColumnStore bool
22+
OrderedColumns []*ColumnReferenceExpression // For COLUMNSTORE INDEX ORDER(columns)
2223
}
2324

2425
func (t *TableClusteredIndexType) node() {}

0 commit comments

Comments
 (0)