Adding upstream version 26.9.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
4c394df415
commit
412e82cbc6
43 changed files with 27039 additions and 26675 deletions
|
@ -34,6 +34,7 @@ from sqlglot.dialects.dialect import (
|
|||
ts_or_ds_add_cast,
|
||||
strposition_sql,
|
||||
count_if_to_sum,
|
||||
groupconcat_sql,
|
||||
)
|
||||
from sqlglot.generator import unsupported_args
|
||||
from sqlglot.helper import is_int, seq_get
|
||||
|
@ -109,19 +110,6 @@ def _substring_sql(self: Postgres.Generator, expression: exp.Substring) -> str:
|
|||
return f"SUBSTRING({this}{from_part}{for_part})"
|
||||
|
||||
|
||||
def _string_agg_sql(self: Postgres.Generator, expression: exp.GroupConcat) -> str:
|
||||
separator = expression.args.get("separator") or exp.Literal.string(",")
|
||||
|
||||
order = ""
|
||||
this = expression.this
|
||||
if isinstance(this, exp.Order):
|
||||
if this.this:
|
||||
this = this.this.pop()
|
||||
order = self.sql(expression.this) # Order has a leading space
|
||||
|
||||
return f"STRING_AGG({self.format_args(this, separator)}{order})"
|
||||
|
||||
|
||||
def _auto_increment_to_serial(expression: exp.Expression) -> exp.Expression:
|
||||
auto = expression.find(exp.AutoIncrementColumnConstraint)
|
||||
|
||||
|
@ -539,6 +527,7 @@ class Postgres(Dialect):
|
|||
exp.DataType.Type.VARBINARY: "BYTEA",
|
||||
exp.DataType.Type.ROWVERSION: "BYTEA",
|
||||
exp.DataType.Type.DATETIME: "TIMESTAMP",
|
||||
exp.DataType.Type.BLOB: "BYTEA",
|
||||
}
|
||||
|
||||
TRANSFORMS = {
|
||||
|
@ -557,7 +546,9 @@ class Postgres(Dialect):
|
|||
exp.DateSub: _date_add_sql("-"),
|
||||
exp.Explode: rename_func("UNNEST"),
|
||||
exp.ExplodingGenerateSeries: rename_func("GENERATE_SERIES"),
|
||||
exp.GroupConcat: _string_agg_sql,
|
||||
exp.GroupConcat: lambda self, e: groupconcat_sql(
|
||||
self, e, func_name="STRING_AGG", within_group=False
|
||||
),
|
||||
exp.IntDiv: rename_func("DIV"),
|
||||
exp.JSONExtract: _json_extract_sql("JSON_EXTRACT_PATH", "->"),
|
||||
exp.JSONExtractScalar: _json_extract_sql("JSON_EXTRACT_PATH_TEXT", "->>"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue