1
0
Fork 0

Adding upstream version 18.11.2.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-13 21:04:14 +01:00
parent be16920347
commit 47f2114347
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
88 changed files with 52059 additions and 46960 deletions

View file

@ -22,6 +22,7 @@ from sqlglot.dialects.dialect import (
rename_func,
simplify_literal,
str_position_sql,
struct_extract_sql,
timestamptrunc_sql,
timestrtotime_sql,
trim_sql,
@ -248,11 +249,10 @@ class Postgres(Dialect):
}
class Tokenizer(tokens.Tokenizer):
QUOTES = ["'", "$$"]
BIT_STRINGS = [("b'", "'"), ("B'", "'")]
HEX_STRINGS = [("x'", "'"), ("X'", "'")]
BYTE_STRINGS = [("e'", "'"), ("E'", "'")]
HEREDOC_STRINGS = ["$"]
KEYWORDS = {
**tokens.Tokenizer.KEYWORDS,
@ -296,7 +296,7 @@ class Postgres(Dialect):
SINGLE_TOKENS = {
**tokens.Tokenizer.SINGLE_TOKENS,
"$": TokenType.PARAMETER,
"$": TokenType.HEREDOC_STRING,
}
VAR_SINGLE_TOKENS = {"$"}
@ -420,9 +420,15 @@ class Postgres(Dialect):
exp.Pow: lambda self, e: self.binary(e, "^"),
exp.RegexpLike: lambda self, e: self.binary(e, "~"),
exp.RegexpILike: lambda self, e: self.binary(e, "~*"),
exp.Select: transforms.preprocess([transforms.eliminate_semi_and_anti_joins]),
exp.Select: transforms.preprocess(
[
transforms.eliminate_semi_and_anti_joins,
transforms.eliminate_qualify,
]
),
exp.StrPosition: str_position_sql,
exp.StrToTime: lambda self, e: f"TO_TIMESTAMP({self.sql(e, 'this')}, {self.format_time(e)})",
exp.StructExtract: struct_extract_sql,
exp.Substring: _substring_sql,
exp.TimestampTrunc: timestamptrunc_sql,
exp.TimeStrToTime: timestrtotime_sql,