Skip to content

Commit cf71f6a

Browse files
committed
Add ALTER EXTERNAL LANGUAGE statement parsing
- Add AUTHORIZATION clause support - Add SET/ADD/REMOVE operation parsing - Add file options (CONTENT, FILE_NAME, PLATFORM, PARAMETERS, ENVIRONMENT_VARIABLES) - Add REMOVE PLATFORM option - Update AlterExternalLanguageStatement AST type - Enable AlterExternalLanguage150 and Baselines150_AlterExternalLanguage150 tests
1 parent d71c181 commit cf71f6a

5 files changed

Lines changed: 98 additions & 4 deletions

File tree

ast/external_statements.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ func (s *AlterExternalDataSourceStatement) statement() {}
133133
// AlterExternalLanguageStatement represents ALTER EXTERNAL LANGUAGE statement
134134
type AlterExternalLanguageStatement struct {
135135
Name *Identifier
136+
Owner *Identifier
137+
Operation *Identifier
138+
Platform *Identifier
136139
ExternalLanguageFiles []*ExternalLanguageFileOption
137140
}
138141

parser/marshal.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14650,9 +14650,25 @@ func alterExternalLanguageStatementToJSON(s *ast.AlterExternalLanguageStatement)
1465014650
node := jsonNode{
1465114651
"$type": "AlterExternalLanguageStatement",
1465214652
}
14653+
if s.Platform != nil {
14654+
node["Platform"] = identifierToJSON(s.Platform)
14655+
}
14656+
if s.Operation != nil {
14657+
node["Operation"] = identifierToJSON(s.Operation)
14658+
}
14659+
if s.Owner != nil {
14660+
node["Owner"] = identifierToJSON(s.Owner)
14661+
}
1465314662
if s.Name != nil {
1465414663
node["Name"] = identifierToJSON(s.Name)
1465514664
}
14665+
if len(s.ExternalLanguageFiles) > 0 {
14666+
files := make([]jsonNode, len(s.ExternalLanguageFiles))
14667+
for i, f := range s.ExternalLanguageFiles {
14668+
files[i] = externalLanguageFileOptionToJSON(f)
14669+
}
14670+
node["ExternalLanguageFiles"] = files
14671+
}
1465614672
return node
1465714673
}
1465814674

parser/parse_ddl.go

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6330,8 +6330,83 @@ func (p *Parser) parseAlterExternalLanguageStatement() (*ast.AlterExternalLangua
63306330
// Parse name
63316331
stmt.Name = p.parseIdentifier()
63326332

6333-
// Skip rest of statement
6334-
p.skipToEndOfStatement()
6333+
// Parse optional AUTHORIZATION
6334+
if strings.ToUpper(p.curTok.Literal) == "AUTHORIZATION" {
6335+
p.nextToken() // consume AUTHORIZATION
6336+
stmt.Owner = p.parseIdentifier()
6337+
}
6338+
6339+
// Parse operation (SET, ADD, REMOVE)
6340+
upperLit := strings.ToUpper(p.curTok.Literal)
6341+
if upperLit == "SET" || upperLit == "ADD" || upperLit == "REMOVE" {
6342+
stmt.Operation = p.parseIdentifier()
6343+
6344+
if upperLit == "REMOVE" {
6345+
// REMOVE PLATFORM <platform>
6346+
if strings.ToUpper(p.curTok.Literal) == "PLATFORM" {
6347+
p.nextToken() // consume PLATFORM
6348+
stmt.Platform = p.parseIdentifier()
6349+
}
6350+
} else {
6351+
// SET or ADD - parse file options
6352+
if p.curTok.Type == TokenLParen {
6353+
p.nextToken() // consume (
6354+
fileOption := &ast.ExternalLanguageFileOption{}
6355+
for p.curTok.Type != TokenRParen && p.curTok.Type != TokenEOF {
6356+
switch strings.ToUpper(p.curTok.Literal) {
6357+
case "CONTENT":
6358+
p.nextToken() // consume CONTENT
6359+
if p.curTok.Type == TokenEquals {
6360+
p.nextToken() // consume =
6361+
}
6362+
expr, _ := p.parseScalarExpression()
6363+
fileOption.Content = expr
6364+
case "FILE_NAME":
6365+
p.nextToken() // consume FILE_NAME
6366+
if p.curTok.Type == TokenEquals {
6367+
p.nextToken() // consume =
6368+
}
6369+
expr, _ := p.parseScalarExpression()
6370+
fileOption.FileName = expr
6371+
case "PLATFORM":
6372+
p.nextToken() // consume PLATFORM
6373+
if p.curTok.Type == TokenEquals {
6374+
p.nextToken() // consume =
6375+
}
6376+
fileOption.Platform = p.parseIdentifier()
6377+
case "PARAMETERS":
6378+
p.nextToken() // consume PARAMETERS
6379+
if p.curTok.Type == TokenEquals {
6380+
p.nextToken() // consume =
6381+
}
6382+
expr, _ := p.parseScalarExpression()
6383+
fileOption.Parameters = expr
6384+
case "ENVIRONMENT_VARIABLES":
6385+
p.nextToken() // consume ENVIRONMENT_VARIABLES
6386+
if p.curTok.Type == TokenEquals {
6387+
p.nextToken() // consume =
6388+
}
6389+
expr, _ := p.parseScalarExpression()
6390+
fileOption.EnvironmentVariables = expr
6391+
default:
6392+
p.nextToken()
6393+
}
6394+
if p.curTok.Type == TokenComma {
6395+
p.nextToken()
6396+
}
6397+
}
6398+
if p.curTok.Type == TokenRParen {
6399+
p.nextToken() // consume )
6400+
}
6401+
stmt.ExternalLanguageFiles = append(stmt.ExternalLanguageFiles, fileOption)
6402+
}
6403+
}
6404+
}
6405+
6406+
// Skip optional semicolon
6407+
if p.curTok.Type == TokenSemicolon {
6408+
p.nextToken()
6409+
}
63356410

63366411
return stmt, nil
63376412
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"todo": true}
1+
{}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"todo": true}
1+
{}

0 commit comments

Comments
 (0)