1
0
Fork 0

Adding upstream version 24.1.0.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-13 21:36:52 +01:00
parent 8b1190270c
commit dd3422a695
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
70 changed files with 55134 additions and 50721 deletions

View file

@ -473,6 +473,14 @@ class Snowflake(Dialect):
"TERSE USERS": _show_parser("USERS"),
}
CONSTRAINT_PARSERS = {
**parser.Parser.CONSTRAINT_PARSERS,
"WITH": lambda self: self._parse_with_constraint(),
"MASKING": lambda self: self._parse_with_constraint(),
"PROJECTION": lambda self: self._parse_with_constraint(),
"TAG": lambda self: self._parse_with_constraint(),
}
STAGED_FILE_SINGLE_TOKENS = {
TokenType.DOT,
TokenType.MOD,
@ -497,6 +505,29 @@ class Snowflake(Dialect):
),
}
def _parse_with_constraint(self) -> t.Optional[exp.Expression]:
if self._prev.token_type != TokenType.WITH:
self._retreat(self._index - 1)
if self._match_text_seq("MASKING", "POLICY"):
return self.expression(
exp.MaskingPolicyColumnConstraint,
this=self._parse_id_var(),
expressions=self._match(TokenType.USING)
and self._parse_wrapped_csv(self._parse_id_var),
)
if self._match_text_seq("PROJECTION", "POLICY"):
return self.expression(
exp.ProjectionPolicyColumnConstraint, this=self._parse_id_var()
)
if self._match(TokenType.TAG):
return self.expression(
exp.TagColumnConstraint,
expressions=self._parse_wrapped_csv(self._parse_property),
)
return None
def _parse_create(self) -> exp.Create | exp.Command:
expression = super()._parse_create()
if isinstance(expression, exp.Create) and expression.kind in self.NON_TABLE_CREATABLES: