Adding upstream version 21.0.1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
07f4660f31
commit
91f2cef5f0
115 changed files with 66603 additions and 60920 deletions
|
@ -7,11 +7,11 @@ from sqlglot.dialects.dialect import (
|
|||
DATE_ADD_OR_SUB,
|
||||
Dialect,
|
||||
any_value_to_max_sql,
|
||||
arrow_json_extract_scalar_sql,
|
||||
arrow_json_extract_sql,
|
||||
bool_xor_sql,
|
||||
datestrtodate_sql,
|
||||
format_time_lambda,
|
||||
json_extract_segments,
|
||||
json_path_key_only_name,
|
||||
max_or_greatest,
|
||||
merge_without_target_sql,
|
||||
min_or_least,
|
||||
|
@ -20,6 +20,7 @@ from sqlglot.dialects.dialect import (
|
|||
no_paren_current_date_sql,
|
||||
no_pivot_sql,
|
||||
no_trycast_sql,
|
||||
parse_json_extract_path,
|
||||
parse_timestamp_trunc,
|
||||
rename_func,
|
||||
str_position_sql,
|
||||
|
@ -292,6 +293,8 @@ class Postgres(Dialect):
|
|||
**parser.Parser.FUNCTIONS,
|
||||
"DATE_TRUNC": parse_timestamp_trunc,
|
||||
"GENERATE_SERIES": _generate_series,
|
||||
"JSON_EXTRACT_PATH": parse_json_extract_path(exp.JSONExtract),
|
||||
"JSON_EXTRACT_PATH_TEXT": parse_json_extract_path(exp.JSONExtractScalar),
|
||||
"MAKE_TIME": exp.TimeFromParts.from_arg_list,
|
||||
"MAKE_TIMESTAMP": exp.TimestampFromParts.from_arg_list,
|
||||
"NOW": exp.CurrentTimestamp.from_arg_list,
|
||||
|
@ -375,8 +378,15 @@ class Postgres(Dialect):
|
|||
TABLESAMPLE_SIZE_IS_ROWS = False
|
||||
TABLESAMPLE_SEED_KEYWORD = "REPEATABLE"
|
||||
SUPPORTS_SELECT_INTO = True
|
||||
# https://www.postgresql.org/docs/current/sql-createtable.html
|
||||
JSON_TYPE_REQUIRED_FOR_EXTRACTION = True
|
||||
SUPPORTS_UNLOGGED_TABLES = True
|
||||
LIKE_PROPERTY_INSIDE_SCHEMA = True
|
||||
|
||||
SUPPORTED_JSON_PATH_PARTS = {
|
||||
exp.JSONPathKey,
|
||||
exp.JSONPathRoot,
|
||||
exp.JSONPathSubscript,
|
||||
}
|
||||
|
||||
TYPE_MAPPING = {
|
||||
**generator.Generator.TYPE_MAPPING,
|
||||
|
@ -412,11 +422,14 @@ class Postgres(Dialect):
|
|||
exp.DateSub: _date_add_sql("-"),
|
||||
exp.Explode: rename_func("UNNEST"),
|
||||
exp.GroupConcat: _string_agg_sql,
|
||||
exp.JSONExtract: arrow_json_extract_sql,
|
||||
exp.JSONExtractScalar: arrow_json_extract_scalar_sql,
|
||||
exp.JSONExtract: json_extract_segments("JSON_EXTRACT_PATH"),
|
||||
exp.JSONExtractScalar: json_extract_segments("JSON_EXTRACT_PATH_TEXT"),
|
||||
exp.JSONBExtract: lambda self, e: self.binary(e, "#>"),
|
||||
exp.JSONBExtractScalar: lambda self, e: self.binary(e, "#>>"),
|
||||
exp.JSONBContains: lambda self, e: self.binary(e, "?"),
|
||||
exp.JSONPathKey: json_path_key_only_name,
|
||||
exp.JSONPathRoot: lambda *_: "",
|
||||
exp.JSONPathSubscript: lambda self, e: self.json_path_part(e.this),
|
||||
exp.LastDay: no_last_day_sql,
|
||||
exp.LogicalOr: rename_func("BOOL_OR"),
|
||||
exp.LogicalAnd: rename_func("BOOL_AND"),
|
||||
|
@ -443,7 +456,8 @@ class Postgres(Dialect):
|
|||
]
|
||||
),
|
||||
exp.StrPosition: str_position_sql,
|
||||
exp.StrToTime: lambda self, e: f"TO_TIMESTAMP({self.sql(e, 'this')}, {self.format_time(e)})",
|
||||
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.TimeFromParts: rename_func("MAKE_TIME"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue