Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: introduce new google sql parser (#14108)
h3n4l8841113ac39a
diff --git a/backend/plugin/parser/bigquery/bigquery.go b/backend/plugin/parser/bigquery/bigquery.goindex 7a0d386ea0..9e7b285d4e 100644--- a/backend/plugin/parser/bigquery/bigquery.go+++ b/backend/plugin/parser/bigquery/bigquery.go@@ -4,7 +4,8 @@ import ("strings""github.com/antlr4-go/antlr/v4"- parser "github.com/bytebase/bq-parser"++ parser "github.com/bytebase/google-sql-parser""github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/utils"@@ -19,9 +20,9 @@ type ParseResult struct {func ParseBigQuerySQL(statement string) (*ParseResult, error) {statement = strings.TrimRightFunc(statement, utils.IsSpaceOrSemicolon) + "\n;"inputStream := antlr.NewInputStream(statement)- lexer := parser.NewBigQueryLexer(inputStream)+ lexer := parser.NewGoogleSQLLexer(inputStream)stream := antlr.NewCommonTokenStream(lexer, antlr.TokenDefaultChannel)- p := parser.NewBigQueryParser(stream)+ p := parser.NewGoogleSQLParser(stream)// Remove default error listener and add our own error listener.lexer.RemoveErrorListeners()diff --git a/go.mod b/go.modindex fec124d662..b19ee198d6 100644--- a/go.mod+++ b/go.mod@@ -19,7 +19,7 @@ require (github.com/beltran/gohive v1.7.0github.com/blang/semver/v4 v4.0.0github.com/buger/jsonparser v1.1.1- github.com/bytebase/bq-parser v0.0.0-20240529032606-614a0230b8f7+ github.com/bytebase/google-sql-parser v0.0.0-20241016105851-ce803f0fa608github.com/bytebase/mysql-parser v0.0.0-20240810145851-ab2c11629c24github.com/bytebase/plsql-parser v0.0.0-20240929073008-6b57c2e2525dgithub.com/bytebase/postgresql-parser v0.0.0-20241008085234-a95eacac994adiff --git a/go.sum b/go.sumindex 00d19850e3..cb293d47be 100644--- a/go.sum+++ b/go.sum@@ -807,8 +807,6 @@ github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUgithub.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=github.com/bytebase/antlr/v4 v4.0.0-20240827034948-8c385f108920 h1:IfmPt5o5R70NKtOrs+QHOoCgViYZelZysGxVBvV4ybA=github.com/bytebase/antlr/v4 v4.0.0-20240827034948-8c385f108920/go.mod h1:ykhjIPiv0IWpu3OGXCHdz2eUSe8UNGGD6baqjs8jSuU=-github.com/bytebase/bq-parser v0.0.0-20240529032606-614a0230b8f7 h1:tDEAGOa3tSmTOfUshYBwsOqunGajGu7SBL8NMlM71bU=-github.com/bytebase/bq-parser v0.0.0-20240529032606-614a0230b8f7/go.mod h1:uDDETOUNvOuKjha/g+oC8NdqhcGyGEl4NOeoKh2OhNE=github.com/bytebase/gh-ost2 v0.0.0-20240731091141-e7a12a9401ab h1:hJ3tfjfm5D63QwCH+znK1ZQQzk9/rG4Jjz7CSxVtSrQ=github.com/bytebase/gh-ost2 v0.0.0-20240731091141-e7a12a9401ab/go.mod h1:VRPqaDM7UYxJbcCtQkjBcNkxW17p6LJJdkM/nYwQhqg=github.com/bytebase/go-lsp v0.0.0-20240130071507-c04b5c75010c h1:W832GNANCst4C6TgYbQnKKxbuMZKQxTD4++b3HOuzBo=@@ -819,6 +817,8 @@ github.com/bytebase/go-obo v0.0.0-20231026081615-705a7fffbfd2 h1:nEHZi8S7PHT4GxPgithub.com/bytebase/go-obo v0.0.0-20231026081615-705a7fffbfd2/go.mod h1:wjDx6Xm9q7dFtHJvIlrI99JytznLw5wQ4R+9mNXJwGI=github.com/bytebase/gohive v0.0.0-20240422092929-d76993a958a4 h1:5o+GWOu+j68eAODMw7/lFJavWCCiPMeqEHuOGx0YmoU=github.com/bytebase/gohive v0.0.0-20240422092929-d76993a958a4/go.mod h1:sV29Oj7v/xsXJjJwLRYimdnEX6aZOA1ofAlZ+D/snOo=+github.com/bytebase/google-sql-parser v0.0.0-20241016105851-ce803f0fa608 h1:B88Y+MXApoe6RjsKYihTABPR3F2L5WJTAVNalxD6AVc=+github.com/bytebase/google-sql-parser v0.0.0-20241016105851-ce803f0fa608/go.mod h1:H+oTK2I5O8AGiB6ZMGMBDP9jk4d3CFJDP1lsbAurH6A=github.com/bytebase/gosasl v0.0.0-20240422091407-6b7481e86f08 h1:S1GgjJLspz4E4z4CvomGvKgxyv0ATfZm27qHM418jWc=github.com/bytebase/gosasl v0.0.0-20240422091407-6b7481e86f08/go.mod h1:Qx8cW6jkI8riyzmklj80kAIkv+iezFUTBiGU0qHhHes=github.com/bytebase/mysql-parser v0.0.0-20240810145851-ab2c11629c24 h1:tI2/dg8P5DkwVODgDtqzOoFhmhUBFxSKpMyoyGOq1YU=