@@ -95,6 +95,60 @@ func (p *Parser) parseCreateStatement() (ast.Statement, error) {
9595 }
9696 return stmt , nil
9797 }
98+
99+ // Snowflake object-type extensions: STAGE, STREAM, TASK, PIPE, FILE FORMAT,
100+ // WAREHOUSE, DATABASE, SCHEMA, ROLE, FUNCTION, PROCEDURE, SEQUENCE.
101+ // Parse-only: record the object kind and name on a DescribeStatement
102+ // placeholder, then consume the rest of the statement body permissively
103+ // until ';' or EOF (tracking balanced parens so embedded expressions with
104+ // semicolons inside string literals round-trip).
105+ if p .dialect == string (keywords .DialectSnowflake ) {
106+ kind := strings .ToUpper (p .currentToken .Token .Value )
107+ if kind == "FILE" && strings .EqualFold (p .peekToken ().Token .Value , "FORMAT" ) {
108+ p .advance () // FILE
109+ kind = "FILE FORMAT"
110+ }
111+ switch kind {
112+ case "STAGE" , "STREAM" , "TASK" , "PIPE" , "FILE FORMAT" ,
113+ "WAREHOUSE" , "DATABASE" , "SCHEMA" , "ROLE" , "SEQUENCE" ,
114+ "FUNCTION" , "PROCEDURE" :
115+ p .advance () // Consume object-kind keyword
116+ // Optional IF NOT EXISTS
117+ if p .isType (models .TokenTypeIf ) {
118+ p .advance ()
119+ if p .isType (models .TokenTypeNot ) {
120+ p .advance ()
121+ }
122+ if p .isType (models .TokenTypeExists ) {
123+ p .advance ()
124+ }
125+ }
126+ // Object name (qualified identifier)
127+ name , _ := p .parseQualifiedName ()
128+ // Consume the rest of the statement body until ';' or EOF,
129+ // tracking balanced parens.
130+ depth := 0
131+ for {
132+ t := p .currentToken .Token .Type
133+ if t == models .TokenTypeEOF {
134+ break
135+ }
136+ if t == models .TokenTypeSemicolon && depth == 0 {
137+ break
138+ }
139+ if t == models .TokenTypeLParen {
140+ depth ++
141+ } else if t == models .TokenTypeRParen {
142+ depth --
143+ }
144+ p .advance ()
145+ }
146+ stub := ast .GetDescribeStatement ()
147+ stub .TableName = "CREATE " + kind + " " + name
148+ return stub , nil
149+ }
150+ }
151+
98152 return nil , p .expectedError ("TABLE, VIEW, MATERIALIZED VIEW, or INDEX after CREATE" )
99153}
100154
0 commit comments