TestSnowflakeKeywordsBaseOverlap verifies that keywords which exist in both the base set and the Snowflake set don't cause issues (the base definition takes precedence since addKeywordsWithCategory skips duplicates).
(t *testing.T)
| 160 | // the base set and the Snowflake set don't cause issues (the base definition |
| 161 | // takes precedence since addKeywordsWithCategory skips duplicates). |
| 162 | func TestSnowflakeKeywordsBaseOverlap(t *testing.T) { |
| 163 | k := New(DialectSnowflake, true) |
| 164 | |
| 165 | // These keywords exist in the base set and should retain their base token types |
| 166 | baseOverlapKeywords := []struct { |
| 167 | word string |
| 168 | expectedType models.TokenType |
| 169 | }{ |
| 170 | {"ARRAY", models.TokenTypeArray}, |
| 171 | {"LATERAL", models.TokenTypeLateral}, |
| 172 | {"QUALIFY", models.TokenTypeKeyword}, |
| 173 | {"SAMPLE", models.TokenTypeKeyword}, |
| 174 | {"CLUSTER", models.TokenTypeKeyword}, |
| 175 | {"OFFSET", models.TokenTypeOffset}, |
| 176 | {"SHARE", models.TokenTypeShare}, |
| 177 | {"LIST", models.TokenTypeKeyword}, |
| 178 | } |
| 179 | |
| 180 | for _, tt := range baseOverlapKeywords { |
| 181 | t.Run(tt.word, func(t *testing.T) { |
| 182 | if !k.IsKeyword(tt.word) { |
| 183 | t.Errorf("Overlapping keyword %q should exist in Snowflake dialect", tt.word) |
| 184 | } |
| 185 | |
| 186 | tokenType := k.GetTokenType(tt.word) |
| 187 | if tokenType != tt.expectedType { |
| 188 | t.Errorf("GetTokenType(%q) = %v, want %v (base definition should take precedence)", |
| 189 | tt.word, tokenType, tt.expectedType) |
| 190 | } |
| 191 | }) |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | // TestSnowflakeDialectKeywords verifies DialectKeywords returns the Snowflake keyword list. |
| 196 | func TestSnowflakeDialectKeywords(t *testing.T) { |
nothing calls this directly
no test coverage detected