@@ -691,7 +691,9 @@ func (p *Parser) parseStatement() (ast.Statement, error) {
691691 case models .TokenTypeShow :
692692 p .advance ()
693693 return p .parseShowStatement ()
694- case models .TokenTypeDescribe , models .TokenTypeExplain :
694+ case models .TokenTypeDescribe , models .TokenTypeExplain , models .TokenTypeDesc :
695+ // DESC is the ORDER-BY sort-direction token but also a synonym for
696+ // DESCRIBE at statement position (Oracle, Snowflake, MySQL).
695697 p .advance ()
696698 return p .parseDescribeStatement ()
697699 case models .TokenTypeReplace :
@@ -713,10 +715,39 @@ func (p *Parser) parseStatement() (ast.Statement, error) {
713715 p .advance ()
714716 return p .parsePragmaStatement ()
715717 }
718+ // Snowflake session-context switches: USE [WAREHOUSE|DATABASE|SCHEMA|ROLE] <name>.
719+ // USE is not tokenized as a keyword; dispatch by value in the Snowflake dialect.
720+ if p .dialect == string (keywords .DialectSnowflake ) &&
721+ strings .EqualFold (p .currentToken .Token .Value , "USE" ) {
722+ return p .parseSnowflakeUseStatement ()
723+ }
716724 }
717725 return nil , p .expectedError ("statement" )
718726}
719727
728+ // parseSnowflakeUseStatement parses:
729+ //
730+ // USE [WAREHOUSE | DATABASE | SCHEMA | ROLE] <name>
731+ //
732+ // The object-kind keyword is optional (plain "USE <name>" switches the current
733+ // database). We parse-only; the statement is represented as a DescribeStatement
734+ // placeholder until a dedicated UseStatement node is introduced.
735+ func (p * Parser ) parseSnowflakeUseStatement () (ast.Statement , error ) {
736+ p .advance () // Consume USE
737+ // Optional object kind.
738+ switch strings .ToUpper (p .currentToken .Token .Value ) {
739+ case "WAREHOUSE" , "DATABASE" , "SCHEMA" , "ROLE" :
740+ p .advance ()
741+ }
742+ name , err := p .parseQualifiedName ()
743+ if err != nil {
744+ return nil , p .expectedError ("name after USE" )
745+ }
746+ stmt := ast .GetDescribeStatement ()
747+ stmt .TableName = "USE " + name
748+ return stmt , nil
749+ }
750+
720751// NewParser creates a new parser with optional configuration.
721752func NewParser (opts ... ParserOption ) * Parser {
722753 p := & Parser {}
0 commit comments