Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: align Snowflake BaseLine calculation with Cassandra approach (#18156)
h3n4l29b6ac037e61
diff --git a/backend/plugin/parser/snowflake/snowflake.go b/backend/plugin/parser/snowflake/snowflake.goindex 9d3387a2c9..d45b37614e 100644--- a/backend/plugin/parser/snowflake/snowflake.go+++ b/backend/plugin/parser/snowflake/snowflake.go@@ -54,11 +54,6 @@ func ParseSnowSQL(sql string) ([]*ParseResult, error) {// parseSingleSnowSQL parses a single Snowflake statement and returns the ParseResult.func parseSingleSnowSQL(statement string, baseLine int) (*ParseResult, error) {- // Trim leading newlines to ensure the first token starts at line 1 in ANTLR- // This makes baseLine calculations simpler: baseLine + line = original line- statement = strings.TrimLeftFunc(statement, func(r rune) bool {- return r == '\n' || r == '\r'- })statement = strings.TrimRightFunc(statement, utils.IsSpaceOrSemicolon) + "\n;"inputStream := antlr.NewInputStream(statement)lexer := parser.NewSnowflakeLexer(inputStream)diff --git a/backend/plugin/parser/snowflake/snowflake_test.go b/backend/plugin/parser/snowflake/snowflake_test.goindex a7292aa611..733bd1cc41 100644--- a/backend/plugin/parser/snowflake/snowflake_test.go+++ b/backend/plugin/parser/snowflake/snowflake_test.go@@ -54,8 +54,7 @@ func TestParseSnowSQL(t *testing.T) {sql: "SELECT 1;\n SELEC 5;\nSELECT 6;",// After standardization, each statement is parsed separately, so the error context// only includes the current statement being parsed (not previous statements).- // Leading newlines are trimmed, so the error context shows the trimmed text.- err: "Syntax error at line 2:4 \nrelated text: SELEC",+ err: "Syntax error at line 2:4 \nrelated text: \n SELEC",},}diff --git a/backend/plugin/parser/snowflake/split.go b/backend/plugin/parser/snowflake/split.goindex bdd13c2e21..601991eb38 100644--- a/backend/plugin/parser/snowflake/split.go+++ b/backend/plugin/parser/snowflake/split.go@@ -15,13 +15,6 @@ func init() {base.RegisterSplitterFunc(storepb.Engine_SNOWFLAKE, SplitSQL)}-// calculateBaseLine calculates the base line offset for a split statement.-// Since we trim leading newlines before parsing, the first token will be on line 1-// in the parsed result. Therefore, baseLine = original line - 1.-func calculateBaseLine(_ []antlr.Token, antlrPosition *common.ANTLRPosition) int {- return int(antlrPosition.Line) - 1-}-// SplitSQL splits the given SQL statement into multiple SQL statements using ANTLR lexer.func SplitSQL(statement string) ([]base.SingleSQL, error) {lexer := parser.NewSnowflakeLexer(antlr.NewInputStream(statement))@@ -54,7 +47,7 @@ func SplitSQL(statement string) ([]base.SingleSQL, error) {// instead of the last token in bufsqls = append(sqls, base.SingleSQL{Text: bufStr.String(),- BaseLine: calculateBaseLine(buf, antlrPosition),+ BaseLine: buf[0].GetLine() - 1,End: common.ConvertANTLRPositionToPosition(&common.ANTLRPosition{Line: int32(token.GetLine()),Column: int32(token.GetColumn()),diff --git a/backend/plugin/parser/snowflake/split_test.go b/backend/plugin/parser/snowflake/split_test.goindex 1beac3a5d6..36cfe03aab 100644--- a/backend/plugin/parser/snowflake/split_test.go+++ b/backend/plugin/parser/snowflake/split_test.go@@ -23,14 +23,14 @@ func TestSplitSQL(t *testing.T) {},{Text: "\n\tSELECT * FROM orders;",- BaseLine: 1, // Corrected: first token is on line 2 of original SQL+ BaseLine: 0,Start: &storepb.Position{Line: 2, Column: 2},End: &storepb.Position{Line: 2, Column: 22},Empty: false,},{Text: "\n\tSELECT * FROM products;",- BaseLine: 2, // Corrected: first token is on line 3 of original SQL+ BaseLine: 1,Start: &storepb.Position{Line: 3, Column: 2},End: &storepb.Position{Line: 3, Column: 24},Empty: false,