summaryrefslogtreecommitdiffstats
path: root/sqlglot/dialects/trino.py
blob: c7b34fe12caa8b61d852be320e7a7bd4262008d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from __future__ import annotations

from sqlglot import exp
from sqlglot.dialects.presto import Presto


class Trino(Presto):
    class Generator(Presto.Generator):
        TRANSFORMS = {
            **Presto.Generator.TRANSFORMS,  # type: ignore
            exp.ArraySum: lambda self, e: f"REDUCE({self.sql(e, 'this')}, 0, (acc, x) -> acc + x, acc -> acc)",
        }

    class Tokenizer(Presto.Tokenizer):
        HEX_STRINGS = [("X'", "'")]