MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / parseSnowflakeStageStatement

Method parseSnowflakeStageStatement

pkg/sql/parser/parser.go:781–809  ·  view source on GitHub ↗

parseSnowflakeStageStatement parses Snowflake stage operations as stubs: COPY INTO FROM [options] PUT file:// @ GET @ file:// LIST @ (or LS) REMOVE @ / The statement is consumed token-by-token (tracking balanced parens) until ';

(kind string)

Source from the content-addressed store, hash-verified

779// ';' or EOF and returned as a DescribeStatement placeholder tagged with the
780// operation kind. No AST modeling yet; follow-up work.
781func (p *Parser) parseSnowflakeStageStatement(kind string) (ast.Statement, error) {
782 p.advance() // Consume leading kind token
783
784 // COPY INTO: consume the INTO keyword if present.
785 if kind == "COPY" && p.isType(models.TokenTypeInto) {
786 p.advance()
787 }
788
789 // Consume the rest of the statement body.
790 depth := 0
791 for {
792 t := p.currentToken.Token.Type
793 if t == models.TokenTypeEOF {
794 break
795 }
796 if t == models.TokenTypeSemicolon && depth == 0 {
797 break
798 }
799 if t == models.TokenTypeLParen {
800 depth++
801 } else if t == models.TokenTypeRParen {
802 depth--
803 }
804 p.advance()
805 }
806 stub := ast.GetDescribeStatement()
807 stub.TableName = kind
808 return stub, nil
809}
810
811// NewParser creates a new parser with optional configuration.
812func NewParser(opts ...ParserOption) *Parser {

Callers 1

parseStatementMethod · 0.95

Calls 3

advanceMethod · 0.95
isTypeMethod · 0.95
GetDescribeStatementFunction · 0.92

Tested by

no test coverage detected