summaryrefslogtreecommitdiffstats
path: root/sqlglot/dialects/dialect.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-09-13 09:17:40 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-09-13 09:17:40 +0000
commitbdf5cc7bdd5ec93dc928d81e286f7b1e678ba19d (patch)
tree4d46f9407b792f6fd5d767d510e6865ec9640569 /sqlglot/dialects/dialect.py
parentReleasing progress-linux version 18.3.0-1. (diff)
downloadsqlglot-bdf5cc7bdd5ec93dc928d81e286f7b1e678ba19d.tar.xz
sqlglot-bdf5cc7bdd5ec93dc928d81e286f7b1e678ba19d.zip
Merging upstream version 18.4.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/dialects/dialect.py')
-rw-r--r--sqlglot/dialects/dialect.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/sqlglot/dialects/dialect.py b/sqlglot/dialects/dialect.py
index 1bfbfef..ff22547 100644
--- a/sqlglot/dialects/dialect.py
+++ b/sqlglot/dialects/dialect.py
@@ -2,6 +2,7 @@ from __future__ import annotations
import typing as t
from enum import Enum
+from functools import reduce
from sqlglot import exp
from sqlglot._typing import E
@@ -656,11 +657,18 @@ def ts_or_ds_to_date_sql(dialect: str) -> t.Callable:
def concat_to_dpipe_sql(self: Generator, expression: exp.Concat | exp.SafeConcat) -> str:
expression = expression.copy()
- this, *rest_args = expression.expressions
- for arg in rest_args:
- this = exp.DPipe(this=this, expression=arg)
+ return self.sql(reduce(lambda x, y: exp.DPipe(this=x, expression=y), expression.expressions))
- return self.sql(this)
+
+def concat_ws_to_dpipe_sql(self: Generator, expression: exp.ConcatWs) -> str:
+ expression = expression.copy()
+ delim, *rest_args = expression.expressions
+ return self.sql(
+ reduce(
+ lambda x, y: exp.DPipe(this=x, expression=exp.DPipe(this=delim, expression=y)),
+ rest_args,
+ )
+ )
def regexp_extract_sql(self: Generator, expression: exp.RegexpExtract) -> str: