2025-02-13 14:53:05 +01:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2025-02-13 06:15:54 +01:00
|
|
|
from sqlglot import exp
|
|
|
|
from sqlglot.dialects.presto import Presto
|
|
|
|
|
|
|
|
|
|
|
|
class Trino(Presto):
|
|
|
|
class Generator(Presto.Generator):
|
|
|
|
TRANSFORMS = {
|
2025-02-13 14:53:05 +01:00
|
|
|
**Presto.Generator.TRANSFORMS, # type: ignore
|
2025-02-13 06:15:54 +01:00
|
|
|
exp.ArraySum: lambda self, e: f"REDUCE({self.sql(e, 'this')}, 0, (acc, x) -> acc + x, acc -> acc)",
|
|
|
|
}
|
2025-02-13 08:04:41 +01:00
|
|
|
|
|
|
|
class Tokenizer(Presto.Tokenizer):
|
|
|
|
HEX_STRINGS = [("X'", "'")]
|