Edit on GitHub

sqlglot.dialects.clickhouse

   1from __future__ import annotations
   2
   3import typing as t
   4
   5from sqlglot import exp, generator, parser, tokens
   6from sqlglot.dialects.dialect import (
   7    Dialect,
   8    NormalizationStrategy,
   9    arg_max_or_min_no_count,
  10    build_date_delta,
  11    build_formatted_time,
  12    inline_array_sql,
  13    json_extract_segments,
  14    json_path_key_only_name,
  15    no_pivot_sql,
  16    build_json_extract_path,
  17    rename_func,
  18    sha256_sql,
  19    var_map_sql,
  20    timestamptrunc_sql,
  21    unit_to_var,
  22)
  23from sqlglot.generator import Generator
  24from sqlglot.helper import is_int, seq_get
  25from sqlglot.tokens import Token, TokenType
  26
  27DATEΤΙΜΕ_DELTA = t.Union[exp.DateAdd, exp.DateDiff, exp.DateSub, exp.TimestampSub, exp.TimestampAdd]
  28
  29
  30def _build_date_format(args: t.List) -> exp.TimeToStr:
  31    expr = build_formatted_time(exp.TimeToStr, "clickhouse")(args)
  32
  33    timezone = seq_get(args, 2)
  34    if timezone:
  35        expr.set("timezone", timezone)
  36
  37    return expr
  38
  39
  40def _unix_to_time_sql(self: ClickHouse.Generator, expression: exp.UnixToTime) -> str:
  41    scale = expression.args.get("scale")
  42    timestamp = expression.this
  43
  44    if scale in (None, exp.UnixToTime.SECONDS):
  45        return self.func("fromUnixTimestamp", exp.cast(timestamp, exp.DataType.Type.BIGINT))
  46    if scale == exp.UnixToTime.MILLIS:
  47        return self.func("fromUnixTimestamp64Milli", exp.cast(timestamp, exp.DataType.Type.BIGINT))
  48    if scale == exp.UnixToTime.MICROS:
  49        return self.func("fromUnixTimestamp64Micro", exp.cast(timestamp, exp.DataType.Type.BIGINT))
  50    if scale == exp.UnixToTime.NANOS:
  51        return self.func("fromUnixTimestamp64Nano", exp.cast(timestamp, exp.DataType.Type.BIGINT))
  52
  53    return self.func(
  54        "fromUnixTimestamp",
  55        exp.cast(
  56            exp.Div(this=timestamp, expression=exp.func("POW", 10, scale)), exp.DataType.Type.BIGINT
  57        ),
  58    )
  59
  60
  61def _lower_func(sql: str) -> str:
  62    index = sql.index("(")
  63    return sql[:index].lower() + sql[index:]
  64
  65
  66def _quantile_sql(self: ClickHouse.Generator, expression: exp.Quantile) -> str:
  67    quantile = expression.args["quantile"]
  68    args = f"({self.sql(expression, 'this')})"
  69
  70    if isinstance(quantile, exp.Array):
  71        func = self.func("quantiles", *quantile)
  72    else:
  73        func = self.func("quantile", quantile)
  74
  75    return func + args
  76
  77
  78def _build_count_if(args: t.List) -> exp.CountIf | exp.CombinedAggFunc:
  79    if len(args) == 1:
  80        return exp.CountIf(this=seq_get(args, 0))
  81
  82    return exp.CombinedAggFunc(this="countIf", expressions=args, parts=("count", "If"))
  83
  84
  85def _build_str_to_date(args: t.List) -> exp.Cast | exp.Anonymous:
  86    if len(args) == 3:
  87        return exp.Anonymous(this="STR_TO_DATE", expressions=args)
  88
  89    strtodate = exp.StrToDate.from_arg_list(args)
  90    return exp.cast(strtodate, exp.DataType.build(exp.DataType.Type.DATETIME))
  91
  92
  93def _datetime_delta_sql(name: str) -> t.Callable[[Generator, DATEΤΙΜΕ_DELTA], str]:
  94    def _delta_sql(self: Generator, expression: DATEΤΙΜΕ_DELTA) -> str:
  95        if not expression.unit:
  96            return rename_func(name)(self, expression)
  97
  98        return self.func(
  99            name,
 100            unit_to_var(expression),
 101            expression.expression,
 102            expression.this,
 103        )
 104
 105    return _delta_sql
 106
 107
 108class ClickHouse(Dialect):
 109    NORMALIZE_FUNCTIONS: bool | str = False
 110    NULL_ORDERING = "nulls_are_last"
 111    SUPPORTS_USER_DEFINED_TYPES = False
 112    SAFE_DIVISION = True
 113    LOG_BASE_FIRST: t.Optional[bool] = None
 114    FORCE_EARLY_ALIAS_REF_EXPANSION = True
 115
 116    # https://github.com/ClickHouse/ClickHouse/issues/33935#issue-1112165779
 117    NORMALIZATION_STRATEGY = NormalizationStrategy.CASE_SENSITIVE
 118
 119    UNESCAPED_SEQUENCES = {
 120        "\\0": "\0",
 121    }
 122
 123    CREATABLE_KIND_MAPPING = {"DATABASE": "SCHEMA"}
 124
 125    class Tokenizer(tokens.Tokenizer):
 126        COMMENTS = ["--", "#", "#!", ("/*", "*/")]
 127        IDENTIFIERS = ['"', "`"]
 128        STRING_ESCAPES = ["'", "\\"]
 129        BIT_STRINGS = [("0b", "")]
 130        HEX_STRINGS = [("0x", ""), ("0X", "")]
 131        HEREDOC_STRINGS = ["$"]
 132
 133        KEYWORDS = {
 134            **tokens.Tokenizer.KEYWORDS,
 135            "ATTACH": TokenType.COMMAND,
 136            "DATE32": TokenType.DATE32,
 137            "DATETIME64": TokenType.DATETIME64,
 138            "DICTIONARY": TokenType.DICTIONARY,
 139            "ENUM8": TokenType.ENUM8,
 140            "ENUM16": TokenType.ENUM16,
 141            "FINAL": TokenType.FINAL,
 142            "FIXEDSTRING": TokenType.FIXEDSTRING,
 143            "FLOAT32": TokenType.FLOAT,
 144            "FLOAT64": TokenType.DOUBLE,
 145            "GLOBAL": TokenType.GLOBAL,
 146            "INT256": TokenType.INT256,
 147            "LOWCARDINALITY": TokenType.LOWCARDINALITY,
 148            "MAP": TokenType.MAP,
 149            "NESTED": TokenType.NESTED,
 150            "SAMPLE": TokenType.TABLE_SAMPLE,
 151            "TUPLE": TokenType.STRUCT,
 152            "UINT128": TokenType.UINT128,
 153            "UINT16": TokenType.USMALLINT,
 154            "UINT256": TokenType.UINT256,
 155            "UINT32": TokenType.UINT,
 156            "UINT64": TokenType.UBIGINT,
 157            "UINT8": TokenType.UTINYINT,
 158            "IPV4": TokenType.IPV4,
 159            "IPV6": TokenType.IPV6,
 160            "AGGREGATEFUNCTION": TokenType.AGGREGATEFUNCTION,
 161            "SIMPLEAGGREGATEFUNCTION": TokenType.SIMPLEAGGREGATEFUNCTION,
 162            "SYSTEM": TokenType.COMMAND,
 163            "PREWHERE": TokenType.PREWHERE,
 164        }
 165        KEYWORDS.pop("/*+")
 166
 167        SINGLE_TOKENS = {
 168            **tokens.Tokenizer.SINGLE_TOKENS,
 169            "$": TokenType.HEREDOC_STRING,
 170        }
 171
 172    class Parser(parser.Parser):
 173        # Tested in ClickHouse's playground, it seems that the following two queries do the same thing
 174        # * select x from t1 union all select x from t2 limit 1;
 175        # * select x from t1 union all (select x from t2 limit 1);
 176        MODIFIERS_ATTACHED_TO_SET_OP = False
 177        INTERVAL_SPANS = False
 178
 179        FUNCTIONS = {
 180            **parser.Parser.FUNCTIONS,
 181            "ANY": exp.AnyValue.from_arg_list,
 182            "ARRAYSUM": exp.ArraySum.from_arg_list,
 183            "COUNTIF": _build_count_if,
 184            "DATE_ADD": build_date_delta(exp.DateAdd, default_unit=None),
 185            "DATEADD": build_date_delta(exp.DateAdd, default_unit=None),
 186            "DATE_DIFF": build_date_delta(exp.DateDiff, default_unit=None),
 187            "DATEDIFF": build_date_delta(exp.DateDiff, default_unit=None),
 188            "DATE_FORMAT": _build_date_format,
 189            "DATE_SUB": build_date_delta(exp.DateSub, default_unit=None),
 190            "DATESUB": build_date_delta(exp.DateSub, default_unit=None),
 191            "FORMATDATETIME": _build_date_format,
 192            "JSONEXTRACTSTRING": build_json_extract_path(
 193                exp.JSONExtractScalar, zero_based_indexing=False
 194            ),
 195            "MAP": parser.build_var_map,
 196            "MATCH": exp.RegexpLike.from_arg_list,
 197            "RANDCANONICAL": exp.Rand.from_arg_list,
 198            "STR_TO_DATE": _build_str_to_date,
 199            "TUPLE": exp.Struct.from_arg_list,
 200            "TIMESTAMP_SUB": build_date_delta(exp.TimestampSub, default_unit=None),
 201            "TIMESTAMPSUB": build_date_delta(exp.TimestampSub, default_unit=None),
 202            "TIMESTAMP_ADD": build_date_delta(exp.TimestampAdd, default_unit=None),
 203            "TIMESTAMPADD": build_date_delta(exp.TimestampAdd, default_unit=None),
 204            "UNIQ": exp.ApproxDistinct.from_arg_list,
 205            "XOR": lambda args: exp.Xor(expressions=args),
 206            "MD5": exp.MD5Digest.from_arg_list,
 207            "SHA256": lambda args: exp.SHA2(this=seq_get(args, 0), length=exp.Literal.number(256)),
 208            "SHA512": lambda args: exp.SHA2(this=seq_get(args, 0), length=exp.Literal.number(512)),
 209        }
 210
 211        AGG_FUNCTIONS = {
 212            "count",
 213            "min",
 214            "max",
 215            "sum",
 216            "avg",
 217            "any",
 218            "stddevPop",
 219            "stddevSamp",
 220            "varPop",
 221            "varSamp",
 222            "corr",
 223            "covarPop",
 224            "covarSamp",
 225            "entropy",
 226            "exponentialMovingAverage",
 227            "intervalLengthSum",
 228            "kolmogorovSmirnovTest",
 229            "mannWhitneyUTest",
 230            "median",
 231            "rankCorr",
 232            "sumKahan",
 233            "studentTTest",
 234            "welchTTest",
 235            "anyHeavy",
 236            "anyLast",
 237            "boundingRatio",
 238            "first_value",
 239            "last_value",
 240            "argMin",
 241            "argMax",
 242            "avgWeighted",
 243            "topK",
 244            "topKWeighted",
 245            "deltaSum",
 246            "deltaSumTimestamp",
 247            "groupArray",
 248            "groupArrayLast",
 249            "groupUniqArray",
 250            "groupArrayInsertAt",
 251            "groupArrayMovingAvg",
 252            "groupArrayMovingSum",
 253            "groupArraySample",
 254            "groupBitAnd",
 255            "groupBitOr",
 256            "groupBitXor",
 257            "groupBitmap",
 258            "groupBitmapAnd",
 259            "groupBitmapOr",
 260            "groupBitmapXor",
 261            "sumWithOverflow",
 262            "sumMap",
 263            "minMap",
 264            "maxMap",
 265            "skewSamp",
 266            "skewPop",
 267            "kurtSamp",
 268            "kurtPop",
 269            "uniq",
 270            "uniqExact",
 271            "uniqCombined",
 272            "uniqCombined64",
 273            "uniqHLL12",
 274            "uniqTheta",
 275            "quantile",
 276            "quantiles",
 277            "quantileExact",
 278            "quantilesExact",
 279            "quantileExactLow",
 280            "quantilesExactLow",
 281            "quantileExactHigh",
 282            "quantilesExactHigh",
 283            "quantileExactWeighted",
 284            "quantilesExactWeighted",
 285            "quantileTiming",
 286            "quantilesTiming",
 287            "quantileTimingWeighted",
 288            "quantilesTimingWeighted",
 289            "quantileDeterministic",
 290            "quantilesDeterministic",
 291            "quantileTDigest",
 292            "quantilesTDigest",
 293            "quantileTDigestWeighted",
 294            "quantilesTDigestWeighted",
 295            "quantileBFloat16",
 296            "quantilesBFloat16",
 297            "quantileBFloat16Weighted",
 298            "quantilesBFloat16Weighted",
 299            "simpleLinearRegression",
 300            "stochasticLinearRegression",
 301            "stochasticLogisticRegression",
 302            "categoricalInformationValue",
 303            "contingency",
 304            "cramersV",
 305            "cramersVBiasCorrected",
 306            "theilsU",
 307            "maxIntersections",
 308            "maxIntersectionsPosition",
 309            "meanZTest",
 310            "quantileInterpolatedWeighted",
 311            "quantilesInterpolatedWeighted",
 312            "quantileGK",
 313            "quantilesGK",
 314            "sparkBar",
 315            "sumCount",
 316            "largestTriangleThreeBuckets",
 317            "histogram",
 318            "sequenceMatch",
 319            "sequenceCount",
 320            "windowFunnel",
 321            "retention",
 322            "uniqUpTo",
 323            "sequenceNextNode",
 324            "exponentialTimeDecayedAvg",
 325        }
 326
 327        AGG_FUNCTIONS_SUFFIXES = [
 328            "If",
 329            "Array",
 330            "ArrayIf",
 331            "Map",
 332            "SimpleState",
 333            "State",
 334            "Merge",
 335            "MergeState",
 336            "ForEach",
 337            "Distinct",
 338            "OrDefault",
 339            "OrNull",
 340            "Resample",
 341            "ArgMin",
 342            "ArgMax",
 343        ]
 344
 345        FUNC_TOKENS = {
 346            *parser.Parser.FUNC_TOKENS,
 347            TokenType.SET,
 348        }
 349
 350        RESERVED_TOKENS = parser.Parser.RESERVED_TOKENS - {TokenType.SELECT}
 351
 352        ID_VAR_TOKENS = {
 353            *parser.Parser.ID_VAR_TOKENS,
 354            TokenType.LIKE,
 355        }
 356
 357        AGG_FUNC_MAPPING = (
 358            lambda functions, suffixes: {
 359                f"{f}{sfx}": (f, sfx) for sfx in (suffixes + [""]) for f in functions
 360            }
 361        )(AGG_FUNCTIONS, AGG_FUNCTIONS_SUFFIXES)
 362
 363        FUNCTIONS_WITH_ALIASED_ARGS = {*parser.Parser.FUNCTIONS_WITH_ALIASED_ARGS, "TUPLE"}
 364
 365        FUNCTION_PARSERS = {
 366            **parser.Parser.FUNCTION_PARSERS,
 367            "ARRAYJOIN": lambda self: self.expression(exp.Explode, this=self._parse_expression()),
 368            "QUANTILE": lambda self: self._parse_quantile(),
 369        }
 370
 371        FUNCTION_PARSERS.pop("MATCH")
 372
 373        NO_PAREN_FUNCTION_PARSERS = parser.Parser.NO_PAREN_FUNCTION_PARSERS.copy()
 374        NO_PAREN_FUNCTION_PARSERS.pop("ANY")
 375
 376        RANGE_PARSERS = {
 377            **parser.Parser.RANGE_PARSERS,
 378            TokenType.GLOBAL: lambda self, this: self._match(TokenType.IN)
 379            and self._parse_in(this, is_global=True),
 380        }
 381
 382        # The PLACEHOLDER entry is popped because 1) it doesn't affect Clickhouse (it corresponds to
 383        # the postgres-specific JSONBContains parser) and 2) it makes parsing the ternary op simpler.
 384        COLUMN_OPERATORS = parser.Parser.COLUMN_OPERATORS.copy()
 385        COLUMN_OPERATORS.pop(TokenType.PLACEHOLDER)
 386
 387        JOIN_KINDS = {
 388            *parser.Parser.JOIN_KINDS,
 389            TokenType.ANY,
 390            TokenType.ASOF,
 391            TokenType.ARRAY,
 392        }
 393
 394        TABLE_ALIAS_TOKENS = parser.Parser.TABLE_ALIAS_TOKENS - {
 395            TokenType.ANY,
 396            TokenType.ARRAY,
 397            TokenType.FINAL,
 398            TokenType.FORMAT,
 399            TokenType.SETTINGS,
 400        }
 401
 402        ALIAS_TOKENS = parser.Parser.ALIAS_TOKENS - {
 403            TokenType.FORMAT,
 404        }
 405
 406        LOG_DEFAULTS_TO_LN = True
 407
 408        QUERY_MODIFIER_PARSERS = {
 409            **parser.Parser.QUERY_MODIFIER_PARSERS,
 410            TokenType.SETTINGS: lambda self: (
 411                "settings",
 412                self._advance() or self._parse_csv(self._parse_assignment),
 413            ),
 414            TokenType.FORMAT: lambda self: ("format", self._advance() or self._parse_id_var()),
 415        }
 416
 417        CONSTRAINT_PARSERS = {
 418            **parser.Parser.CONSTRAINT_PARSERS,
 419            "INDEX": lambda self: self._parse_index_constraint(),
 420            "CODEC": lambda self: self._parse_compress(),
 421        }
 422
 423        ALTER_PARSERS = {
 424            **parser.Parser.ALTER_PARSERS,
 425            "REPLACE": lambda self: self._parse_alter_table_replace(),
 426        }
 427
 428        SCHEMA_UNNAMED_CONSTRAINTS = {
 429            *parser.Parser.SCHEMA_UNNAMED_CONSTRAINTS,
 430            "INDEX",
 431        }
 432
 433        def _parse_types(
 434            self, check_func: bool = False, schema: bool = False, allow_identifiers: bool = True
 435        ) -> t.Optional[exp.Expression]:
 436            dtype = super()._parse_types(
 437                check_func=check_func, schema=schema, allow_identifiers=allow_identifiers
 438            )
 439            if isinstance(dtype, exp.DataType):
 440                # Mark every type as non-nullable which is ClickHouse's default. This marker
 441                # helps us transpile types from other dialects to ClickHouse, so that we can
 442                # e.g. produce `CAST(x AS Nullable(String))` from `CAST(x AS TEXT)`. If there
 443                # is a `NULL` value in `x`, the former would fail in ClickHouse without the
 444                # `Nullable` type constructor
 445                dtype.set("nullable", False)
 446
 447            return dtype
 448
 449        def _parse_extract(self) -> exp.Extract | exp.Anonymous:
 450            index = self._index
 451            this = self._parse_bitwise()
 452            if self._match(TokenType.FROM):
 453                self._retreat(index)
 454                return super()._parse_extract()
 455
 456            # We return Anonymous here because extract and regexpExtract have different semantics,
 457            # so parsing extract(foo, bar) into RegexpExtract can potentially break queries. E.g.,
 458            # `extract('foobar', 'b')` works, but ClickHouse crashes for `regexpExtract('foobar', 'b')`.
 459            #
 460            # TODO: can we somehow convert the former into an equivalent `regexpExtract` call?
 461            self._match(TokenType.COMMA)
 462            return self.expression(
 463                exp.Anonymous, this="extract", expressions=[this, self._parse_bitwise()]
 464            )
 465
 466        def _parse_assignment(self) -> t.Optional[exp.Expression]:
 467            this = super()._parse_assignment()
 468
 469            if self._match(TokenType.PLACEHOLDER):
 470                return self.expression(
 471                    exp.If,
 472                    this=this,
 473                    true=self._parse_assignment(),
 474                    false=self._match(TokenType.COLON) and self._parse_assignment(),
 475                )
 476
 477            return this
 478
 479        def _parse_placeholder(self) -> t.Optional[exp.Expression]:
 480            """
 481            Parse a placeholder expression like SELECT {abc: UInt32} or FROM {table: Identifier}
 482            https://clickhouse.com/docs/en/sql-reference/syntax#defining-and-using-query-parameters
 483            """
 484            if not self._match(TokenType.L_BRACE):
 485                return None
 486
 487            this = self._parse_id_var()
 488            self._match(TokenType.COLON)
 489            kind = self._parse_types(check_func=False, allow_identifiers=False) or (
 490                self._match_text_seq("IDENTIFIER") and "Identifier"
 491            )
 492
 493            if not kind:
 494                self.raise_error("Expecting a placeholder type or 'Identifier' for tables")
 495            elif not self._match(TokenType.R_BRACE):
 496                self.raise_error("Expecting }")
 497
 498            return self.expression(exp.Placeholder, this=this, kind=kind)
 499
 500        def _parse_in(self, this: t.Optional[exp.Expression], is_global: bool = False) -> exp.In:
 501            this = super()._parse_in(this)
 502            this.set("is_global", is_global)
 503            return this
 504
 505        def _parse_table(
 506            self,
 507            schema: bool = False,
 508            joins: bool = False,
 509            alias_tokens: t.Optional[t.Collection[TokenType]] = None,
 510            parse_bracket: bool = False,
 511            is_db_reference: bool = False,
 512            parse_partition: bool = False,
 513        ) -> t.Optional[exp.Expression]:
 514            this = super()._parse_table(
 515                schema=schema,
 516                joins=joins,
 517                alias_tokens=alias_tokens,
 518                parse_bracket=parse_bracket,
 519                is_db_reference=is_db_reference,
 520            )
 521
 522            if self._match(TokenType.FINAL):
 523                this = self.expression(exp.Final, this=this)
 524
 525            return this
 526
 527        def _parse_position(self, haystack_first: bool = False) -> exp.StrPosition:
 528            return super()._parse_position(haystack_first=True)
 529
 530        # https://clickhouse.com/docs/en/sql-reference/statements/select/with/
 531        def _parse_cte(self) -> exp.CTE:
 532            # WITH <identifier> AS <subquery expression>
 533            cte: t.Optional[exp.CTE] = self._try_parse(super()._parse_cte)
 534
 535            if not cte:
 536                # WITH <expression> AS <identifier>
 537                cte = self.expression(
 538                    exp.CTE,
 539                    this=self._parse_assignment(),
 540                    alias=self._parse_table_alias(),
 541                    scalar=True,
 542                )
 543
 544            return cte
 545
 546        def _parse_join_parts(
 547            self,
 548        ) -> t.Tuple[t.Optional[Token], t.Optional[Token], t.Optional[Token]]:
 549            is_global = self._match(TokenType.GLOBAL) and self._prev
 550            kind_pre = self._match_set(self.JOIN_KINDS, advance=False) and self._prev
 551
 552            if kind_pre:
 553                kind = self._match_set(self.JOIN_KINDS) and self._prev
 554                side = self._match_set(self.JOIN_SIDES) and self._prev
 555                return is_global, side, kind
 556
 557            return (
 558                is_global,
 559                self._match_set(self.JOIN_SIDES) and self._prev,
 560                self._match_set(self.JOIN_KINDS) and self._prev,
 561            )
 562
 563        def _parse_join(
 564            self, skip_join_token: bool = False, parse_bracket: bool = False
 565        ) -> t.Optional[exp.Join]:
 566            join = super()._parse_join(skip_join_token=skip_join_token, parse_bracket=True)
 567            if join:
 568                join.set("global", join.args.pop("method", None))
 569
 570            return join
 571
 572        def _parse_function(
 573            self,
 574            functions: t.Optional[t.Dict[str, t.Callable]] = None,
 575            anonymous: bool = False,
 576            optional_parens: bool = True,
 577            any_token: bool = False,
 578        ) -> t.Optional[exp.Expression]:
 579            expr = super()._parse_function(
 580                functions=functions,
 581                anonymous=anonymous,
 582                optional_parens=optional_parens,
 583                any_token=any_token,
 584            )
 585
 586            func = expr.this if isinstance(expr, exp.Window) else expr
 587
 588            # Aggregate functions can be split in 2 parts: <func_name><suffix>
 589            parts = (
 590                self.AGG_FUNC_MAPPING.get(func.this) if isinstance(func, exp.Anonymous) else None
 591            )
 592
 593            if parts:
 594                params = self._parse_func_params(func)
 595
 596                kwargs = {
 597                    "this": func.this,
 598                    "expressions": func.expressions,
 599                }
 600                if parts[1]:
 601                    kwargs["parts"] = parts
 602                    exp_class = exp.CombinedParameterizedAgg if params else exp.CombinedAggFunc
 603                else:
 604                    exp_class = exp.ParameterizedAgg if params else exp.AnonymousAggFunc
 605
 606                kwargs["exp_class"] = exp_class
 607                if params:
 608                    kwargs["params"] = params
 609
 610                func = self.expression(**kwargs)
 611
 612                if isinstance(expr, exp.Window):
 613                    # The window's func was parsed as Anonymous in base parser, fix its
 614                    # type to be ClickHouse style CombinedAnonymousAggFunc / AnonymousAggFunc
 615                    expr.set("this", func)
 616                elif params:
 617                    # Params have blocked super()._parse_function() from parsing the following window
 618                    # (if that exists) as they're standing between the function call and the window spec
 619                    expr = self._parse_window(func)
 620                else:
 621                    expr = func
 622
 623            return expr
 624
 625        def _parse_func_params(
 626            self, this: t.Optional[exp.Func] = None
 627        ) -> t.Optional[t.List[exp.Expression]]:
 628            if self._match_pair(TokenType.R_PAREN, TokenType.L_PAREN):
 629                return self._parse_csv(self._parse_lambda)
 630
 631            if self._match(TokenType.L_PAREN):
 632                params = self._parse_csv(self._parse_lambda)
 633                self._match_r_paren(this)
 634                return params
 635
 636            return None
 637
 638        def _parse_quantile(self) -> exp.Quantile:
 639            this = self._parse_lambda()
 640            params = self._parse_func_params()
 641            if params:
 642                return self.expression(exp.Quantile, this=params[0], quantile=this)
 643            return self.expression(exp.Quantile, this=this, quantile=exp.Literal.number(0.5))
 644
 645        def _parse_wrapped_id_vars(self, optional: bool = False) -> t.List[exp.Expression]:
 646            return super()._parse_wrapped_id_vars(optional=True)
 647
 648        def _parse_primary_key(
 649            self, wrapped_optional: bool = False, in_props: bool = False
 650        ) -> exp.PrimaryKeyColumnConstraint | exp.PrimaryKey:
 651            return super()._parse_primary_key(
 652                wrapped_optional=wrapped_optional or in_props, in_props=in_props
 653            )
 654
 655        def _parse_on_property(self) -> t.Optional[exp.Expression]:
 656            index = self._index
 657            if self._match_text_seq("CLUSTER"):
 658                this = self._parse_id_var()
 659                if this:
 660                    return self.expression(exp.OnCluster, this=this)
 661                else:
 662                    self._retreat(index)
 663            return None
 664
 665        def _parse_index_constraint(
 666            self, kind: t.Optional[str] = None
 667        ) -> exp.IndexColumnConstraint:
 668            # INDEX name1 expr TYPE type1(args) GRANULARITY value
 669            this = self._parse_id_var()
 670            expression = self._parse_assignment()
 671
 672            index_type = self._match_text_seq("TYPE") and (
 673                self._parse_function() or self._parse_var()
 674            )
 675
 676            granularity = self._match_text_seq("GRANULARITY") and self._parse_term()
 677
 678            return self.expression(
 679                exp.IndexColumnConstraint,
 680                this=this,
 681                expression=expression,
 682                index_type=index_type,
 683                granularity=granularity,
 684            )
 685
 686        def _parse_partition(self) -> t.Optional[exp.Partition]:
 687            # https://clickhouse.com/docs/en/sql-reference/statements/alter/partition#how-to-set-partition-expression
 688            if not self._match(TokenType.PARTITION):
 689                return None
 690
 691            if self._match_text_seq("ID"):
 692                # Corresponds to the PARTITION ID <string_value> syntax
 693                expressions: t.List[exp.Expression] = [
 694                    self.expression(exp.PartitionId, this=self._parse_string())
 695                ]
 696            else:
 697                expressions = self._parse_expressions()
 698
 699            return self.expression(exp.Partition, expressions=expressions)
 700
 701        def _parse_alter_table_replace(self) -> t.Optional[exp.Expression]:
 702            partition = self._parse_partition()
 703
 704            if not partition or not self._match(TokenType.FROM):
 705                return None
 706
 707            return self.expression(
 708                exp.ReplacePartition, expression=partition, source=self._parse_table_parts()
 709            )
 710
 711        def _parse_projection_def(self) -> t.Optional[exp.ProjectionDef]:
 712            if not self._match_text_seq("PROJECTION"):
 713                return None
 714
 715            return self.expression(
 716                exp.ProjectionDef,
 717                this=self._parse_id_var(),
 718                expression=self._parse_wrapped(self._parse_statement),
 719            )
 720
 721        def _parse_constraint(self) -> t.Optional[exp.Expression]:
 722            return super()._parse_constraint() or self._parse_projection_def()
 723
 724    class Generator(generator.Generator):
 725        QUERY_HINTS = False
 726        STRUCT_DELIMITER = ("(", ")")
 727        NVL2_SUPPORTED = False
 728        TABLESAMPLE_REQUIRES_PARENS = False
 729        TABLESAMPLE_SIZE_IS_ROWS = False
 730        TABLESAMPLE_KEYWORDS = "SAMPLE"
 731        LAST_DAY_SUPPORTS_DATE_PART = False
 732        CAN_IMPLEMENT_ARRAY_ANY = True
 733        SUPPORTS_TO_NUMBER = False
 734        JOIN_HINTS = False
 735        TABLE_HINTS = False
 736        EXPLICIT_SET_OP = True
 737        GROUPINGS_SEP = ""
 738        SET_OP_MODIFIERS = False
 739        SUPPORTS_TABLE_ALIAS_COLUMNS = False
 740        VALUES_AS_TABLE = False
 741
 742        STRING_TYPE_MAPPING = {
 743            exp.DataType.Type.CHAR: "String",
 744            exp.DataType.Type.LONGBLOB: "String",
 745            exp.DataType.Type.LONGTEXT: "String",
 746            exp.DataType.Type.MEDIUMBLOB: "String",
 747            exp.DataType.Type.MEDIUMTEXT: "String",
 748            exp.DataType.Type.TINYBLOB: "String",
 749            exp.DataType.Type.TINYTEXT: "String",
 750            exp.DataType.Type.TEXT: "String",
 751            exp.DataType.Type.VARBINARY: "String",
 752            exp.DataType.Type.VARCHAR: "String",
 753        }
 754
 755        SUPPORTED_JSON_PATH_PARTS = {
 756            exp.JSONPathKey,
 757            exp.JSONPathRoot,
 758            exp.JSONPathSubscript,
 759        }
 760
 761        TYPE_MAPPING = {
 762            **generator.Generator.TYPE_MAPPING,
 763            **STRING_TYPE_MAPPING,
 764            exp.DataType.Type.ARRAY: "Array",
 765            exp.DataType.Type.BIGINT: "Int64",
 766            exp.DataType.Type.DATE32: "Date32",
 767            exp.DataType.Type.DATETIME64: "DateTime64",
 768            exp.DataType.Type.TIMESTAMPTZ: "TIMESTAMP",
 769            exp.DataType.Type.DOUBLE: "Float64",
 770            exp.DataType.Type.ENUM: "Enum",
 771            exp.DataType.Type.ENUM8: "Enum8",
 772            exp.DataType.Type.ENUM16: "Enum16",
 773            exp.DataType.Type.FIXEDSTRING: "FixedString",
 774            exp.DataType.Type.FLOAT: "Float32",
 775            exp.DataType.Type.INT: "Int32",
 776            exp.DataType.Type.MEDIUMINT: "Int32",
 777            exp.DataType.Type.INT128: "Int128",
 778            exp.DataType.Type.INT256: "Int256",
 779            exp.DataType.Type.LOWCARDINALITY: "LowCardinality",
 780            exp.DataType.Type.MAP: "Map",
 781            exp.DataType.Type.NESTED: "Nested",
 782            exp.DataType.Type.NULLABLE: "Nullable",
 783            exp.DataType.Type.SMALLINT: "Int16",
 784            exp.DataType.Type.STRUCT: "Tuple",
 785            exp.DataType.Type.TINYINT: "Int8",
 786            exp.DataType.Type.UBIGINT: "UInt64",
 787            exp.DataType.Type.UINT: "UInt32",
 788            exp.DataType.Type.UINT128: "UInt128",
 789            exp.DataType.Type.UINT256: "UInt256",
 790            exp.DataType.Type.USMALLINT: "UInt16",
 791            exp.DataType.Type.UTINYINT: "UInt8",
 792            exp.DataType.Type.IPV4: "IPv4",
 793            exp.DataType.Type.IPV6: "IPv6",
 794            exp.DataType.Type.AGGREGATEFUNCTION: "AggregateFunction",
 795            exp.DataType.Type.SIMPLEAGGREGATEFUNCTION: "SimpleAggregateFunction",
 796        }
 797
 798        TRANSFORMS = {
 799            **generator.Generator.TRANSFORMS,
 800            exp.AnyValue: rename_func("any"),
 801            exp.ApproxDistinct: rename_func("uniq"),
 802            exp.ArrayFilter: lambda self, e: self.func("arrayFilter", e.expression, e.this),
 803            exp.ArraySize: rename_func("LENGTH"),
 804            exp.ArraySum: rename_func("arraySum"),
 805            exp.ArgMax: arg_max_or_min_no_count("argMax"),
 806            exp.ArgMin: arg_max_or_min_no_count("argMin"),
 807            exp.Array: inline_array_sql,
 808            exp.CastToStrType: rename_func("CAST"),
 809            exp.CountIf: rename_func("countIf"),
 810            exp.CompressColumnConstraint: lambda self,
 811            e: f"CODEC({self.expressions(e, key='this', flat=True)})",
 812            exp.ComputedColumnConstraint: lambda self,
 813            e: f"{'MATERIALIZED' if e.args.get('persisted') else 'ALIAS'} {self.sql(e, 'this')}",
 814            exp.CurrentDate: lambda self, e: self.func("CURRENT_DATE"),
 815            exp.DateAdd: _datetime_delta_sql("DATE_ADD"),
 816            exp.DateDiff: _datetime_delta_sql("DATE_DIFF"),
 817            exp.DateStrToDate: rename_func("toDate"),
 818            exp.DateSub: _datetime_delta_sql("DATE_SUB"),
 819            exp.Explode: rename_func("arrayJoin"),
 820            exp.Final: lambda self, e: f"{self.sql(e, 'this')} FINAL",
 821            exp.IsNan: rename_func("isNaN"),
 822            exp.JSONExtract: json_extract_segments("JSONExtractString", quoted_index=False),
 823            exp.JSONExtractScalar: json_extract_segments("JSONExtractString", quoted_index=False),
 824            exp.JSONPathKey: json_path_key_only_name,
 825            exp.JSONPathRoot: lambda *_: "",
 826            exp.Map: lambda self, e: _lower_func(var_map_sql(self, e)),
 827            exp.Nullif: rename_func("nullIf"),
 828            exp.PartitionedByProperty: lambda self, e: f"PARTITION BY {self.sql(e, 'this')}",
 829            exp.Pivot: no_pivot_sql,
 830            exp.Quantile: _quantile_sql,
 831            exp.RegexpLike: lambda self, e: self.func("match", e.this, e.expression),
 832            exp.Rand: rename_func("randCanonical"),
 833            exp.StartsWith: rename_func("startsWith"),
 834            exp.StrPosition: lambda self, e: self.func(
 835                "position", e.this, e.args.get("substr"), e.args.get("position")
 836            ),
 837            exp.TimeToStr: lambda self, e: self.func(
 838                "DATE_FORMAT", e.this, self.format_time(e), e.args.get("timezone")
 839            ),
 840            exp.TimestampAdd: _datetime_delta_sql("TIMESTAMP_ADD"),
 841            exp.TimestampSub: _datetime_delta_sql("TIMESTAMP_SUB"),
 842            exp.VarMap: lambda self, e: _lower_func(var_map_sql(self, e)),
 843            exp.Xor: lambda self, e: self.func("xor", e.this, e.expression, *e.expressions),
 844            exp.MD5Digest: rename_func("MD5"),
 845            exp.MD5: lambda self, e: self.func("LOWER", self.func("HEX", self.func("MD5", e.this))),
 846            exp.SHA: rename_func("SHA1"),
 847            exp.SHA2: sha256_sql,
 848            exp.UnixToTime: _unix_to_time_sql,
 849            exp.TimestampTrunc: timestamptrunc_sql(zone=True),
 850            exp.Variance: rename_func("varSamp"),
 851            exp.SchemaCommentProperty: lambda self, e: self.naked_property(e),
 852            exp.Stddev: rename_func("stddevSamp"),
 853        }
 854
 855        PROPERTIES_LOCATION = {
 856            **generator.Generator.PROPERTIES_LOCATION,
 857            exp.VolatileProperty: exp.Properties.Location.UNSUPPORTED,
 858            exp.PartitionedByProperty: exp.Properties.Location.POST_SCHEMA,
 859            exp.OnCluster: exp.Properties.Location.POST_NAME,
 860        }
 861
 862        # There's no list in docs, but it can be found in Clickhouse code
 863        # see `ClickHouse/src/Parsers/ParserCreate*.cpp`
 864        ON_CLUSTER_TARGETS = {
 865            "DATABASE",
 866            "TABLE",
 867            "VIEW",
 868            "DICTIONARY",
 869            "INDEX",
 870            "FUNCTION",
 871            "NAMED COLLECTION",
 872        }
 873
 874        # https://clickhouse.com/docs/en/sql-reference/data-types/nullable
 875        NON_NULLABLE_TYPES = {
 876            exp.DataType.Type.ARRAY,
 877            exp.DataType.Type.MAP,
 878            exp.DataType.Type.NULLABLE,
 879            exp.DataType.Type.STRUCT,
 880        }
 881
 882        def strtodate_sql(self, expression: exp.StrToDate) -> str:
 883            strtodate_sql = self.function_fallback_sql(expression)
 884
 885            if not isinstance(expression.parent, exp.Cast):
 886                # StrToDate returns DATEs in other dialects (eg. postgres), so
 887                # this branch aims to improve the transpilation to clickhouse
 888                return f"CAST({strtodate_sql} AS DATE)"
 889
 890            return strtodate_sql
 891
 892        def cast_sql(self, expression: exp.Cast, safe_prefix: t.Optional[str] = None) -> str:
 893            this = expression.this
 894
 895            if isinstance(this, exp.StrToDate) and expression.to == exp.DataType.build("datetime"):
 896                return self.sql(this)
 897
 898            return super().cast_sql(expression, safe_prefix=safe_prefix)
 899
 900        def trycast_sql(self, expression: exp.TryCast) -> str:
 901            dtype = expression.to
 902            if not dtype.is_type(*self.NON_NULLABLE_TYPES, check_nullable=True):
 903                # Casting x into Nullable(T) appears to behave similarly to TRY_CAST(x AS T)
 904                dtype.set("nullable", True)
 905
 906            return super().cast_sql(expression)
 907
 908        def _jsonpathsubscript_sql(self, expression: exp.JSONPathSubscript) -> str:
 909            this = self.json_path_part(expression.this)
 910            return str(int(this) + 1) if is_int(this) else this
 911
 912        def likeproperty_sql(self, expression: exp.LikeProperty) -> str:
 913            return f"AS {self.sql(expression, 'this')}"
 914
 915        def _any_to_has(
 916            self,
 917            expression: exp.EQ | exp.NEQ,
 918            default: t.Callable[[t.Any], str],
 919            prefix: str = "",
 920        ) -> str:
 921            if isinstance(expression.left, exp.Any):
 922                arr = expression.left
 923                this = expression.right
 924            elif isinstance(expression.right, exp.Any):
 925                arr = expression.right
 926                this = expression.left
 927            else:
 928                return default(expression)
 929
 930            return prefix + self.func("has", arr.this.unnest(), this)
 931
 932        def eq_sql(self, expression: exp.EQ) -> str:
 933            return self._any_to_has(expression, super().eq_sql)
 934
 935        def neq_sql(self, expression: exp.NEQ) -> str:
 936            return self._any_to_has(expression, super().neq_sql, "NOT ")
 937
 938        def regexpilike_sql(self, expression: exp.RegexpILike) -> str:
 939            # Manually add a flag to make the search case-insensitive
 940            regex = self.func("CONCAT", "'(?i)'", expression.expression)
 941            return self.func("match", expression.this, regex)
 942
 943        def datatype_sql(self, expression: exp.DataType) -> str:
 944            # String is the standard ClickHouse type, every other variant is just an alias.
 945            # Additionally, any supplied length parameter will be ignored.
 946            #
 947            # https://clickhouse.com/docs/en/sql-reference/data-types/string
 948            if expression.this in self.STRING_TYPE_MAPPING:
 949                dtype = "String"
 950            else:
 951                dtype = super().datatype_sql(expression)
 952
 953            # This section changes the type to `Nullable(...)` if the following conditions hold:
 954            # - It's marked as nullable - this ensures we won't wrap ClickHouse types with `Nullable`
 955            #   and change their semantics
 956            # - It's not the key type of a `Map`. This is because ClickHouse enforces the following
 957            #   constraint: "Type of Map key must be a type, that can be represented by integer or
 958            #   String or FixedString (possibly LowCardinality) or UUID or IPv6"
 959            # - It's not a composite type, e.g. `Nullable(Array(...))` is not a valid type
 960            parent = expression.parent
 961            if (
 962                expression.args.get("nullable") is not False
 963                and not (
 964                    isinstance(parent, exp.DataType)
 965                    and parent.is_type(exp.DataType.Type.MAP, check_nullable=True)
 966                    and expression.index in (None, 0)
 967                )
 968                and not expression.is_type(*self.NON_NULLABLE_TYPES, check_nullable=True)
 969            ):
 970                dtype = f"Nullable({dtype})"
 971
 972            return dtype
 973
 974        def cte_sql(self, expression: exp.CTE) -> str:
 975            if expression.args.get("scalar"):
 976                this = self.sql(expression, "this")
 977                alias = self.sql(expression, "alias")
 978                return f"{this} AS {alias}"
 979
 980            return super().cte_sql(expression)
 981
 982        def after_limit_modifiers(self, expression: exp.Expression) -> t.List[str]:
 983            return super().after_limit_modifiers(expression) + [
 984                (
 985                    self.seg("SETTINGS ") + self.expressions(expression, key="settings", flat=True)
 986                    if expression.args.get("settings")
 987                    else ""
 988                ),
 989                (
 990                    self.seg("FORMAT ") + self.sql(expression, "format")
 991                    if expression.args.get("format")
 992                    else ""
 993                ),
 994            ]
 995
 996        def parameterizedagg_sql(self, expression: exp.ParameterizedAgg) -> str:
 997            params = self.expressions(expression, key="params", flat=True)
 998            return self.func(expression.name, *expression.expressions) + f"({params})"
 999
1000        def anonymousaggfunc_sql(self, expression: exp.AnonymousAggFunc) -> str:
1001            return self.func(expression.name, *expression.expressions)
1002
1003        def combinedaggfunc_sql(self, expression: exp.CombinedAggFunc) -> str:
1004            return self.anonymousaggfunc_sql(expression)
1005
1006        def combinedparameterizedagg_sql(self, expression: exp.CombinedParameterizedAgg) -> str:
1007            return self.parameterizedagg_sql(expression)
1008
1009        def placeholder_sql(self, expression: exp.Placeholder) -> str:
1010            return f"{{{expression.name}: {self.sql(expression, 'kind')}}}"
1011
1012        def oncluster_sql(self, expression: exp.OnCluster) -> str:
1013            return f"ON CLUSTER {self.sql(expression, 'this')}"
1014
1015        def createable_sql(self, expression: exp.Create, locations: t.DefaultDict) -> str:
1016            if expression.kind in self.ON_CLUSTER_TARGETS and locations.get(
1017                exp.Properties.Location.POST_NAME
1018            ):
1019                this_name = self.sql(
1020                    expression.this if isinstance(expression.this, exp.Schema) else expression,
1021                    "this",
1022                )
1023                this_properties = " ".join(
1024                    [self.sql(prop) for prop in locations[exp.Properties.Location.POST_NAME]]
1025                )
1026                this_schema = self.schema_columns_sql(expression.this)
1027                return f"{this_name}{self.sep()}{this_properties}{self.sep()}{this_schema}"
1028
1029            return super().createable_sql(expression, locations)
1030
1031        def create_sql(self, expression: exp.Create) -> str:
1032            # The comment property comes last in CTAS statements, i.e. after the query
1033            query = expression.expression
1034            if isinstance(query, exp.Query):
1035                comment_prop = expression.find(exp.SchemaCommentProperty)
1036                if comment_prop:
1037                    comment_prop.pop()
1038                    query.replace(exp.paren(query))
1039            else:
1040                comment_prop = None
1041
1042            create_sql = super().create_sql(expression)
1043
1044            comment_sql = self.sql(comment_prop)
1045            comment_sql = f" {comment_sql}" if comment_sql else ""
1046
1047            return f"{create_sql}{comment_sql}"
1048
1049        def prewhere_sql(self, expression: exp.PreWhere) -> str:
1050            this = self.indent(self.sql(expression, "this"))
1051            return f"{self.seg('PREWHERE')}{self.sep()}{this}"
1052
1053        def indexcolumnconstraint_sql(self, expression: exp.IndexColumnConstraint) -> str:
1054            this = self.sql(expression, "this")
1055            this = f" {this}" if this else ""
1056            expr = self.sql(expression, "expression")
1057            expr = f" {expr}" if expr else ""
1058            index_type = self.sql(expression, "index_type")
1059            index_type = f" TYPE {index_type}" if index_type else ""
1060            granularity = self.sql(expression, "granularity")
1061            granularity = f" GRANULARITY {granularity}" if granularity else ""
1062
1063            return f"INDEX{this}{expr}{index_type}{granularity}"
1064
1065        def partition_sql(self, expression: exp.Partition) -> str:
1066            return f"PARTITION {self.expressions(expression, flat=True)}"
1067
1068        def partitionid_sql(self, expression: exp.PartitionId) -> str:
1069            return f"ID {self.sql(expression.this)}"
1070
1071        def replacepartition_sql(self, expression: exp.ReplacePartition) -> str:
1072            return (
1073                f"REPLACE {self.sql(expression.expression)} FROM {self.sql(expression, 'source')}"
1074            )
1075
1076        def projectiondef_sql(self, expression: exp.ProjectionDef) -> str:
1077            return f"PROJECTION {self.sql(expression.this)} {self.wrap(expression.expression)}"
class ClickHouse(sqlglot.dialects.dialect.Dialect):
 109class ClickHouse(Dialect):
 110    NORMALIZE_FUNCTIONS: bool | str = False
 111    NULL_ORDERING = "nulls_are_last"
 112    SUPPORTS_USER_DEFINED_TYPES = False
 113    SAFE_DIVISION = True
 114    LOG_BASE_FIRST: t.Optional[bool] = None
 115    FORCE_EARLY_ALIAS_REF_EXPANSION = True
 116
 117    # https://github.com/ClickHouse/ClickHouse/issues/33935#issue-1112165779
 118    NORMALIZATION_STRATEGY = NormalizationStrategy.CASE_SENSITIVE
 119
 120    UNESCAPED_SEQUENCES = {
 121        "\\0": "\0",
 122    }
 123
 124    CREATABLE_KIND_MAPPING = {"DATABASE": "SCHEMA"}
 125
 126    class Tokenizer(tokens.Tokenizer):
 127        COMMENTS = ["--", "#", "#!", ("/*", "*/")]
 128        IDENTIFIERS = ['"', "`"]
 129        STRING_ESCAPES = ["'", "\\"]
 130        BIT_STRINGS = [("0b", "")]
 131        HEX_STRINGS = [("0x", ""), ("0X", "")]
 132        HEREDOC_STRINGS = ["$"]
 133
 134        KEYWORDS = {
 135            **tokens.Tokenizer.KEYWORDS,
 136            "ATTACH": TokenType.COMMAND,
 137            "DATE32": TokenType.DATE32,
 138            "DATETIME64": TokenType.DATETIME64,
 139            "DICTIONARY": TokenType.DICTIONARY,
 140            "ENUM8": TokenType.ENUM8,
 141            "ENUM16": TokenType.ENUM16,
 142            "FINAL": TokenType.FINAL,
 143            "FIXEDSTRING": TokenType.FIXEDSTRING,
 144            "FLOAT32": TokenType.FLOAT,
 145            "FLOAT64": TokenType.DOUBLE,
 146            "GLOBAL": TokenType.GLOBAL,
 147            "INT256": TokenType.INT256,
 148            "LOWCARDINALITY": TokenType.LOWCARDINALITY,
 149            "MAP": TokenType.MAP,
 150            "NESTED": TokenType.NESTED,
 151            "SAMPLE": TokenType.TABLE_SAMPLE,
 152            "TUPLE": TokenType.STRUCT,
 153            "UINT128": TokenType.UINT128,
 154            "UINT16": TokenType.USMALLINT,
 155            "UINT256": TokenType.UINT256,
 156            "UINT32": TokenType.UINT,
 157            "UINT64": TokenType.UBIGINT,
 158            "UINT8": TokenType.UTINYINT,
 159            "IPV4": TokenType.IPV4,
 160            "IPV6": TokenType.IPV6,
 161            "AGGREGATEFUNCTION": TokenType.AGGREGATEFUNCTION,
 162            "SIMPLEAGGREGATEFUNCTION": TokenType.SIMPLEAGGREGATEFUNCTION,
 163            "SYSTEM": TokenType.COMMAND,
 164            "PREWHERE": TokenType.PREWHERE,
 165        }
 166        KEYWORDS.pop("/*+")
 167
 168        SINGLE_TOKENS = {
 169            **tokens.Tokenizer.SINGLE_TOKENS,
 170            "$": TokenType.HEREDOC_STRING,
 171        }
 172
 173    class Parser(parser.Parser):
 174        # Tested in ClickHouse's playground, it seems that the following two queries do the same thing
 175        # * select x from t1 union all select x from t2 limit 1;
 176        # * select x from t1 union all (select x from t2 limit 1);
 177        MODIFIERS_ATTACHED_TO_SET_OP = False
 178        INTERVAL_SPANS = False
 179
 180        FUNCTIONS = {
 181            **parser.Parser.FUNCTIONS,
 182            "ANY": exp.AnyValue.from_arg_list,
 183            "ARRAYSUM": exp.ArraySum.from_arg_list,
 184            "COUNTIF": _build_count_if,
 185            "DATE_ADD": build_date_delta(exp.DateAdd, default_unit=None),
 186            "DATEADD": build_date_delta(exp.DateAdd, default_unit=None),
 187            "DATE_DIFF": build_date_delta(exp.DateDiff, default_unit=None),
 188            "DATEDIFF": build_date_delta(exp.DateDiff, default_unit=None),
 189            "DATE_FORMAT": _build_date_format,
 190            "DATE_SUB": build_date_delta(exp.DateSub, default_unit=None),
 191            "DATESUB": build_date_delta(exp.DateSub, default_unit=None),
 192            "FORMATDATETIME": _build_date_format,
 193            "JSONEXTRACTSTRING": build_json_extract_path(
 194                exp.JSONExtractScalar, zero_based_indexing=False
 195            ),
 196            "MAP": parser.build_var_map,
 197            "MATCH": exp.RegexpLike.from_arg_list,
 198            "RANDCANONICAL": exp.Rand.from_arg_list,
 199            "STR_TO_DATE": _build_str_to_date,
 200            "TUPLE": exp.Struct.from_arg_list,
 201            "TIMESTAMP_SUB": build_date_delta(exp.TimestampSub, default_unit=None),
 202            "TIMESTAMPSUB": build_date_delta(exp.TimestampSub, default_unit=None),
 203            "TIMESTAMP_ADD": build_date_delta(exp.TimestampAdd, default_unit=None),
 204            "TIMESTAMPADD": build_date_delta(exp.TimestampAdd, default_unit=None),
 205            "UNIQ": exp.ApproxDistinct.from_arg_list,
 206            "XOR": lambda args: exp.Xor(expressions=args),
 207            "MD5": exp.MD5Digest.from_arg_list,
 208            "SHA256": lambda args: exp.SHA2(this=seq_get(args, 0), length=exp.Literal.number(256)),
 209            "SHA512": lambda args: exp.SHA2(this=seq_get(args, 0), length=exp.Literal.number(512)),
 210        }
 211
 212        AGG_FUNCTIONS = {
 213            "count",
 214            "min",
 215            "max",
 216            "sum",
 217            "avg",
 218            "any",
 219            "stddevPop",
 220            "stddevSamp",
 221            "varPop",
 222            "varSamp",
 223            "corr",
 224            "covarPop",
 225            "covarSamp",
 226            "entropy",
 227            "exponentialMovingAverage",
 228            "intervalLengthSum",
 229            "kolmogorovSmirnovTest",
 230            "mannWhitneyUTest",
 231            "median",
 232            "rankCorr",
 233            "sumKahan",
 234            "studentTTest",
 235            "welchTTest",
 236            "anyHeavy",
 237            "anyLast",
 238            "boundingRatio",
 239            "first_value",
 240            "last_value",
 241            "argMin",
 242            "argMax",
 243            "avgWeighted",
 244            "topK",
 245            "topKWeighted",
 246            "deltaSum",
 247            "deltaSumTimestamp",
 248            "groupArray",
 249            "groupArrayLast",
 250            "groupUniqArray",
 251            "groupArrayInsertAt",
 252            "groupArrayMovingAvg",
 253            "groupArrayMovingSum",
 254            "groupArraySample",
 255            "groupBitAnd",
 256            "groupBitOr",
 257            "groupBitXor",
 258            "groupBitmap",
 259            "groupBitmapAnd",
 260            "groupBitmapOr",
 261            "groupBitmapXor",
 262            "sumWithOverflow",
 263            "sumMap",
 264            "minMap",
 265            "maxMap",
 266            "skewSamp",
 267            "skewPop",
 268            "kurtSamp",
 269            "kurtPop",
 270            "uniq",
 271            "uniqExact",
 272            "uniqCombined",
 273            "uniqCombined64",
 274            "uniqHLL12",
 275            "uniqTheta",
 276            "quantile",
 277            "quantiles",
 278            "quantileExact",
 279            "quantilesExact",
 280            "quantileExactLow",
 281            "quantilesExactLow",
 282            "quantileExactHigh",
 283            "quantilesExactHigh",
 284            "quantileExactWeighted",
 285            "quantilesExactWeighted",
 286            "quantileTiming",
 287            "quantilesTiming",
 288            "quantileTimingWeighted",
 289            "quantilesTimingWeighted",
 290            "quantileDeterministic",
 291            "quantilesDeterministic",
 292            "quantileTDigest",
 293            "quantilesTDigest",
 294            "quantileTDigestWeighted",
 295            "quantilesTDigestWeighted",
 296            "quantileBFloat16",
 297            "quantilesBFloat16",
 298            "quantileBFloat16Weighted",
 299            "quantilesBFloat16Weighted",
 300            "simpleLinearRegression",
 301            "stochasticLinearRegression",
 302            "stochasticLogisticRegression",
 303            "categoricalInformationValue",
 304            "contingency",
 305            "cramersV",
 306            "cramersVBiasCorrected",
 307            "theilsU",
 308            "maxIntersections",
 309            "maxIntersectionsPosition",
 310            "meanZTest",
 311            "quantileInterpolatedWeighted",
 312            "quantilesInterpolatedWeighted",
 313            "quantileGK",
 314            "quantilesGK",
 315            "sparkBar",
 316            "sumCount",
 317            "largestTriangleThreeBuckets",
 318            "histogram",
 319            "sequenceMatch",
 320            "sequenceCount",
 321            "windowFunnel",
 322            "retention",
 323            "uniqUpTo",
 324            "sequenceNextNode",
 325            "exponentialTimeDecayedAvg",
 326        }
 327
 328        AGG_FUNCTIONS_SUFFIXES = [
 329            "If",
 330            "Array",
 331            "ArrayIf",
 332            "Map",
 333            "SimpleState",
 334            "State",
 335            "Merge",
 336            "MergeState",
 337            "ForEach",
 338            "Distinct",
 339            "OrDefault",
 340            "OrNull",
 341            "Resample",
 342            "ArgMin",
 343            "ArgMax",
 344        ]
 345
 346        FUNC_TOKENS = {
 347            *parser.Parser.FUNC_TOKENS,
 348            TokenType.SET,
 349        }
 350
 351        RESERVED_TOKENS = parser.Parser.RESERVED_TOKENS - {TokenType.SELECT}
 352
 353        ID_VAR_TOKENS = {
 354            *parser.Parser.ID_VAR_TOKENS,
 355            TokenType.LIKE,
 356        }
 357
 358        AGG_FUNC_MAPPING = (
 359            lambda functions, suffixes: {
 360                f"{f}{sfx}": (f, sfx) for sfx in (suffixes + [""]) for f in functions
 361            }
 362        )(AGG_FUNCTIONS, AGG_FUNCTIONS_SUFFIXES)
 363
 364        FUNCTIONS_WITH_ALIASED_ARGS = {*parser.Parser.FUNCTIONS_WITH_ALIASED_ARGS, "TUPLE"}
 365
 366        FUNCTION_PARSERS = {
 367            **parser.Parser.FUNCTION_PARSERS,
 368            "ARRAYJOIN": lambda self: self.expression(exp.Explode, this=self._parse_expression()),
 369            "QUANTILE": lambda self: self._parse_quantile(),
 370        }
 371
 372        FUNCTION_PARSERS.pop("MATCH")
 373
 374        NO_PAREN_FUNCTION_PARSERS = parser.Parser.NO_PAREN_FUNCTION_PARSERS.copy()
 375        NO_PAREN_FUNCTION_PARSERS.pop("ANY")
 376
 377        RANGE_PARSERS = {
 378            **parser.Parser.RANGE_PARSERS,
 379            TokenType.GLOBAL: lambda self, this: self._match(TokenType.IN)
 380            and self._parse_in(this, is_global=True),
 381        }
 382
 383        # The PLACEHOLDER entry is popped because 1) it doesn't affect Clickhouse (it corresponds to
 384        # the postgres-specific JSONBContains parser) and 2) it makes parsing the ternary op simpler.
 385        COLUMN_OPERATORS = parser.Parser.COLUMN_OPERATORS.copy()
 386        COLUMN_OPERATORS.pop(TokenType.PLACEHOLDER)
 387
 388        JOIN_KINDS = {
 389            *parser.Parser.JOIN_KINDS,
 390            TokenType.ANY,
 391            TokenType.ASOF,
 392            TokenType.ARRAY,
 393        }
 394
 395        TABLE_ALIAS_TOKENS = parser.Parser.TABLE_ALIAS_TOKENS - {
 396            TokenType.ANY,
 397            TokenType.ARRAY,
 398            TokenType.FINAL,
 399            TokenType.FORMAT,
 400            TokenType.SETTINGS,
 401        }
 402
 403        ALIAS_TOKENS = parser.Parser.ALIAS_TOKENS - {
 404            TokenType.FORMAT,
 405        }
 406
 407        LOG_DEFAULTS_TO_LN = True
 408
 409        QUERY_MODIFIER_PARSERS = {
 410            **parser.Parser.QUERY_MODIFIER_PARSERS,
 411            TokenType.SETTINGS: lambda self: (
 412                "settings",
 413                self._advance() or self._parse_csv(self._parse_assignment),
 414            ),
 415            TokenType.FORMAT: lambda self: ("format", self._advance() or self._parse_id_var()),
 416        }
 417
 418        CONSTRAINT_PARSERS = {
 419            **parser.Parser.CONSTRAINT_PARSERS,
 420            "INDEX": lambda self: self._parse_index_constraint(),
 421            "CODEC": lambda self: self._parse_compress(),
 422        }
 423
 424        ALTER_PARSERS = {
 425            **parser.Parser.ALTER_PARSERS,
 426            "REPLACE": lambda self: self._parse_alter_table_replace(),
 427        }
 428
 429        SCHEMA_UNNAMED_CONSTRAINTS = {
 430            *parser.Parser.SCHEMA_UNNAMED_CONSTRAINTS,
 431            "INDEX",
 432        }
 433
 434        def _parse_types(
 435            self, check_func: bool = False, schema: bool = False, allow_identifiers: bool = True
 436        ) -> t.Optional[exp.Expression]:
 437            dtype = super()._parse_types(
 438                check_func=check_func, schema=schema, allow_identifiers=allow_identifiers
 439            )
 440            if isinstance(dtype, exp.DataType):
 441                # Mark every type as non-nullable which is ClickHouse's default. This marker
 442                # helps us transpile types from other dialects to ClickHouse, so that we can
 443                # e.g. produce `CAST(x AS Nullable(String))` from `CAST(x AS TEXT)`. If there
 444                # is a `NULL` value in `x`, the former would fail in ClickHouse without the
 445                # `Nullable` type constructor
 446                dtype.set("nullable", False)
 447
 448            return dtype
 449
 450        def _parse_extract(self) -> exp.Extract | exp.Anonymous:
 451            index = self._index
 452            this = self._parse_bitwise()
 453            if self._match(TokenType.FROM):
 454                self._retreat(index)
 455                return super()._parse_extract()
 456
 457            # We return Anonymous here because extract and regexpExtract have different semantics,
 458            # so parsing extract(foo, bar) into RegexpExtract can potentially break queries. E.g.,
 459            # `extract('foobar', 'b')` works, but ClickHouse crashes for `regexpExtract('foobar', 'b')`.
 460            #
 461            # TODO: can we somehow convert the former into an equivalent `regexpExtract` call?
 462            self._match(TokenType.COMMA)
 463            return self.expression(
 464                exp.Anonymous, this="extract", expressions=[this, self._parse_bitwise()]
 465            )
 466
 467        def _parse_assignment(self) -> t.Optional[exp.Expression]:
 468            this = super()._parse_assignment()
 469
 470            if self._match(TokenType.PLACEHOLDER):
 471                return self.expression(
 472                    exp.If,
 473                    this=this,
 474                    true=self._parse_assignment(),
 475                    false=self._match(TokenType.COLON) and self._parse_assignment(),
 476                )
 477
 478            return this
 479
 480        def _parse_placeholder(self) -> t.Optional[exp.Expression]:
 481            """
 482            Parse a placeholder expression like SELECT {abc: UInt32} or FROM {table: Identifier}
 483            https://clickhouse.com/docs/en/sql-reference/syntax#defining-and-using-query-parameters
 484            """
 485            if not self._match(TokenType.L_BRACE):
 486                return None
 487
 488            this = self._parse_id_var()
 489            self._match(TokenType.COLON)
 490            kind = self._parse_types(check_func=False, allow_identifiers=False) or (
 491                self._match_text_seq("IDENTIFIER") and "Identifier"
 492            )
 493
 494            if not kind:
 495                self.raise_error("Expecting a placeholder type or 'Identifier' for tables")
 496            elif not self._match(TokenType.R_BRACE):
 497                self.raise_error("Expecting }")
 498
 499            return self.expression(exp.Placeholder, this=this, kind=kind)
 500
 501        def _parse_in(self, this: t.Optional[exp.Expression], is_global: bool = False) -> exp.In:
 502            this = super()._parse_in(this)
 503            this.set("is_global", is_global)
 504            return this
 505
 506        def _parse_table(
 507            self,
 508            schema: bool = False,
 509            joins: bool = False,
 510            alias_tokens: t.Optional[t.Collection[TokenType]] = None,
 511            parse_bracket: bool = False,
 512            is_db_reference: bool = False,
 513            parse_partition: bool = False,
 514        ) -> t.Optional[exp.Expression]:
 515            this = super()._parse_table(
 516                schema=schema,
 517                joins=joins,
 518                alias_tokens=alias_tokens,
 519                parse_bracket=parse_bracket,
 520                is_db_reference=is_db_reference,
 521            )
 522
 523            if self._match(TokenType.FINAL):
 524                this = self.expression(exp.Final, this=this)
 525
 526            return this
 527
 528        def _parse_position(self, haystack_first: bool = False) -> exp.StrPosition:
 529            return super()._parse_position(haystack_first=True)
 530
 531        # https://clickhouse.com/docs/en/sql-reference/statements/select/with/
 532        def _parse_cte(self) -> exp.CTE:
 533            # WITH <identifier> AS <subquery expression>
 534            cte: t.Optional[exp.CTE] = self._try_parse(super()._parse_cte)
 535
 536            if not cte:
 537                # WITH <expression> AS <identifier>
 538                cte = self.expression(
 539                    exp.CTE,
 540                    this=self._parse_assignment(),
 541                    alias=self._parse_table_alias(),
 542                    scalar=True,
 543                )
 544
 545            return cte
 546
 547        def _parse_join_parts(
 548            self,
 549        ) -> t.Tuple[t.Optional[Token], t.Optional[Token], t.Optional[Token]]:
 550            is_global = self._match(TokenType.GLOBAL) and self._prev
 551            kind_pre = self._match_set(self.JOIN_KINDS, advance=False) and self._prev
 552
 553            if kind_pre:
 554                kind = self._match_set(self.JOIN_KINDS) and self._prev
 555                side = self._match_set(self.JOIN_SIDES) and self._prev
 556                return is_global, side, kind
 557
 558            return (
 559                is_global,
 560                self._match_set(self.JOIN_SIDES) and self._prev,
 561                self._match_set(self.JOIN_KINDS) and self._prev,
 562            )
 563
 564        def _parse_join(
 565            self, skip_join_token: bool = False, parse_bracket: bool = False
 566        ) -> t.Optional[exp.Join]:
 567            join = super()._parse_join(skip_join_token=skip_join_token, parse_bracket=True)
 568            if join:
 569                join.set("global", join.args.pop("method", None))
 570
 571            return join
 572
 573        def _parse_function(
 574            self,
 575            functions: t.Optional[t.Dict[str, t.Callable]] = None,
 576            anonymous: bool = False,
 577            optional_parens: bool = True,
 578            any_token: bool = False,
 579        ) -> t.Optional[exp.Expression]:
 580            expr = super()._parse_function(
 581                functions=functions,
 582                anonymous=anonymous,
 583                optional_parens=optional_parens,
 584                any_token=any_token,
 585            )
 586
 587            func = expr.this if isinstance(expr, exp.Window) else expr
 588
 589            # Aggregate functions can be split in 2 parts: <func_name><suffix>
 590            parts = (
 591                self.AGG_FUNC_MAPPING.get(func.this) if isinstance(func, exp.Anonymous) else None
 592            )
 593
 594            if parts:
 595                params = self._parse_func_params(func)
 596
 597                kwargs = {
 598                    "this": func.this,
 599                    "expressions": func.expressions,
 600                }
 601                if parts[1]:
 602                    kwargs["parts"] = parts
 603                    exp_class = exp.CombinedParameterizedAgg if params else exp.CombinedAggFunc
 604                else:
 605                    exp_class = exp.ParameterizedAgg if params else exp.AnonymousAggFunc
 606
 607                kwargs["exp_class"] = exp_class
 608                if params:
 609                    kwargs["params"] = params
 610
 611                func = self.expression(**kwargs)
 612
 613                if isinstance(expr, exp.Window):
 614                    # The window's func was parsed as Anonymous in base parser, fix its
 615                    # type to be ClickHouse style CombinedAnonymousAggFunc / AnonymousAggFunc
 616                    expr.set("this", func)
 617                elif params:
 618                    # Params have blocked super()._parse_function() from parsing the following window
 619                    # (if that exists) as they're standing between the function call and the window spec
 620                    expr = self._parse_window(func)
 621                else:
 622                    expr = func
 623
 624            return expr
 625
 626        def _parse_func_params(
 627            self, this: t.Optional[exp.Func] = None
 628        ) -> t.Optional[t.List[exp.Expression]]:
 629            if self._match_pair(TokenType.R_PAREN, TokenType.L_PAREN):
 630                return self._parse_csv(self._parse_lambda)
 631
 632            if self._match(TokenType.L_PAREN):
 633                params = self._parse_csv(self._parse_lambda)
 634                self._match_r_paren(this)
 635                return params
 636
 637            return None
 638
 639        def _parse_quantile(self) -> exp.Quantile:
 640            this = self._parse_lambda()
 641            params = self._parse_func_params()
 642            if params:
 643                return self.expression(exp.Quantile, this=params[0], quantile=this)
 644            return self.expression(exp.Quantile, this=this, quantile=exp.Literal.number(0.5))
 645
 646        def _parse_wrapped_id_vars(self, optional: bool = False) -> t.List[exp.Expression]:
 647            return super()._parse_wrapped_id_vars(optional=True)
 648
 649        def _parse_primary_key(
 650            self, wrapped_optional: bool = False, in_props: bool = False
 651        ) -> exp.PrimaryKeyColumnConstraint | exp.PrimaryKey:
 652            return super()._parse_primary_key(
 653                wrapped_optional=wrapped_optional or in_props, in_props=in_props
 654            )
 655
 656        def _parse_on_property(self) -> t.Optional[exp.Expression]:
 657            index = self._index
 658            if self._match_text_seq("CLUSTER"):
 659                this = self._parse_id_var()
 660                if this:
 661                    return self.expression(exp.OnCluster, this=this)
 662                else:
 663                    self._retreat(index)
 664            return None
 665
 666        def _parse_index_constraint(
 667            self, kind: t.Optional[str] = None
 668        ) -> exp.IndexColumnConstraint:
 669            # INDEX name1 expr TYPE type1(args) GRANULARITY value
 670            this = self._parse_id_var()
 671            expression = self._parse_assignment()
 672
 673            index_type = self._match_text_seq("TYPE") and (
 674                self._parse_function() or self._parse_var()
 675            )
 676
 677            granularity = self._match_text_seq("GRANULARITY") and self._parse_term()
 678
 679            return self.expression(
 680                exp.IndexColumnConstraint,
 681                this=this,
 682                expression=expression,
 683                index_type=index_type,
 684                granularity=granularity,
 685            )
 686
 687        def _parse_partition(self) -> t.Optional[exp.Partition]:
 688            # https://clickhouse.com/docs/en/sql-reference/statements/alter/partition#how-to-set-partition-expression
 689            if not self._match(TokenType.PARTITION):
 690                return None
 691
 692            if self._match_text_seq("ID"):
 693                # Corresponds to the PARTITION ID <string_value> syntax
 694                expressions: t.List[exp.Expression] = [
 695                    self.expression(exp.PartitionId, this=self._parse_string())
 696                ]
 697            else:
 698                expressions = self._parse_expressions()
 699
 700            return self.expression(exp.Partition, expressions=expressions)
 701
 702        def _parse_alter_table_replace(self) -> t.Optional[exp.Expression]:
 703            partition = self._parse_partition()
 704
 705            if not partition or not self._match(TokenType.FROM):
 706                return None
 707
 708            return self.expression(
 709                exp.ReplacePartition, expression=partition, source=self._parse_table_parts()
 710            )
 711
 712        def _parse_projection_def(self) -> t.Optional[exp.ProjectionDef]:
 713            if not self._match_text_seq("PROJECTION"):
 714                return None
 715
 716            return self.expression(
 717                exp.ProjectionDef,
 718                this=self._parse_id_var(),
 719                expression=self._parse_wrapped(self._parse_statement),
 720            )
 721
 722        def _parse_constraint(self) -> t.Optional[exp.Expression]:
 723            return super()._parse_constraint() or self._parse_projection_def()
 724
 725    class Generator(generator.Generator):
 726        QUERY_HINTS = False
 727        STRUCT_DELIMITER = ("(", ")")
 728        NVL2_SUPPORTED = False
 729        TABLESAMPLE_REQUIRES_PARENS = False
 730        TABLESAMPLE_SIZE_IS_ROWS = False
 731        TABLESAMPLE_KEYWORDS = "SAMPLE"
 732        LAST_DAY_SUPPORTS_DATE_PART = False
 733        CAN_IMPLEMENT_ARRAY_ANY = True
 734        SUPPORTS_TO_NUMBER = False
 735        JOIN_HINTS = False
 736        TABLE_HINTS = False
 737        EXPLICIT_SET_OP = True
 738        GROUPINGS_SEP = ""
 739        SET_OP_MODIFIERS = False
 740        SUPPORTS_TABLE_ALIAS_COLUMNS = False
 741        VALUES_AS_TABLE = False
 742
 743        STRING_TYPE_MAPPING = {
 744            exp.DataType.Type.CHAR: "String",
 745            exp.DataType.Type.LONGBLOB: "String",
 746            exp.DataType.Type.LONGTEXT: "String",
 747            exp.DataType.Type.MEDIUMBLOB: "String",
 748            exp.DataType.Type.MEDIUMTEXT: "String",
 749            exp.DataType.Type.TINYBLOB: "String",
 750            exp.DataType.Type.TINYTEXT: "String",
 751            exp.DataType.Type.TEXT: "String",
 752            exp.DataType.Type.VARBINARY: "String",
 753            exp.DataType.Type.VARCHAR: "String",
 754        }
 755
 756        SUPPORTED_JSON_PATH_PARTS = {
 757            exp.JSONPathKey,
 758            exp.JSONPathRoot,
 759            exp.JSONPathSubscript,
 760        }
 761
 762        TYPE_MAPPING = {
 763            **generator.Generator.TYPE_MAPPING,
 764            **STRING_TYPE_MAPPING,
 765            exp.DataType.Type.ARRAY: "Array",
 766            exp.DataType.Type.BIGINT: "Int64",
 767            exp.DataType.Type.DATE32: "Date32",
 768            exp.DataType.Type.DATETIME64: "DateTime64",
 769            exp.DataType.Type.TIMESTAMPTZ: "TIMESTAMP",
 770            exp.DataType.Type.DOUBLE: "Float64",
 771            exp.DataType.Type.ENUM: "Enum",
 772            exp.DataType.Type.ENUM8: "Enum8",
 773            exp.DataType.Type.ENUM16: "Enum16",
 774            exp.DataType.Type.FIXEDSTRING: "FixedString",
 775            exp.DataType.Type.FLOAT: "Float32",
 776            exp.DataType.Type.INT: "Int32",
 777            exp.DataType.Type.MEDIUMINT: "Int32",
 778            exp.DataType.Type.INT128: "Int128",
 779            exp.DataType.Type.INT256: "Int256",
 780            exp.DataType.Type.LOWCARDINALITY: "LowCardinality",
 781            exp.DataType.Type.MAP: "Map",
 782            exp.DataType.Type.NESTED: "Nested",
 783            exp.DataType.Type.NULLABLE: "Nullable",
 784            exp.DataType.Type.SMALLINT: "Int16",
 785            exp.DataType.Type.STRUCT: "Tuple",
 786            exp.DataType.Type.TINYINT: "Int8",
 787            exp.DataType.Type.UBIGINT: "UInt64",
 788            exp.DataType.Type.UINT: "UInt32",
 789            exp.DataType.Type.UINT128: "UInt128",
 790            exp.DataType.Type.UINT256: "UInt256",
 791            exp.DataType.Type.USMALLINT: "UInt16",
 792            exp.DataType.Type.UTINYINT: "UInt8",
 793            exp.DataType.Type.IPV4: "IPv4",
 794            exp.DataType.Type.IPV6: "IPv6",
 795            exp.DataType.Type.AGGREGATEFUNCTION: "AggregateFunction",
 796            exp.DataType.Type.SIMPLEAGGREGATEFUNCTION: "SimpleAggregateFunction",
 797        }
 798
 799        TRANSFORMS = {
 800            **generator.Generator.TRANSFORMS,
 801            exp.AnyValue: rename_func("any"),
 802            exp.ApproxDistinct: rename_func("uniq"),
 803            exp.ArrayFilter: lambda self, e: self.func("arrayFilter", e.expression, e.this),
 804            exp.ArraySize: rename_func("LENGTH"),
 805            exp.ArraySum: rename_func("arraySum"),
 806            exp.ArgMax: arg_max_or_min_no_count("argMax"),
 807            exp.ArgMin: arg_max_or_min_no_count("argMin"),
 808            exp.Array: inline_array_sql,
 809            exp.CastToStrType: rename_func("CAST"),
 810            exp.CountIf: rename_func("countIf"),
 811            exp.CompressColumnConstraint: lambda self,
 812            e: f"CODEC({self.expressions(e, key='this', flat=True)})",
 813            exp.ComputedColumnConstraint: lambda self,
 814            e: f"{'MATERIALIZED' if e.args.get('persisted') else 'ALIAS'} {self.sql(e, 'this')}",
 815            exp.CurrentDate: lambda self, e: self.func("CURRENT_DATE"),
 816            exp.DateAdd: _datetime_delta_sql("DATE_ADD"),
 817            exp.DateDiff: _datetime_delta_sql("DATE_DIFF"),
 818            exp.DateStrToDate: rename_func("toDate"),
 819            exp.DateSub: _datetime_delta_sql("DATE_SUB"),
 820            exp.Explode: rename_func("arrayJoin"),
 821            exp.Final: lambda self, e: f"{self.sql(e, 'this')} FINAL",
 822            exp.IsNan: rename_func("isNaN"),
 823            exp.JSONExtract: json_extract_segments("JSONExtractString", quoted_index=False),
 824            exp.JSONExtractScalar: json_extract_segments("JSONExtractString", quoted_index=False),
 825            exp.JSONPathKey: json_path_key_only_name,
 826            exp.JSONPathRoot: lambda *_: "",
 827            exp.Map: lambda self, e: _lower_func(var_map_sql(self, e)),
 828            exp.Nullif: rename_func("nullIf"),
 829            exp.PartitionedByProperty: lambda self, e: f"PARTITION BY {self.sql(e, 'this')}",
 830            exp.Pivot: no_pivot_sql,
 831            exp.Quantile: _quantile_sql,
 832            exp.RegexpLike: lambda self, e: self.func("match", e.this, e.expression),
 833            exp.Rand: rename_func("randCanonical"),
 834            exp.StartsWith: rename_func("startsWith"),
 835            exp.StrPosition: lambda self, e: self.func(
 836                "position", e.this, e.args.get("substr"), e.args.get("position")
 837            ),
 838            exp.TimeToStr: lambda self, e: self.func(
 839                "DATE_FORMAT", e.this, self.format_time(e), e.args.get("timezone")
 840            ),
 841            exp.TimestampAdd: _datetime_delta_sql("TIMESTAMP_ADD"),
 842            exp.TimestampSub: _datetime_delta_sql("TIMESTAMP_SUB"),
 843            exp.VarMap: lambda self, e: _lower_func(var_map_sql(self, e)),
 844            exp.Xor: lambda self, e: self.func("xor", e.this, e.expression, *e.expressions),
 845            exp.MD5Digest: rename_func("MD5"),
 846            exp.MD5: lambda self, e: self.func("LOWER", self.func("HEX", self.func("MD5", e.this))),
 847            exp.SHA: rename_func("SHA1"),
 848            exp.SHA2: sha256_sql,
 849            exp.UnixToTime: _unix_to_time_sql,
 850            exp.TimestampTrunc: timestamptrunc_sql(zone=True),
 851            exp.Variance: rename_func("varSamp"),
 852            exp.SchemaCommentProperty: lambda self, e: self.naked_property(e),
 853            exp.Stddev: rename_func("stddevSamp"),
 854        }
 855
 856        PROPERTIES_LOCATION = {
 857            **generator.Generator.PROPERTIES_LOCATION,
 858            exp.VolatileProperty: exp.Properties.Location.UNSUPPORTED,
 859            exp.PartitionedByProperty: exp.Properties.Location.POST_SCHEMA,
 860            exp.OnCluster: exp.Properties.Location.POST_NAME,
 861        }
 862
 863        # There's no list in docs, but it can be found in Clickhouse code
 864        # see `ClickHouse/src/Parsers/ParserCreate*.cpp`
 865        ON_CLUSTER_TARGETS = {
 866            "DATABASE",
 867            "TABLE",
 868            "VIEW",
 869            "DICTIONARY",
 870            "INDEX",
 871            "FUNCTION",
 872            "NAMED COLLECTION",
 873        }
 874
 875        # https://clickhouse.com/docs/en/sql-reference/data-types/nullable
 876        NON_NULLABLE_TYPES = {
 877            exp.DataType.Type.ARRAY,
 878            exp.DataType.Type.MAP,
 879            exp.DataType.Type.NULLABLE,
 880            exp.DataType.Type.STRUCT,
 881        }
 882
 883        def strtodate_sql(self, expression: exp.StrToDate) -> str:
 884            strtodate_sql = self.function_fallback_sql(expression)
 885
 886            if not isinstance(expression.parent, exp.Cast):
 887                # StrToDate returns DATEs in other dialects (eg. postgres), so
 888                # this branch aims to improve the transpilation to clickhouse
 889                return f"CAST({strtodate_sql} AS DATE)"
 890
 891            return strtodate_sql
 892
 893        def cast_sql(self, expression: exp.Cast, safe_prefix: t.Optional[str] = None) -> str:
 894            this = expression.this
 895
 896            if isinstance(this, exp.StrToDate) and expression.to == exp.DataType.build("datetime"):
 897                return self.sql(this)
 898
 899            return super().cast_sql(expression, safe_prefix=safe_prefix)
 900
 901        def trycast_sql(self, expression: exp.TryCast) -> str:
 902            dtype = expression.to
 903            if not dtype.is_type(*self.NON_NULLABLE_TYPES, check_nullable=True):
 904                # Casting x into Nullable(T) appears to behave similarly to TRY_CAST(x AS T)
 905                dtype.set("nullable", True)
 906
 907            return super().cast_sql(expression)
 908
 909        def _jsonpathsubscript_sql(self, expression: exp.JSONPathSubscript) -> str:
 910            this = self.json_path_part(expression.this)
 911            return str(int(this) + 1) if is_int(this) else this
 912
 913        def likeproperty_sql(self, expression: exp.LikeProperty) -> str:
 914            return f"AS {self.sql(expression, 'this')}"
 915
 916        def _any_to_has(
 917            self,
 918            expression: exp.EQ | exp.NEQ,
 919            default: t.Callable[[t.Any], str],
 920            prefix: str = "",
 921        ) -> str:
 922            if isinstance(expression.left, exp.Any):
 923                arr = expression.left
 924                this = expression.right
 925            elif isinstance(expression.right, exp.Any):
 926                arr = expression.right
 927                this = expression.left
 928            else:
 929                return default(expression)
 930
 931            return prefix + self.func("has", arr.this.unnest(), this)
 932
 933        def eq_sql(self, expression: exp.EQ) -> str:
 934            return self._any_to_has(expression, super().eq_sql)
 935
 936        def neq_sql(self, expression: exp.NEQ) -> str:
 937            return self._any_to_has(expression, super().neq_sql, "NOT ")
 938
 939        def regexpilike_sql(self, expression: exp.RegexpILike) -> str:
 940            # Manually add a flag to make the search case-insensitive
 941            regex = self.func("CONCAT", "'(?i)'", expression.expression)
 942            return self.func("match", expression.this, regex)
 943
 944        def datatype_sql(self, expression: exp.DataType) -> str:
 945            # String is the standard ClickHouse type, every other variant is just an alias.
 946            # Additionally, any supplied length parameter will be ignored.
 947            #
 948            # https://clickhouse.com/docs/en/sql-reference/data-types/string
 949            if expression.this in self.STRING_TYPE_MAPPING:
 950                dtype = "String"
 951            else:
 952                dtype = super().datatype_sql(expression)
 953
 954            # This section changes the type to `Nullable(...)` if the following conditions hold:
 955            # - It's marked as nullable - this ensures we won't wrap ClickHouse types with `Nullable`
 956            #   and change their semantics
 957            # - It's not the key type of a `Map`. This is because ClickHouse enforces the following
 958            #   constraint: "Type of Map key must be a type, that can be represented by integer or
 959            #   String or FixedString (possibly LowCardinality) or UUID or IPv6"
 960            # - It's not a composite type, e.g. `Nullable(Array(...))` is not a valid type
 961            parent = expression.parent
 962            if (
 963                expression.args.get("nullable") is not False
 964                and not (
 965                    isinstance(parent, exp.DataType)
 966                    and parent.is_type(exp.DataType.Type.MAP, check_nullable=True)
 967                    and expression.index in (None, 0)
 968                )
 969                and not expression.is_type(*self.NON_NULLABLE_TYPES, check_nullable=True)
 970            ):
 971                dtype = f"Nullable({dtype})"
 972
 973            return dtype
 974
 975        def cte_sql(self, expression: exp.CTE) -> str:
 976            if expression.args.get("scalar"):
 977                this = self.sql(expression, "this")
 978                alias = self.sql(expression, "alias")
 979                return f"{this} AS {alias}"
 980
 981            return super().cte_sql(expression)
 982
 983        def after_limit_modifiers(self, expression: exp.Expression) -> t.List[str]:
 984            return super().after_limit_modifiers(expression) + [
 985                (
 986                    self.seg("SETTINGS ") + self.expressions(expression, key="settings", flat=True)
 987                    if expression.args.get("settings")
 988                    else ""
 989                ),
 990                (
 991                    self.seg("FORMAT ") + self.sql(expression, "format")
 992                    if expression.args.get("format")
 993                    else ""
 994                ),
 995            ]
 996
 997        def parameterizedagg_sql(self, expression: exp.ParameterizedAgg) -> str:
 998            params = self.expressions(expression, key="params", flat=True)
 999            return self.func(expression.name, *expression.expressions) + f"({params})"
1000
1001        def anonymousaggfunc_sql(self, expression: exp.AnonymousAggFunc) -> str:
1002            return self.func(expression.name, *expression.expressions)
1003
1004        def combinedaggfunc_sql(self, expression: exp.CombinedAggFunc) -> str:
1005            return self.anonymousaggfunc_sql(expression)
1006
1007        def combinedparameterizedagg_sql(self, expression: exp.CombinedParameterizedAgg) -> str:
1008            return self.parameterizedagg_sql(expression)
1009
1010        def placeholder_sql(self, expression: exp.Placeholder) -> str:
1011            return f"{{{expression.name}: {self.sql(expression, 'kind')}}}"
1012
1013        def oncluster_sql(self, expression: exp.OnCluster) -> str:
1014            return f"ON CLUSTER {self.sql(expression, 'this')}"
1015
1016        def createable_sql(self, expression: exp.Create, locations: t.DefaultDict) -> str:
1017            if expression.kind in self.ON_CLUSTER_TARGETS and locations.get(
1018                exp.Properties.Location.POST_NAME
1019            ):
1020                this_name = self.sql(
1021                    expression.this if isinstance(expression.this, exp.Schema) else expression,
1022                    "this",
1023                )
1024                this_properties = " ".join(
1025                    [self.sql(prop) for prop in locations[exp.Properties.Location.POST_NAME]]
1026                )
1027                this_schema = self.schema_columns_sql(expression.this)
1028                return f"{this_name}{self.sep()}{this_properties}{self.sep()}{this_schema}"
1029
1030            return super().createable_sql(expression, locations)
1031
1032        def create_sql(self, expression: exp.Create) -> str:
1033            # The comment property comes last in CTAS statements, i.e. after the query
1034            query = expression.expression
1035            if isinstance(query, exp.Query):
1036                comment_prop = expression.find(exp.SchemaCommentProperty)
1037                if comment_prop:
1038                    comment_prop.pop()
1039                    query.replace(exp.paren(query))
1040            else:
1041                comment_prop = None
1042
1043            create_sql = super().create_sql(expression)
1044
1045            comment_sql = self.sql(comment_prop)
1046            comment_sql = f" {comment_sql}" if comment_sql else ""
1047
1048            return f"{create_sql}{comment_sql}"
1049
1050        def prewhere_sql(self, expression: exp.PreWhere) -> str:
1051            this = self.indent(self.sql(expression, "this"))
1052            return f"{self.seg('PREWHERE')}{self.sep()}{this}"
1053
1054        def indexcolumnconstraint_sql(self, expression: exp.IndexColumnConstraint) -> str:
1055            this = self.sql(expression, "this")
1056            this = f" {this}" if this else ""
1057            expr = self.sql(expression, "expression")
1058            expr = f" {expr}" if expr else ""
1059            index_type = self.sql(expression, "index_type")
1060            index_type = f" TYPE {index_type}" if index_type else ""
1061            granularity = self.sql(expression, "granularity")
1062            granularity = f" GRANULARITY {granularity}" if granularity else ""
1063
1064            return f"INDEX{this}{expr}{index_type}{granularity}"
1065
1066        def partition_sql(self, expression: exp.Partition) -> str:
1067            return f"PARTITION {self.expressions(expression, flat=True)}"
1068
1069        def partitionid_sql(self, expression: exp.PartitionId) -> str:
1070            return f"ID {self.sql(expression.this)}"
1071
1072        def replacepartition_sql(self, expression: exp.ReplacePartition) -> str:
1073            return (
1074                f"REPLACE {self.sql(expression.expression)} FROM {self.sql(expression, 'source')}"
1075            )
1076
1077        def projectiondef_sql(self, expression: exp.ProjectionDef) -> str:
1078            return f"PROJECTION {self.sql(expression.this)} {self.wrap(expression.expression)}"
NORMALIZE_FUNCTIONS: bool | str = False

Determines how function names are going to be normalized.

Possible values:

"upper" or True: Convert names to uppercase. "lower": Convert names to lowercase. False: Disables function name normalization.

NULL_ORDERING = 'nulls_are_last'

Default NULL ordering method to use if not explicitly set. Possible values: "nulls_are_small", "nulls_are_large", "nulls_are_last"

SUPPORTS_USER_DEFINED_TYPES = False

Whether user-defined data types are supported.

SAFE_DIVISION = True

Whether division by zero throws an error (False) or returns NULL (True).

LOG_BASE_FIRST: Optional[bool] = None

Whether the base comes first in the LOG function. Possible values: True, False, None (two arguments are not supported by LOG)

FORCE_EARLY_ALIAS_REF_EXPANSION = True

Whether alias reference expansion (_expand_alias_refs()) should run before column qualification (_qualify_columns()).

For example:

WITH data AS ( SELECT 1 AS id, 2 AS my_id ) SELECT id AS my_id FROM data WHERE my_id = 1 GROUP BY my_id, HAVING my_id = 1

In most dialects "my_id" would refer to "data.my_id" (which is done in _qualify_columns()) across the query, except: - BigQuery, which will forward the alias to GROUP BY + HAVING clauses i.e it resolves to "WHERE my_id = 1 GROUP BY id HAVING id = 1" - Clickhouse, which will forward the alias across the query i.e it resolves to "WHERE id = 1 GROUP BY id HAVING id = 1"

NORMALIZATION_STRATEGY = <NormalizationStrategy.CASE_SENSITIVE: 'CASE_SENSITIVE'>

Specifies the strategy according to which identifiers should be normalized.

UNESCAPED_SEQUENCES = {'\\a': '\x07', '\\b': '\x08', '\\f': '\x0c', '\\n': '\n', '\\r': '\r', '\\t': '\t', '\\v': '\x0b', '\\\\': '\\', '\\0': '\x00'}

Mapping of an escaped sequence (\n) to its unescaped version ( ).

CREATABLE_KIND_MAPPING = {'DATABASE': 'SCHEMA'}

Helper for dialects that use a different name for the same creatable kind. For example, the Clickhouse equivalent of CREATE SCHEMA is CREATE DATABASE.

SUPPORTS_COLUMN_JOIN_MARKS = False

Whether the old-style outer join (+) syntax is supported.

tokenizer_class = <class 'ClickHouse.Tokenizer'>
jsonpath_tokenizer_class = <class 'sqlglot.tokens.JSONPathTokenizer'>
parser_class = <class 'ClickHouse.Parser'>
generator_class = <class 'ClickHouse.Generator'>
TIME_TRIE: Dict = {}
FORMAT_TRIE: Dict = {}
INVERSE_TIME_MAPPING: Dict[str, str] = {}
INVERSE_TIME_TRIE: Dict = {}
INVERSE_FORMAT_MAPPING: Dict[str, str] = {}
INVERSE_FORMAT_TRIE: Dict = {}
INVERSE_CREATABLE_KIND_MAPPING: dict[str, str] = {'SCHEMA': 'DATABASE'}
ESCAPED_SEQUENCES: Dict[str, str] = {'\x07': '\\a', '\x08': '\\b', '\x0c': '\\f', '\n': '\\n', '\r': '\\r', '\t': '\\t', '\x0b': '\\v', '\\': '\\\\', '\x00': '\\0'}
QUOTE_START = "'"
QUOTE_END = "'"
IDENTIFIER_START = '"'
IDENTIFIER_END = '"'
BIT_START: Optional[str] = '0b'
BIT_END: Optional[str] = ''
HEX_START: Optional[str] = '0x'
HEX_END: Optional[str] = ''
BYTE_START: Optional[str] = None
BYTE_END: Optional[str] = None
UNICODE_START: Optional[str] = None
UNICODE_END: Optional[str] = None
class ClickHouse.Tokenizer(sqlglot.tokens.Tokenizer):
126    class Tokenizer(tokens.Tokenizer):
127        COMMENTS = ["--", "#", "#!", ("/*", "*/")]
128        IDENTIFIERS = ['"', "`"]
129        STRING_ESCAPES = ["'", "\\"]
130        BIT_STRINGS = [("0b", "")]
131        HEX_STRINGS = [("0x", ""), ("0X", "")]
132        HEREDOC_STRINGS = ["$"]
133
134        KEYWORDS = {
135            **tokens.Tokenizer.KEYWORDS,
136            "ATTACH": TokenType.COMMAND,
137            "DATE32": TokenType.DATE32,
138            "DATETIME64": TokenType.DATETIME64,
139            "DICTIONARY": TokenType.DICTIONARY,
140            "ENUM8": TokenType.ENUM8,
141            "ENUM16": TokenType.ENUM16,
142            "FINAL": TokenType.FINAL,
143            "FIXEDSTRING": TokenType.FIXEDSTRING,
144            "FLOAT32": TokenType.FLOAT,
145            "FLOAT64": TokenType.DOUBLE,
146            "GLOBAL": TokenType.GLOBAL,
147            "INT256": TokenType.INT256,
148            "LOWCARDINALITY": TokenType.LOWCARDINALITY,
149            "MAP": TokenType.MAP,
150            "NESTED": TokenType.NESTED,
151            "SAMPLE": TokenType.TABLE_SAMPLE,
152            "TUPLE": TokenType.STRUCT,
153            "UINT128": TokenType.UINT128,
154            "UINT16": TokenType.USMALLINT,
155            "UINT256": TokenType.UINT256,
156            "UINT32": TokenType.UINT,
157            "UINT64": TokenType.UBIGINT,
158            "UINT8": TokenType.UTINYINT,
159            "IPV4": TokenType.IPV4,
160            "IPV6": TokenType.IPV6,
161            "AGGREGATEFUNCTION": TokenType.AGGREGATEFUNCTION,
162            "SIMPLEAGGREGATEFUNCTION": TokenType.SIMPLEAGGREGATEFUNCTION,
163            "SYSTEM": TokenType.COMMAND,
164            "PREWHERE": TokenType.PREWHERE,
165        }
166        KEYWORDS.pop("/*+")
167
168        SINGLE_TOKENS = {
169            **tokens.Tokenizer.SINGLE_TOKENS,
170            "$": TokenType.HEREDOC_STRING,
171        }
COMMENTS = ['--', '#', '#!', ('/*', '*/')]
IDENTIFIERS = ['"', '`']
STRING_ESCAPES = ["'", '\\']
BIT_STRINGS = [('0b', '')]
HEX_STRINGS = [('0x', ''), ('0X', '')]
HEREDOC_STRINGS = ['$']
KEYWORDS = {'{%': <TokenType.BLOCK_START: 'BLOCK_START'>, '{%+': <TokenType.BLOCK_START: 'BLOCK_START'>, '{%-': <TokenType.BLOCK_START: 'BLOCK_START'>, '%}': <TokenType.BLOCK_END: 'BLOCK_END'>, '+%}': <TokenType.BLOCK_END: 'BLOCK_END'>, '-%}': <TokenType.BLOCK_END: 'BLOCK_END'>, '{{+': <TokenType.BLOCK_START: 'BLOCK_START'>, '{{-': <TokenType.BLOCK_START: 'BLOCK_START'>, '+}}': <TokenType.BLOCK_END: 'BLOCK_END'>, '-}}': <TokenType.BLOCK_END: 'BLOCK_END'>, '==': <TokenType.EQ: 'EQ'>, '::': <TokenType.DCOLON: 'DCOLON'>, '||': <TokenType.DPIPE: 'DPIPE'>, '>=': <TokenType.GTE: 'GTE'>, '<=': <TokenType.LTE: 'LTE'>, '<>': <TokenType.NEQ: 'NEQ'>, '!=': <TokenType.NEQ: 'NEQ'>, ':=': <TokenType.COLON_EQ: 'COLON_EQ'>, '<=>': <TokenType.NULLSAFE_EQ: 'NULLSAFE_EQ'>, '->': <TokenType.ARROW: 'ARROW'>, '->>': <TokenType.DARROW: 'DARROW'>, '=>': <TokenType.FARROW: 'FARROW'>, '#>': <TokenType.HASH_ARROW: 'HASH_ARROW'>, '#>>': <TokenType.DHASH_ARROW: 'DHASH_ARROW'>, '<->': <TokenType.LR_ARROW: 'LR_ARROW'>, '&&': <TokenType.DAMP: 'DAMP'>, '??': <TokenType.DQMARK: 'DQMARK'>, 'ALL': <TokenType.ALL: 'ALL'>, 'ALWAYS': <TokenType.ALWAYS: 'ALWAYS'>, 'AND': <TokenType.AND: 'AND'>, 'ANTI': <TokenType.ANTI: 'ANTI'>, 'ANY': <TokenType.ANY: 'ANY'>, 'ASC': <TokenType.ASC: 'ASC'>, 'AS': <TokenType.ALIAS: 'ALIAS'>, 'ASOF': <TokenType.ASOF: 'ASOF'>, 'AUTOINCREMENT': <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, 'AUTO_INCREMENT': <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, 'BEGIN': <TokenType.BEGIN: 'BEGIN'>, 'BETWEEN': <TokenType.BETWEEN: 'BETWEEN'>, 'CACHE': <TokenType.CACHE: 'CACHE'>, 'UNCACHE': <TokenType.UNCACHE: 'UNCACHE'>, 'CASE': <TokenType.CASE: 'CASE'>, 'CHARACTER SET': <TokenType.CHARACTER_SET: 'CHARACTER_SET'>, 'CLUSTER BY': <TokenType.CLUSTER_BY: 'CLUSTER_BY'>, 'COLLATE': <TokenType.COLLATE: 'COLLATE'>, 'COLUMN': <TokenType.COLUMN: 'COLUMN'>, 'COMMIT': <TokenType.COMMIT: 'COMMIT'>, 'CONNECT BY': <TokenType.CONNECT_BY: 'CONNECT_BY'>, 'CONSTRAINT': <TokenType.CONSTRAINT: 'CONSTRAINT'>, 'COPY': <TokenType.COPY: 'COPY'>, 'CREATE': <TokenType.CREATE: 'CREATE'>, 'CROSS': <TokenType.CROSS: 'CROSS'>, 'CUBE': <TokenType.CUBE: 'CUBE'>, 'CURRENT_DATE': <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, 'CURRENT_TIME': <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, 'CURRENT_TIMESTAMP': <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, 'CURRENT_USER': <TokenType.CURRENT_USER: 'CURRENT_USER'>, 'DATABASE': <TokenType.DATABASE: 'DATABASE'>, 'DEFAULT': <TokenType.DEFAULT: 'DEFAULT'>, 'DELETE': <TokenType.DELETE: 'DELETE'>, 'DESC': <TokenType.DESC: 'DESC'>, 'DESCRIBE': <TokenType.DESCRIBE: 'DESCRIBE'>, 'DISTINCT': <TokenType.DISTINCT: 'DISTINCT'>, 'DISTRIBUTE BY': <TokenType.DISTRIBUTE_BY: 'DISTRIBUTE_BY'>, 'DIV': <TokenType.DIV: 'DIV'>, 'DROP': <TokenType.DROP: 'DROP'>, 'ELSE': <TokenType.ELSE: 'ELSE'>, 'END': <TokenType.END: 'END'>, 'ENUM': <TokenType.ENUM: 'ENUM'>, 'ESCAPE': <TokenType.ESCAPE: 'ESCAPE'>, 'EXCEPT': <TokenType.EXCEPT: 'EXCEPT'>, 'EXECUTE': <TokenType.EXECUTE: 'EXECUTE'>, 'EXISTS': <TokenType.EXISTS: 'EXISTS'>, 'FALSE': <TokenType.FALSE: 'FALSE'>, 'FETCH': <TokenType.FETCH: 'FETCH'>, 'FILTER': <TokenType.FILTER: 'FILTER'>, 'FIRST': <TokenType.FIRST: 'FIRST'>, 'FULL': <TokenType.FULL: 'FULL'>, 'FUNCTION': <TokenType.FUNCTION: 'FUNCTION'>, 'FOR': <TokenType.FOR: 'FOR'>, 'FOREIGN KEY': <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, 'FORMAT': <TokenType.FORMAT: 'FORMAT'>, 'FROM': <TokenType.FROM: 'FROM'>, 'GEOGRAPHY': <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, 'GEOMETRY': <TokenType.GEOMETRY: 'GEOMETRY'>, 'GLOB': <TokenType.GLOB: 'GLOB'>, 'GROUP BY': <TokenType.GROUP_BY: 'GROUP_BY'>, 'GROUPING SETS': <TokenType.GROUPING_SETS: 'GROUPING_SETS'>, 'HAVING': <TokenType.HAVING: 'HAVING'>, 'ILIKE': <TokenType.ILIKE: 'ILIKE'>, 'IN': <TokenType.IN: 'IN'>, 'INDEX': <TokenType.INDEX: 'INDEX'>, 'INET': <TokenType.INET: 'INET'>, 'INNER': <TokenType.INNER: 'INNER'>, 'INSERT': <TokenType.INSERT: 'INSERT'>, 'INTERVAL': <TokenType.INTERVAL: 'INTERVAL'>, 'INTERSECT': <TokenType.INTERSECT: 'INTERSECT'>, 'INTO': <TokenType.INTO: 'INTO'>, 'IS': <TokenType.IS: 'IS'>, 'ISNULL': <TokenType.ISNULL: 'ISNULL'>, 'JOIN': <TokenType.JOIN: 'JOIN'>, 'KEEP': <TokenType.KEEP: 'KEEP'>, 'KILL': <TokenType.KILL: 'KILL'>, 'LATERAL': <TokenType.LATERAL: 'LATERAL'>, 'LEFT': <TokenType.LEFT: 'LEFT'>, 'LIKE': <TokenType.LIKE: 'LIKE'>, 'LIMIT': <TokenType.LIMIT: 'LIMIT'>, 'LOAD': <TokenType.LOAD: 'LOAD'>, 'LOCK': <TokenType.LOCK: 'LOCK'>, 'MERGE': <TokenType.MERGE: 'MERGE'>, 'NATURAL': <TokenType.NATURAL: 'NATURAL'>, 'NEXT': <TokenType.NEXT: 'NEXT'>, 'NOT': <TokenType.NOT: 'NOT'>, 'NOTNULL': <TokenType.NOTNULL: 'NOTNULL'>, 'NULL': <TokenType.NULL: 'NULL'>, 'OBJECT': <TokenType.OBJECT: 'OBJECT'>, 'OFFSET': <TokenType.OFFSET: 'OFFSET'>, 'ON': <TokenType.ON: 'ON'>, 'OR': <TokenType.OR: 'OR'>, 'XOR': <TokenType.XOR: 'XOR'>, 'ORDER BY': <TokenType.ORDER_BY: 'ORDER_BY'>, 'ORDINALITY': <TokenType.ORDINALITY: 'ORDINALITY'>, 'OUTER': <TokenType.OUTER: 'OUTER'>, 'OVER': <TokenType.OVER: 'OVER'>, 'OVERLAPS': <TokenType.OVERLAPS: 'OVERLAPS'>, 'OVERWRITE': <TokenType.OVERWRITE: 'OVERWRITE'>, 'PARTITION': <TokenType.PARTITION: 'PARTITION'>, 'PARTITION BY': <TokenType.PARTITION_BY: 'PARTITION_BY'>, 'PARTITIONED BY': <TokenType.PARTITION_BY: 'PARTITION_BY'>, 'PARTITIONED_BY': <TokenType.PARTITION_BY: 'PARTITION_BY'>, 'PERCENT': <TokenType.PERCENT: 'PERCENT'>, 'PIVOT': <TokenType.PIVOT: 'PIVOT'>, 'PRAGMA': <TokenType.PRAGMA: 'PRAGMA'>, 'PRIMARY KEY': <TokenType.PRIMARY_KEY: 'PRIMARY_KEY'>, 'PROCEDURE': <TokenType.PROCEDURE: 'PROCEDURE'>, 'QUALIFY': <TokenType.QUALIFY: 'QUALIFY'>, 'RANGE': <TokenType.RANGE: 'RANGE'>, 'RECURSIVE': <TokenType.RECURSIVE: 'RECURSIVE'>, 'REGEXP': <TokenType.RLIKE: 'RLIKE'>, 'RENAME': <TokenType.RENAME: 'RENAME'>, 'REPLACE': <TokenType.REPLACE: 'REPLACE'>, 'RETURNING': <TokenType.RETURNING: 'RETURNING'>, 'REFERENCES': <TokenType.REFERENCES: 'REFERENCES'>, 'RIGHT': <TokenType.RIGHT: 'RIGHT'>, 'RLIKE': <TokenType.RLIKE: 'RLIKE'>, 'ROLLBACK': <TokenType.ROLLBACK: 'ROLLBACK'>, 'ROLLUP': <TokenType.ROLLUP: 'ROLLUP'>, 'ROW': <TokenType.ROW: 'ROW'>, 'ROWS': <TokenType.ROWS: 'ROWS'>, 'SCHEMA': <TokenType.SCHEMA: 'SCHEMA'>, 'SELECT': <TokenType.SELECT: 'SELECT'>, 'SEMI': <TokenType.SEMI: 'SEMI'>, 'SET': <TokenType.SET: 'SET'>, 'SETTINGS': <TokenType.SETTINGS: 'SETTINGS'>, 'SHOW': <TokenType.SHOW: 'SHOW'>, 'SIMILAR TO': <TokenType.SIMILAR_TO: 'SIMILAR_TO'>, 'SOME': <TokenType.SOME: 'SOME'>, 'SORT BY': <TokenType.SORT_BY: 'SORT_BY'>, 'START WITH': <TokenType.START_WITH: 'START_WITH'>, 'STRAIGHT_JOIN': <TokenType.STRAIGHT_JOIN: 'STRAIGHT_JOIN'>, 'TABLE': <TokenType.TABLE: 'TABLE'>, 'TABLESAMPLE': <TokenType.TABLE_SAMPLE: 'TABLE_SAMPLE'>, 'TEMP': <TokenType.TEMPORARY: 'TEMPORARY'>, 'TEMPORARY': <TokenType.TEMPORARY: 'TEMPORARY'>, 'THEN': <TokenType.THEN: 'THEN'>, 'TRUE': <TokenType.TRUE: 'TRUE'>, 'TRUNCATE': <TokenType.TRUNCATE: 'TRUNCATE'>, 'UNION': <TokenType.UNION: 'UNION'>, 'UNKNOWN': <TokenType.UNKNOWN: 'UNKNOWN'>, 'UNNEST': <TokenType.UNNEST: 'UNNEST'>, 'UNPIVOT': <TokenType.UNPIVOT: 'UNPIVOT'>, 'UPDATE': <TokenType.UPDATE: 'UPDATE'>, 'USE': <TokenType.USE: 'USE'>, 'USING': <TokenType.USING: 'USING'>, 'UUID': <TokenType.UUID: 'UUID'>, 'VALUES': <TokenType.VALUES: 'VALUES'>, 'VIEW': <TokenType.VIEW: 'VIEW'>, 'VOLATILE': <TokenType.VOLATILE: 'VOLATILE'>, 'WHEN': <TokenType.WHEN: 'WHEN'>, 'WHERE': <TokenType.WHERE: 'WHERE'>, 'WINDOW': <TokenType.WINDOW: 'WINDOW'>, 'WITH': <TokenType.WITH: 'WITH'>, 'APPLY': <TokenType.APPLY: 'APPLY'>, 'ARRAY': <TokenType.ARRAY: 'ARRAY'>, 'BIT': <TokenType.BIT: 'BIT'>, 'BOOL': <TokenType.BOOLEAN: 'BOOLEAN'>, 'BOOLEAN': <TokenType.BOOLEAN: 'BOOLEAN'>, 'BYTE': <TokenType.TINYINT: 'TINYINT'>, 'MEDIUMINT': <TokenType.MEDIUMINT: 'MEDIUMINT'>, 'INT1': <TokenType.TINYINT: 'TINYINT'>, 'TINYINT': <TokenType.TINYINT: 'TINYINT'>, 'INT16': <TokenType.SMALLINT: 'SMALLINT'>, 'SHORT': <TokenType.SMALLINT: 'SMALLINT'>, 'SMALLINT': <TokenType.SMALLINT: 'SMALLINT'>, 'INT128': <TokenType.INT128: 'INT128'>, 'HUGEINT': <TokenType.INT128: 'INT128'>, 'INT2': <TokenType.SMALLINT: 'SMALLINT'>, 'INTEGER': <TokenType.INT: 'INT'>, 'INT': <TokenType.INT: 'INT'>, 'INT4': <TokenType.INT: 'INT'>, 'INT32': <TokenType.INT: 'INT'>, 'INT64': <TokenType.BIGINT: 'BIGINT'>, 'LONG': <TokenType.BIGINT: 'BIGINT'>, 'BIGINT': <TokenType.BIGINT: 'BIGINT'>, 'INT8': <TokenType.TINYINT: 'TINYINT'>, 'UINT': <TokenType.UINT: 'UINT'>, 'DEC': <TokenType.DECIMAL: 'DECIMAL'>, 'DECIMAL': <TokenType.DECIMAL: 'DECIMAL'>, 'BIGDECIMAL': <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, 'BIGNUMERIC': <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, 'LIST': <TokenType.LIST: 'LIST'>, 'MAP': <TokenType.MAP: 'MAP'>, 'NULLABLE': <TokenType.NULLABLE: 'NULLABLE'>, 'NUMBER': <TokenType.DECIMAL: 'DECIMAL'>, 'NUMERIC': <TokenType.DECIMAL: 'DECIMAL'>, 'FIXED': <TokenType.DECIMAL: 'DECIMAL'>, 'REAL': <TokenType.FLOAT: 'FLOAT'>, 'FLOAT': <TokenType.FLOAT: 'FLOAT'>, 'FLOAT4': <TokenType.FLOAT: 'FLOAT'>, 'FLOAT8': <TokenType.DOUBLE: 'DOUBLE'>, 'DOUBLE': <TokenType.DOUBLE: 'DOUBLE'>, 'DOUBLE PRECISION': <TokenType.DOUBLE: 'DOUBLE'>, 'JSON': <TokenType.JSON: 'JSON'>, 'JSONB': <TokenType.JSONB: 'JSONB'>, 'CHAR': <TokenType.CHAR: 'CHAR'>, 'CHARACTER': <TokenType.CHAR: 'CHAR'>, 'NCHAR': <TokenType.NCHAR: 'NCHAR'>, 'VARCHAR': <TokenType.VARCHAR: 'VARCHAR'>, 'VARCHAR2': <TokenType.VARCHAR: 'VARCHAR'>, 'NVARCHAR': <TokenType.NVARCHAR: 'NVARCHAR'>, 'NVARCHAR2': <TokenType.NVARCHAR: 'NVARCHAR'>, 'BPCHAR': <TokenType.BPCHAR: 'BPCHAR'>, 'STR': <TokenType.TEXT: 'TEXT'>, 'STRING': <TokenType.TEXT: 'TEXT'>, 'TEXT': <TokenType.TEXT: 'TEXT'>, 'LONGTEXT': <TokenType.LONGTEXT: 'LONGTEXT'>, 'MEDIUMTEXT': <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, 'TINYTEXT': <TokenType.TINYTEXT: 'TINYTEXT'>, 'CLOB': <TokenType.TEXT: 'TEXT'>, 'LONGVARCHAR': <TokenType.TEXT: 'TEXT'>, 'BINARY': <TokenType.BINARY: 'BINARY'>, 'BLOB': <TokenType.VARBINARY: 'VARBINARY'>, 'LONGBLOB': <TokenType.LONGBLOB: 'LONGBLOB'>, 'MEDIUMBLOB': <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, 'TINYBLOB': <TokenType.TINYBLOB: 'TINYBLOB'>, 'BYTEA': <TokenType.VARBINARY: 'VARBINARY'>, 'VARBINARY': <TokenType.VARBINARY: 'VARBINARY'>, 'TIME': <TokenType.TIME: 'TIME'>, 'TIMETZ': <TokenType.TIMETZ: 'TIMETZ'>, 'TIMESTAMP': <TokenType.TIMESTAMP: 'TIMESTAMP'>, 'TIMESTAMPTZ': <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, 'TIMESTAMPLTZ': <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, 'TIMESTAMP_LTZ': <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, 'TIMESTAMPNTZ': <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, 'TIMESTAMP_NTZ': <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, 'DATE': <TokenType.DATE: 'DATE'>, 'DATETIME': <TokenType.DATETIME: 'DATETIME'>, 'INT4RANGE': <TokenType.INT4RANGE: 'INT4RANGE'>, 'INT4MULTIRANGE': <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, 'INT8RANGE': <TokenType.INT8RANGE: 'INT8RANGE'>, 'INT8MULTIRANGE': <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, 'NUMRANGE': <TokenType.NUMRANGE: 'NUMRANGE'>, 'NUMMULTIRANGE': <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, 'TSRANGE': <TokenType.TSRANGE: 'TSRANGE'>, 'TSMULTIRANGE': <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, 'TSTZRANGE': <TokenType.TSTZRANGE: 'TSTZRANGE'>, 'TSTZMULTIRANGE': <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, 'DATERANGE': <TokenType.DATERANGE: 'DATERANGE'>, 'DATEMULTIRANGE': <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, 'UNIQUE': <TokenType.UNIQUE: 'UNIQUE'>, 'VECTOR': <TokenType.VECTOR: 'VECTOR'>, 'STRUCT': <TokenType.STRUCT: 'STRUCT'>, 'SEQUENCE': <TokenType.SEQUENCE: 'SEQUENCE'>, 'VARIANT': <TokenType.VARIANT: 'VARIANT'>, 'ALTER': <TokenType.ALTER: 'ALTER'>, 'ANALYZE': <TokenType.COMMAND: 'COMMAND'>, 'CALL': <TokenType.COMMAND: 'COMMAND'>, 'COMMENT': <TokenType.COMMENT: 'COMMENT'>, 'EXPLAIN': <TokenType.COMMAND: 'COMMAND'>, 'GRANT': <TokenType.COMMAND: 'COMMAND'>, 'OPTIMIZE': <TokenType.COMMAND: 'COMMAND'>, 'PREPARE': <TokenType.COMMAND: 'COMMAND'>, 'VACUUM': <TokenType.COMMAND: 'COMMAND'>, 'USER-DEFINED': <TokenType.USERDEFINED: 'USERDEFINED'>, 'FOR VERSION': <TokenType.VERSION_SNAPSHOT: 'VERSION_SNAPSHOT'>, 'FOR TIMESTAMP': <TokenType.TIMESTAMP_SNAPSHOT: 'TIMESTAMP_SNAPSHOT'>, 'ATTACH': <TokenType.COMMAND: 'COMMAND'>, 'DATE32': <TokenType.DATE32: 'DATE32'>, 'DATETIME64': <TokenType.DATETIME64: 'DATETIME64'>, 'DICTIONARY': <TokenType.DICTIONARY: 'DICTIONARY'>, 'ENUM8': <TokenType.ENUM8: 'ENUM8'>, 'ENUM16': <TokenType.ENUM16: 'ENUM16'>, 'FINAL': <TokenType.FINAL: 'FINAL'>, 'FIXEDSTRING': <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, 'FLOAT32': <TokenType.FLOAT: 'FLOAT'>, 'FLOAT64': <TokenType.DOUBLE: 'DOUBLE'>, 'GLOBAL': <TokenType.GLOBAL: 'GLOBAL'>, 'INT256': <TokenType.INT256: 'INT256'>, 'LOWCARDINALITY': <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, 'NESTED': <TokenType.NESTED: 'NESTED'>, 'SAMPLE': <TokenType.TABLE_SAMPLE: 'TABLE_SAMPLE'>, 'TUPLE': <TokenType.STRUCT: 'STRUCT'>, 'UINT128': <TokenType.UINT128: 'UINT128'>, 'UINT16': <TokenType.USMALLINT: 'USMALLINT'>, 'UINT256': <TokenType.UINT256: 'UINT256'>, 'UINT32': <TokenType.UINT: 'UINT'>, 'UINT64': <TokenType.UBIGINT: 'UBIGINT'>, 'UINT8': <TokenType.UTINYINT: 'UTINYINT'>, 'IPV4': <TokenType.IPV4: 'IPV4'>, 'IPV6': <TokenType.IPV6: 'IPV6'>, 'AGGREGATEFUNCTION': <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, 'SIMPLEAGGREGATEFUNCTION': <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, 'SYSTEM': <TokenType.COMMAND: 'COMMAND'>, 'PREWHERE': <TokenType.PREWHERE: 'PREWHERE'>}
SINGLE_TOKENS = {'(': <TokenType.L_PAREN: 'L_PAREN'>, ')': <TokenType.R_PAREN: 'R_PAREN'>, '[': <TokenType.L_BRACKET: 'L_BRACKET'>, ']': <TokenType.R_BRACKET: 'R_BRACKET'>, '{': <TokenType.L_BRACE: 'L_BRACE'>, '}': <TokenType.R_BRACE: 'R_BRACE'>, '&': <TokenType.AMP: 'AMP'>, '^': <TokenType.CARET: 'CARET'>, ':': <TokenType.COLON: 'COLON'>, ',': <TokenType.COMMA: 'COMMA'>, '.': <TokenType.DOT: 'DOT'>, '-': <TokenType.DASH: 'DASH'>, '=': <TokenType.EQ: 'EQ'>, '>': <TokenType.GT: 'GT'>, '<': <TokenType.LT: 'LT'>, '%': <TokenType.MOD: 'MOD'>, '!': <TokenType.NOT: 'NOT'>, '|': <TokenType.PIPE: 'PIPE'>, '+': <TokenType.PLUS: 'PLUS'>, ';': <TokenType.SEMICOLON: 'SEMICOLON'>, '/': <TokenType.SLASH: 'SLASH'>, '\\': <TokenType.BACKSLASH: 'BACKSLASH'>, '*': <TokenType.STAR: 'STAR'>, '~': <TokenType.TILDA: 'TILDA'>, '?': <TokenType.PLACEHOLDER: 'PLACEHOLDER'>, '@': <TokenType.PARAMETER: 'PARAMETER'>, '#': <TokenType.HASH: 'HASH'>, "'": <TokenType.UNKNOWN: 'UNKNOWN'>, '`': <TokenType.UNKNOWN: 'UNKNOWN'>, '"': <TokenType.UNKNOWN: 'UNKNOWN'>, '$': <TokenType.HEREDOC_STRING: 'HEREDOC_STRING'>}
class ClickHouse.Parser(sqlglot.parser.Parser):
173    class Parser(parser.Parser):
174        # Tested in ClickHouse's playground, it seems that the following two queries do the same thing
175        # * select x from t1 union all select x from t2 limit 1;
176        # * select x from t1 union all (select x from t2 limit 1);
177        MODIFIERS_ATTACHED_TO_SET_OP = False
178        INTERVAL_SPANS = False
179
180        FUNCTIONS = {
181            **parser.Parser.FUNCTIONS,
182            "ANY": exp.AnyValue.from_arg_list,
183            "ARRAYSUM": exp.ArraySum.from_arg_list,
184            "COUNTIF": _build_count_if,
185            "DATE_ADD": build_date_delta(exp.DateAdd, default_unit=None),
186            "DATEADD": build_date_delta(exp.DateAdd, default_unit=None),
187            "DATE_DIFF": build_date_delta(exp.DateDiff, default_unit=None),
188            "DATEDIFF": build_date_delta(exp.DateDiff, default_unit=None),
189            "DATE_FORMAT": _build_date_format,
190            "DATE_SUB": build_date_delta(exp.DateSub, default_unit=None),
191            "DATESUB": build_date_delta(exp.DateSub, default_unit=None),
192            "FORMATDATETIME": _build_date_format,
193            "JSONEXTRACTSTRING": build_json_extract_path(
194                exp.JSONExtractScalar, zero_based_indexing=False
195            ),
196            "MAP": parser.build_var_map,
197            "MATCH": exp.RegexpLike.from_arg_list,
198            "RANDCANONICAL": exp.Rand.from_arg_list,
199            "STR_TO_DATE": _build_str_to_date,
200            "TUPLE": exp.Struct.from_arg_list,
201            "TIMESTAMP_SUB": build_date_delta(exp.TimestampSub, default_unit=None),
202            "TIMESTAMPSUB": build_date_delta(exp.TimestampSub, default_unit=None),
203            "TIMESTAMP_ADD": build_date_delta(exp.TimestampAdd, default_unit=None),
204            "TIMESTAMPADD": build_date_delta(exp.TimestampAdd, default_unit=None),
205            "UNIQ": exp.ApproxDistinct.from_arg_list,
206            "XOR": lambda args: exp.Xor(expressions=args),
207            "MD5": exp.MD5Digest.from_arg_list,
208            "SHA256": lambda args: exp.SHA2(this=seq_get(args, 0), length=exp.Literal.number(256)),
209            "SHA512": lambda args: exp.SHA2(this=seq_get(args, 0), length=exp.Literal.number(512)),
210        }
211
212        AGG_FUNCTIONS = {
213            "count",
214            "min",
215            "max",
216            "sum",
217            "avg",
218            "any",
219            "stddevPop",
220            "stddevSamp",
221            "varPop",
222            "varSamp",
223            "corr",
224            "covarPop",
225            "covarSamp",
226            "entropy",
227            "exponentialMovingAverage",
228            "intervalLengthSum",
229            "kolmogorovSmirnovTest",
230            "mannWhitneyUTest",
231            "median",
232            "rankCorr",
233            "sumKahan",
234            "studentTTest",
235            "welchTTest",
236            "anyHeavy",
237            "anyLast",
238            "boundingRatio",
239            "first_value",
240            "last_value",
241            "argMin",
242            "argMax",
243            "avgWeighted",
244            "topK",
245            "topKWeighted",
246            "deltaSum",
247            "deltaSumTimestamp",
248            "groupArray",
249            "groupArrayLast",
250            "groupUniqArray",
251            "groupArrayInsertAt",
252            "groupArrayMovingAvg",
253            "groupArrayMovingSum",
254            "groupArraySample",
255            "groupBitAnd",
256            "groupBitOr",
257            "groupBitXor",
258            "groupBitmap",
259            "groupBitmapAnd",
260            "groupBitmapOr",
261            "groupBitmapXor",
262            "sumWithOverflow",
263            "sumMap",
264            "minMap",
265            "maxMap",
266            "skewSamp",
267            "skewPop",
268            "kurtSamp",
269            "kurtPop",
270            "uniq",
271            "uniqExact",
272            "uniqCombined",
273            "uniqCombined64",
274            "uniqHLL12",
275            "uniqTheta",
276            "quantile",
277            "quantiles",
278            "quantileExact",
279            "quantilesExact",
280            "quantileExactLow",
281            "quantilesExactLow",
282            "quantileExactHigh",
283            "quantilesExactHigh",
284            "quantileExactWeighted",
285            "quantilesExactWeighted",
286            "quantileTiming",
287            "quantilesTiming",
288            "quantileTimingWeighted",
289            "quantilesTimingWeighted",
290            "quantileDeterministic",
291            "quantilesDeterministic",
292            "quantileTDigest",
293            "quantilesTDigest",
294            "quantileTDigestWeighted",
295            "quantilesTDigestWeighted",
296            "quantileBFloat16",
297            "quantilesBFloat16",
298            "quantileBFloat16Weighted",
299            "quantilesBFloat16Weighted",
300            "simpleLinearRegression",
301            "stochasticLinearRegression",
302            "stochasticLogisticRegression",
303            "categoricalInformationValue",
304            "contingency",
305            "cramersV",
306            "cramersVBiasCorrected",
307            "theilsU",
308            "maxIntersections",
309            "maxIntersectionsPosition",
310            "meanZTest",
311            "quantileInterpolatedWeighted",
312            "quantilesInterpolatedWeighted",
313            "quantileGK",
314            "quantilesGK",
315            "sparkBar",
316            "sumCount",
317            "largestTriangleThreeBuckets",
318            "histogram",
319            "sequenceMatch",
320            "sequenceCount",
321            "windowFunnel",
322            "retention",
323            "uniqUpTo",
324            "sequenceNextNode",
325            "exponentialTimeDecayedAvg",
326        }
327
328        AGG_FUNCTIONS_SUFFIXES = [
329            "If",
330            "Array",
331            "ArrayIf",
332            "Map",
333            "SimpleState",
334            "State",
335            "Merge",
336            "MergeState",
337            "ForEach",
338            "Distinct",
339            "OrDefault",
340            "OrNull",
341            "Resample",
342            "ArgMin",
343            "ArgMax",
344        ]
345
346        FUNC_TOKENS = {
347            *parser.Parser.FUNC_TOKENS,
348            TokenType.SET,
349        }
350
351        RESERVED_TOKENS = parser.Parser.RESERVED_TOKENS - {TokenType.SELECT}
352
353        ID_VAR_TOKENS = {
354            *parser.Parser.ID_VAR_TOKENS,
355            TokenType.LIKE,
356        }
357
358        AGG_FUNC_MAPPING = (
359            lambda functions, suffixes: {
360                f"{f}{sfx}": (f, sfx) for sfx in (suffixes + [""]) for f in functions
361            }
362        )(AGG_FUNCTIONS, AGG_FUNCTIONS_SUFFIXES)
363
364        FUNCTIONS_WITH_ALIASED_ARGS = {*parser.Parser.FUNCTIONS_WITH_ALIASED_ARGS, "TUPLE"}
365
366        FUNCTION_PARSERS = {
367            **parser.Parser.FUNCTION_PARSERS,
368            "ARRAYJOIN": lambda self: self.expression(exp.Explode, this=self._parse_expression()),
369            "QUANTILE": lambda self: self._parse_quantile(),
370        }
371
372        FUNCTION_PARSERS.pop("MATCH")
373
374        NO_PAREN_FUNCTION_PARSERS = parser.Parser.NO_PAREN_FUNCTION_PARSERS.copy()
375        NO_PAREN_FUNCTION_PARSERS.pop("ANY")
376
377        RANGE_PARSERS = {
378            **parser.Parser.RANGE_PARSERS,
379            TokenType.GLOBAL: lambda self, this: self._match(TokenType.IN)
380            and self._parse_in(this, is_global=True),
381        }
382
383        # The PLACEHOLDER entry is popped because 1) it doesn't affect Clickhouse (it corresponds to
384        # the postgres-specific JSONBContains parser) and 2) it makes parsing the ternary op simpler.
385        COLUMN_OPERATORS = parser.Parser.COLUMN_OPERATORS.copy()
386        COLUMN_OPERATORS.pop(TokenType.PLACEHOLDER)
387
388        JOIN_KINDS = {
389            *parser.Parser.JOIN_KINDS,
390            TokenType.ANY,
391            TokenType.ASOF,
392            TokenType.ARRAY,
393        }
394
395        TABLE_ALIAS_TOKENS = parser.Parser.TABLE_ALIAS_TOKENS - {
396            TokenType.ANY,
397            TokenType.ARRAY,
398            TokenType.FINAL,
399            TokenType.FORMAT,
400            TokenType.SETTINGS,
401        }
402
403        ALIAS_TOKENS = parser.Parser.ALIAS_TOKENS - {
404            TokenType.FORMAT,
405        }
406
407        LOG_DEFAULTS_TO_LN = True
408
409        QUERY_MODIFIER_PARSERS = {
410            **parser.Parser.QUERY_MODIFIER_PARSERS,
411            TokenType.SETTINGS: lambda self: (
412                "settings",
413                self._advance() or self._parse_csv(self._parse_assignment),
414            ),
415            TokenType.FORMAT: lambda self: ("format", self._advance() or self._parse_id_var()),
416        }
417
418        CONSTRAINT_PARSERS = {
419            **parser.Parser.CONSTRAINT_PARSERS,
420            "INDEX": lambda self: self._parse_index_constraint(),
421            "CODEC": lambda self: self._parse_compress(),
422        }
423
424        ALTER_PARSERS = {
425            **parser.Parser.ALTER_PARSERS,
426            "REPLACE": lambda self: self._parse_alter_table_replace(),
427        }
428
429        SCHEMA_UNNAMED_CONSTRAINTS = {
430            *parser.Parser.SCHEMA_UNNAMED_CONSTRAINTS,
431            "INDEX",
432        }
433
434        def _parse_types(
435            self, check_func: bool = False, schema: bool = False, allow_identifiers: bool = True
436        ) -> t.Optional[exp.Expression]:
437            dtype = super()._parse_types(
438                check_func=check_func, schema=schema, allow_identifiers=allow_identifiers
439            )
440            if isinstance(dtype, exp.DataType):
441                # Mark every type as non-nullable which is ClickHouse's default. This marker
442                # helps us transpile types from other dialects to ClickHouse, so that we can
443                # e.g. produce `CAST(x AS Nullable(String))` from `CAST(x AS TEXT)`. If there
444                # is a `NULL` value in `x`, the former would fail in ClickHouse without the
445                # `Nullable` type constructor
446                dtype.set("nullable", False)
447
448            return dtype
449
450        def _parse_extract(self) -> exp.Extract | exp.Anonymous:
451            index = self._index
452            this = self._parse_bitwise()
453            if self._match(TokenType.FROM):
454                self._retreat(index)
455                return super()._parse_extract()
456
457            # We return Anonymous here because extract and regexpExtract have different semantics,
458            # so parsing extract(foo, bar) into RegexpExtract can potentially break queries. E.g.,
459            # `extract('foobar', 'b')` works, but ClickHouse crashes for `regexpExtract('foobar', 'b')`.
460            #
461            # TODO: can we somehow convert the former into an equivalent `regexpExtract` call?
462            self._match(TokenType.COMMA)
463            return self.expression(
464                exp.Anonymous, this="extract", expressions=[this, self._parse_bitwise()]
465            )
466
467        def _parse_assignment(self) -> t.Optional[exp.Expression]:
468            this = super()._parse_assignment()
469
470            if self._match(TokenType.PLACEHOLDER):
471                return self.expression(
472                    exp.If,
473                    this=this,
474                    true=self._parse_assignment(),
475                    false=self._match(TokenType.COLON) and self._parse_assignment(),
476                )
477
478            return this
479
480        def _parse_placeholder(self) -> t.Optional[exp.Expression]:
481            """
482            Parse a placeholder expression like SELECT {abc: UInt32} or FROM {table: Identifier}
483            https://clickhouse.com/docs/en/sql-reference/syntax#defining-and-using-query-parameters
484            """
485            if not self._match(TokenType.L_BRACE):
486                return None
487
488            this = self._parse_id_var()
489            self._match(TokenType.COLON)
490            kind = self._parse_types(check_func=False, allow_identifiers=False) or (
491                self._match_text_seq("IDENTIFIER") and "Identifier"
492            )
493
494            if not kind:
495                self.raise_error("Expecting a placeholder type or 'Identifier' for tables")
496            elif not self._match(TokenType.R_BRACE):
497                self.raise_error("Expecting }")
498
499            return self.expression(exp.Placeholder, this=this, kind=kind)
500
501        def _parse_in(self, this: t.Optional[exp.Expression], is_global: bool = False) -> exp.In:
502            this = super()._parse_in(this)
503            this.set("is_global", is_global)
504            return this
505
506        def _parse_table(
507            self,
508            schema: bool = False,
509            joins: bool = False,
510            alias_tokens: t.Optional[t.Collection[TokenType]] = None,
511            parse_bracket: bool = False,
512            is_db_reference: bool = False,
513            parse_partition: bool = False,
514        ) -> t.Optional[exp.Expression]:
515            this = super()._parse_table(
516                schema=schema,
517                joins=joins,
518                alias_tokens=alias_tokens,
519                parse_bracket=parse_bracket,
520                is_db_reference=is_db_reference,
521            )
522
523            if self._match(TokenType.FINAL):
524                this = self.expression(exp.Final, this=this)
525
526            return this
527
528        def _parse_position(self, haystack_first: bool = False) -> exp.StrPosition:
529            return super()._parse_position(haystack_first=True)
530
531        # https://clickhouse.com/docs/en/sql-reference/statements/select/with/
532        def _parse_cte(self) -> exp.CTE:
533            # WITH <identifier> AS <subquery expression>
534            cte: t.Optional[exp.CTE] = self._try_parse(super()._parse_cte)
535
536            if not cte:
537                # WITH <expression> AS <identifier>
538                cte = self.expression(
539                    exp.CTE,
540                    this=self._parse_assignment(),
541                    alias=self._parse_table_alias(),
542                    scalar=True,
543                )
544
545            return cte
546
547        def _parse_join_parts(
548            self,
549        ) -> t.Tuple[t.Optional[Token], t.Optional[Token], t.Optional[Token]]:
550            is_global = self._match(TokenType.GLOBAL) and self._prev
551            kind_pre = self._match_set(self.JOIN_KINDS, advance=False) and self._prev
552
553            if kind_pre:
554                kind = self._match_set(self.JOIN_KINDS) and self._prev
555                side = self._match_set(self.JOIN_SIDES) and self._prev
556                return is_global, side, kind
557
558            return (
559                is_global,
560                self._match_set(self.JOIN_SIDES) and self._prev,
561                self._match_set(self.JOIN_KINDS) and self._prev,
562            )
563
564        def _parse_join(
565            self, skip_join_token: bool = False, parse_bracket: bool = False
566        ) -> t.Optional[exp.Join]:
567            join = super()._parse_join(skip_join_token=skip_join_token, parse_bracket=True)
568            if join:
569                join.set("global", join.args.pop("method", None))
570
571            return join
572
573        def _parse_function(
574            self,
575            functions: t.Optional[t.Dict[str, t.Callable]] = None,
576            anonymous: bool = False,
577            optional_parens: bool = True,
578            any_token: bool = False,
579        ) -> t.Optional[exp.Expression]:
580            expr = super()._parse_function(
581                functions=functions,
582                anonymous=anonymous,
583                optional_parens=optional_parens,
584                any_token=any_token,
585            )
586
587            func = expr.this if isinstance(expr, exp.Window) else expr
588
589            # Aggregate functions can be split in 2 parts: <func_name><suffix>
590            parts = (
591                self.AGG_FUNC_MAPPING.get(func.this) if isinstance(func, exp.Anonymous) else None
592            )
593
594            if parts:
595                params = self._parse_func_params(func)
596
597                kwargs = {
598                    "this": func.this,
599                    "expressions": func.expressions,
600                }
601                if parts[1]:
602                    kwargs["parts"] = parts
603                    exp_class = exp.CombinedParameterizedAgg if params else exp.CombinedAggFunc
604                else:
605                    exp_class = exp.ParameterizedAgg if params else exp.AnonymousAggFunc
606
607                kwargs["exp_class"] = exp_class
608                if params:
609                    kwargs["params"] = params
610
611                func = self.expression(**kwargs)
612
613                if isinstance(expr, exp.Window):
614                    # The window's func was parsed as Anonymous in base parser, fix its
615                    # type to be ClickHouse style CombinedAnonymousAggFunc / AnonymousAggFunc
616                    expr.set("this", func)
617                elif params:
618                    # Params have blocked super()._parse_function() from parsing the following window
619                    # (if that exists) as they're standing between the function call and the window spec
620                    expr = self._parse_window(func)
621                else:
622                    expr = func
623
624            return expr
625
626        def _parse_func_params(
627            self, this: t.Optional[exp.Func] = None
628        ) -> t.Optional[t.List[exp.Expression]]:
629            if self._match_pair(TokenType.R_PAREN, TokenType.L_PAREN):
630                return self._parse_csv(self._parse_lambda)
631
632            if self._match(TokenType.L_PAREN):
633                params = self._parse_csv(self._parse_lambda)
634                self._match_r_paren(this)
635                return params
636
637            return None
638
639        def _parse_quantile(self) -> exp.Quantile:
640            this = self._parse_lambda()
641            params = self._parse_func_params()
642            if params:
643                return self.expression(exp.Quantile, this=params[0], quantile=this)
644            return self.expression(exp.Quantile, this=this, quantile=exp.Literal.number(0.5))
645
646        def _parse_wrapped_id_vars(self, optional: bool = False) -> t.List[exp.Expression]:
647            return super()._parse_wrapped_id_vars(optional=True)
648
649        def _parse_primary_key(
650            self, wrapped_optional: bool = False, in_props: bool = False
651        ) -> exp.PrimaryKeyColumnConstraint | exp.PrimaryKey:
652            return super()._parse_primary_key(
653                wrapped_optional=wrapped_optional or in_props, in_props=in_props
654            )
655
656        def _parse_on_property(self) -> t.Optional[exp.Expression]:
657            index = self._index
658            if self._match_text_seq("CLUSTER"):
659                this = self._parse_id_var()
660                if this:
661                    return self.expression(exp.OnCluster, this=this)
662                else:
663                    self._retreat(index)
664            return None
665
666        def _parse_index_constraint(
667            self, kind: t.Optional[str] = None
668        ) -> exp.IndexColumnConstraint:
669            # INDEX name1 expr TYPE type1(args) GRANULARITY value
670            this = self._parse_id_var()
671            expression = self._parse_assignment()
672
673            index_type = self._match_text_seq("TYPE") and (
674                self._parse_function() or self._parse_var()
675            )
676
677            granularity = self._match_text_seq("GRANULARITY") and self._parse_term()
678
679            return self.expression(
680                exp.IndexColumnConstraint,
681                this=this,
682                expression=expression,
683                index_type=index_type,
684                granularity=granularity,
685            )
686
687        def _parse_partition(self) -> t.Optional[exp.Partition]:
688            # https://clickhouse.com/docs/en/sql-reference/statements/alter/partition#how-to-set-partition-expression
689            if not self._match(TokenType.PARTITION):
690                return None
691
692            if self._match_text_seq("ID"):
693                # Corresponds to the PARTITION ID <string_value> syntax
694                expressions: t.List[exp.Expression] = [
695                    self.expression(exp.PartitionId, this=self._parse_string())
696                ]
697            else:
698                expressions = self._parse_expressions()
699
700            return self.expression(exp.Partition, expressions=expressions)
701
702        def _parse_alter_table_replace(self) -> t.Optional[exp.Expression]:
703            partition = self._parse_partition()
704
705            if not partition or not self._match(TokenType.FROM):
706                return None
707
708            return self.expression(
709                exp.ReplacePartition, expression=partition, source=self._parse_table_parts()
710            )
711
712        def _parse_projection_def(self) -> t.Optional[exp.ProjectionDef]:
713            if not self._match_text_seq("PROJECTION"):
714                return None
715
716            return self.expression(
717                exp.ProjectionDef,
718                this=self._parse_id_var(),
719                expression=self._parse_wrapped(self._parse_statement),
720            )
721
722        def _parse_constraint(self) -> t.Optional[exp.Expression]:
723            return super()._parse_constraint() or self._parse_projection_def()

Parser consumes a list of tokens produced by the Tokenizer and produces a parsed syntax tree.

Arguments:
  • error_level: The desired error level. Default: ErrorLevel.IMMEDIATE
  • error_message_context: The amount of context to capture from a query string when displaying the error message (in number of characters). Default: 100
  • max_errors: Maximum number of error messages to include in a raised ParseError. This is only relevant if error_level is ErrorLevel.RAISE. Default: 3
MODIFIERS_ATTACHED_TO_SET_OP = False
INTERVAL_SPANS = False
FUNCTIONS = {'ABS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Abs'>>, 'ADD_MONTHS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.AddMonths'>>, 'ANONYMOUS_AGG_FUNC': <bound method Func.from_arg_list of <class 'sqlglot.expressions.AnonymousAggFunc'>>, 'ANY_VALUE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.AnyValue'>>, 'APPROX_DISTINCT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ApproxDistinct'>>, 'APPROX_COUNT_DISTINCT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ApproxDistinct'>>, 'APPROX_QUANTILE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ApproxQuantile'>>, 'APPROX_TOP_K': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ApproxTopK'>>, 'ARG_MAX': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArgMax'>>, 'ARGMAX': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArgMax'>>, 'MAX_BY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArgMax'>>, 'ARG_MIN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArgMin'>>, 'ARGMIN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArgMin'>>, 'MIN_BY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArgMin'>>, 'ARRAY': <function Parser.<lambda>>, 'ARRAY_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayAgg'>>, 'ARRAY_ALL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayAll'>>, 'ARRAY_ANY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayAny'>>, 'ARRAY_CONCAT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayConcat'>>, 'ARRAY_CAT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayConcat'>>, 'ARRAY_CONSTRUCT_COMPACT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayConstructCompact'>>, 'ARRAY_CONTAINS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayContains'>>, 'ARRAY_HAS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayContains'>>, 'ARRAY_CONTAINS_ALL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayContainsAll'>>, 'ARRAY_HAS_ALL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayContainsAll'>>, 'FILTER': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayFilter'>>, 'ARRAY_FILTER': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayFilter'>>, 'ARRAY_OVERLAPS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayOverlaps'>>, 'ARRAY_SIZE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArraySize'>>, 'ARRAY_LENGTH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArraySize'>>, 'ARRAY_SORT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArraySort'>>, 'ARRAY_SUM': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArraySum'>>, 'ARRAY_TO_STRING': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayToString'>>, 'ARRAY_JOIN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayToString'>>, 'ARRAY_UNION_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayUnionAgg'>>, 'ARRAY_UNIQUE_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayUniqueAgg'>>, 'AVG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Avg'>>, 'CASE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Case'>>, 'CAST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Cast'>>, 'CAST_TO_STR_TYPE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CastToStrType'>>, 'CBRT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Cbrt'>>, 'CEIL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Ceil'>>, 'CEILING': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Ceil'>>, 'CHR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Chr'>>, 'CHAR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Chr'>>, 'COALESCE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Coalesce'>>, 'IFNULL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Coalesce'>>, 'NVL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Coalesce'>>, 'COLLATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Collate'>>, 'COMBINED_AGG_FUNC': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CombinedAggFunc'>>, 'COMBINED_PARAMETERIZED_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CombinedParameterizedAgg'>>, 'CONCAT': <function Parser.<lambda>>, 'CONCAT_WS': <function Parser.<lambda>>, 'CONNECT_BY_ROOT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ConnectByRoot'>>, 'CONVERT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Convert'>>, 'CONVERT_TIMEZONE': <function build_convert_timezone>, 'CORR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Corr'>>, 'COUNT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Count'>>, 'COUNT_IF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CountIf'>>, 'COUNTIF': <function _build_count_if>, 'COVAR_POP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CovarPop'>>, 'COVAR_SAMP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CovarSamp'>>, 'CURRENT_DATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CurrentDate'>>, 'CURRENT_DATETIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CurrentDatetime'>>, 'CURRENT_TIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CurrentTime'>>, 'CURRENT_TIMESTAMP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CurrentTimestamp'>>, 'CURRENT_USER': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CurrentUser'>>, 'DATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Date'>>, 'DATE_ADD': <function build_date_delta.<locals>._builder>, 'DATEDIFF': <function build_date_delta.<locals>._builder>, 'DATE_DIFF': <function build_date_delta.<locals>._builder>, 'DATE_FROM_PARTS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DateFromParts'>>, 'DATEFROMPARTS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DateFromParts'>>, 'DATE_STR_TO_DATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DateStrToDate'>>, 'DATE_SUB': <function build_date_delta.<locals>._builder>, 'DATE_TO_DATE_STR': <function Parser.<lambda>>, 'DATE_TO_DI': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DateToDi'>>, 'DATE_TRUNC': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DateTrunc'>>, 'DATETIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Datetime'>>, 'DATETIME_ADD': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DatetimeAdd'>>, 'DATETIME_DIFF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DatetimeDiff'>>, 'DATETIME_SUB': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DatetimeSub'>>, 'DATETIME_TRUNC': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DatetimeTrunc'>>, 'DAY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Day'>>, 'DAY_OF_MONTH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DayOfMonth'>>, 'DAYOFMONTH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DayOfMonth'>>, 'DAY_OF_WEEK': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DayOfWeek'>>, 'DAYOFWEEK': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DayOfWeek'>>, 'DAY_OF_YEAR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DayOfYear'>>, 'DAYOFYEAR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DayOfYear'>>, 'DECODE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Decode'>>, 'DI_TO_DATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DiToDate'>>, 'ENCODE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Encode'>>, 'EXP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Exp'>>, 'EXPLODE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Explode'>>, 'EXPLODE_OUTER': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ExplodeOuter'>>, 'EXPLODING_GENERATE_SERIES': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ExplodingGenerateSeries'>>, 'EXTRACT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Extract'>>, 'FIRST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.First'>>, 'FIRST_VALUE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.FirstValue'>>, 'FLATTEN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Flatten'>>, 'FLOOR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Floor'>>, 'FROM_BASE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.FromBase'>>, 'FROM_BASE64': <bound method Func.from_arg_list of <class 'sqlglot.expressions.FromBase64'>>, 'GAP_FILL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.GapFill'>>, 'GENERATE_DATE_ARRAY': <function Parser.<lambda>>, 'GENERATE_SERIES': <bound method Func.from_arg_list of <class 'sqlglot.expressions.GenerateSeries'>>, 'GENERATE_TIMESTAMP_ARRAY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.GenerateTimestampArray'>>, 'GREATEST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Greatest'>>, 'GROUP_CONCAT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.GroupConcat'>>, 'HEX': <function build_hex>, 'HLL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Hll'>>, 'IF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.If'>>, 'IIF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.If'>>, 'INITCAP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Initcap'>>, 'IS_INF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.IsInf'>>, 'ISINF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.IsInf'>>, 'IS_NAN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.IsNan'>>, 'ISNAN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.IsNan'>>, 'J_S_O_N_ARRAY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONArray'>>, 'J_S_O_N_ARRAY_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONArrayAgg'>>, 'JSON_ARRAY_CONTAINS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONArrayContains'>>, 'JSONB_CONTAINS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONBContains'>>, 'JSONB_EXTRACT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONBExtract'>>, 'JSONB_EXTRACT_SCALAR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONBExtractScalar'>>, 'JSON_EXTRACT': <function build_extract_json_with_path.<locals>._builder>, 'JSON_EXTRACT_SCALAR': <function build_extract_json_with_path.<locals>._builder>, 'JSON_FORMAT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONFormat'>>, 'J_S_O_N_OBJECT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONObject'>>, 'J_S_O_N_OBJECT_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONObjectAgg'>>, 'J_S_O_N_TABLE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONTable'>>, 'LAG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Lag'>>, 'LAST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Last'>>, 'LAST_DAY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LastDay'>>, 'LAST_DAY_OF_MONTH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LastDay'>>, 'LAST_VALUE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LastValue'>>, 'LEAD': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Lead'>>, 'LEAST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Least'>>, 'LEFT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Left'>>, 'LENGTH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Length'>>, 'LEN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Length'>>, 'LEVENSHTEIN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Levenshtein'>>, 'LIST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.List'>>, 'LN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Ln'>>, 'LOG': <function build_logarithm>, 'LOGICAL_AND': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LogicalAnd'>>, 'BOOL_AND': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LogicalAnd'>>, 'BOOLAND_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LogicalAnd'>>, 'LOGICAL_OR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LogicalOr'>>, 'BOOL_OR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LogicalOr'>>, 'BOOLOR_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LogicalOr'>>, 'LOWER': <function build_lower>, 'LCASE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Lower'>>, 'LOWER_HEX': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LowerHex'>>, 'MD5': <bound method Func.from_arg_list of <class 'sqlglot.expressions.MD5Digest'>>, 'MD5_DIGEST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.MD5Digest'>>, 'MAP': <function build_var_map>, 'MAP_FROM_ENTRIES': <bound method Func.from_arg_list of <class 'sqlglot.expressions.MapFromEntries'>>, 'MATCH_AGAINST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.MatchAgainst'>>, 'MAX': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Max'>>, 'MIN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Min'>>, 'MONTH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Month'>>, 'MONTHS_BETWEEN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.MonthsBetween'>>, 'NEXT_VALUE_FOR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.NextValueFor'>>, 'NTH_VALUE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.NthValue'>>, 'NULLIF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Nullif'>>, 'NUMBER_TO_STR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.NumberToStr'>>, 'NVL2': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Nvl2'>>, 'OBJECT_INSERT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ObjectInsert'>>, 'OPEN_J_S_O_N': <bound method Func.from_arg_list of <class 'sqlglot.expressions.OpenJSON'>>, 'PAD': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Pad'>>, 'PARAMETERIZED_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ParameterizedAgg'>>, 'PARSE_JSON': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ParseJSON'>>, 'JSON_PARSE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ParseJSON'>>, 'PERCENTILE_CONT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.PercentileCont'>>, 'PERCENTILE_DISC': <bound method Func.from_arg_list of <class 'sqlglot.expressions.PercentileDisc'>>, 'POSEXPLODE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Posexplode'>>, 'POSEXPLODE_OUTER': <bound method Func.from_arg_list of <class 'sqlglot.expressions.PosexplodeOuter'>>, 'POWER': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Pow'>>, 'POW': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Pow'>>, 'PREDICT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Predict'>>, 'QUANTILE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Quantile'>>, 'QUARTER': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Quarter'>>, 'RAND': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Rand'>>, 'RANDOM': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Rand'>>, 'RANDN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Randn'>>, 'RANGE_N': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RangeN'>>, 'READ_CSV': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ReadCSV'>>, 'REDUCE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Reduce'>>, 'REGEXP_EXTRACT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RegexpExtract'>>, 'REGEXP_I_LIKE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RegexpILike'>>, 'REGEXP_LIKE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RegexpLike'>>, 'REGEXP_REPLACE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RegexpReplace'>>, 'REGEXP_SPLIT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RegexpSplit'>>, 'REPEAT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Repeat'>>, 'RIGHT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Right'>>, 'ROUND': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Round'>>, 'ROW_NUMBER': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RowNumber'>>, 'SHA': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SHA'>>, 'SHA1': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SHA'>>, 'SHA2': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SHA2'>>, 'SAFE_DIVIDE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SafeDivide'>>, 'SIGN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Sign'>>, 'SIGNUM': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Sign'>>, 'SORT_ARRAY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SortArray'>>, 'SPLIT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Split'>>, 'SQRT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Sqrt'>>, 'STANDARD_HASH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StandardHash'>>, 'STAR_MAP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StarMap'>>, 'STARTS_WITH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StartsWith'>>, 'STARTSWITH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StartsWith'>>, 'STDDEV': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Stddev'>>, 'STDEV': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Stddev'>>, 'STDDEV_POP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StddevPop'>>, 'STDDEV_SAMP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StddevSamp'>>, 'STR_POSITION': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StrPosition'>>, 'STR_TO_DATE': <function _build_str_to_date>, 'STR_TO_MAP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StrToMap'>>, 'STR_TO_TIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StrToTime'>>, 'STR_TO_UNIX': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StrToUnix'>>, 'STRING_TO_ARRAY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StringToArray'>>, 'SPLIT_BY_STRING': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StringToArray'>>, 'STRUCT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Struct'>>, 'STRUCT_EXTRACT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StructExtract'>>, 'STUFF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Stuff'>>, 'INSERT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Stuff'>>, 'SUBSTRING': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Substring'>>, 'SUM': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Sum'>>, 'TIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Time'>>, 'TIME_ADD': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeAdd'>>, 'TIME_DIFF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeDiff'>>, 'TIME_FROM_PARTS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeFromParts'>>, 'TIMEFROMPARTS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeFromParts'>>, 'TIME_STR_TO_DATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeStrToDate'>>, 'TIME_STR_TO_TIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeStrToTime'>>, 'TIME_STR_TO_UNIX': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeStrToUnix'>>, 'TIME_SUB': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeSub'>>, 'TIME_TO_STR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeToStr'>>, 'TIME_TO_TIME_STR': <function Parser.<lambda>>, 'TIME_TO_UNIX': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeToUnix'>>, 'TIME_TRUNC': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeTrunc'>>, 'TIMESTAMP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Timestamp'>>, 'TIMESTAMP_ADD': <function build_date_delta.<locals>._builder>, 'TIMESTAMPDIFF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimestampDiff'>>, 'TIMESTAMP_DIFF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimestampDiff'>>, 'TIMESTAMP_FROM_PARTS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimestampFromParts'>>, 'TIMESTAMPFROMPARTS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimestampFromParts'>>, 'TIMESTAMP_SUB': <function build_date_delta.<locals>._builder>, 'TIMESTAMP_TRUNC': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimestampTrunc'>>, 'TO_ARRAY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ToArray'>>, 'TO_BASE64': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ToBase64'>>, 'TO_CHAR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ToChar'>>, 'TO_DAYS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ToDays'>>, 'TO_MAP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ToMap'>>, 'TO_NUMBER': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ToNumber'>>, 'TRANSFORM': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Transform'>>, 'TRIM': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Trim'>>, 'TRY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Try'>>, 'TRY_CAST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TryCast'>>, 'TS_OR_DI_TO_DI': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TsOrDiToDi'>>, 'TS_OR_DS_ADD': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TsOrDsAdd'>>, 'TS_OR_DS_DIFF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TsOrDsDiff'>>, 'TS_OR_DS_TO_DATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TsOrDsToDate'>>, 'TS_OR_DS_TO_DATE_STR': <function Parser.<lambda>>, 'TS_OR_DS_TO_TIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TsOrDsToTime'>>, 'TS_OR_DS_TO_TIMESTAMP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TsOrDsToTimestamp'>>, 'UNHEX': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Unhex'>>, 'UNIX_DATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.UnixDate'>>, 'UNIX_TO_STR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.UnixToStr'>>, 'UNIX_TO_TIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.UnixToTime'>>, 'UNIX_TO_TIME_STR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.UnixToTimeStr'>>, 'UNNEST': <function Parser.<lambda>>, 'UPPER': <function build_upper>, 'UCASE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Upper'>>, 'VAR_MAP': <function build_var_map>, 'VARIANCE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Variance'>>, 'VARIANCE_SAMP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Variance'>>, 'VAR_SAMP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Variance'>>, 'VARIANCE_POP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.VariancePop'>>, 'VAR_POP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.VariancePop'>>, 'WEEK': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Week'>>, 'WEEK_OF_YEAR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.WeekOfYear'>>, 'WEEKOFYEAR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.WeekOfYear'>>, 'WHEN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.When'>>, 'X_M_L_TABLE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.XMLTable'>>, 'XOR': <function ClickHouse.Parser.<lambda>>, 'YEAR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Year'>>, 'GLOB': <function Parser.<lambda>>, 'JSON_EXTRACT_PATH_TEXT': <function build_extract_json_with_path.<locals>._builder>, 'LIKE': <function build_like>, 'LOG2': <function Parser.<lambda>>, 'LOG10': <function Parser.<lambda>>, 'LPAD': <function Parser.<lambda>>, 'LEFTPAD': <function Parser.<lambda>>, 'MOD': <function build_mod>, 'RPAD': <function Parser.<lambda>>, 'RIGHTPAD': <function Parser.<lambda>>, 'SCOPE_RESOLUTION': <function Parser.<lambda>>, 'TO_HEX': <function build_hex>, 'ANY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.AnyValue'>>, 'ARRAYSUM': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArraySum'>>, 'DATEADD': <function build_date_delta.<locals>._builder>, 'DATE_FORMAT': <function _build_date_format>, 'DATESUB': <function build_date_delta.<locals>._builder>, 'FORMATDATETIME': <function _build_date_format>, 'JSONEXTRACTSTRING': <function build_json_extract_path.<locals>._builder>, 'MATCH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RegexpLike'>>, 'RANDCANONICAL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Rand'>>, 'TUPLE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Struct'>>, 'TIMESTAMPSUB': <function build_date_delta.<locals>._builder>, 'TIMESTAMPADD': <function build_date_delta.<locals>._builder>, 'UNIQ': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ApproxDistinct'>>, 'SHA256': <function ClickHouse.Parser.<lambda>>, 'SHA512': <function ClickHouse.Parser.<lambda>>}
AGG_FUNCTIONS = {'histogram', 'groupBitmapXor', 'topKWeighted', 'quantileExactLow', 'groupBitmapAnd', 'quantileGK', 'quantilesGK', 'mannWhitneyUTest', 'studentTTest', 'sequenceCount', 'sequenceNextNode', 'exponentialMovingAverage', 'quantilesExactHigh', 'kurtSamp', 'quantileTDigest', 'exponentialTimeDecayedAvg', 'skewPop', 'sumWithOverflow', 'kolmogorovSmirnovTest', 'median', 'groupBitAnd', 'quantilesExact', 'meanZTest', 'largestTriangleThreeBuckets', 'covarPop', 'sequenceMatch', 'entropy', 'cramersVBiasCorrected', 'welchTTest', 'groupBitmap', 'simpleLinearRegression', 'quantilesTDigestWeighted', 'anyHeavy', 'anyLast', 'sparkBar', 'groupBitXor', 'sumMap', 'avg', 'quantilesInterpolatedWeighted', 'first_value', 'corr', 'quantileExactWeighted', 'maxIntersectionsPosition', 'quantileInterpolatedWeighted', 'quantilesTDigest', 'topK', 'quantilesBFloat16', 'argMin', 'maxIntersections', 'max', 'uniqTheta', 'avgWeighted', 'count', 'stochasticLogisticRegression', 'quantileDeterministic', 'uniqCombined64', 'sumCount', 'kurtPop', 'groupBitOr', 'groupArrayInsertAt', 'uniqCombined', 'argMax', 'contingency', 'quantilesExactWeighted', 'groupArray', 'quantileTDigestWeighted', 'quantileExactHigh', 'any', 'quantilesTimingWeighted', 'rankCorr', 'quantileTimingWeighted', 'quantile', 'stochasticLinearRegression', 'last_value', 'quantilesExactLow', 'groupArrayLast', 'boundingRatio', 'quantileBFloat16', 'categoricalInformationValue', 'quantilesBFloat16Weighted', 'quantileExact', 'varPop', 'quantiles', 'groupArraySample', 'deltaSum', 'min', 'stddevPop', 'quantileTiming', 'groupBitmapOr', 'skewSamp', 'uniq', 'covarSamp', 'groupUniqArray', 'quantileBFloat16Weighted', 'retention', 'minMap', 'uniqExact', 'deltaSumTimestamp', 'groupArrayMovingAvg', 'uniqUpTo', 'quantilesDeterministic', 'theilsU', 'stddevSamp', 'windowFunnel', 'groupArrayMovingSum', 'maxMap', 'quantilesTiming', 'intervalLengthSum', 'varSamp', 'sum', 'sumKahan', 'cramersV', 'uniqHLL12'}
AGG_FUNCTIONS_SUFFIXES = ['If', 'Array', 'ArrayIf', 'Map', 'SimpleState', 'State', 'Merge', 'MergeState', 'ForEach', 'Distinct', 'OrDefault', 'OrNull', 'Resample', 'ArgMin', 'ArgMax']
FUNC_TOKENS = {<TokenType.UTINYINT: 'UTINYINT'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.NAME: 'NAME'>, <TokenType.SEQUENCE: 'SEQUENCE'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.INSERT: 'INSERT'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.PRIMARY_KEY: 'PRIMARY_KEY'>, <TokenType.GLOB: 'GLOB'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.SOME: 'SOME'>, <TokenType.XOR: 'XOR'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.ILIKE: 'ILIKE'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.NESTED: 'NESTED'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.IDENTIFIER: 'IDENTIFIER'>, <TokenType.WINDOW: 'WINDOW'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.XML: 'XML'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.LEFT: 'LEFT'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.INDEX: 'INDEX'>, <TokenType.ANY: 'ANY'>, <TokenType.TDIGEST: 'TDIGEST'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.SET: 'SET'>, <TokenType.RANGE: 'RANGE'>, <TokenType.UUID: 'UUID'>, <TokenType.INT256: 'INT256'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.VAR: 'VAR'>, <TokenType.TRUNCATE: 'TRUNCATE'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.TIME: 'TIME'>, <TokenType.ENUM: 'ENUM'>, <TokenType.LIKE: 'LIKE'>, <TokenType.SUPER: 'SUPER'>, <TokenType.RIGHT: 'RIGHT'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.UINT128: 'UINT128'>, <TokenType.MAP: 'MAP'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.VECTOR: 'VECTOR'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.REPLACE: 'REPLACE'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.ALL: 'ALL'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.RLIKE: 'RLIKE'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.TEXT: 'TEXT'>, <TokenType.MONEY: 'MONEY'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.FILTER: 'FILTER'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.YEAR: 'YEAR'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.IPV6: 'IPV6'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.DATE32: 'DATE32'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.FIRST: 'FIRST'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.FORMAT: 'FORMAT'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.TABLE: 'TABLE'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.CHAR: 'CHAR'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.JSON: 'JSON'>, <TokenType.UNNEST: 'UNNEST'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.BINARY: 'BINARY'>, <TokenType.IPV4: 'IPV4'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.MERGE: 'MERGE'>, <TokenType.INET: 'INET'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.UNIQUEIDENTIFIER: 'UNIQUEIDENTIFIER'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.INT128: 'INT128'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.OFFSET: 'OFFSET'>, <TokenType.NULL: 'NULL'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.DATE: 'DATE'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.UINT256: 'UINT256'>, <TokenType.INT: 'INT'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.ROW: 'ROW'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.JSONB: 'JSONB'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.UINT: 'UINT'>, <TokenType.BIT: 'BIT'>, <TokenType.LIST: 'LIST'>, <TokenType.COMMAND: 'COMMAND'>}
RESERVED_TOKENS = {<TokenType.LT: 'LT'>, <TokenType.L_PAREN: 'L_PAREN'>, <TokenType.SLASH: 'SLASH'>, <TokenType.DASH: 'DASH'>, <TokenType.DOT: 'DOT'>, <TokenType.GT: 'GT'>, <TokenType.TILDA: 'TILDA'>, <TokenType.PLUS: 'PLUS'>, <TokenType.L_BRACE: 'L_BRACE'>, <TokenType.PIPE: 'PIPE'>, <TokenType.SEMICOLON: 'SEMICOLON'>, <TokenType.HASH: 'HASH'>, <TokenType.AMP: 'AMP'>, <TokenType.STAR: 'STAR'>, <TokenType.EQ: 'EQ'>, <TokenType.PARAMETER: 'PARAMETER'>, <TokenType.R_BRACE: 'R_BRACE'>, <TokenType.MOD: 'MOD'>, <TokenType.PLACEHOLDER: 'PLACEHOLDER'>, <TokenType.R_PAREN: 'R_PAREN'>, <TokenType.NOT: 'NOT'>, <TokenType.BACKSLASH: 'BACKSLASH'>, <TokenType.L_BRACKET: 'L_BRACKET'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.CARET: 'CARET'>, <TokenType.COLON: 'COLON'>, <TokenType.R_BRACKET: 'R_BRACKET'>, <TokenType.COMMA: 'COMMA'>}
ID_VAR_TOKENS = {<TokenType.COMMENT: 'COMMENT'>, <TokenType.RECURSIVE: 'RECURSIVE'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.DEFAULT: 'DEFAULT'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.END: 'END'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.REFERENCES: 'REFERENCES'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.NAME: 'NAME'>, <TokenType.SEQUENCE: 'SEQUENCE'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.FUNCTION: 'FUNCTION'>, <TokenType.ASC: 'ASC'>, <TokenType.OPERATOR: 'OPERATOR'>, <TokenType.OVERLAPS: 'OVERLAPS'>, <TokenType.PRAGMA: 'PRAGMA'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.SCHEMA: 'SCHEMA'>, <TokenType.PIVOT: 'PIVOT'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.OVERWRITE: 'OVERWRITE'>, <TokenType.STREAMLIT: 'STREAMLIT'>, <TokenType.ASOF: 'ASOF'>, <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.FULL: 'FULL'>, <TokenType.WAREHOUSE: 'WAREHOUSE'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.COLUMN: 'COLUMN'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.UNIQUE: 'UNIQUE'>, <TokenType.SOME: 'SOME'>, <TokenType.CONSTRAINT: 'CONSTRAINT'>, <TokenType.STRAIGHT_JOIN: 'STRAIGHT_JOIN'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.APPLY: 'APPLY'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.NESTED: 'NESTED'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.DESC: 'DESC'>, <TokenType.IDENTIFIER: 'IDENTIFIER'>, <TokenType.WINDOW: 'WINDOW'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.XML: 'XML'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.LEFT: 'LEFT'>, <TokenType.ORDINALITY: 'ORDINALITY'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.INDEX: 'INDEX'>, <TokenType.ANY: 'ANY'>, <TokenType.TDIGEST: 'TDIGEST'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.SET: 'SET'>, <TokenType.LOAD: 'LOAD'>, <TokenType.RANGE: 'RANGE'>, <TokenType.UUID: 'UUID'>, <TokenType.INT256: 'INT256'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.PROCEDURE: 'PROCEDURE'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.VAR: 'VAR'>, <TokenType.TRUNCATE: 'TRUNCATE'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.TIME: 'TIME'>, <TokenType.VOLATILE: 'VOLATILE'>, <TokenType.ENUM: 'ENUM'>, <TokenType.SUPER: 'SUPER'>, <TokenType.LIKE: 'LIKE'>, <TokenType.RIGHT: 'RIGHT'>, <TokenType.ANTI: 'ANTI'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.UINT128: 'UINT128'>, <TokenType.MAP: 'MAP'>, <TokenType.EXECUTE: 'EXECUTE'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.TRUE: 'TRUE'>, <TokenType.ESCAPE: 'ESCAPE'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.VECTOR: 'VECTOR'>, <TokenType.DELETE: 'DELETE'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.COPY: 'COPY'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.SEMI: 'SEMI'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.FALSE: 'FALSE'>, <TokenType.REPLACE: 'REPLACE'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.USE: 'USE'>, <TokenType.TOP: 'TOP'>, <TokenType.DICTIONARY: 'DICTIONARY'>, <TokenType.BEGIN: 'BEGIN'>, <TokenType.ALL: 'ALL'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.TAG: 'TAG'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.UPDATE: 'UPDATE'>, <TokenType.TEXT: 'TEXT'>, <TokenType.MONEY: 'MONEY'>, <TokenType.CUBE: 'CUBE'>, <TokenType.KILL: 'KILL'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.FILTER: 'FILTER'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.YEAR: 'YEAR'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.IPV6: 'IPV6'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.DATE32: 'DATE32'>, <TokenType.FINAL: 'FINAL'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.FIRST: 'FIRST'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.FORMAT: 'FORMAT'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.RENAME: 'RENAME'>, <TokenType.DIV: 'DIV'>, <TokenType.TABLE: 'TABLE'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.CHAR: 'CHAR'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.JSON: 'JSON'>, <TokenType.UNNEST: 'UNNEST'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.VIEW: 'VIEW'>, <TokenType.SHOW: 'SHOW'>, <TokenType.REFRESH: 'REFRESH'>, <TokenType.SETTINGS: 'SETTINGS'>, <TokenType.STORAGE_INTEGRATION: 'STORAGE_INTEGRATION'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.NATURAL: 'NATURAL'>, <TokenType.BINARY: 'BINARY'>, <TokenType.IPV4: 'IPV4'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.MERGE: 'MERGE'>, <TokenType.CASE: 'CASE'>, <TokenType.CACHE: 'CACHE'>, <TokenType.PERCENT: 'PERCENT'>, <TokenType.INET: 'INET'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.UNIQUEIDENTIFIER: 'UNIQUEIDENTIFIER'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.INT128: 'INT128'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.IS: 'IS'>, <TokenType.ROWS: 'ROWS'>, <TokenType.KEEP: 'KEEP'>, <TokenType.OFFSET: 'OFFSET'>, <TokenType.PARTITION: 'PARTITION'>, <TokenType.DESCRIBE: 'DESCRIBE'>, <TokenType.NULL: 'NULL'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.DATE: 'DATE'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.UNPIVOT: 'UNPIVOT'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.UINT256: 'UINT256'>, <TokenType.COMMIT: 'COMMIT'>, <TokenType.INT: 'INT'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.ROLLUP: 'ROLLUP'>, <TokenType.ROW: 'ROW'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.JSONB: 'JSONB'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.MODEL: 'MODEL'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.TEMPORARY: 'TEMPORARY'>, <TokenType.NEXT: 'NEXT'>, <TokenType.UINT: 'UINT'>, <TokenType.BIT: 'BIT'>, <TokenType.DATABASE: 'DATABASE'>, <TokenType.LIST: 'LIST'>, <TokenType.COMMAND: 'COMMAND'>}
AGG_FUNC_MAPPING = {'histogramIf': ('histogram', 'If'), 'groupBitmapXorIf': ('groupBitmapXor', 'If'), 'topKWeightedIf': ('topKWeighted', 'If'), 'quantileExactLowIf': ('quantileExactLow', 'If'), 'groupBitmapAndIf': ('groupBitmapAnd', 'If'), 'quantileGKIf': ('quantileGK', 'If'), 'quantilesGKIf': ('quantilesGK', 'If'), 'mannWhitneyUTestIf': ('mannWhitneyUTest', 'If'), 'studentTTestIf': ('studentTTest', 'If'), 'sequenceCountIf': ('sequenceCount', 'If'), 'sequenceNextNodeIf': ('sequenceNextNode', 'If'), 'exponentialMovingAverageIf': ('exponentialMovingAverage', 'If'), 'quantilesExactHighIf': ('quantilesExactHigh', 'If'), 'kurtSampIf': ('kurtSamp', 'If'), 'quantileTDigestIf': ('quantileTDigest', 'If'), 'exponentialTimeDecayedAvgIf': ('exponentialTimeDecayedAvg', 'If'), 'skewPopIf': ('skewPop', 'If'), 'sumWithOverflowIf': ('sumWithOverflow', 'If'), 'kolmogorovSmirnovTestIf': ('kolmogorovSmirnovTest', 'If'), 'medianIf': ('median', 'If'), 'groupBitAndIf': ('groupBitAnd', 'If'), 'quantilesExactIf': ('quantilesExact', 'If'), 'meanZTestIf': ('meanZTest', 'If'), 'largestTriangleThreeBucketsIf': ('largestTriangleThreeBuckets', 'If'), 'covarPopIf': ('covarPop', 'If'), 'sequenceMatchIf': ('sequenceMatch', 'If'), 'entropyIf': ('entropy', 'If'), 'cramersVBiasCorrectedIf': ('cramersVBiasCorrected', 'If'), 'welchTTestIf': ('welchTTest', 'If'), 'groupBitmapIf': ('groupBitmap', 'If'), 'simpleLinearRegressionIf': ('simpleLinearRegression', 'If'), 'quantilesTDigestWeightedIf': ('quantilesTDigestWeighted', 'If'), 'anyHeavyIf': ('anyHeavy', 'If'), 'anyLastIf': ('anyLast', 'If'), 'sparkBarIf': ('sparkBar', 'If'), 'groupBitXorIf': ('groupBitXor', 'If'), 'sumMapIf': ('sumMap', 'If'), 'avgIf': ('avg', 'If'), 'quantilesInterpolatedWeightedIf': ('quantilesInterpolatedWeighted', 'If'), 'first_valueIf': ('first_value', 'If'), 'corrIf': ('corr', 'If'), 'quantileExactWeightedIf': ('quantileExactWeighted', 'If'), 'maxIntersectionsPositionIf': ('maxIntersectionsPosition', 'If'), 'quantileInterpolatedWeightedIf': ('quantileInterpolatedWeighted', 'If'), 'quantilesTDigestIf': ('quantilesTDigest', 'If'), 'topKIf': ('topK', 'If'), 'quantilesBFloat16If': ('quantilesBFloat16', 'If'), 'argMinIf': ('argMin', 'If'), 'maxIntersectionsIf': ('maxIntersections', 'If'), 'maxIf': ('max', 'If'), 'uniqThetaIf': ('uniqTheta', 'If'), 'avgWeightedIf': ('avgWeighted', 'If'), 'countIf': ('count', 'If'), 'stochasticLogisticRegressionIf': ('stochasticLogisticRegression', 'If'), 'quantileDeterministicIf': ('quantileDeterministic', 'If'), 'uniqCombined64If': ('uniqCombined64', 'If'), 'sumCountIf': ('sumCount', 'If'), 'kurtPopIf': ('kurtPop', 'If'), 'groupBitOrIf': ('groupBitOr', 'If'), 'groupArrayInsertAtIf': ('groupArrayInsertAt', 'If'), 'uniqCombinedIf': ('uniqCombined', 'If'), 'argMaxIf': ('argMax', 'If'), 'contingencyIf': ('contingency', 'If'), 'quantilesExactWeightedIf': ('quantilesExactWeighted', 'If'), 'groupArrayIf': ('groupArray', 'If'), 'quantileTDigestWeightedIf': ('quantileTDigestWeighted', 'If'), 'quantileExactHighIf': ('quantileExactHigh', 'If'), 'anyIf': ('any', 'If'), 'quantilesTimingWeightedIf': ('quantilesTimingWeighted', 'If'), 'rankCorrIf': ('rankCorr', 'If'), 'quantileTimingWeightedIf': ('quantileTimingWeighted', 'If'), 'quantileIf': ('quantile', 'If'), 'stochasticLinearRegressionIf': ('stochasticLinearRegression', 'If'), 'last_valueIf': ('last_value', 'If'), 'quantilesExactLowIf': ('quantilesExactLow', 'If'), 'groupArrayLastIf': ('groupArrayLast', 'If'), 'boundingRatioIf': ('boundingRatio', 'If'), 'quantileBFloat16If': ('quantileBFloat16', 'If'), 'categoricalInformationValueIf': ('categoricalInformationValue', 'If'), 'quantilesBFloat16WeightedIf': ('quantilesBFloat16Weighted', 'If'), 'quantileExactIf': ('quantileExact', 'If'), 'varPopIf': ('varPop', 'If'), 'quantilesIf': ('quantiles', 'If'), 'groupArraySampleIf': ('groupArraySample', 'If'), 'deltaSumIf': ('deltaSum', 'If'), 'minIf': ('min', 'If'), 'stddevPopIf': ('stddevPop', 'If'), 'quantileTimingIf': ('quantileTiming', 'If'), 'groupBitmapOrIf': ('groupBitmapOr', 'If'), 'skewSampIf': ('skewSamp', 'If'), 'uniqIf': ('uniq', 'If'), 'covarSampIf': ('covarSamp', 'If'), 'groupUniqArrayIf': ('groupUniqArray', 'If'), 'quantileBFloat16WeightedIf': ('quantileBFloat16Weighted', 'If'), 'retentionIf': ('retention', 'If'), 'minMapIf': ('minMap', 'If'), 'uniqExactIf': ('uniqExact', 'If'), 'deltaSumTimestampIf': ('deltaSumTimestamp', 'If'), 'groupArrayMovingAvgIf': ('groupArrayMovingAvg', 'If'), 'uniqUpToIf': ('uniqUpTo', 'If'), 'quantilesDeterministicIf': ('quantilesDeterministic', 'If'), 'theilsUIf': ('theilsU', 'If'), 'stddevSampIf': ('stddevSamp', 'If'), 'windowFunnelIf': ('windowFunnel', 'If'), 'groupArrayMovingSumIf': ('groupArrayMovingSum', 'If'), 'maxMapIf': ('maxMap', 'If'), 'quantilesTimingIf': ('quantilesTiming', 'If'), 'intervalLengthSumIf': ('intervalLengthSum', 'If'), 'varSampIf': ('varSamp', 'If'), 'sumIf': ('sum', 'If'), 'sumKahanIf': ('sumKahan', 'If'), 'cramersVIf': ('cramersV', 'If'), 'uniqHLL12If': ('uniqHLL12', 'If'), 'histogramArray': ('histogram', 'Array'), 'groupBitmapXorArray': ('groupBitmapXor', 'Array'), 'topKWeightedArray': ('topKWeighted', 'Array'), 'quantileExactLowArray': ('quantileExactLow', 'Array'), 'groupBitmapAndArray': ('groupBitmapAnd', 'Array'), 'quantileGKArray': ('quantileGK', 'Array'), 'quantilesGKArray': ('quantilesGK', 'Array'), 'mannWhitneyUTestArray': ('mannWhitneyUTest', 'Array'), 'studentTTestArray': ('studentTTest', 'Array'), 'sequenceCountArray': ('sequenceCount', 'Array'), 'sequenceNextNodeArray': ('sequenceNextNode', 'Array'), 'exponentialMovingAverageArray': ('exponentialMovingAverage', 'Array'), 'quantilesExactHighArray': ('quantilesExactHigh', 'Array'), 'kurtSampArray': ('kurtSamp', 'Array'), 'quantileTDigestArray': ('quantileTDigest', 'Array'), 'exponentialTimeDecayedAvgArray': ('exponentialTimeDecayedAvg', 'Array'), 'skewPopArray': ('skewPop', 'Array'), 'sumWithOverflowArray': ('sumWithOverflow', 'Array'), 'kolmogorovSmirnovTestArray': ('kolmogorovSmirnovTest', 'Array'), 'medianArray': ('median', 'Array'), 'groupBitAndArray': ('groupBitAnd', 'Array'), 'quantilesExactArray': ('quantilesExact', 'Array'), 'meanZTestArray': ('meanZTest', 'Array'), 'largestTriangleThreeBucketsArray': ('largestTriangleThreeBuckets', 'Array'), 'covarPopArray': ('covarPop', 'Array'), 'sequenceMatchArray': ('sequenceMatch', 'Array'), 'entropyArray': ('entropy', 'Array'), 'cramersVBiasCorrectedArray': ('cramersVBiasCorrected', 'Array'), 'welchTTestArray': ('welchTTest', 'Array'), 'groupBitmapArray': ('groupBitmap', 'Array'), 'simpleLinearRegressionArray': ('simpleLinearRegression', 'Array'), 'quantilesTDigestWeightedArray': ('quantilesTDigestWeighted', 'Array'), 'anyHeavyArray': ('anyHeavy', 'Array'), 'anyLastArray': ('anyLast', 'Array'), 'sparkBarArray': ('sparkBar', 'Array'), 'groupBitXorArray': ('groupBitXor', 'Array'), 'sumMapArray': ('sumMap', 'Array'), 'avgArray': ('avg', 'Array'), 'quantilesInterpolatedWeightedArray': ('quantilesInterpolatedWeighted', 'Array'), 'first_valueArray': ('first_value', 'Array'), 'corrArray': ('corr', 'Array'), 'quantileExactWeightedArray': ('quantileExactWeighted', 'Array'), 'maxIntersectionsPositionArray': ('maxIntersectionsPosition', 'Array'), 'quantileInterpolatedWeightedArray': ('quantileInterpolatedWeighted', 'Array'), 'quantilesTDigestArray': ('quantilesTDigest', 'Array'), 'topKArray': ('topK', 'Array'), 'quantilesBFloat16Array': ('quantilesBFloat16', 'Array'), 'argMinArray': ('argMin', 'Array'), 'maxIntersectionsArray': ('maxIntersections', 'Array'), 'maxArray': ('max', 'Array'), 'uniqThetaArray': ('uniqTheta', 'Array'), 'avgWeightedArray': ('avgWeighted', 'Array'), 'countArray': ('count', 'Array'), 'stochasticLogisticRegressionArray': ('stochasticLogisticRegression', 'Array'), 'quantileDeterministicArray': ('quantileDeterministic', 'Array'), 'uniqCombined64Array': ('uniqCombined64', 'Array'), 'sumCountArray': ('sumCount', 'Array'), 'kurtPopArray': ('kurtPop', 'Array'), 'groupBitOrArray': ('groupBitOr', 'Array'), 'groupArrayInsertAtArray': ('groupArrayInsertAt', 'Array'), 'uniqCombinedArray': ('uniqCombined', 'Array'), 'argMaxArray': ('argMax', 'Array'), 'contingencyArray': ('contingency', 'Array'), 'quantilesExactWeightedArray': ('quantilesExactWeighted', 'Array'), 'groupArrayArray': ('groupArray', 'Array'), 'quantileTDigestWeightedArray': ('quantileTDigestWeighted', 'Array'), 'quantileExactHighArray': ('quantileExactHigh', 'Array'), 'anyArray': ('any', 'Array'), 'quantilesTimingWeightedArray': ('quantilesTimingWeighted', 'Array'), 'rankCorrArray': ('rankCorr', 'Array'), 'quantileTimingWeightedArray': ('quantileTimingWeighted', 'Array'), 'quantileArray': ('quantile', 'Array'), 'stochasticLinearRegressionArray': ('stochasticLinearRegression', 'Array'), 'last_valueArray': ('last_value', 'Array'), 'quantilesExactLowArray': ('quantilesExactLow', 'Array'), 'groupArrayLastArray': ('groupArrayLast', 'Array'), 'boundingRatioArray': ('boundingRatio', 'Array'), 'quantileBFloat16Array': ('quantileBFloat16', 'Array'), 'categoricalInformationValueArray': ('categoricalInformationValue', 'Array'), 'quantilesBFloat16WeightedArray': ('quantilesBFloat16Weighted', 'Array'), 'quantileExactArray': ('quantileExact', 'Array'), 'varPopArray': ('varPop', 'Array'), 'quantilesArray': ('quantiles', 'Array'), 'groupArraySampleArray': ('groupArraySample', 'Array'), 'deltaSumArray': ('deltaSum', 'Array'), 'minArray': ('min', 'Array'), 'stddevPopArray': ('stddevPop', 'Array'), 'quantileTimingArray': ('quantileTiming', 'Array'), 'groupBitmapOrArray': ('groupBitmapOr', 'Array'), 'skewSampArray': ('skewSamp', 'Array'), 'uniqArray': ('uniq', 'Array'), 'covarSampArray': ('covarSamp', 'Array'), 'groupUniqArrayArray': ('groupUniqArray', 'Array'), 'quantileBFloat16WeightedArray': ('quantileBFloat16Weighted', 'Array'), 'retentionArray': ('retention', 'Array'), 'minMapArray': ('minMap', 'Array'), 'uniqExactArray': ('uniqExact', 'Array'), 'deltaSumTimestampArray': ('deltaSumTimestamp', 'Array'), 'groupArrayMovingAvgArray': ('groupArrayMovingAvg', 'Array'), 'uniqUpToArray': ('uniqUpTo', 'Array'), 'quantilesDeterministicArray': ('quantilesDeterministic', 'Array'), 'theilsUArray': ('theilsU', 'Array'), 'stddevSampArray': ('stddevSamp', 'Array'), 'windowFunnelArray': ('windowFunnel', 'Array'), 'groupArrayMovingSumArray': ('groupArrayMovingSum', 'Array'), 'maxMapArray': ('maxMap', 'Array'), 'quantilesTimingArray': ('quantilesTiming', 'Array'), 'intervalLengthSumArray': ('intervalLengthSum', 'Array'), 'varSampArray': ('varSamp', 'Array'), 'sumArray': ('sum', 'Array'), 'sumKahanArray': ('sumKahan', 'Array'), 'cramersVArray': ('cramersV', 'Array'), 'uniqHLL12Array': ('uniqHLL12', 'Array'), 'histogramArrayIf': ('histogram', 'ArrayIf'), 'groupBitmapXorArrayIf': ('groupBitmapXor', 'ArrayIf'), 'topKWeightedArrayIf': ('topKWeighted', 'ArrayIf'), 'quantileExactLowArrayIf': ('quantileExactLow', 'ArrayIf'), 'groupBitmapAndArrayIf': ('groupBitmapAnd', 'ArrayIf'), 'quantileGKArrayIf': ('quantileGK', 'ArrayIf'), 'quantilesGKArrayIf': ('quantilesGK', 'ArrayIf'), 'mannWhitneyUTestArrayIf': ('mannWhitneyUTest', 'ArrayIf'), 'studentTTestArrayIf': ('studentTTest', 'ArrayIf'), 'sequenceCountArrayIf': ('sequenceCount', 'ArrayIf'), 'sequenceNextNodeArrayIf': ('sequenceNextNode', 'ArrayIf'), 'exponentialMovingAverageArrayIf': ('exponentialMovingAverage', 'ArrayIf'), 'quantilesExactHighArrayIf': ('quantilesExactHigh', 'ArrayIf'), 'kurtSampArrayIf': ('kurtSamp', 'ArrayIf'), 'quantileTDigestArrayIf': ('quantileTDigest', 'ArrayIf'), 'exponentialTimeDecayedAvgArrayIf': ('exponentialTimeDecayedAvg', 'ArrayIf'), 'skewPopArrayIf': ('skewPop', 'ArrayIf'), 'sumWithOverflowArrayIf': ('sumWithOverflow', 'ArrayIf'), 'kolmogorovSmirnovTestArrayIf': ('kolmogorovSmirnovTest', 'ArrayIf'), 'medianArrayIf': ('median', 'ArrayIf'), 'groupBitAndArrayIf': ('groupBitAnd', 'ArrayIf'), 'quantilesExactArrayIf': ('quantilesExact', 'ArrayIf'), 'meanZTestArrayIf': ('meanZTest', 'ArrayIf'), 'largestTriangleThreeBucketsArrayIf': ('largestTriangleThreeBuckets', 'ArrayIf'), 'covarPopArrayIf': ('covarPop', 'ArrayIf'), 'sequenceMatchArrayIf': ('sequenceMatch', 'ArrayIf'), 'entropyArrayIf': ('entropy', 'ArrayIf'), 'cramersVBiasCorrectedArrayIf': ('cramersVBiasCorrected', 'ArrayIf'), 'welchTTestArrayIf': ('welchTTest', 'ArrayIf'), 'groupBitmapArrayIf': ('groupBitmap', 'ArrayIf'), 'simpleLinearRegressionArrayIf': ('simpleLinearRegression', 'ArrayIf'), 'quantilesTDigestWeightedArrayIf': ('quantilesTDigestWeighted', 'ArrayIf'), 'anyHeavyArrayIf': ('anyHeavy', 'ArrayIf'), 'anyLastArrayIf': ('anyLast', 'ArrayIf'), 'sparkBarArrayIf': ('sparkBar', 'ArrayIf'), 'groupBitXorArrayIf': ('groupBitXor', 'ArrayIf'), 'sumMapArrayIf': ('sumMap', 'ArrayIf'), 'avgArrayIf': ('avg', 'ArrayIf'), 'quantilesInterpolatedWeightedArrayIf': ('quantilesInterpolatedWeighted', 'ArrayIf'), 'first_valueArrayIf': ('first_value', 'ArrayIf'), 'corrArrayIf': ('corr', 'ArrayIf'), 'quantileExactWeightedArrayIf': ('quantileExactWeighted', 'ArrayIf'), 'maxIntersectionsPositionArrayIf': ('maxIntersectionsPosition', 'ArrayIf'), 'quantileInterpolatedWeightedArrayIf': ('quantileInterpolatedWeighted', 'ArrayIf'), 'quantilesTDigestArrayIf': ('quantilesTDigest', 'ArrayIf'), 'topKArrayIf': ('topK', 'ArrayIf'), 'quantilesBFloat16ArrayIf': ('quantilesBFloat16', 'ArrayIf'), 'argMinArrayIf': ('argMin', 'ArrayIf'), 'maxIntersectionsArrayIf': ('maxIntersections', 'ArrayIf'), 'maxArrayIf': ('max', 'ArrayIf'), 'uniqThetaArrayIf': ('uniqTheta', 'ArrayIf'), 'avgWeightedArrayIf': ('avgWeighted', 'ArrayIf'), 'countArrayIf': ('count', 'ArrayIf'), 'stochasticLogisticRegressionArrayIf': ('stochasticLogisticRegression', 'ArrayIf'), 'quantileDeterministicArrayIf': ('quantileDeterministic', 'ArrayIf'), 'uniqCombined64ArrayIf': ('uniqCombined64', 'ArrayIf'), 'sumCountArrayIf': ('sumCount', 'ArrayIf'), 'kurtPopArrayIf': ('kurtPop', 'ArrayIf'), 'groupBitOrArrayIf': ('groupBitOr', 'ArrayIf'), 'groupArrayInsertAtArrayIf': ('groupArrayInsertAt', 'ArrayIf'), 'uniqCombinedArrayIf': ('uniqCombined', 'ArrayIf'), 'argMaxArrayIf': ('argMax', 'ArrayIf'), 'contingencyArrayIf': ('contingency', 'ArrayIf'), 'quantilesExactWeightedArrayIf': ('quantilesExactWeighted', 'ArrayIf'), 'groupArrayArrayIf': ('groupArray', 'ArrayIf'), 'quantileTDigestWeightedArrayIf': ('quantileTDigestWeighted', 'ArrayIf'), 'quantileExactHighArrayIf': ('quantileExactHigh', 'ArrayIf'), 'anyArrayIf': ('any', 'ArrayIf'), 'quantilesTimingWeightedArrayIf': ('quantilesTimingWeighted', 'ArrayIf'), 'rankCorrArrayIf': ('rankCorr', 'ArrayIf'), 'quantileTimingWeightedArrayIf': ('quantileTimingWeighted', 'ArrayIf'), 'quantileArrayIf': ('quantile', 'ArrayIf'), 'stochasticLinearRegressionArrayIf': ('stochasticLinearRegression', 'ArrayIf'), 'last_valueArrayIf': ('last_value', 'ArrayIf'), 'quantilesExactLowArrayIf': ('quantilesExactLow', 'ArrayIf'), 'groupArrayLastArrayIf': ('groupArrayLast', 'ArrayIf'), 'boundingRatioArrayIf': ('boundingRatio', 'ArrayIf'), 'quantileBFloat16ArrayIf': ('quantileBFloat16', 'ArrayIf'), 'categoricalInformationValueArrayIf': ('categoricalInformationValue', 'ArrayIf'), 'quantilesBFloat16WeightedArrayIf': ('quantilesBFloat16Weighted', 'ArrayIf'), 'quantileExactArrayIf': ('quantileExact', 'ArrayIf'), 'varPopArrayIf': ('varPop', 'ArrayIf'), 'quantilesArrayIf': ('quantiles', 'ArrayIf'), 'groupArraySampleArrayIf': ('groupArraySample', 'ArrayIf'), 'deltaSumArrayIf': ('deltaSum', 'ArrayIf'), 'minArrayIf': ('min', 'ArrayIf'), 'stddevPopArrayIf': ('stddevPop', 'ArrayIf'), 'quantileTimingArrayIf': ('quantileTiming', 'ArrayIf'), 'groupBitmapOrArrayIf': ('groupBitmapOr', 'ArrayIf'), 'skewSampArrayIf': ('skewSamp', 'ArrayIf'), 'uniqArrayIf': ('uniq', 'ArrayIf'), 'covarSampArrayIf': ('covarSamp', 'ArrayIf'), 'groupUniqArrayArrayIf': ('groupUniqArray', 'ArrayIf'), 'quantileBFloat16WeightedArrayIf': ('quantileBFloat16Weighted', 'ArrayIf'), 'retentionArrayIf': ('retention', 'ArrayIf'), 'minMapArrayIf': ('minMap', 'ArrayIf'), 'uniqExactArrayIf': ('uniqExact', 'ArrayIf'), 'deltaSumTimestampArrayIf': ('deltaSumTimestamp', 'ArrayIf'), 'groupArrayMovingAvgArrayIf': ('groupArrayMovingAvg', 'ArrayIf'), 'uniqUpToArrayIf': ('uniqUpTo', 'ArrayIf'), 'quantilesDeterministicArrayIf': ('quantilesDeterministic', 'ArrayIf'), 'theilsUArrayIf': ('theilsU', 'ArrayIf'), 'stddevSampArrayIf': ('stddevSamp', 'ArrayIf'), 'windowFunnelArrayIf': ('windowFunnel', 'ArrayIf'), 'groupArrayMovingSumArrayIf': ('groupArrayMovingSum', 'ArrayIf'), 'maxMapArrayIf': ('maxMap', 'ArrayIf'), 'quantilesTimingArrayIf': ('quantilesTiming', 'ArrayIf'), 'intervalLengthSumArrayIf': ('intervalLengthSum', 'ArrayIf'), 'varSampArrayIf': ('varSamp', 'ArrayIf'), 'sumArrayIf': ('sum', 'ArrayIf'), 'sumKahanArrayIf': ('sumKahan', 'ArrayIf'), 'cramersVArrayIf': ('cramersV', 'ArrayIf'), 'uniqHLL12ArrayIf': ('uniqHLL12', 'ArrayIf'), 'histogramMap': ('histogram', 'Map'), 'groupBitmapXorMap': ('groupBitmapXor', 'Map'), 'topKWeightedMap': ('topKWeighted', 'Map'), 'quantileExactLowMap': ('quantileExactLow', 'Map'), 'groupBitmapAndMap': ('groupBitmapAnd', 'Map'), 'quantileGKMap': ('quantileGK', 'Map'), 'quantilesGKMap': ('quantilesGK', 'Map'), 'mannWhitneyUTestMap': ('mannWhitneyUTest', 'Map'), 'studentTTestMap': ('studentTTest', 'Map'), 'sequenceCountMap': ('sequenceCount', 'Map'), 'sequenceNextNodeMap': ('sequenceNextNode', 'Map'), 'exponentialMovingAverageMap': ('exponentialMovingAverage', 'Map'), 'quantilesExactHighMap': ('quantilesExactHigh', 'Map'), 'kurtSampMap': ('kurtSamp', 'Map'), 'quantileTDigestMap': ('quantileTDigest', 'Map'), 'exponentialTimeDecayedAvgMap': ('exponentialTimeDecayedAvg', 'Map'), 'skewPopMap': ('skewPop', 'Map'), 'sumWithOverflowMap': ('sumWithOverflow', 'Map'), 'kolmogorovSmirnovTestMap': ('kolmogorovSmirnovTest', 'Map'), 'medianMap': ('median', 'Map'), 'groupBitAndMap': ('groupBitAnd', 'Map'), 'quantilesExactMap': ('quantilesExact', 'Map'), 'meanZTestMap': ('meanZTest', 'Map'), 'largestTriangleThreeBucketsMap': ('largestTriangleThreeBuckets', 'Map'), 'covarPopMap': ('covarPop', 'Map'), 'sequenceMatchMap': ('sequenceMatch', 'Map'), 'entropyMap': ('entropy', 'Map'), 'cramersVBiasCorrectedMap': ('cramersVBiasCorrected', 'Map'), 'welchTTestMap': ('welchTTest', 'Map'), 'groupBitmapMap': ('groupBitmap', 'Map'), 'simpleLinearRegressionMap': ('simpleLinearRegression', 'Map'), 'quantilesTDigestWeightedMap': ('quantilesTDigestWeighted', 'Map'), 'anyHeavyMap': ('anyHeavy', 'Map'), 'anyLastMap': ('anyLast', 'Map'), 'sparkBarMap': ('sparkBar', 'Map'), 'groupBitXorMap': ('groupBitXor', 'Map'), 'sumMapMap': ('sumMap', 'Map'), 'avgMap': ('avg', 'Map'), 'quantilesInterpolatedWeightedMap': ('quantilesInterpolatedWeighted', 'Map'), 'first_valueMap': ('first_value', 'Map'), 'corrMap': ('corr', 'Map'), 'quantileExactWeightedMap': ('quantileExactWeighted', 'Map'), 'maxIntersectionsPositionMap': ('maxIntersectionsPosition', 'Map'), 'quantileInterpolatedWeightedMap': ('quantileInterpolatedWeighted', 'Map'), 'quantilesTDigestMap': ('quantilesTDigest', 'Map'), 'topKMap': ('topK', 'Map'), 'quantilesBFloat16Map': ('quantilesBFloat16', 'Map'), 'argMinMap': ('argMin', 'Map'), 'maxIntersectionsMap': ('maxIntersections', 'Map'), 'maxMap': ('maxMap', ''), 'uniqThetaMap': ('uniqTheta', 'Map'), 'avgWeightedMap': ('avgWeighted', 'Map'), 'countMap': ('count', 'Map'), 'stochasticLogisticRegressionMap': ('stochasticLogisticRegression', 'Map'), 'quantileDeterministicMap': ('quantileDeterministic', 'Map'), 'uniqCombined64Map': ('uniqCombined64', 'Map'), 'sumCountMap': ('sumCount', 'Map'), 'kurtPopMap': ('kurtPop', 'Map'), 'groupBitOrMap': ('groupBitOr', 'Map'), 'groupArrayInsertAtMap': ('groupArrayInsertAt', 'Map'), 'uniqCombinedMap': ('uniqCombined', 'Map'), 'argMaxMap': ('argMax', 'Map'), 'contingencyMap': ('contingency', 'Map'), 'quantilesExactWeightedMap': ('quantilesExactWeighted', 'Map'), 'groupArrayMap': ('groupArray', 'Map'), 'quantileTDigestWeightedMap': ('quantileTDigestWeighted', 'Map'), 'quantileExactHighMap': ('quantileExactHigh', 'Map'), 'anyMap': ('any', 'Map'), 'quantilesTimingWeightedMap': ('quantilesTimingWeighted', 'Map'), 'rankCorrMap': ('rankCorr', 'Map'), 'quantileTimingWeightedMap': ('quantileTimingWeighted', 'Map'), 'quantileMap': ('quantile', 'Map'), 'stochasticLinearRegressionMap': ('stochasticLinearRegression', 'Map'), 'last_valueMap': ('last_value', 'Map'), 'quantilesExactLowMap': ('quantilesExactLow', 'Map'), 'groupArrayLastMap': ('groupArrayLast', 'Map'), 'boundingRatioMap': ('boundingRatio', 'Map'), 'quantileBFloat16Map': ('quantileBFloat16', 'Map'), 'categoricalInformationValueMap': ('categoricalInformationValue', 'Map'), 'quantilesBFloat16WeightedMap': ('quantilesBFloat16Weighted', 'Map'), 'quantileExactMap': ('quantileExact', 'Map'), 'varPopMap': ('varPop', 'Map'), 'quantilesMap': ('quantiles', 'Map'), 'groupArraySampleMap': ('groupArraySample', 'Map'), 'deltaSumMap': ('deltaSum', 'Map'), 'minMap': ('minMap', ''), 'stddevPopMap': ('stddevPop', 'Map'), 'quantileTimingMap': ('quantileTiming', 'Map'), 'groupBitmapOrMap': ('groupBitmapOr', 'Map'), 'skewSampMap': ('skewSamp', 'Map'), 'uniqMap': ('uniq', 'Map'), 'covarSampMap': ('covarSamp', 'Map'), 'groupUniqArrayMap': ('groupUniqArray', 'Map'), 'quantileBFloat16WeightedMap': ('quantileBFloat16Weighted', 'Map'), 'retentionMap': ('retention', 'Map'), 'minMapMap': ('minMap', 'Map'), 'uniqExactMap': ('uniqExact', 'Map'), 'deltaSumTimestampMap': ('deltaSumTimestamp', 'Map'), 'groupArrayMovingAvgMap': ('groupArrayMovingAvg', 'Map'), 'uniqUpToMap': ('uniqUpTo', 'Map'), 'quantilesDeterministicMap': ('quantilesDeterministic', 'Map'), 'theilsUMap': ('theilsU', 'Map'), 'stddevSampMap': ('stddevSamp', 'Map'), 'windowFunnelMap': ('windowFunnel', 'Map'), 'groupArrayMovingSumMap': ('groupArrayMovingSum', 'Map'), 'maxMapMap': ('maxMap', 'Map'), 'quantilesTimingMap': ('quantilesTiming', 'Map'), 'intervalLengthSumMap': ('intervalLengthSum', 'Map'), 'varSampMap': ('varSamp', 'Map'), 'sumMap': ('sumMap', ''), 'sumKahanMap': ('sumKahan', 'Map'), 'cramersVMap': ('cramersV', 'Map'), 'uniqHLL12Map': ('uniqHLL12', 'Map'), 'histogramSimpleState': ('histogram', 'SimpleState'), 'groupBitmapXorSimpleState': ('groupBitmapXor', 'SimpleState'), 'topKWeightedSimpleState': ('topKWeighted', 'SimpleState'), 'quantileExactLowSimpleState': ('quantileExactLow', 'SimpleState'), 'groupBitmapAndSimpleState': ('groupBitmapAnd', 'SimpleState'), 'quantileGKSimpleState': ('quantileGK', 'SimpleState'), 'quantilesGKSimpleState': ('quantilesGK', 'SimpleState'), 'mannWhitneyUTestSimpleState': ('mannWhitneyUTest', 'SimpleState'), 'studentTTestSimpleState': ('studentTTest', 'SimpleState'), 'sequenceCountSimpleState': ('sequenceCount', 'SimpleState'), 'sequenceNextNodeSimpleState': ('sequenceNextNode', 'SimpleState'), 'exponentialMovingAverageSimpleState': ('exponentialMovingAverage', 'SimpleState'), 'quantilesExactHighSimpleState': ('quantilesExactHigh', 'SimpleState'), 'kurtSampSimpleState': ('kurtSamp', 'SimpleState'), 'quantileTDigestSimpleState': ('quantileTDigest', 'SimpleState'), 'exponentialTimeDecayedAvgSimpleState': ('exponentialTimeDecayedAvg', 'SimpleState'), 'skewPopSimpleState': ('skewPop', 'SimpleState'), 'sumWithOverflowSimpleState': ('sumWithOverflow', 'SimpleState'), 'kolmogorovSmirnovTestSimpleState': ('kolmogorovSmirnovTest', 'SimpleState'), 'medianSimpleState': ('median', 'SimpleState'), 'groupBitAndSimpleState': ('groupBitAnd', 'SimpleState'), 'quantilesExactSimpleState': ('quantilesExact', 'SimpleState'), 'meanZTestSimpleState': ('meanZTest', 'SimpleState'), 'largestTriangleThreeBucketsSimpleState': ('largestTriangleThreeBuckets', 'SimpleState'), 'covarPopSimpleState': ('covarPop', 'SimpleState'), 'sequenceMatchSimpleState': ('sequenceMatch', 'SimpleState'), 'entropySimpleState': ('entropy', 'SimpleState'), 'cramersVBiasCorrectedSimpleState': ('cramersVBiasCorrected', 'SimpleState'), 'welchTTestSimpleState': ('welchTTest', 'SimpleState'), 'groupBitmapSimpleState': ('groupBitmap', 'SimpleState'), 'simpleLinearRegressionSimpleState': ('simpleLinearRegression', 'SimpleState'), 'quantilesTDigestWeightedSimpleState': ('quantilesTDigestWeighted', 'SimpleState'), 'anyHeavySimpleState': ('anyHeavy', 'SimpleState'), 'anyLastSimpleState': ('anyLast', 'SimpleState'), 'sparkBarSimpleState': ('sparkBar', 'SimpleState'), 'groupBitXorSimpleState': ('groupBitXor', 'SimpleState'), 'sumMapSimpleState': ('sumMap', 'SimpleState'), 'avgSimpleState': ('avg', 'SimpleState'), 'quantilesInterpolatedWeightedSimpleState': ('quantilesInterpolatedWeighted', 'SimpleState'), 'first_valueSimpleState': ('first_value', 'SimpleState'), 'corrSimpleState': ('corr', 'SimpleState'), 'quantileExactWeightedSimpleState': ('quantileExactWeighted', 'SimpleState'), 'maxIntersectionsPositionSimpleState': ('maxIntersectionsPosition', 'SimpleState'), 'quantileInterpolatedWeightedSimpleState': ('quantileInterpolatedWeighted', 'SimpleState'), 'quantilesTDigestSimpleState': ('quantilesTDigest', 'SimpleState'), 'topKSimpleState': ('topK', 'SimpleState'), 'quantilesBFloat16SimpleState': ('quantilesBFloat16', 'SimpleState'), 'argMinSimpleState': ('argMin', 'SimpleState'), 'maxIntersectionsSimpleState': ('maxIntersections', 'SimpleState'), 'maxSimpleState': ('max', 'SimpleState'), 'uniqThetaSimpleState': ('uniqTheta', 'SimpleState'), 'avgWeightedSimpleState': ('avgWeighted', 'SimpleState'), 'countSimpleState': ('count', 'SimpleState'), 'stochasticLogisticRegressionSimpleState': ('stochasticLogisticRegression', 'SimpleState'), 'quantileDeterministicSimpleState': ('quantileDeterministic', 'SimpleState'), 'uniqCombined64SimpleState': ('uniqCombined64', 'SimpleState'), 'sumCountSimpleState': ('sumCount', 'SimpleState'), 'kurtPopSimpleState': ('kurtPop', 'SimpleState'), 'groupBitOrSimpleState': ('groupBitOr', 'SimpleState'), 'groupArrayInsertAtSimpleState': ('groupArrayInsertAt', 'SimpleState'), 'uniqCombinedSimpleState': ('uniqCombined', 'SimpleState'), 'argMaxSimpleState': ('argMax', 'SimpleState'), 'contingencySimpleState': ('contingency', 'SimpleState'), 'quantilesExactWeightedSimpleState': ('quantilesExactWeighted', 'SimpleState'), 'groupArraySimpleState': ('groupArray', 'SimpleState'), 'quantileTDigestWeightedSimpleState': ('quantileTDigestWeighted', 'SimpleState'), 'quantileExactHighSimpleState': ('quantileExactHigh', 'SimpleState'), 'anySimpleState': ('any', 'SimpleState'), 'quantilesTimingWeightedSimpleState': ('quantilesTimingWeighted', 'SimpleState'), 'rankCorrSimpleState': ('rankCorr', 'SimpleState'), 'quantileTimingWeightedSimpleState': ('quantileTimingWeighted', 'SimpleState'), 'quantileSimpleState': ('quantile', 'SimpleState'), 'stochasticLinearRegressionSimpleState': ('stochasticLinearRegression', 'SimpleState'), 'last_valueSimpleState': ('last_value', 'SimpleState'), 'quantilesExactLowSimpleState': ('quantilesExactLow', 'SimpleState'), 'groupArrayLastSimpleState': ('groupArrayLast', 'SimpleState'), 'boundingRatioSimpleState': ('boundingRatio', 'SimpleState'), 'quantileBFloat16SimpleState': ('quantileBFloat16', 'SimpleState'), 'categoricalInformationValueSimpleState': ('categoricalInformationValue', 'SimpleState'), 'quantilesBFloat16WeightedSimpleState': ('quantilesBFloat16Weighted', 'SimpleState'), 'quantileExactSimpleState': ('quantileExact', 'SimpleState'), 'varPopSimpleState': ('varPop', 'SimpleState'), 'quantilesSimpleState': ('quantiles', 'SimpleState'), 'groupArraySampleSimpleState': ('groupArraySample', 'SimpleState'), 'deltaSumSimpleState': ('deltaSum', 'SimpleState'), 'minSimpleState': ('min', 'SimpleState'), 'stddevPopSimpleState': ('stddevPop', 'SimpleState'), 'quantileTimingSimpleState': ('quantileTiming', 'SimpleState'), 'groupBitmapOrSimpleState': ('groupBitmapOr', 'SimpleState'), 'skewSampSimpleState': ('skewSamp', 'SimpleState'), 'uniqSimpleState': ('uniq', 'SimpleState'), 'covarSampSimpleState': ('covarSamp', 'SimpleState'), 'groupUniqArraySimpleState': ('groupUniqArray', 'SimpleState'), 'quantileBFloat16WeightedSimpleState': ('quantileBFloat16Weighted', 'SimpleState'), 'retentionSimpleState': ('retention', 'SimpleState'), 'minMapSimpleState': ('minMap', 'SimpleState'), 'uniqExactSimpleState': ('uniqExact', 'SimpleState'), 'deltaSumTimestampSimpleState': ('deltaSumTimestamp', 'SimpleState'), 'groupArrayMovingAvgSimpleState': ('groupArrayMovingAvg', 'SimpleState'), 'uniqUpToSimpleState': ('uniqUpTo', 'SimpleState'), 'quantilesDeterministicSimpleState': ('quantilesDeterministic', 'SimpleState'), 'theilsUSimpleState': ('theilsU', 'SimpleState'), 'stddevSampSimpleState': ('stddevSamp', 'SimpleState'), 'windowFunnelSimpleState': ('windowFunnel', 'SimpleState'), 'groupArrayMovingSumSimpleState': ('groupArrayMovingSum', 'SimpleState'), 'maxMapSimpleState': ('maxMap', 'SimpleState'), 'quantilesTimingSimpleState': ('quantilesTiming', 'SimpleState'), 'intervalLengthSumSimpleState': ('intervalLengthSum', 'SimpleState'), 'varSampSimpleState': ('varSamp', 'SimpleState'), 'sumSimpleState': ('sum', 'SimpleState'), 'sumKahanSimpleState': ('sumKahan', 'SimpleState'), 'cramersVSimpleState': ('cramersV', 'SimpleState'), 'uniqHLL12SimpleState': ('uniqHLL12', 'SimpleState'), 'histogramState': ('histogram', 'State'), 'groupBitmapXorState': ('groupBitmapXor', 'State'), 'topKWeightedState': ('topKWeighted', 'State'), 'quantileExactLowState': ('quantileExactLow', 'State'), 'groupBitmapAndState': ('groupBitmapAnd', 'State'), 'quantileGKState': ('quantileGK', 'State'), 'quantilesGKState': ('quantilesGK', 'State'), 'mannWhitneyUTestState': ('mannWhitneyUTest', 'State'), 'studentTTestState': ('studentTTest', 'State'), 'sequenceCountState': ('sequenceCount', 'State'), 'sequenceNextNodeState': ('sequenceNextNode', 'State'), 'exponentialMovingAverageState': ('exponentialMovingAverage', 'State'), 'quantilesExactHighState': ('quantilesExactHigh', 'State'), 'kurtSampState': ('kurtSamp', 'State'), 'quantileTDigestState': ('quantileTDigest', 'State'), 'exponentialTimeDecayedAvgState': ('exponentialTimeDecayedAvg', 'State'), 'skewPopState': ('skewPop', 'State'), 'sumWithOverflowState': ('sumWithOverflow', 'State'), 'kolmogorovSmirnovTestState': ('kolmogorovSmirnovTest', 'State'), 'medianState': ('median', 'State'), 'groupBitAndState': ('groupBitAnd', 'State'), 'quantilesExactState': ('quantilesExact', 'State'), 'meanZTestState': ('meanZTest', 'State'), 'largestTriangleThreeBucketsState': ('largestTriangleThreeBuckets', 'State'), 'covarPopState': ('covarPop', 'State'), 'sequenceMatchState': ('sequenceMatch', 'State'), 'entropyState': ('entropy', 'State'), 'cramersVBiasCorrectedState': ('cramersVBiasCorrected', 'State'), 'welchTTestState': ('welchTTest', 'State'), 'groupBitmapState': ('groupBitmap', 'State'), 'simpleLinearRegressionState': ('simpleLinearRegression', 'State'), 'quantilesTDigestWeightedState': ('quantilesTDigestWeighted', 'State'), 'anyHeavyState': ('anyHeavy', 'State'), 'anyLastState': ('anyLast', 'State'), 'sparkBarState': ('sparkBar', 'State'), 'groupBitXorState': ('groupBitXor', 'State'), 'sumMapState': ('sumMap', 'State'), 'avgState': ('avg', 'State'), 'quantilesInterpolatedWeightedState': ('quantilesInterpolatedWeighted', 'State'), 'first_valueState': ('first_value', 'State'), 'corrState': ('corr', 'State'), 'quantileExactWeightedState': ('quantileExactWeighted', 'State'), 'maxIntersectionsPositionState': ('maxIntersectionsPosition', 'State'), 'quantileInterpolatedWeightedState': ('quantileInterpolatedWeighted', 'State'), 'quantilesTDigestState': ('quantilesTDigest', 'State'), 'topKState': ('topK', 'State'), 'quantilesBFloat16State': ('quantilesBFloat16', 'State'), 'argMinState': ('argMin', 'State'), 'maxIntersectionsState': ('maxIntersections', 'State'), 'maxState': ('max', 'State'), 'uniqThetaState': ('uniqTheta', 'State'), 'avgWeightedState': ('avgWeighted', 'State'), 'countState': ('count', 'State'), 'stochasticLogisticRegressionState': ('stochasticLogisticRegression', 'State'), 'quantileDeterministicState': ('quantileDeterministic', 'State'), 'uniqCombined64State': ('uniqCombined64', 'State'), 'sumCountState': ('sumCount', 'State'), 'kurtPopState': ('kurtPop', 'State'), 'groupBitOrState': ('groupBitOr', 'State'), 'groupArrayInsertAtState': ('groupArrayInsertAt', 'State'), 'uniqCombinedState': ('uniqCombined', 'State'), 'argMaxState': ('argMax', 'State'), 'contingencyState': ('contingency', 'State'), 'quantilesExactWeightedState': ('quantilesExactWeighted', 'State'), 'groupArrayState': ('groupArray', 'State'), 'quantileTDigestWeightedState': ('quantileTDigestWeighted', 'State'), 'quantileExactHighState': ('quantileExactHigh', 'State'), 'anyState': ('any', 'State'), 'quantilesTimingWeightedState': ('quantilesTimingWeighted', 'State'), 'rankCorrState': ('rankCorr', 'State'), 'quantileTimingWeightedState': ('quantileTimingWeighted', 'State'), 'quantileState': ('quantile', 'State'), 'stochasticLinearRegressionState': ('stochasticLinearRegression', 'State'), 'last_valueState': ('last_value', 'State'), 'quantilesExactLowState': ('quantilesExactLow', 'State'), 'groupArrayLastState': ('groupArrayLast', 'State'), 'boundingRatioState': ('boundingRatio', 'State'), 'quantileBFloat16State': ('quantileBFloat16', 'State'), 'categoricalInformationValueState': ('categoricalInformationValue', 'State'), 'quantilesBFloat16WeightedState': ('quantilesBFloat16Weighted', 'State'), 'quantileExactState': ('quantileExact', 'State'), 'varPopState': ('varPop', 'State'), 'quantilesState': ('quantiles', 'State'), 'groupArraySampleState': ('groupArraySample', 'State'), 'deltaSumState': ('deltaSum', 'State'), 'minState': ('min', 'State'), 'stddevPopState': ('stddevPop', 'State'), 'quantileTimingState': ('quantileTiming', 'State'), 'groupBitmapOrState': ('groupBitmapOr', 'State'), 'skewSampState': ('skewSamp', 'State'), 'uniqState': ('uniq', 'State'), 'covarSampState': ('covarSamp', 'State'), 'groupUniqArrayState': ('groupUniqArray', 'State'), 'quantileBFloat16WeightedState': ('quantileBFloat16Weighted', 'State'), 'retentionState': ('retention', 'State'), 'minMapState': ('minMap', 'State'), 'uniqExactState': ('uniqExact', 'State'), 'deltaSumTimestampState': ('deltaSumTimestamp', 'State'), 'groupArrayMovingAvgState': ('groupArrayMovingAvg', 'State'), 'uniqUpToState': ('uniqUpTo', 'State'), 'quantilesDeterministicState': ('quantilesDeterministic', 'State'), 'theilsUState': ('theilsU', 'State'), 'stddevSampState': ('stddevSamp', 'State'), 'windowFunnelState': ('windowFunnel', 'State'), 'groupArrayMovingSumState': ('groupArrayMovingSum', 'State'), 'maxMapState': ('maxMap', 'State'), 'quantilesTimingState': ('quantilesTiming', 'State'), 'intervalLengthSumState': ('intervalLengthSum', 'State'), 'varSampState': ('varSamp', 'State'), 'sumState': ('sum', 'State'), 'sumKahanState': ('sumKahan', 'State'), 'cramersVState': ('cramersV', 'State'), 'uniqHLL12State': ('uniqHLL12', 'State'), 'histogramMerge': ('histogram', 'Merge'), 'groupBitmapXorMerge': ('groupBitmapXor', 'Merge'), 'topKWeightedMerge': ('topKWeighted', 'Merge'), 'quantileExactLowMerge': ('quantileExactLow', 'Merge'), 'groupBitmapAndMerge': ('groupBitmapAnd', 'Merge'), 'quantileGKMerge': ('quantileGK', 'Merge'), 'quantilesGKMerge': ('quantilesGK', 'Merge'), 'mannWhitneyUTestMerge': ('mannWhitneyUTest', 'Merge'), 'studentTTestMerge': ('studentTTest', 'Merge'), 'sequenceCountMerge': ('sequenceCount', 'Merge'), 'sequenceNextNodeMerge': ('sequenceNextNode', 'Merge'), 'exponentialMovingAverageMerge': ('exponentialMovingAverage', 'Merge'), 'quantilesExactHighMerge': ('quantilesExactHigh', 'Merge'), 'kurtSampMerge': ('kurtSamp', 'Merge'), 'quantileTDigestMerge': ('quantileTDigest', 'Merge'), 'exponentialTimeDecayedAvgMerge': ('exponentialTimeDecayedAvg', 'Merge'), 'skewPopMerge': ('skewPop', 'Merge'), 'sumWithOverflowMerge': ('sumWithOverflow', 'Merge'), 'kolmogorovSmirnovTestMerge': ('kolmogorovSmirnovTest', 'Merge'), 'medianMerge': ('median', 'Merge'), 'groupBitAndMerge': ('groupBitAnd', 'Merge'), 'quantilesExactMerge': ('quantilesExact', 'Merge'), 'meanZTestMerge': ('meanZTest', 'Merge'), 'largestTriangleThreeBucketsMerge': ('largestTriangleThreeBuckets', 'Merge'), 'covarPopMerge': ('covarPop', 'Merge'), 'sequenceMatchMerge': ('sequenceMatch', 'Merge'), 'entropyMerge': ('entropy', 'Merge'), 'cramersVBiasCorrectedMerge': ('cramersVBiasCorrected', 'Merge'), 'welchTTestMerge': ('welchTTest', 'Merge'), 'groupBitmapMerge': ('groupBitmap', 'Merge'), 'simpleLinearRegressionMerge': ('simpleLinearRegression', 'Merge'), 'quantilesTDigestWeightedMerge': ('quantilesTDigestWeighted', 'Merge'), 'anyHeavyMerge': ('anyHeavy', 'Merge'), 'anyLastMerge': ('anyLast', 'Merge'), 'sparkBarMerge': ('sparkBar', 'Merge'), 'groupBitXorMerge': ('groupBitXor', 'Merge'), 'sumMapMerge': ('sumMap', 'Merge'), 'avgMerge': ('avg', 'Merge'), 'quantilesInterpolatedWeightedMerge': ('quantilesInterpolatedWeighted', 'Merge'), 'first_valueMerge': ('first_value', 'Merge'), 'corrMerge': ('corr', 'Merge'), 'quantileExactWeightedMerge': ('quantileExactWeighted', 'Merge'), 'maxIntersectionsPositionMerge': ('maxIntersectionsPosition', 'Merge'), 'quantileInterpolatedWeightedMerge': ('quantileInterpolatedWeighted', 'Merge'), 'quantilesTDigestMerge': ('quantilesTDigest', 'Merge'), 'topKMerge': ('topK', 'Merge'), 'quantilesBFloat16Merge': ('quantilesBFloat16', 'Merge'), 'argMinMerge': ('argMin', 'Merge'), 'maxIntersectionsMerge': ('maxIntersections', 'Merge'), 'maxMerge': ('max', 'Merge'), 'uniqThetaMerge': ('uniqTheta', 'Merge'), 'avgWeightedMerge': ('avgWeighted', 'Merge'), 'countMerge': ('count', 'Merge'), 'stochasticLogisticRegressionMerge': ('stochasticLogisticRegression', 'Merge'), 'quantileDeterministicMerge': ('quantileDeterministic', 'Merge'), 'uniqCombined64Merge': ('uniqCombined64', 'Merge'), 'sumCountMerge': ('sumCount', 'Merge'), 'kurtPopMerge': ('kurtPop', 'Merge'), 'groupBitOrMerge': ('groupBitOr', 'Merge'), 'groupArrayInsertAtMerge': ('groupArrayInsertAt', 'Merge'), 'uniqCombinedMerge': ('uniqCombined', 'Merge'), 'argMaxMerge': ('argMax', 'Merge'), 'contingencyMerge': ('contingency', 'Merge'), 'quantilesExactWeightedMerge': ('quantilesExactWeighted', 'Merge'), 'groupArrayMerge': ('groupArray', 'Merge'), 'quantileTDigestWeightedMerge': ('quantileTDigestWeighted', 'Merge'), 'quantileExactHighMerge': ('quantileExactHigh', 'Merge'), 'anyMerge': ('any', 'Merge'), 'quantilesTimingWeightedMerge': ('quantilesTimingWeighted', 'Merge'), 'rankCorrMerge': ('rankCorr', 'Merge'), 'quantileTimingWeightedMerge': ('quantileTimingWeighted', 'Merge'), 'quantileMerge': ('quantile', 'Merge'), 'stochasticLinearRegressionMerge': ('stochasticLinearRegression', 'Merge'), 'last_valueMerge': ('last_value', 'Merge'), 'quantilesExactLowMerge': ('quantilesExactLow', 'Merge'), 'groupArrayLastMerge': ('groupArrayLast', 'Merge'), 'boundingRatioMerge': ('boundingRatio', 'Merge'), 'quantileBFloat16Merge': ('quantileBFloat16', 'Merge'), 'categoricalInformationValueMerge': ('categoricalInformationValue', 'Merge'), 'quantilesBFloat16WeightedMerge': ('quantilesBFloat16Weighted', 'Merge'), 'quantileExactMerge': ('quantileExact', 'Merge'), 'varPopMerge': ('varPop', 'Merge'), 'quantilesMerge': ('quantiles', 'Merge'), 'groupArraySampleMerge': ('groupArraySample', 'Merge'), 'deltaSumMerge': ('deltaSum', 'Merge'), 'minMerge': ('min', 'Merge'), 'stddevPopMerge': ('stddevPop', 'Merge'), 'quantileTimingMerge': ('quantileTiming', 'Merge'), 'groupBitmapOrMerge': ('groupBitmapOr', 'Merge'), 'skewSampMerge': ('skewSamp', 'Merge'), 'uniqMerge': ('uniq', 'Merge'), 'covarSampMerge': ('covarSamp', 'Merge'), 'groupUniqArrayMerge': ('groupUniqArray', 'Merge'), 'quantileBFloat16WeightedMerge': ('quantileBFloat16Weighted', 'Merge'), 'retentionMerge': ('retention', 'Merge'), 'minMapMerge': ('minMap', 'Merge'), 'uniqExactMerge': ('uniqExact', 'Merge'), 'deltaSumTimestampMerge': ('deltaSumTimestamp', 'Merge'), 'groupArrayMovingAvgMerge': ('groupArrayMovingAvg', 'Merge'), 'uniqUpToMerge': ('uniqUpTo', 'Merge'), 'quantilesDeterministicMerge': ('quantilesDeterministic', 'Merge'), 'theilsUMerge': ('theilsU', 'Merge'), 'stddevSampMerge': ('stddevSamp', 'Merge'), 'windowFunnelMerge': ('windowFunnel', 'Merge'), 'groupArrayMovingSumMerge': ('groupArrayMovingSum', 'Merge'), 'maxMapMerge': ('maxMap', 'Merge'), 'quantilesTimingMerge': ('quantilesTiming', 'Merge'), 'intervalLengthSumMerge': ('intervalLengthSum', 'Merge'), 'varSampMerge': ('varSamp', 'Merge'), 'sumMerge': ('sum', 'Merge'), 'sumKahanMerge': ('sumKahan', 'Merge'), 'cramersVMerge': ('cramersV', 'Merge'), 'uniqHLL12Merge': ('uniqHLL12', 'Merge'), 'histogramMergeState': ('histogram', 'MergeState'), 'groupBitmapXorMergeState': ('groupBitmapXor', 'MergeState'), 'topKWeightedMergeState': ('topKWeighted', 'MergeState'), 'quantileExactLowMergeState': ('quantileExactLow', 'MergeState'), 'groupBitmapAndMergeState': ('groupBitmapAnd', 'MergeState'), 'quantileGKMergeState': ('quantileGK', 'MergeState'), 'quantilesGKMergeState': ('quantilesGK', 'MergeState'), 'mannWhitneyUTestMergeState': ('mannWhitneyUTest', 'MergeState'), 'studentTTestMergeState': ('studentTTest', 'MergeState'), 'sequenceCountMergeState': ('sequenceCount', 'MergeState'), 'sequenceNextNodeMergeState': ('sequenceNextNode', 'MergeState'), 'exponentialMovingAverageMergeState': ('exponentialMovingAverage', 'MergeState'), 'quantilesExactHighMergeState': ('quantilesExactHigh', 'MergeState'), 'kurtSampMergeState': ('kurtSamp', 'MergeState'), 'quantileTDigestMergeState': ('quantileTDigest', 'MergeState'), 'exponentialTimeDecayedAvgMergeState': ('exponentialTimeDecayedAvg', 'MergeState'), 'skewPopMergeState': ('skewPop', 'MergeState'), 'sumWithOverflowMergeState': ('sumWithOverflow', 'MergeState'), 'kolmogorovSmirnovTestMergeState': ('kolmogorovSmirnovTest', 'MergeState'), 'medianMergeState': ('median', 'MergeState'), 'groupBitAndMergeState': ('groupBitAnd', 'MergeState'), 'quantilesExactMergeState': ('quantilesExact', 'MergeState'), 'meanZTestMergeState': ('meanZTest', 'MergeState'), 'largestTriangleThreeBucketsMergeState': ('largestTriangleThreeBuckets', 'MergeState'), 'covarPopMergeState': ('covarPop', 'MergeState'), 'sequenceMatchMergeState': ('sequenceMatch', 'MergeState'), 'entropyMergeState': ('entropy', 'MergeState'), 'cramersVBiasCorrectedMergeState': ('cramersVBiasCorrected', 'MergeState'), 'welchTTestMergeState': ('welchTTest', 'MergeState'), 'groupBitmapMergeState': ('groupBitmap', 'MergeState'), 'simpleLinearRegressionMergeState': ('simpleLinearRegression', 'MergeState'), 'quantilesTDigestWeightedMergeState': ('quantilesTDigestWeighted', 'MergeState'), 'anyHeavyMergeState': ('anyHeavy', 'MergeState'), 'anyLastMergeState': ('anyLast', 'MergeState'), 'sparkBarMergeState': ('sparkBar', 'MergeState'), 'groupBitXorMergeState': ('groupBitXor', 'MergeState'), 'sumMapMergeState': ('sumMap', 'MergeState'), 'avgMergeState': ('avg', 'MergeState'), 'quantilesInterpolatedWeightedMergeState': ('quantilesInterpolatedWeighted', 'MergeState'), 'first_valueMergeState': ('first_value', 'MergeState'), 'corrMergeState': ('corr', 'MergeState'), 'quantileExactWeightedMergeState': ('quantileExactWeighted', 'MergeState'), 'maxIntersectionsPositionMergeState': ('maxIntersectionsPosition', 'MergeState'), 'quantileInterpolatedWeightedMergeState': ('quantileInterpolatedWeighted', 'MergeState'), 'quantilesTDigestMergeState': ('quantilesTDigest', 'MergeState'), 'topKMergeState': ('topK', 'MergeState'), 'quantilesBFloat16MergeState': ('quantilesBFloat16', 'MergeState'), 'argMinMergeState': ('argMin', 'MergeState'), 'maxIntersectionsMergeState': ('maxIntersections', 'MergeState'), 'maxMergeState': ('max', 'MergeState'), 'uniqThetaMergeState': ('uniqTheta', 'MergeState'), 'avgWeightedMergeState': ('avgWeighted', 'MergeState'), 'countMergeState': ('count', 'MergeState'), 'stochasticLogisticRegressionMergeState': ('stochasticLogisticRegression', 'MergeState'), 'quantileDeterministicMergeState': ('quantileDeterministic', 'MergeState'), 'uniqCombined64MergeState': ('uniqCombined64', 'MergeState'), 'sumCountMergeState': ('sumCount', 'MergeState'), 'kurtPopMergeState': ('kurtPop', 'MergeState'), 'groupBitOrMergeState': ('groupBitOr', 'MergeState'), 'groupArrayInsertAtMergeState': ('groupArrayInsertAt', 'MergeState'), 'uniqCombinedMergeState': ('uniqCombined', 'MergeState'), 'argMaxMergeState': ('argMax', 'MergeState'), 'contingencyMergeState': ('contingency', 'MergeState'), 'quantilesExactWeightedMergeState': ('quantilesExactWeighted', 'MergeState'), 'groupArrayMergeState': ('groupArray', 'MergeState'), 'quantileTDigestWeightedMergeState': ('quantileTDigestWeighted', 'MergeState'), 'quantileExactHighMergeState': ('quantileExactHigh', 'MergeState'), 'anyMergeState': ('any', 'MergeState'), 'quantilesTimingWeightedMergeState': ('quantilesTimingWeighted', 'MergeState'), 'rankCorrMergeState': ('rankCorr', 'MergeState'), 'quantileTimingWeightedMergeState': ('quantileTimingWeighted', 'MergeState'), 'quantileMergeState': ('quantile', 'MergeState'), 'stochasticLinearRegressionMergeState': ('stochasticLinearRegression', 'MergeState'), 'last_valueMergeState': ('last_value', 'MergeState'), 'quantilesExactLowMergeState': ('quantilesExactLow', 'MergeState'), 'groupArrayLastMergeState': ('groupArrayLast', 'MergeState'), 'boundingRatioMergeState': ('boundingRatio', 'MergeState'), 'quantileBFloat16MergeState': ('quantileBFloat16', 'MergeState'), 'categoricalInformationValueMergeState': ('categoricalInformationValue', 'MergeState'), 'quantilesBFloat16WeightedMergeState': ('quantilesBFloat16Weighted', 'MergeState'), 'quantileExactMergeState': ('quantileExact', 'MergeState'), 'varPopMergeState': ('varPop', 'MergeState'), 'quantilesMergeState': ('quantiles', 'MergeState'), 'groupArraySampleMergeState': ('groupArraySample', 'MergeState'), 'deltaSumMergeState': ('deltaSum', 'MergeState'), 'minMergeState': ('min', 'MergeState'), 'stddevPopMergeState': ('stddevPop', 'MergeState'), 'quantileTimingMergeState': ('quantileTiming', 'MergeState'), 'groupBitmapOrMergeState': ('groupBitmapOr', 'MergeState'), 'skewSampMergeState': ('skewSamp', 'MergeState'), 'uniqMergeState': ('uniq', 'MergeState'), 'covarSampMergeState': ('covarSamp', 'MergeState'), 'groupUniqArrayMergeState': ('groupUniqArray', 'MergeState'), 'quantileBFloat16WeightedMergeState': ('quantileBFloat16Weighted', 'MergeState'), 'retentionMergeState': ('retention', 'MergeState'), 'minMapMergeState': ('minMap', 'MergeState'), 'uniqExactMergeState': ('uniqExact', 'MergeState'), 'deltaSumTimestampMergeState': ('deltaSumTimestamp', 'MergeState'), 'groupArrayMovingAvgMergeState': ('groupArrayMovingAvg', 'MergeState'), 'uniqUpToMergeState': ('uniqUpTo', 'MergeState'), 'quantilesDeterministicMergeState': ('quantilesDeterministic', 'MergeState'), 'theilsUMergeState': ('theilsU', 'MergeState'), 'stddevSampMergeState': ('stddevSamp', 'MergeState'), 'windowFunnelMergeState': ('windowFunnel', 'MergeState'), 'groupArrayMovingSumMergeState': ('groupArrayMovingSum', 'MergeState'), 'maxMapMergeState': ('maxMap', 'MergeState'), 'quantilesTimingMergeState': ('quantilesTiming', 'MergeState'), 'intervalLengthSumMergeState': ('intervalLengthSum', 'MergeState'), 'varSampMergeState': ('varSamp', 'MergeState'), 'sumMergeState': ('sum', 'MergeState'), 'sumKahanMergeState': ('sumKahan', 'MergeState'), 'cramersVMergeState': ('cramersV', 'MergeState'), 'uniqHLL12MergeState': ('uniqHLL12', 'MergeState'), 'histogramForEach': ('histogram', 'ForEach'), 'groupBitmapXorForEach': ('groupBitmapXor', 'ForEach'), 'topKWeightedForEach': ('topKWeighted', 'ForEach'), 'quantileExactLowForEach': ('quantileExactLow', 'ForEach'), 'groupBitmapAndForEach': ('groupBitmapAnd', 'ForEach'), 'quantileGKForEach': ('quantileGK', 'ForEach'), 'quantilesGKForEach': ('quantilesGK', 'ForEach'), 'mannWhitneyUTestForEach': ('mannWhitneyUTest', 'ForEach'), 'studentTTestForEach': ('studentTTest', 'ForEach'), 'sequenceCountForEach': ('sequenceCount', 'ForEach'), 'sequenceNextNodeForEach': ('sequenceNextNode', 'ForEach'), 'exponentialMovingAverageForEach': ('exponentialMovingAverage', 'ForEach'), 'quantilesExactHighForEach': ('quantilesExactHigh', 'ForEach'), 'kurtSampForEach': ('kurtSamp', 'ForEach'), 'quantileTDigestForEach': ('quantileTDigest', 'ForEach'), 'exponentialTimeDecayedAvgForEach': ('exponentialTimeDecayedAvg', 'ForEach'), 'skewPopForEach': ('skewPop', 'ForEach'), 'sumWithOverflowForEach': ('sumWithOverflow', 'ForEach'), 'kolmogorovSmirnovTestForEach': ('kolmogorovSmirnovTest', 'ForEach'), 'medianForEach': ('median', 'ForEach'), 'groupBitAndForEach': ('groupBitAnd', 'ForEach'), 'quantilesExactForEach': ('quantilesExact', 'ForEach'), 'meanZTestForEach': ('meanZTest', 'ForEach'), 'largestTriangleThreeBucketsForEach': ('largestTriangleThreeBuckets', 'ForEach'), 'covarPopForEach': ('covarPop', 'ForEach'), 'sequenceMatchForEach': ('sequenceMatch', 'ForEach'), 'entropyForEach': ('entropy', 'ForEach'), 'cramersVBiasCorrectedForEach': ('cramersVBiasCorrected', 'ForEach'), 'welchTTestForEach': ('welchTTest', 'ForEach'), 'groupBitmapForEach': ('groupBitmap', 'ForEach'), 'simpleLinearRegressionForEach': ('simpleLinearRegression', 'ForEach'), 'quantilesTDigestWeightedForEach': ('quantilesTDigestWeighted', 'ForEach'), 'anyHeavyForEach': ('anyHeavy', 'ForEach'), 'anyLastForEach': ('anyLast', 'ForEach'), 'sparkBarForEach': ('sparkBar', 'ForEach'), 'groupBitXorForEach': ('groupBitXor', 'ForEach'), 'sumMapForEach': ('sumMap', 'ForEach'), 'avgForEach': ('avg', 'ForEach'), 'quantilesInterpolatedWeightedForEach': ('quantilesInterpolatedWeighted', 'ForEach'), 'first_valueForEach': ('first_value', 'ForEach'), 'corrForEach': ('corr', 'ForEach'), 'quantileExactWeightedForEach': ('quantileExactWeighted', 'ForEach'), 'maxIntersectionsPositionForEach': ('maxIntersectionsPosition', 'ForEach'), 'quantileInterpolatedWeightedForEach': ('quantileInterpolatedWeighted', 'ForEach'), 'quantilesTDigestForEach': ('quantilesTDigest', 'ForEach'), 'topKForEach': ('topK', 'ForEach'), 'quantilesBFloat16ForEach': ('quantilesBFloat16', 'ForEach'), 'argMinForEach': ('argMin', 'ForEach'), 'maxIntersectionsForEach': ('maxIntersections', 'ForEach'), 'maxForEach': ('max', 'ForEach'), 'uniqThetaForEach': ('uniqTheta', 'ForEach'), 'avgWeightedForEach': ('avgWeighted', 'ForEach'), 'countForEach': ('count', 'ForEach'), 'stochasticLogisticRegressionForEach': ('stochasticLogisticRegression', 'ForEach'), 'quantileDeterministicForEach': ('quantileDeterministic', 'ForEach'), 'uniqCombined64ForEach': ('uniqCombined64', 'ForEach'), 'sumCountForEach': ('sumCount', 'ForEach'), 'kurtPopForEach': ('kurtPop', 'ForEach'), 'groupBitOrForEach': ('groupBitOr', 'ForEach'), 'groupArrayInsertAtForEach': ('groupArrayInsertAt', 'ForEach'), 'uniqCombinedForEach': ('uniqCombined', 'ForEach'), 'argMaxForEach': ('argMax', 'ForEach'), 'contingencyForEach': ('contingency', 'ForEach'), 'quantilesExactWeightedForEach': ('quantilesExactWeighted', 'ForEach'), 'groupArrayForEach': ('groupArray', 'ForEach'), 'quantileTDigestWeightedForEach': ('quantileTDigestWeighted', 'ForEach'), 'quantileExactHighForEach': ('quantileExactHigh', 'ForEach'), 'anyForEach': ('any', 'ForEach'), 'quantilesTimingWeightedForEach': ('quantilesTimingWeighted', 'ForEach'), 'rankCorrForEach': ('rankCorr', 'ForEach'), 'quantileTimingWeightedForEach': ('quantileTimingWeighted', 'ForEach'), 'quantileForEach': ('quantile', 'ForEach'), 'stochasticLinearRegressionForEach': ('stochasticLinearRegression', 'ForEach'), 'last_valueForEach': ('last_value', 'ForEach'), 'quantilesExactLowForEach': ('quantilesExactLow', 'ForEach'), 'groupArrayLastForEach': ('groupArrayLast', 'ForEach'), 'boundingRatioForEach': ('boundingRatio', 'ForEach'), 'quantileBFloat16ForEach': ('quantileBFloat16', 'ForEach'), 'categoricalInformationValueForEach': ('categoricalInformationValue', 'ForEach'), 'quantilesBFloat16WeightedForEach': ('quantilesBFloat16Weighted', 'ForEach'), 'quantileExactForEach': ('quantileExact', 'ForEach'), 'varPopForEach': ('varPop', 'ForEach'), 'quantilesForEach': ('quantiles', 'ForEach'), 'groupArraySampleForEach': ('groupArraySample', 'ForEach'), 'deltaSumForEach': ('deltaSum', 'ForEach'), 'minForEach': ('min', 'ForEach'), 'stddevPopForEach': ('stddevPop', 'ForEach'), 'quantileTimingForEach': ('quantileTiming', 'ForEach'), 'groupBitmapOrForEach': ('groupBitmapOr', 'ForEach'), 'skewSampForEach': ('skewSamp', 'ForEach'), 'uniqForEach': ('uniq', 'ForEach'), 'covarSampForEach': ('covarSamp', 'ForEach'), 'groupUniqArrayForEach': ('groupUniqArray', 'ForEach'), 'quantileBFloat16WeightedForEach': ('quantileBFloat16Weighted', 'ForEach'), 'retentionForEach': ('retention', 'ForEach'), 'minMapForEach': ('minMap', 'ForEach'), 'uniqExactForEach': ('uniqExact', 'ForEach'), 'deltaSumTimestampForEach': ('deltaSumTimestamp', 'ForEach'), 'groupArrayMovingAvgForEach': ('groupArrayMovingAvg', 'ForEach'), 'uniqUpToForEach': ('uniqUpTo', 'ForEach'), 'quantilesDeterministicForEach': ('quantilesDeterministic', 'ForEach'), 'theilsUForEach': ('theilsU', 'ForEach'), 'stddevSampForEach': ('stddevSamp', 'ForEach'), 'windowFunnelForEach': ('windowFunnel', 'ForEach'), 'groupArrayMovingSumForEach': ('groupArrayMovingSum', 'ForEach'), 'maxMapForEach': ('maxMap', 'ForEach'), 'quantilesTimingForEach': ('quantilesTiming', 'ForEach'), 'intervalLengthSumForEach': ('intervalLengthSum', 'ForEach'), 'varSampForEach': ('varSamp', 'ForEach'), 'sumForEach': ('sum', 'ForEach'), 'sumKahanForEach': ('sumKahan', 'ForEach'), 'cramersVForEach': ('cramersV', 'ForEach'), 'uniqHLL12ForEach': ('uniqHLL12', 'ForEach'), 'histogramDistinct': ('histogram', 'Distinct'), 'groupBitmapXorDistinct': ('groupBitmapXor', 'Distinct'), 'topKWeightedDistinct': ('topKWeighted', 'Distinct'), 'quantileExactLowDistinct': ('quantileExactLow', 'Distinct'), 'groupBitmapAndDistinct': ('groupBitmapAnd', 'Distinct'), 'quantileGKDistinct': ('quantileGK', 'Distinct'), 'quantilesGKDistinct': ('quantilesGK', 'Distinct'), 'mannWhitneyUTestDistinct': ('mannWhitneyUTest', 'Distinct'), 'studentTTestDistinct': ('studentTTest', 'Distinct'), 'sequenceCountDistinct': ('sequenceCount', 'Distinct'), 'sequenceNextNodeDistinct': ('sequenceNextNode', 'Distinct'), 'exponentialMovingAverageDistinct': ('exponentialMovingAverage', 'Distinct'), 'quantilesExactHighDistinct': ('quantilesExactHigh', 'Distinct'), 'kurtSampDistinct': ('kurtSamp', 'Distinct'), 'quantileTDigestDistinct': ('quantileTDigest', 'Distinct'), 'exponentialTimeDecayedAvgDistinct': ('exponentialTimeDecayedAvg', 'Distinct'), 'skewPopDistinct': ('skewPop', 'Distinct'), 'sumWithOverflowDistinct': ('sumWithOverflow', 'Distinct'), 'kolmogorovSmirnovTestDistinct': ('kolmogorovSmirnovTest', 'Distinct'), 'medianDistinct': ('median', 'Distinct'), 'groupBitAndDistinct': ('groupBitAnd', 'Distinct'), 'quantilesExactDistinct': ('quantilesExact', 'Distinct'), 'meanZTestDistinct': ('meanZTest', 'Distinct'), 'largestTriangleThreeBucketsDistinct': ('largestTriangleThreeBuckets', 'Distinct'), 'covarPopDistinct': ('covarPop', 'Distinct'), 'sequenceMatchDistinct': ('sequenceMatch', 'Distinct'), 'entropyDistinct': ('entropy', 'Distinct'), 'cramersVBiasCorrectedDistinct': ('cramersVBiasCorrected', 'Distinct'), 'welchTTestDistinct': ('welchTTest', 'Distinct'), 'groupBitmapDistinct': ('groupBitmap', 'Distinct'), 'simpleLinearRegressionDistinct': ('simpleLinearRegression', 'Distinct'), 'quantilesTDigestWeightedDistinct': ('quantilesTDigestWeighted', 'Distinct'), 'anyHeavyDistinct': ('anyHeavy', 'Distinct'), 'anyLastDistinct': ('anyLast', 'Distinct'), 'sparkBarDistinct': ('sparkBar', 'Distinct'), 'groupBitXorDistinct': ('groupBitXor', 'Distinct'), 'sumMapDistinct': ('sumMap', 'Distinct'), 'avgDistinct': ('avg', 'Distinct'), 'quantilesInterpolatedWeightedDistinct': ('quantilesInterpolatedWeighted', 'Distinct'), 'first_valueDistinct': ('first_value', 'Distinct'), 'corrDistinct': ('corr', 'Distinct'), 'quantileExactWeightedDistinct': ('quantileExactWeighted', 'Distinct'), 'maxIntersectionsPositionDistinct': ('maxIntersectionsPosition', 'Distinct'), 'quantileInterpolatedWeightedDistinct': ('quantileInterpolatedWeighted', 'Distinct'), 'quantilesTDigestDistinct': ('quantilesTDigest', 'Distinct'), 'topKDistinct': ('topK', 'Distinct'), 'quantilesBFloat16Distinct': ('quantilesBFloat16', 'Distinct'), 'argMinDistinct': ('argMin', 'Distinct'), 'maxIntersectionsDistinct': ('maxIntersections', 'Distinct'), 'maxDistinct': ('max', 'Distinct'), 'uniqThetaDistinct': ('uniqTheta', 'Distinct'), 'avgWeightedDistinct': ('avgWeighted', 'Distinct'), 'countDistinct': ('count', 'Distinct'), 'stochasticLogisticRegressionDistinct': ('stochasticLogisticRegression', 'Distinct'), 'quantileDeterministicDistinct': ('quantileDeterministic', 'Distinct'), 'uniqCombined64Distinct': ('uniqCombined64', 'Distinct'), 'sumCountDistinct': ('sumCount', 'Distinct'), 'kurtPopDistinct': ('kurtPop', 'Distinct'), 'groupBitOrDistinct': ('groupBitOr', 'Distinct'), 'groupArrayInsertAtDistinct': ('groupArrayInsertAt', 'Distinct'), 'uniqCombinedDistinct': ('uniqCombined', 'Distinct'), 'argMaxDistinct': ('argMax', 'Distinct'), 'contingencyDistinct': ('contingency', 'Distinct'), 'quantilesExactWeightedDistinct': ('quantilesExactWeighted', 'Distinct'), 'groupArrayDistinct': ('groupArray', 'Distinct'), 'quantileTDigestWeightedDistinct': ('quantileTDigestWeighted', 'Distinct'), 'quantileExactHighDistinct': ('quantileExactHigh', 'Distinct'), 'anyDistinct': ('any', 'Distinct'), 'quantilesTimingWeightedDistinct': ('quantilesTimingWeighted', 'Distinct'), 'rankCorrDistinct': ('rankCorr', 'Distinct'), 'quantileTimingWeightedDistinct': ('quantileTimingWeighted', 'Distinct'), 'quantileDistinct': ('quantile', 'Distinct'), 'stochasticLinearRegressionDistinct': ('stochasticLinearRegression', 'Distinct'), 'last_valueDistinct': ('last_value', 'Distinct'), 'quantilesExactLowDistinct': ('quantilesExactLow', 'Distinct'), 'groupArrayLastDistinct': ('groupArrayLast', 'Distinct'), 'boundingRatioDistinct': ('boundingRatio', 'Distinct'), 'quantileBFloat16Distinct': ('quantileBFloat16', 'Distinct'), 'categoricalInformationValueDistinct': ('categoricalInformationValue', 'Distinct'), 'quantilesBFloat16WeightedDistinct': ('quantilesBFloat16Weighted', 'Distinct'), 'quantileExactDistinct': ('quantileExact', 'Distinct'), 'varPopDistinct': ('varPop', 'Distinct'), 'quantilesDistinct': ('quantiles', 'Distinct'), 'groupArraySampleDistinct': ('groupArraySample', 'Distinct'), 'deltaSumDistinct': ('deltaSum', 'Distinct'), 'minDistinct': ('min', 'Distinct'), 'stddevPopDistinct': ('stddevPop', 'Distinct'), 'quantileTimingDistinct': ('quantileTiming', 'Distinct'), 'groupBitmapOrDistinct': ('groupBitmapOr', 'Distinct'), 'skewSampDistinct': ('skewSamp', 'Distinct'), 'uniqDistinct': ('uniq', 'Distinct'), 'covarSampDistinct': ('covarSamp', 'Distinct'), 'groupUniqArrayDistinct': ('groupUniqArray', 'Distinct'), 'quantileBFloat16WeightedDistinct': ('quantileBFloat16Weighted', 'Distinct'), 'retentionDistinct': ('retention', 'Distinct'), 'minMapDistinct': ('minMap', 'Distinct'), 'uniqExactDistinct': ('uniqExact', 'Distinct'), 'deltaSumTimestampDistinct': ('deltaSumTimestamp', 'Distinct'), 'groupArrayMovingAvgDistinct': ('groupArrayMovingAvg', 'Distinct'), 'uniqUpToDistinct': ('uniqUpTo', 'Distinct'), 'quantilesDeterministicDistinct': ('quantilesDeterministic', 'Distinct'), 'theilsUDistinct': ('theilsU', 'Distinct'), 'stddevSampDistinct': ('stddevSamp', 'Distinct'), 'windowFunnelDistinct': ('windowFunnel', 'Distinct'), 'groupArrayMovingSumDistinct': ('groupArrayMovingSum', 'Distinct'), 'maxMapDistinct': ('maxMap', 'Distinct'), 'quantilesTimingDistinct': ('quantilesTiming', 'Distinct'), 'intervalLengthSumDistinct': ('intervalLengthSum', 'Distinct'), 'varSampDistinct': ('varSamp', 'Distinct'), 'sumDistinct': ('sum', 'Distinct'), 'sumKahanDistinct': ('sumKahan', 'Distinct'), 'cramersVDistinct': ('cramersV', 'Distinct'), 'uniqHLL12Distinct': ('uniqHLL12', 'Distinct'), 'histogramOrDefault': ('histogram', 'OrDefault'), 'groupBitmapXorOrDefault': ('groupBitmapXor', 'OrDefault'), 'topKWeightedOrDefault': ('topKWeighted', 'OrDefault'), 'quantileExactLowOrDefault': ('quantileExactLow', 'OrDefault'), 'groupBitmapAndOrDefault': ('groupBitmapAnd', 'OrDefault'), 'quantileGKOrDefault': ('quantileGK', 'OrDefault'), 'quantilesGKOrDefault': ('quantilesGK', 'OrDefault'), 'mannWhitneyUTestOrDefault': ('mannWhitneyUTest', 'OrDefault'), 'studentTTestOrDefault': ('studentTTest', 'OrDefault'), 'sequenceCountOrDefault': ('sequenceCount', 'OrDefault'), 'sequenceNextNodeOrDefault': ('sequenceNextNode', 'OrDefault'), 'exponentialMovingAverageOrDefault': ('exponentialMovingAverage', 'OrDefault'), 'quantilesExactHighOrDefault': ('quantilesExactHigh', 'OrDefault'), 'kurtSampOrDefault': ('kurtSamp', 'OrDefault'), 'quantileTDigestOrDefault': ('quantileTDigest', 'OrDefault'), 'exponentialTimeDecayedAvgOrDefault': ('exponentialTimeDecayedAvg', 'OrDefault'), 'skewPopOrDefault': ('skewPop', 'OrDefault'), 'sumWithOverflowOrDefault': ('sumWithOverflow', 'OrDefault'), 'kolmogorovSmirnovTestOrDefault': ('kolmogorovSmirnovTest', 'OrDefault'), 'medianOrDefault': ('median', 'OrDefault'), 'groupBitAndOrDefault': ('groupBitAnd', 'OrDefault'), 'quantilesExactOrDefault': ('quantilesExact', 'OrDefault'), 'meanZTestOrDefault': ('meanZTest', 'OrDefault'), 'largestTriangleThreeBucketsOrDefault': ('largestTriangleThreeBuckets', 'OrDefault'), 'covarPopOrDefault': ('covarPop', 'OrDefault'), 'sequenceMatchOrDefault': ('sequenceMatch', 'OrDefault'), 'entropyOrDefault': ('entropy', 'OrDefault'), 'cramersVBiasCorrectedOrDefault': ('cramersVBiasCorrected', 'OrDefault'), 'welchTTestOrDefault': ('welchTTest', 'OrDefault'), 'groupBitmapOrDefault': ('groupBitmap', 'OrDefault'), 'simpleLinearRegressionOrDefault': ('simpleLinearRegression', 'OrDefault'), 'quantilesTDigestWeightedOrDefault': ('quantilesTDigestWeighted', 'OrDefault'), 'anyHeavyOrDefault': ('anyHeavy', 'OrDefault'), 'anyLastOrDefault': ('anyLast', 'OrDefault'), 'sparkBarOrDefault': ('sparkBar', 'OrDefault'), 'groupBitXorOrDefault': ('groupBitXor', 'OrDefault'), 'sumMapOrDefault': ('sumMap', 'OrDefault'), 'avgOrDefault': ('avg', 'OrDefault'), 'quantilesInterpolatedWeightedOrDefault': ('quantilesInterpolatedWeighted', 'OrDefault'), 'first_valueOrDefault': ('first_value', 'OrDefault'), 'corrOrDefault': ('corr', 'OrDefault'), 'quantileExactWeightedOrDefault': ('quantileExactWeighted', 'OrDefault'), 'maxIntersectionsPositionOrDefault': ('maxIntersectionsPosition', 'OrDefault'), 'quantileInterpolatedWeightedOrDefault': ('quantileInterpolatedWeighted', 'OrDefault'), 'quantilesTDigestOrDefault': ('quantilesTDigest', 'OrDefault'), 'topKOrDefault': ('topK', 'OrDefault'), 'quantilesBFloat16OrDefault': ('quantilesBFloat16', 'OrDefault'), 'argMinOrDefault': ('argMin', 'OrDefault'), 'maxIntersectionsOrDefault': ('maxIntersections', 'OrDefault'), 'maxOrDefault': ('max', 'OrDefault'), 'uniqThetaOrDefault': ('uniqTheta', 'OrDefault'), 'avgWeightedOrDefault': ('avgWeighted', 'OrDefault'), 'countOrDefault': ('count', 'OrDefault'), 'stochasticLogisticRegressionOrDefault': ('stochasticLogisticRegression', 'OrDefault'), 'quantileDeterministicOrDefault': ('quantileDeterministic', 'OrDefault'), 'uniqCombined64OrDefault': ('uniqCombined64', 'OrDefault'), 'sumCountOrDefault': ('sumCount', 'OrDefault'), 'kurtPopOrDefault': ('kurtPop', 'OrDefault'), 'groupBitOrOrDefault': ('groupBitOr', 'OrDefault'), 'groupArrayInsertAtOrDefault': ('groupArrayInsertAt', 'OrDefault'), 'uniqCombinedOrDefault': ('uniqCombined', 'OrDefault'), 'argMaxOrDefault': ('argMax', 'OrDefault'), 'contingencyOrDefault': ('contingency', 'OrDefault'), 'quantilesExactWeightedOrDefault': ('quantilesExactWeighted', 'OrDefault'), 'groupArrayOrDefault': ('groupArray', 'OrDefault'), 'quantileTDigestWeightedOrDefault': ('quantileTDigestWeighted', 'OrDefault'), 'quantileExactHighOrDefault': ('quantileExactHigh', 'OrDefault'), 'anyOrDefault': ('any', 'OrDefault'), 'quantilesTimingWeightedOrDefault': ('quantilesTimingWeighted', 'OrDefault'), 'rankCorrOrDefault': ('rankCorr', 'OrDefault'), 'quantileTimingWeightedOrDefault': ('quantileTimingWeighted', 'OrDefault'), 'quantileOrDefault': ('quantile', 'OrDefault'), 'stochasticLinearRegressionOrDefault': ('stochasticLinearRegression', 'OrDefault'), 'last_valueOrDefault': ('last_value', 'OrDefault'), 'quantilesExactLowOrDefault': ('quantilesExactLow', 'OrDefault'), 'groupArrayLastOrDefault': ('groupArrayLast', 'OrDefault'), 'boundingRatioOrDefault': ('boundingRatio', 'OrDefault'), 'quantileBFloat16OrDefault': ('quantileBFloat16', 'OrDefault'), 'categoricalInformationValueOrDefault': ('categoricalInformationValue', 'OrDefault'), 'quantilesBFloat16WeightedOrDefault': ('quantilesBFloat16Weighted', 'OrDefault'), 'quantileExactOrDefault': ('quantileExact', 'OrDefault'), 'varPopOrDefault': ('varPop', 'OrDefault'), 'quantilesOrDefault': ('quantiles', 'OrDefault'), 'groupArraySampleOrDefault': ('groupArraySample', 'OrDefault'), 'deltaSumOrDefault': ('deltaSum', 'OrDefault'), 'minOrDefault': ('min', 'OrDefault'), 'stddevPopOrDefault': ('stddevPop', 'OrDefault'), 'quantileTimingOrDefault': ('quantileTiming', 'OrDefault'), 'groupBitmapOrOrDefault': ('groupBitmapOr', 'OrDefault'), 'skewSampOrDefault': ('skewSamp', 'OrDefault'), 'uniqOrDefault': ('uniq', 'OrDefault'), 'covarSampOrDefault': ('covarSamp', 'OrDefault'), 'groupUniqArrayOrDefault': ('groupUniqArray', 'OrDefault'), 'quantileBFloat16WeightedOrDefault': ('quantileBFloat16Weighted', 'OrDefault'), 'retentionOrDefault': ('retention', 'OrDefault'), 'minMapOrDefault': ('minMap', 'OrDefault'), 'uniqExactOrDefault': ('uniqExact', 'OrDefault'), 'deltaSumTimestampOrDefault': ('deltaSumTimestamp', 'OrDefault'), 'groupArrayMovingAvgOrDefault': ('groupArrayMovingAvg', 'OrDefault'), 'uniqUpToOrDefault': ('uniqUpTo', 'OrDefault'), 'quantilesDeterministicOrDefault': ('quantilesDeterministic', 'OrDefault'), 'theilsUOrDefault': ('theilsU', 'OrDefault'), 'stddevSampOrDefault': ('stddevSamp', 'OrDefault'), 'windowFunnelOrDefault': ('windowFunnel', 'OrDefault'), 'groupArrayMovingSumOrDefault': ('groupArrayMovingSum', 'OrDefault'), 'maxMapOrDefault': ('maxMap', 'OrDefault'), 'quantilesTimingOrDefault': ('quantilesTiming', 'OrDefault'), 'intervalLengthSumOrDefault': ('intervalLengthSum', 'OrDefault'), 'varSampOrDefault': ('varSamp', 'OrDefault'), 'sumOrDefault': ('sum', 'OrDefault'), 'sumKahanOrDefault': ('sumKahan', 'OrDefault'), 'cramersVOrDefault': ('cramersV', 'OrDefault'), 'uniqHLL12OrDefault': ('uniqHLL12', 'OrDefault'), 'histogramOrNull': ('histogram', 'OrNull'), 'groupBitmapXorOrNull': ('groupBitmapXor', 'OrNull'), 'topKWeightedOrNull': ('topKWeighted', 'OrNull'), 'quantileExactLowOrNull': ('quantileExactLow', 'OrNull'), 'groupBitmapAndOrNull': ('groupBitmapAnd', 'OrNull'), 'quantileGKOrNull': ('quantileGK', 'OrNull'), 'quantilesGKOrNull': ('quantilesGK', 'OrNull'), 'mannWhitneyUTestOrNull': ('mannWhitneyUTest', 'OrNull'), 'studentTTestOrNull': ('studentTTest', 'OrNull'), 'sequenceCountOrNull': ('sequenceCount', 'OrNull'), 'sequenceNextNodeOrNull': ('sequenceNextNode', 'OrNull'), 'exponentialMovingAverageOrNull': ('exponentialMovingAverage', 'OrNull'), 'quantilesExactHighOrNull': ('quantilesExactHigh', 'OrNull'), 'kurtSampOrNull': ('kurtSamp', 'OrNull'), 'quantileTDigestOrNull': ('quantileTDigest', 'OrNull'), 'exponentialTimeDecayedAvgOrNull': ('exponentialTimeDecayedAvg', 'OrNull'), 'skewPopOrNull': ('skewPop', 'OrNull'), 'sumWithOverflowOrNull': ('sumWithOverflow', 'OrNull'), 'kolmogorovSmirnovTestOrNull': ('kolmogorovSmirnovTest', 'OrNull'), 'medianOrNull': ('median', 'OrNull'), 'groupBitAndOrNull': ('groupBitAnd', 'OrNull'), 'quantilesExactOrNull': ('quantilesExact', 'OrNull'), 'meanZTestOrNull': ('meanZTest', 'OrNull'), 'largestTriangleThreeBucketsOrNull': ('largestTriangleThreeBuckets', 'OrNull'), 'covarPopOrNull': ('covarPop', 'OrNull'), 'sequenceMatchOrNull': ('sequenceMatch', 'OrNull'), 'entropyOrNull': ('entropy', 'OrNull'), 'cramersVBiasCorrectedOrNull': ('cramersVBiasCorrected', 'OrNull'), 'welchTTestOrNull': ('welchTTest', 'OrNull'), 'groupBitmapOrNull': ('groupBitmap', 'OrNull'), 'simpleLinearRegressionOrNull': ('simpleLinearRegression', 'OrNull'), 'quantilesTDigestWeightedOrNull': ('quantilesTDigestWeighted', 'OrNull'), 'anyHeavyOrNull': ('anyHeavy', 'OrNull'), 'anyLastOrNull': ('anyLast', 'OrNull'), 'sparkBarOrNull': ('sparkBar', 'OrNull'), 'groupBitXorOrNull': ('groupBitXor', 'OrNull'), 'sumMapOrNull': ('sumMap', 'OrNull'), 'avgOrNull': ('avg', 'OrNull'), 'quantilesInterpolatedWeightedOrNull': ('quantilesInterpolatedWeighted', 'OrNull'), 'first_valueOrNull': ('first_value', 'OrNull'), 'corrOrNull': ('corr', 'OrNull'), 'quantileExactWeightedOrNull': ('quantileExactWeighted', 'OrNull'), 'maxIntersectionsPositionOrNull': ('maxIntersectionsPosition', 'OrNull'), 'quantileInterpolatedWeightedOrNull': ('quantileInterpolatedWeighted', 'OrNull'), 'quantilesTDigestOrNull': ('quantilesTDigest', 'OrNull'), 'topKOrNull': ('topK', 'OrNull'), 'quantilesBFloat16OrNull': ('quantilesBFloat16', 'OrNull'), 'argMinOrNull': ('argMin', 'OrNull'), 'maxIntersectionsOrNull': ('maxIntersections', 'OrNull'), 'maxOrNull': ('max', 'OrNull'), 'uniqThetaOrNull': ('uniqTheta', 'OrNull'), 'avgWeightedOrNull': ('avgWeighted', 'OrNull'), 'countOrNull': ('count', 'OrNull'), 'stochasticLogisticRegressionOrNull': ('stochasticLogisticRegression', 'OrNull'), 'quantileDeterministicOrNull': ('quantileDeterministic', 'OrNull'), 'uniqCombined64OrNull': ('uniqCombined64', 'OrNull'), 'sumCountOrNull': ('sumCount', 'OrNull'), 'kurtPopOrNull': ('kurtPop', 'OrNull'), 'groupBitOrOrNull': ('groupBitOr', 'OrNull'), 'groupArrayInsertAtOrNull': ('groupArrayInsertAt', 'OrNull'), 'uniqCombinedOrNull': ('uniqCombined', 'OrNull'), 'argMaxOrNull': ('argMax', 'OrNull'), 'contingencyOrNull': ('contingency', 'OrNull'), 'quantilesExactWeightedOrNull': ('quantilesExactWeighted', 'OrNull'), 'groupArrayOrNull': ('groupArray', 'OrNull'), 'quantileTDigestWeightedOrNull': ('quantileTDigestWeighted', 'OrNull'), 'quantileExactHighOrNull': ('quantileExactHigh', 'OrNull'), 'anyOrNull': ('any', 'OrNull'), 'quantilesTimingWeightedOrNull': ('quantilesTimingWeighted', 'OrNull'), 'rankCorrOrNull': ('rankCorr', 'OrNull'), 'quantileTimingWeightedOrNull': ('quantileTimingWeighted', 'OrNull'), 'quantileOrNull': ('quantile', 'OrNull'), 'stochasticLinearRegressionOrNull': ('stochasticLinearRegression', 'OrNull'), 'last_valueOrNull': ('last_value', 'OrNull'), 'quantilesExactLowOrNull': ('quantilesExactLow', 'OrNull'), 'groupArrayLastOrNull': ('groupArrayLast', 'OrNull'), 'boundingRatioOrNull': ('boundingRatio', 'OrNull'), 'quantileBFloat16OrNull': ('quantileBFloat16', 'OrNull'), 'categoricalInformationValueOrNull': ('categoricalInformationValue', 'OrNull'), 'quantilesBFloat16WeightedOrNull': ('quantilesBFloat16Weighted', 'OrNull'), 'quantileExactOrNull': ('quantileExact', 'OrNull'), 'varPopOrNull': ('varPop', 'OrNull'), 'quantilesOrNull': ('quantiles', 'OrNull'), 'groupArraySampleOrNull': ('groupArraySample', 'OrNull'), 'deltaSumOrNull': ('deltaSum', 'OrNull'), 'minOrNull': ('min', 'OrNull'), 'stddevPopOrNull': ('stddevPop', 'OrNull'), 'quantileTimingOrNull': ('quantileTiming', 'OrNull'), 'groupBitmapOrOrNull': ('groupBitmapOr', 'OrNull'), 'skewSampOrNull': ('skewSamp', 'OrNull'), 'uniqOrNull': ('uniq', 'OrNull'), 'covarSampOrNull': ('covarSamp', 'OrNull'), 'groupUniqArrayOrNull': ('groupUniqArray', 'OrNull'), 'quantileBFloat16WeightedOrNull': ('quantileBFloat16Weighted', 'OrNull'), 'retentionOrNull': ('retention', 'OrNull'), 'minMapOrNull': ('minMap', 'OrNull'), 'uniqExactOrNull': ('uniqExact', 'OrNull'), 'deltaSumTimestampOrNull': ('deltaSumTimestamp', 'OrNull'), 'groupArrayMovingAvgOrNull': ('groupArrayMovingAvg', 'OrNull'), 'uniqUpToOrNull': ('uniqUpTo', 'OrNull'), 'quantilesDeterministicOrNull': ('quantilesDeterministic', 'OrNull'), 'theilsUOrNull': ('theilsU', 'OrNull'), 'stddevSampOrNull': ('stddevSamp', 'OrNull'), 'windowFunnelOrNull': ('windowFunnel', 'OrNull'), 'groupArrayMovingSumOrNull': ('groupArrayMovingSum', 'OrNull'), 'maxMapOrNull': ('maxMap', 'OrNull'), 'quantilesTimingOrNull': ('quantilesTiming', 'OrNull'), 'intervalLengthSumOrNull': ('intervalLengthSum', 'OrNull'), 'varSampOrNull': ('varSamp', 'OrNull'), 'sumOrNull': ('sum', 'OrNull'), 'sumKahanOrNull': ('sumKahan', 'OrNull'), 'cramersVOrNull': ('cramersV', 'OrNull'), 'uniqHLL12OrNull': ('uniqHLL12', 'OrNull'), 'histogramResample': ('histogram', 'Resample'), 'groupBitmapXorResample': ('groupBitmapXor', 'Resample'), 'topKWeightedResample': ('topKWeighted', 'Resample'), 'quantileExactLowResample': ('quantileExactLow', 'Resample'), 'groupBitmapAndResample': ('groupBitmapAnd', 'Resample'), 'quantileGKResample': ('quantileGK', 'Resample'), 'quantilesGKResample': ('quantilesGK', 'Resample'), 'mannWhitneyUTestResample': ('mannWhitneyUTest', 'Resample'), 'studentTTestResample': ('studentTTest', 'Resample'), 'sequenceCountResample': ('sequenceCount', 'Resample'), 'sequenceNextNodeResample': ('sequenceNextNode', 'Resample'), 'exponentialMovingAverageResample': ('exponentialMovingAverage', 'Resample'), 'quantilesExactHighResample': ('quantilesExactHigh', 'Resample'), 'kurtSampResample': ('kurtSamp', 'Resample'), 'quantileTDigestResample': ('quantileTDigest', 'Resample'), 'exponentialTimeDecayedAvgResample': ('exponentialTimeDecayedAvg', 'Resample'), 'skewPopResample': ('skewPop', 'Resample'), 'sumWithOverflowResample': ('sumWithOverflow', 'Resample'), 'kolmogorovSmirnovTestResample': ('kolmogorovSmirnovTest', 'Resample'), 'medianResample': ('median', 'Resample'), 'groupBitAndResample': ('groupBitAnd', 'Resample'), 'quantilesExactResample': ('quantilesExact', 'Resample'), 'meanZTestResample': ('meanZTest', 'Resample'), 'largestTriangleThreeBucketsResample': ('largestTriangleThreeBuckets', 'Resample'), 'covarPopResample': ('covarPop', 'Resample'), 'sequenceMatchResample': ('sequenceMatch', 'Resample'), 'entropyResample': ('entropy', 'Resample'), 'cramersVBiasCorrectedResample': ('cramersVBiasCorrected', 'Resample'), 'welchTTestResample': ('welchTTest', 'Resample'), 'groupBitmapResample': ('groupBitmap', 'Resample'), 'simpleLinearRegressionResample': ('simpleLinearRegression', 'Resample'), 'quantilesTDigestWeightedResample': ('quantilesTDigestWeighted', 'Resample'), 'anyHeavyResample': ('anyHeavy', 'Resample'), 'anyLastResample': ('anyLast', 'Resample'), 'sparkBarResample': ('sparkBar', 'Resample'), 'groupBitXorResample': ('groupBitXor', 'Resample'), 'sumMapResample': ('sumMap', 'Resample'), 'avgResample': ('avg', 'Resample'), 'quantilesInterpolatedWeightedResample': ('quantilesInterpolatedWeighted', 'Resample'), 'first_valueResample': ('first_value', 'Resample'), 'corrResample': ('corr', 'Resample'), 'quantileExactWeightedResample': ('quantileExactWeighted', 'Resample'), 'maxIntersectionsPositionResample': ('maxIntersectionsPosition', 'Resample'), 'quantileInterpolatedWeightedResample': ('quantileInterpolatedWeighted', 'Resample'), 'quantilesTDigestResample': ('quantilesTDigest', 'Resample'), 'topKResample': ('topK', 'Resample'), 'quantilesBFloat16Resample': ('quantilesBFloat16', 'Resample'), 'argMinResample': ('argMin', 'Resample'), 'maxIntersectionsResample': ('maxIntersections', 'Resample'), 'maxResample': ('max', 'Resample'), 'uniqThetaResample': ('uniqTheta', 'Resample'), 'avgWeightedResample': ('avgWeighted', 'Resample'), 'countResample': ('count', 'Resample'), 'stochasticLogisticRegressionResample': ('stochasticLogisticRegression', 'Resample'), 'quantileDeterministicResample': ('quantileDeterministic', 'Resample'), 'uniqCombined64Resample': ('uniqCombined64', 'Resample'), 'sumCountResample': ('sumCount', 'Resample'), 'kurtPopResample': ('kurtPop', 'Resample'), 'groupBitOrResample': ('groupBitOr', 'Resample'), 'groupArrayInsertAtResample': ('groupArrayInsertAt', 'Resample'), 'uniqCombinedResample': ('uniqCombined', 'Resample'), 'argMaxResample': ('argMax', 'Resample'), 'contingencyResample': ('contingency', 'Resample'), 'quantilesExactWeightedResample': ('quantilesExactWeighted', 'Resample'), 'groupArrayResample': ('groupArray', 'Resample'), 'quantileTDigestWeightedResample': ('quantileTDigestWeighted', 'Resample'), 'quantileExactHighResample': ('quantileExactHigh', 'Resample'), 'anyResample': ('any', 'Resample'), 'quantilesTimingWeightedResample': ('quantilesTimingWeighted', 'Resample'), 'rankCorrResample': ('rankCorr', 'Resample'), 'quantileTimingWeightedResample': ('quantileTimingWeighted', 'Resample'), 'quantileResample': ('quantile', 'Resample'), 'stochasticLinearRegressionResample': ('stochasticLinearRegression', 'Resample'), 'last_valueResample': ('last_value', 'Resample'), 'quantilesExactLowResample': ('quantilesExactLow', 'Resample'), 'groupArrayLastResample': ('groupArrayLast', 'Resample'), 'boundingRatioResample': ('boundingRatio', 'Resample'), 'quantileBFloat16Resample': ('quantileBFloat16', 'Resample'), 'categoricalInformationValueResample': ('categoricalInformationValue', 'Resample'), 'quantilesBFloat16WeightedResample': ('quantilesBFloat16Weighted', 'Resample'), 'quantileExactResample': ('quantileExact', 'Resample'), 'varPopResample': ('varPop', 'Resample'), 'quantilesResample': ('quantiles', 'Resample'), 'groupArraySampleResample': ('groupArraySample', 'Resample'), 'deltaSumResample': ('deltaSum', 'Resample'), 'minResample': ('min', 'Resample'), 'stddevPopResample': ('stddevPop', 'Resample'), 'quantileTimingResample': ('quantileTiming', 'Resample'), 'groupBitmapOrResample': ('groupBitmapOr', 'Resample'), 'skewSampResample': ('skewSamp', 'Resample'), 'uniqResample': ('uniq', 'Resample'), 'covarSampResample': ('covarSamp', 'Resample'), 'groupUniqArrayResample': ('groupUniqArray', 'Resample'), 'quantileBFloat16WeightedResample': ('quantileBFloat16Weighted', 'Resample'), 'retentionResample': ('retention', 'Resample'), 'minMapResample': ('minMap', 'Resample'), 'uniqExactResample': ('uniqExact', 'Resample'), 'deltaSumTimestampResample': ('deltaSumTimestamp', 'Resample'), 'groupArrayMovingAvgResample': ('groupArrayMovingAvg', 'Resample'), 'uniqUpToResample': ('uniqUpTo', 'Resample'), 'quantilesDeterministicResample': ('quantilesDeterministic', 'Resample'), 'theilsUResample': ('theilsU', 'Resample'), 'stddevSampResample': ('stddevSamp', 'Resample'), 'windowFunnelResample': ('windowFunnel', 'Resample'), 'groupArrayMovingSumResample': ('groupArrayMovingSum', 'Resample'), 'maxMapResample': ('maxMap', 'Resample'), 'quantilesTimingResample': ('quantilesTiming', 'Resample'), 'intervalLengthSumResample': ('intervalLengthSum', 'Resample'), 'varSampResample': ('varSamp', 'Resample'), 'sumResample': ('sum', 'Resample'), 'sumKahanResample': ('sumKahan', 'Resample'), 'cramersVResample': ('cramersV', 'Resample'), 'uniqHLL12Resample': ('uniqHLL12', 'Resample'), 'histogramArgMin': ('histogram', 'ArgMin'), 'groupBitmapXorArgMin': ('groupBitmapXor', 'ArgMin'), 'topKWeightedArgMin': ('topKWeighted', 'ArgMin'), 'quantileExactLowArgMin': ('quantileExactLow', 'ArgMin'), 'groupBitmapAndArgMin': ('groupBitmapAnd', 'ArgMin'), 'quantileGKArgMin': ('quantileGK', 'ArgMin'), 'quantilesGKArgMin': ('quantilesGK', 'ArgMin'), 'mannWhitneyUTestArgMin': ('mannWhitneyUTest', 'ArgMin'), 'studentTTestArgMin': ('studentTTest', 'ArgMin'), 'sequenceCountArgMin': ('sequenceCount', 'ArgMin'), 'sequenceNextNodeArgMin': ('sequenceNextNode', 'ArgMin'), 'exponentialMovingAverageArgMin': ('exponentialMovingAverage', 'ArgMin'), 'quantilesExactHighArgMin': ('quantilesExactHigh', 'ArgMin'), 'kurtSampArgMin': ('kurtSamp', 'ArgMin'), 'quantileTDigestArgMin': ('quantileTDigest', 'ArgMin'), 'exponentialTimeDecayedAvgArgMin': ('exponentialTimeDecayedAvg', 'ArgMin'), 'skewPopArgMin': ('skewPop', 'ArgMin'), 'sumWithOverflowArgMin': ('sumWithOverflow', 'ArgMin'), 'kolmogorovSmirnovTestArgMin': ('kolmogorovSmirnovTest', 'ArgMin'), 'medianArgMin': ('median', 'ArgMin'), 'groupBitAndArgMin': ('groupBitAnd', 'ArgMin'), 'quantilesExactArgMin': ('quantilesExact', 'ArgMin'), 'meanZTestArgMin': ('meanZTest', 'ArgMin'), 'largestTriangleThreeBucketsArgMin': ('largestTriangleThreeBuckets', 'ArgMin'), 'covarPopArgMin': ('covarPop', 'ArgMin'), 'sequenceMatchArgMin': ('sequenceMatch', 'ArgMin'), 'entropyArgMin': ('entropy', 'ArgMin'), 'cramersVBiasCorrectedArgMin': ('cramersVBiasCorrected', 'ArgMin'), 'welchTTestArgMin': ('welchTTest', 'ArgMin'), 'groupBitmapArgMin': ('groupBitmap', 'ArgMin'), 'simpleLinearRegressionArgMin': ('simpleLinearRegression', 'ArgMin'), 'quantilesTDigestWeightedArgMin': ('quantilesTDigestWeighted', 'ArgMin'), 'anyHeavyArgMin': ('anyHeavy', 'ArgMin'), 'anyLastArgMin': ('anyLast', 'ArgMin'), 'sparkBarArgMin': ('sparkBar', 'ArgMin'), 'groupBitXorArgMin': ('groupBitXor', 'ArgMin'), 'sumMapArgMin': ('sumMap', 'ArgMin'), 'avgArgMin': ('avg', 'ArgMin'), 'quantilesInterpolatedWeightedArgMin': ('quantilesInterpolatedWeighted', 'ArgMin'), 'first_valueArgMin': ('first_value', 'ArgMin'), 'corrArgMin': ('corr', 'ArgMin'), 'quantileExactWeightedArgMin': ('quantileExactWeighted', 'ArgMin'), 'maxIntersectionsPositionArgMin': ('maxIntersectionsPosition', 'ArgMin'), 'quantileInterpolatedWeightedArgMin': ('quantileInterpolatedWeighted', 'ArgMin'), 'quantilesTDigestArgMin': ('quantilesTDigest', 'ArgMin'), 'topKArgMin': ('topK', 'ArgMin'), 'quantilesBFloat16ArgMin': ('quantilesBFloat16', 'ArgMin'), 'argMinArgMin': ('argMin', 'ArgMin'), 'maxIntersectionsArgMin': ('maxIntersections', 'ArgMin'), 'maxArgMin': ('max', 'ArgMin'), 'uniqThetaArgMin': ('uniqTheta', 'ArgMin'), 'avgWeightedArgMin': ('avgWeighted', 'ArgMin'), 'countArgMin': ('count', 'ArgMin'), 'stochasticLogisticRegressionArgMin': ('stochasticLogisticRegression', 'ArgMin'), 'quantileDeterministicArgMin': ('quantileDeterministic', 'ArgMin'), 'uniqCombined64ArgMin': ('uniqCombined64', 'ArgMin'), 'sumCountArgMin': ('sumCount', 'ArgMin'), 'kurtPopArgMin': ('kurtPop', 'ArgMin'), 'groupBitOrArgMin': ('groupBitOr', 'ArgMin'), 'groupArrayInsertAtArgMin': ('groupArrayInsertAt', 'ArgMin'), 'uniqCombinedArgMin': ('uniqCombined', 'ArgMin'), 'argMaxArgMin': ('argMax', 'ArgMin'), 'contingencyArgMin': ('contingency', 'ArgMin'), 'quantilesExactWeightedArgMin': ('quantilesExactWeighted', 'ArgMin'), 'groupArrayArgMin': ('groupArray', 'ArgMin'), 'quantileTDigestWeightedArgMin': ('quantileTDigestWeighted', 'ArgMin'), 'quantileExactHighArgMin': ('quantileExactHigh', 'ArgMin'), 'anyArgMin': ('any', 'ArgMin'), 'quantilesTimingWeightedArgMin': ('quantilesTimingWeighted', 'ArgMin'), 'rankCorrArgMin': ('rankCorr', 'ArgMin'), 'quantileTimingWeightedArgMin': ('quantileTimingWeighted', 'ArgMin'), 'quantileArgMin': ('quantile', 'ArgMin'), 'stochasticLinearRegressionArgMin': ('stochasticLinearRegression', 'ArgMin'), 'last_valueArgMin': ('last_value', 'ArgMin'), 'quantilesExactLowArgMin': ('quantilesExactLow', 'ArgMin'), 'groupArrayLastArgMin': ('groupArrayLast', 'ArgMin'), 'boundingRatioArgMin': ('boundingRatio', 'ArgMin'), 'quantileBFloat16ArgMin': ('quantileBFloat16', 'ArgMin'), 'categoricalInformationValueArgMin': ('categoricalInformationValue', 'ArgMin'), 'quantilesBFloat16WeightedArgMin': ('quantilesBFloat16Weighted', 'ArgMin'), 'quantileExactArgMin': ('quantileExact', 'ArgMin'), 'varPopArgMin': ('varPop', 'ArgMin'), 'quantilesArgMin': ('quantiles', 'ArgMin'), 'groupArraySampleArgMin': ('groupArraySample', 'ArgMin'), 'deltaSumArgMin': ('deltaSum', 'ArgMin'), 'minArgMin': ('min', 'ArgMin'), 'stddevPopArgMin': ('stddevPop', 'ArgMin'), 'quantileTimingArgMin': ('quantileTiming', 'ArgMin'), 'groupBitmapOrArgMin': ('groupBitmapOr', 'ArgMin'), 'skewSampArgMin': ('skewSamp', 'ArgMin'), 'uniqArgMin': ('uniq', 'ArgMin'), 'covarSampArgMin': ('covarSamp', 'ArgMin'), 'groupUniqArrayArgMin': ('groupUniqArray', 'ArgMin'), 'quantileBFloat16WeightedArgMin': ('quantileBFloat16Weighted', 'ArgMin'), 'retentionArgMin': ('retention', 'ArgMin'), 'minMapArgMin': ('minMap', 'ArgMin'), 'uniqExactArgMin': ('uniqExact', 'ArgMin'), 'deltaSumTimestampArgMin': ('deltaSumTimestamp', 'ArgMin'), 'groupArrayMovingAvgArgMin': ('groupArrayMovingAvg', 'ArgMin'), 'uniqUpToArgMin': ('uniqUpTo', 'ArgMin'), 'quantilesDeterministicArgMin': ('quantilesDeterministic', 'ArgMin'), 'theilsUArgMin': ('theilsU', 'ArgMin'), 'stddevSampArgMin': ('stddevSamp', 'ArgMin'), 'windowFunnelArgMin': ('windowFunnel', 'ArgMin'), 'groupArrayMovingSumArgMin': ('groupArrayMovingSum', 'ArgMin'), 'maxMapArgMin': ('maxMap', 'ArgMin'), 'quantilesTimingArgMin': ('quantilesTiming', 'ArgMin'), 'intervalLengthSumArgMin': ('intervalLengthSum', 'ArgMin'), 'varSampArgMin': ('varSamp', 'ArgMin'), 'sumArgMin': ('sum', 'ArgMin'), 'sumKahanArgMin': ('sumKahan', 'ArgMin'), 'cramersVArgMin': ('cramersV', 'ArgMin'), 'uniqHLL12ArgMin': ('uniqHLL12', 'ArgMin'), 'histogramArgMax': ('histogram', 'ArgMax'), 'groupBitmapXorArgMax': ('groupBitmapXor', 'ArgMax'), 'topKWeightedArgMax': ('topKWeighted', 'ArgMax'), 'quantileExactLowArgMax': ('quantileExactLow', 'ArgMax'), 'groupBitmapAndArgMax': ('groupBitmapAnd', 'ArgMax'), 'quantileGKArgMax': ('quantileGK', 'ArgMax'), 'quantilesGKArgMax': ('quantilesGK', 'ArgMax'), 'mannWhitneyUTestArgMax': ('mannWhitneyUTest', 'ArgMax'), 'studentTTestArgMax': ('studentTTest', 'ArgMax'), 'sequenceCountArgMax': ('sequenceCount', 'ArgMax'), 'sequenceNextNodeArgMax': ('sequenceNextNode', 'ArgMax'), 'exponentialMovingAverageArgMax': ('exponentialMovingAverage', 'ArgMax'), 'quantilesExactHighArgMax': ('quantilesExactHigh', 'ArgMax'), 'kurtSampArgMax': ('kurtSamp', 'ArgMax'), 'quantileTDigestArgMax': ('quantileTDigest', 'ArgMax'), 'exponentialTimeDecayedAvgArgMax': ('exponentialTimeDecayedAvg', 'ArgMax'), 'skewPopArgMax': ('skewPop', 'ArgMax'), 'sumWithOverflowArgMax': ('sumWithOverflow', 'ArgMax'), 'kolmogorovSmirnovTestArgMax': ('kolmogorovSmirnovTest', 'ArgMax'), 'medianArgMax': ('median', 'ArgMax'), 'groupBitAndArgMax': ('groupBitAnd', 'ArgMax'), 'quantilesExactArgMax': ('quantilesExact', 'ArgMax'), 'meanZTestArgMax': ('meanZTest', 'ArgMax'), 'largestTriangleThreeBucketsArgMax': ('largestTriangleThreeBuckets', 'ArgMax'), 'covarPopArgMax': ('covarPop', 'ArgMax'), 'sequenceMatchArgMax': ('sequenceMatch', 'ArgMax'), 'entropyArgMax': ('entropy', 'ArgMax'), 'cramersVBiasCorrectedArgMax': ('cramersVBiasCorrected', 'ArgMax'), 'welchTTestArgMax': ('welchTTest', 'ArgMax'), 'groupBitmapArgMax': ('groupBitmap', 'ArgMax'), 'simpleLinearRegressionArgMax': ('simpleLinearRegression', 'ArgMax'), 'quantilesTDigestWeightedArgMax': ('quantilesTDigestWeighted', 'ArgMax'), 'anyHeavyArgMax': ('anyHeavy', 'ArgMax'), 'anyLastArgMax': ('anyLast', 'ArgMax'), 'sparkBarArgMax': ('sparkBar', 'ArgMax'), 'groupBitXorArgMax': ('groupBitXor', 'ArgMax'), 'sumMapArgMax': ('sumMap', 'ArgMax'), 'avgArgMax': ('avg', 'ArgMax'), 'quantilesInterpolatedWeightedArgMax': ('quantilesInterpolatedWeighted', 'ArgMax'), 'first_valueArgMax': ('first_value', 'ArgMax'), 'corrArgMax': ('corr', 'ArgMax'), 'quantileExactWeightedArgMax': ('quantileExactWeighted', 'ArgMax'), 'maxIntersectionsPositionArgMax': ('maxIntersectionsPosition', 'ArgMax'), 'quantileInterpolatedWeightedArgMax': ('quantileInterpolatedWeighted', 'ArgMax'), 'quantilesTDigestArgMax': ('quantilesTDigest', 'ArgMax'), 'topKArgMax': ('topK', 'ArgMax'), 'quantilesBFloat16ArgMax': ('quantilesBFloat16', 'ArgMax'), 'argMinArgMax': ('argMin', 'ArgMax'), 'maxIntersectionsArgMax': ('maxIntersections', 'ArgMax'), 'maxArgMax': ('max', 'ArgMax'), 'uniqThetaArgMax': ('uniqTheta', 'ArgMax'), 'avgWeightedArgMax': ('avgWeighted', 'ArgMax'), 'countArgMax': ('count', 'ArgMax'), 'stochasticLogisticRegressionArgMax': ('stochasticLogisticRegression', 'ArgMax'), 'quantileDeterministicArgMax': ('quantileDeterministic', 'ArgMax'), 'uniqCombined64ArgMax': ('uniqCombined64', 'ArgMax'), 'sumCountArgMax': ('sumCount', 'ArgMax'), 'kurtPopArgMax': ('kurtPop', 'ArgMax'), 'groupBitOrArgMax': ('groupBitOr', 'ArgMax'), 'groupArrayInsertAtArgMax': ('groupArrayInsertAt', 'ArgMax'), 'uniqCombinedArgMax': ('uniqCombined', 'ArgMax'), 'argMaxArgMax': ('argMax', 'ArgMax'), 'contingencyArgMax': ('contingency', 'ArgMax'), 'quantilesExactWeightedArgMax': ('quantilesExactWeighted', 'ArgMax'), 'groupArrayArgMax': ('groupArray', 'ArgMax'), 'quantileTDigestWeightedArgMax': ('quantileTDigestWeighted', 'ArgMax'), 'quantileExactHighArgMax': ('quantileExactHigh', 'ArgMax'), 'anyArgMax': ('any', 'ArgMax'), 'quantilesTimingWeightedArgMax': ('quantilesTimingWeighted', 'ArgMax'), 'rankCorrArgMax': ('rankCorr', 'ArgMax'), 'quantileTimingWeightedArgMax': ('quantileTimingWeighted', 'ArgMax'), 'quantileArgMax': ('quantile', 'ArgMax'), 'stochasticLinearRegressionArgMax': ('stochasticLinearRegression', 'ArgMax'), 'last_valueArgMax': ('last_value', 'ArgMax'), 'quantilesExactLowArgMax': ('quantilesExactLow', 'ArgMax'), 'groupArrayLastArgMax': ('groupArrayLast', 'ArgMax'), 'boundingRatioArgMax': ('boundingRatio', 'ArgMax'), 'quantileBFloat16ArgMax': ('quantileBFloat16', 'ArgMax'), 'categoricalInformationValueArgMax': ('categoricalInformationValue', 'ArgMax'), 'quantilesBFloat16WeightedArgMax': ('quantilesBFloat16Weighted', 'ArgMax'), 'quantileExactArgMax': ('quantileExact', 'ArgMax'), 'varPopArgMax': ('varPop', 'ArgMax'), 'quantilesArgMax': ('quantiles', 'ArgMax'), 'groupArraySampleArgMax': ('groupArraySample', 'ArgMax'), 'deltaSumArgMax': ('deltaSum', 'ArgMax'), 'minArgMax': ('min', 'ArgMax'), 'stddevPopArgMax': ('stddevPop', 'ArgMax'), 'quantileTimingArgMax': ('quantileTiming', 'ArgMax'), 'groupBitmapOrArgMax': ('groupBitmapOr', 'ArgMax'), 'skewSampArgMax': ('skewSamp', 'ArgMax'), 'uniqArgMax': ('uniq', 'ArgMax'), 'covarSampArgMax': ('covarSamp', 'ArgMax'), 'groupUniqArrayArgMax': ('groupUniqArray', 'ArgMax'), 'quantileBFloat16WeightedArgMax': ('quantileBFloat16Weighted', 'ArgMax'), 'retentionArgMax': ('retention', 'ArgMax'), 'minMapArgMax': ('minMap', 'ArgMax'), 'uniqExactArgMax': ('uniqExact', 'ArgMax'), 'deltaSumTimestampArgMax': ('deltaSumTimestamp', 'ArgMax'), 'groupArrayMovingAvgArgMax': ('groupArrayMovingAvg', 'ArgMax'), 'uniqUpToArgMax': ('uniqUpTo', 'ArgMax'), 'quantilesDeterministicArgMax': ('quantilesDeterministic', 'ArgMax'), 'theilsUArgMax': ('theilsU', 'ArgMax'), 'stddevSampArgMax': ('stddevSamp', 'ArgMax'), 'windowFunnelArgMax': ('windowFunnel', 'ArgMax'), 'groupArrayMovingSumArgMax': ('groupArrayMovingSum', 'ArgMax'), 'maxMapArgMax': ('maxMap', 'ArgMax'), 'quantilesTimingArgMax': ('quantilesTiming', 'ArgMax'), 'intervalLengthSumArgMax': ('intervalLengthSum', 'ArgMax'), 'varSampArgMax': ('varSamp', 'ArgMax'), 'sumArgMax': ('sum', 'ArgMax'), 'sumKahanArgMax': ('sumKahan', 'ArgMax'), 'cramersVArgMax': ('cramersV', 'ArgMax'), 'uniqHLL12ArgMax': ('uniqHLL12', 'ArgMax'), 'histogram': ('histogram', ''), 'groupBitmapXor': ('groupBitmapXor', ''), 'topKWeighted': ('topKWeighted', ''), 'quantileExactLow': ('quantileExactLow', ''), 'groupBitmapAnd': ('groupBitmapAnd', ''), 'quantileGK': ('quantileGK', ''), 'quantilesGK': ('quantilesGK', ''), 'mannWhitneyUTest': ('mannWhitneyUTest', ''), 'studentTTest': ('studentTTest', ''), 'sequenceCount': ('sequenceCount', ''), 'sequenceNextNode': ('sequenceNextNode', ''), 'exponentialMovingAverage': ('exponentialMovingAverage', ''), 'quantilesExactHigh': ('quantilesExactHigh', ''), 'kurtSamp': ('kurtSamp', ''), 'quantileTDigest': ('quantileTDigest', ''), 'exponentialTimeDecayedAvg': ('exponentialTimeDecayedAvg', ''), 'skewPop': ('skewPop', ''), 'sumWithOverflow': ('sumWithOverflow', ''), 'kolmogorovSmirnovTest': ('kolmogorovSmirnovTest', ''), 'median': ('median', ''), 'groupBitAnd': ('groupBitAnd', ''), 'quantilesExact': ('quantilesExact', ''), 'meanZTest': ('meanZTest', ''), 'largestTriangleThreeBuckets': ('largestTriangleThreeBuckets', ''), 'covarPop': ('covarPop', ''), 'sequenceMatch': ('sequenceMatch', ''), 'entropy': ('entropy', ''), 'cramersVBiasCorrected': ('cramersVBiasCorrected', ''), 'welchTTest': ('welchTTest', ''), 'groupBitmap': ('groupBitmap', ''), 'simpleLinearRegression': ('simpleLinearRegression', ''), 'quantilesTDigestWeighted': ('quantilesTDigestWeighted', ''), 'anyHeavy': ('anyHeavy', ''), 'anyLast': ('anyLast', ''), 'sparkBar': ('sparkBar', ''), 'groupBitXor': ('groupBitXor', ''), 'avg': ('avg', ''), 'quantilesInterpolatedWeighted': ('quantilesInterpolatedWeighted', ''), 'first_value': ('first_value', ''), 'corr': ('corr', ''), 'quantileExactWeighted': ('quantileExactWeighted', ''), 'maxIntersectionsPosition': ('maxIntersectionsPosition', ''), 'quantileInterpolatedWeighted': ('quantileInterpolatedWeighted', ''), 'quantilesTDigest': ('quantilesTDigest', ''), 'topK': ('topK', ''), 'quantilesBFloat16': ('quantilesBFloat16', ''), 'argMin': ('argMin', ''), 'maxIntersections': ('maxIntersections', ''), 'max': ('max', ''), 'uniqTheta': ('uniqTheta', ''), 'avgWeighted': ('avgWeighted', ''), 'count': ('count', ''), 'stochasticLogisticRegression': ('stochasticLogisticRegression', ''), 'quantileDeterministic': ('quantileDeterministic', ''), 'uniqCombined64': ('uniqCombined64', ''), 'sumCount': ('sumCount', ''), 'kurtPop': ('kurtPop', ''), 'groupBitOr': ('groupBitOr', ''), 'groupArrayInsertAt': ('groupArrayInsertAt', ''), 'uniqCombined': ('uniqCombined', ''), 'argMax': ('argMax', ''), 'contingency': ('contingency', ''), 'quantilesExactWeighted': ('quantilesExactWeighted', ''), 'groupArray': ('groupArray', ''), 'quantileTDigestWeighted': ('quantileTDigestWeighted', ''), 'quantileExactHigh': ('quantileExactHigh', ''), 'any': ('any', ''), 'quantilesTimingWeighted': ('quantilesTimingWeighted', ''), 'rankCorr': ('rankCorr', ''), 'quantileTimingWeighted': ('quantileTimingWeighted', ''), 'quantile': ('quantile', ''), 'stochasticLinearRegression': ('stochasticLinearRegression', ''), 'last_value': ('last_value', ''), 'quantilesExactLow': ('quantilesExactLow', ''), 'groupArrayLast': ('groupArrayLast', ''), 'boundingRatio': ('boundingRatio', ''), 'quantileBFloat16': ('quantileBFloat16', ''), 'categoricalInformationValue': ('categoricalInformationValue', ''), 'quantilesBFloat16Weighted': ('quantilesBFloat16Weighted', ''), 'quantileExact': ('quantileExact', ''), 'varPop': ('varPop', ''), 'quantiles': ('quantiles', ''), 'groupArraySample': ('groupArraySample', ''), 'deltaSum': ('deltaSum', ''), 'min': ('min', ''), 'stddevPop': ('stddevPop', ''), 'quantileTiming': ('quantileTiming', ''), 'groupBitmapOr': ('groupBitmapOr', ''), 'skewSamp': ('skewSamp', ''), 'uniq': ('uniq', ''), 'covarSamp': ('covarSamp', ''), 'groupUniqArray': ('groupUniqArray', ''), 'quantileBFloat16Weighted': ('quantileBFloat16Weighted', ''), 'retention': ('retention', ''), 'uniqExact': ('uniqExact', ''), 'deltaSumTimestamp': ('deltaSumTimestamp', ''), 'groupArrayMovingAvg': ('groupArrayMovingAvg', ''), 'uniqUpTo': ('uniqUpTo', ''), 'quantilesDeterministic': ('quantilesDeterministic', ''), 'theilsU': ('theilsU', ''), 'stddevSamp': ('stddevSamp', ''), 'windowFunnel': ('windowFunnel', ''), 'groupArrayMovingSum': ('groupArrayMovingSum', ''), 'quantilesTiming': ('quantilesTiming', ''), 'intervalLengthSum': ('intervalLengthSum', ''), 'varSamp': ('varSamp', ''), 'sum': ('sum', ''), 'sumKahan': ('sumKahan', ''), 'cramersV': ('cramersV', ''), 'uniqHLL12': ('uniqHLL12', '')}
FUNCTIONS_WITH_ALIASED_ARGS = {'TUPLE', 'STRUCT'}
FUNCTION_PARSERS = {'CAST': <function Parser.<lambda>>, 'CONVERT': <function Parser.<lambda>>, 'DECODE': <function Parser.<lambda>>, 'EXTRACT': <function Parser.<lambda>>, 'GAP_FILL': <function Parser.<lambda>>, 'JSON_OBJECT': <function Parser.<lambda>>, 'JSON_OBJECTAGG': <function Parser.<lambda>>, 'JSON_TABLE': <function Parser.<lambda>>, 'OPENJSON': <function Parser.<lambda>>, 'POSITION': <function Parser.<lambda>>, 'PREDICT': <function Parser.<lambda>>, 'SAFE_CAST': <function Parser.<lambda>>, 'STRING_AGG': <function Parser.<lambda>>, 'SUBSTRING': <function Parser.<lambda>>, 'TRIM': <function Parser.<lambda>>, 'TRY_CAST': <function Parser.<lambda>>, 'TRY_CONVERT': <function Parser.<lambda>>, 'ARRAYJOIN': <function ClickHouse.Parser.<lambda>>, 'QUANTILE': <function ClickHouse.Parser.<lambda>>}
NO_PAREN_FUNCTION_PARSERS = {'CASE': <function Parser.<lambda>>, 'CONNECT_BY_ROOT': <function Parser.<lambda>>, 'IF': <function Parser.<lambda>>, 'NEXT': <function Parser.<lambda>>}
RANGE_PARSERS = {<TokenType.BETWEEN: 'BETWEEN'>: <function Parser.<lambda>>, <TokenType.GLOB: 'GLOB'>: <function binary_range_parser.<locals>._parse_binary_range>, <TokenType.ILIKE: 'ILIKE'>: <function binary_range_parser.<locals>._parse_binary_range>, <TokenType.IN: 'IN'>: <function Parser.<lambda>>, <TokenType.IRLIKE: 'IRLIKE'>: <function binary_range_parser.<locals>._parse_binary_range>, <TokenType.IS: 'IS'>: <function Parser.<lambda>>, <TokenType.LIKE: 'LIKE'>: <function binary_range_parser.<locals>._parse_binary_range>, <TokenType.OVERLAPS: 'OVERLAPS'>: <function binary_range_parser.<locals>._parse_binary_range>, <TokenType.RLIKE: 'RLIKE'>: <function binary_range_parser.<locals>._parse_binary_range>, <TokenType.SIMILAR_TO: 'SIMILAR_TO'>: <function binary_range_parser.<locals>._parse_binary_range>, <TokenType.FOR: 'FOR'>: <function Parser.<lambda>>, <TokenType.GLOBAL: 'GLOBAL'>: <function ClickHouse.Parser.<lambda>>}
COLUMN_OPERATORS = {<TokenType.DOT: 'DOT'>: None, <TokenType.DCOLON: 'DCOLON'>: <function Parser.<lambda>>, <TokenType.ARROW: 'ARROW'>: <function Parser.<lambda>>, <TokenType.DARROW: 'DARROW'>: <function Parser.<lambda>>, <TokenType.HASH_ARROW: 'HASH_ARROW'>: <function Parser.<lambda>>, <TokenType.DHASH_ARROW: 'DHASH_ARROW'>: <function Parser.<lambda>>}
JOIN_KINDS = {<TokenType.ANTI: 'ANTI'>, <TokenType.ASOF: 'ASOF'>, <TokenType.ANY: 'ANY'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.CROSS: 'CROSS'>, <TokenType.OUTER: 'OUTER'>, <TokenType.SEMI: 'SEMI'>, <TokenType.INNER: 'INNER'>, <TokenType.STRAIGHT_JOIN: 'STRAIGHT_JOIN'>}
TABLE_ALIAS_TOKENS = {<TokenType.COMMENT: 'COMMENT'>, <TokenType.RECURSIVE: 'RECURSIVE'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.DEFAULT: 'DEFAULT'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.END: 'END'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.REFERENCES: 'REFERENCES'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.NAME: 'NAME'>, <TokenType.SEQUENCE: 'SEQUENCE'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.FUNCTION: 'FUNCTION'>, <TokenType.ASC: 'ASC'>, <TokenType.OPERATOR: 'OPERATOR'>, <TokenType.OVERLAPS: 'OVERLAPS'>, <TokenType.PRAGMA: 'PRAGMA'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.SCHEMA: 'SCHEMA'>, <TokenType.PIVOT: 'PIVOT'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.OVERWRITE: 'OVERWRITE'>, <TokenType.STREAMLIT: 'STREAMLIT'>, <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.WAREHOUSE: 'WAREHOUSE'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.COLUMN: 'COLUMN'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.UNIQUE: 'UNIQUE'>, <TokenType.SOME: 'SOME'>, <TokenType.CONSTRAINT: 'CONSTRAINT'>, <TokenType.STRAIGHT_JOIN: 'STRAIGHT_JOIN'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.NESTED: 'NESTED'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.DESC: 'DESC'>, <TokenType.IDENTIFIER: 'IDENTIFIER'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.XML: 'XML'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.ORDINALITY: 'ORDINALITY'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.INDEX: 'INDEX'>, <TokenType.TDIGEST: 'TDIGEST'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.SET: 'SET'>, <TokenType.LOAD: 'LOAD'>, <TokenType.RANGE: 'RANGE'>, <TokenType.UUID: 'UUID'>, <TokenType.INT256: 'INT256'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.PROCEDURE: 'PROCEDURE'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.VAR: 'VAR'>, <TokenType.TRUNCATE: 'TRUNCATE'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.TIME: 'TIME'>, <TokenType.VOLATILE: 'VOLATILE'>, <TokenType.ENUM: 'ENUM'>, <TokenType.SUPER: 'SUPER'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.UINT128: 'UINT128'>, <TokenType.MAP: 'MAP'>, <TokenType.EXECUTE: 'EXECUTE'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.TRUE: 'TRUE'>, <TokenType.ESCAPE: 'ESCAPE'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.VECTOR: 'VECTOR'>, <TokenType.DELETE: 'DELETE'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.COPY: 'COPY'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.FALSE: 'FALSE'>, <TokenType.REPLACE: 'REPLACE'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.USE: 'USE'>, <TokenType.TOP: 'TOP'>, <TokenType.DICTIONARY: 'DICTIONARY'>, <TokenType.BEGIN: 'BEGIN'>, <TokenType.ALL: 'ALL'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.TAG: 'TAG'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.UPDATE: 'UPDATE'>, <TokenType.TEXT: 'TEXT'>, <TokenType.MONEY: 'MONEY'>, <TokenType.CUBE: 'CUBE'>, <TokenType.KILL: 'KILL'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.FILTER: 'FILTER'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.YEAR: 'YEAR'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.IPV6: 'IPV6'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.DATE32: 'DATE32'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.FIRST: 'FIRST'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.RENAME: 'RENAME'>, <TokenType.DIV: 'DIV'>, <TokenType.TABLE: 'TABLE'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.CHAR: 'CHAR'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.JSON: 'JSON'>, <TokenType.UNNEST: 'UNNEST'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.VIEW: 'VIEW'>, <TokenType.SHOW: 'SHOW'>, <TokenType.REFRESH: 'REFRESH'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.STORAGE_INTEGRATION: 'STORAGE_INTEGRATION'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.BINARY: 'BINARY'>, <TokenType.IPV4: 'IPV4'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.MERGE: 'MERGE'>, <TokenType.CASE: 'CASE'>, <TokenType.CACHE: 'CACHE'>, <TokenType.PERCENT: 'PERCENT'>, <TokenType.INET: 'INET'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.UNIQUEIDENTIFIER: 'UNIQUEIDENTIFIER'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.INT128: 'INT128'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.IS: 'IS'>, <TokenType.ROWS: 'ROWS'>, <TokenType.KEEP: 'KEEP'>, <TokenType.PARTITION: 'PARTITION'>, <TokenType.DESCRIBE: 'DESCRIBE'>, <TokenType.NULL: 'NULL'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.DATE: 'DATE'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.UNPIVOT: 'UNPIVOT'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.UINT256: 'UINT256'>, <TokenType.COMMIT: 'COMMIT'>, <TokenType.INT: 'INT'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.ROLLUP: 'ROLLUP'>, <TokenType.ROW: 'ROW'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.JSONB: 'JSONB'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.MODEL: 'MODEL'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.TEMPORARY: 'TEMPORARY'>, <TokenType.NEXT: 'NEXT'>, <TokenType.UINT: 'UINT'>, <TokenType.BIT: 'BIT'>, <TokenType.DATABASE: 'DATABASE'>, <TokenType.LIST: 'LIST'>, <TokenType.COMMAND: 'COMMAND'>}
ALIAS_TOKENS = {<TokenType.COMMENT: 'COMMENT'>, <TokenType.RECURSIVE: 'RECURSIVE'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.DEFAULT: 'DEFAULT'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.END: 'END'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.REFERENCES: 'REFERENCES'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.NAME: 'NAME'>, <TokenType.SEQUENCE: 'SEQUENCE'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.FUNCTION: 'FUNCTION'>, <TokenType.ASC: 'ASC'>, <TokenType.OPERATOR: 'OPERATOR'>, <TokenType.OVERLAPS: 'OVERLAPS'>, <TokenType.PRAGMA: 'PRAGMA'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.SCHEMA: 'SCHEMA'>, <TokenType.PIVOT: 'PIVOT'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.OVERWRITE: 'OVERWRITE'>, <TokenType.STREAMLIT: 'STREAMLIT'>, <TokenType.ASOF: 'ASOF'>, <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.FULL: 'FULL'>, <TokenType.WAREHOUSE: 'WAREHOUSE'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.COLUMN: 'COLUMN'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.UNIQUE: 'UNIQUE'>, <TokenType.SOME: 'SOME'>, <TokenType.CONSTRAINT: 'CONSTRAINT'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.APPLY: 'APPLY'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.NESTED: 'NESTED'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.DESC: 'DESC'>, <TokenType.IDENTIFIER: 'IDENTIFIER'>, <TokenType.WINDOW: 'WINDOW'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.XML: 'XML'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.LEFT: 'LEFT'>, <TokenType.ORDINALITY: 'ORDINALITY'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.INDEX: 'INDEX'>, <TokenType.ANY: 'ANY'>, <TokenType.TDIGEST: 'TDIGEST'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.SET: 'SET'>, <TokenType.LOAD: 'LOAD'>, <TokenType.RANGE: 'RANGE'>, <TokenType.UUID: 'UUID'>, <TokenType.INT256: 'INT256'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.PROCEDURE: 'PROCEDURE'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.VAR: 'VAR'>, <TokenType.TRUNCATE: 'TRUNCATE'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.TIME: 'TIME'>, <TokenType.VOLATILE: 'VOLATILE'>, <TokenType.ENUM: 'ENUM'>, <TokenType.SUPER: 'SUPER'>, <TokenType.RIGHT: 'RIGHT'>, <TokenType.ANTI: 'ANTI'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.UINT128: 'UINT128'>, <TokenType.MAP: 'MAP'>, <TokenType.EXECUTE: 'EXECUTE'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.TRUE: 'TRUE'>, <TokenType.ESCAPE: 'ESCAPE'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.VECTOR: 'VECTOR'>, <TokenType.DELETE: 'DELETE'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.COPY: 'COPY'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.SEMI: 'SEMI'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.FALSE: 'FALSE'>, <TokenType.REPLACE: 'REPLACE'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.USE: 'USE'>, <TokenType.TOP: 'TOP'>, <TokenType.DICTIONARY: 'DICTIONARY'>, <TokenType.BEGIN: 'BEGIN'>, <TokenType.ALL: 'ALL'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.TAG: 'TAG'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.UPDATE: 'UPDATE'>, <TokenType.TEXT: 'TEXT'>, <TokenType.MONEY: 'MONEY'>, <TokenType.CUBE: 'CUBE'>, <TokenType.KILL: 'KILL'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.FILTER: 'FILTER'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.YEAR: 'YEAR'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.IPV6: 'IPV6'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.DATE32: 'DATE32'>, <TokenType.FINAL: 'FINAL'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.FIRST: 'FIRST'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.RENAME: 'RENAME'>, <TokenType.DIV: 'DIV'>, <TokenType.TABLE: 'TABLE'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.CHAR: 'CHAR'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.JSON: 'JSON'>, <TokenType.UNNEST: 'UNNEST'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.VIEW: 'VIEW'>, <TokenType.SHOW: 'SHOW'>, <TokenType.REFRESH: 'REFRESH'>, <TokenType.SETTINGS: 'SETTINGS'>, <TokenType.STORAGE_INTEGRATION: 'STORAGE_INTEGRATION'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.NATURAL: 'NATURAL'>, <TokenType.BINARY: 'BINARY'>, <TokenType.IPV4: 'IPV4'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.MERGE: 'MERGE'>, <TokenType.CASE: 'CASE'>, <TokenType.CACHE: 'CACHE'>, <TokenType.PERCENT: 'PERCENT'>, <TokenType.INET: 'INET'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.UNIQUEIDENTIFIER: 'UNIQUEIDENTIFIER'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.INT128: 'INT128'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.IS: 'IS'>, <TokenType.ROWS: 'ROWS'>, <TokenType.KEEP: 'KEEP'>, <TokenType.OFFSET: 'OFFSET'>, <TokenType.PARTITION: 'PARTITION'>, <TokenType.DESCRIBE: 'DESCRIBE'>, <TokenType.NULL: 'NULL'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.DATE: 'DATE'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.UNPIVOT: 'UNPIVOT'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.UINT256: 'UINT256'>, <TokenType.COMMIT: 'COMMIT'>, <TokenType.INT: 'INT'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.ROLLUP: 'ROLLUP'>, <TokenType.ROW: 'ROW'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.JSONB: 'JSONB'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.MODEL: 'MODEL'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.TEMPORARY: 'TEMPORARY'>, <TokenType.NEXT: 'NEXT'>, <TokenType.UINT: 'UINT'>, <TokenType.BIT: 'BIT'>, <TokenType.DATABASE: 'DATABASE'>, <TokenType.LIST: 'LIST'>, <TokenType.COMMAND: 'COMMAND'>}
LOG_DEFAULTS_TO_LN = True
QUERY_MODIFIER_PARSERS = {<TokenType.MATCH_RECOGNIZE: 'MATCH_RECOGNIZE'>: <function Parser.<lambda>>, <TokenType.PREWHERE: 'PREWHERE'>: <function Parser.<lambda>>, <TokenType.WHERE: 'WHERE'>: <function Parser.<lambda>>, <TokenType.GROUP_BY: 'GROUP_BY'>: <function Parser.<lambda>>, <TokenType.HAVING: 'HAVING'>: <function Parser.<lambda>>, <TokenType.QUALIFY: 'QUALIFY'>: <function Parser.<lambda>>, <TokenType.WINDOW: 'WINDOW'>: <function Parser.<lambda>>, <TokenType.ORDER_BY: 'ORDER_BY'>: <function Parser.<lambda>>, <TokenType.LIMIT: 'LIMIT'>: <function Parser.<lambda>>, <TokenType.FETCH: 'FETCH'>: <function Parser.<lambda>>, <TokenType.OFFSET: 'OFFSET'>: <function Parser.<lambda>>, <TokenType.FOR: 'FOR'>: <function Parser.<lambda>>, <TokenType.LOCK: 'LOCK'>: <function Parser.<lambda>>, <TokenType.TABLE_SAMPLE: 'TABLE_SAMPLE'>: <function Parser.<lambda>>, <TokenType.USING: 'USING'>: <function Parser.<lambda>>, <TokenType.CLUSTER_BY: 'CLUSTER_BY'>: <function Parser.<lambda>>, <TokenType.DISTRIBUTE_BY: 'DISTRIBUTE_BY'>: <function Parser.<lambda>>, <TokenType.SORT_BY: 'SORT_BY'>: <function Parser.<lambda>>, <TokenType.CONNECT_BY: 'CONNECT_BY'>: <function Parser.<lambda>>, <TokenType.START_WITH: 'START_WITH'>: <function Parser.<lambda>>, <TokenType.SETTINGS: 'SETTINGS'>: <function ClickHouse.Parser.<lambda>>, <TokenType.FORMAT: 'FORMAT'>: <function ClickHouse.Parser.<lambda>>}
CONSTRAINT_PARSERS = {'AUTOINCREMENT': <function Parser.<lambda>>, 'AUTO_INCREMENT': <function Parser.<lambda>>, 'CASESPECIFIC': <function Parser.<lambda>>, 'CHARACTER SET': <function Parser.<lambda>>, 'CHECK': <function Parser.<lambda>>, 'COLLATE': <function Parser.<lambda>>, 'COMMENT': <function Parser.<lambda>>, 'COMPRESS': <function Parser.<lambda>>, 'CLUSTERED': <function Parser.<lambda>>, 'NONCLUSTERED': <function Parser.<lambda>>, 'DEFAULT': <function Parser.<lambda>>, 'ENCODE': <function Parser.<lambda>>, 'EPHEMERAL': <function Parser.<lambda>>, 'EXCLUDE': <function Parser.<lambda>>, 'FOREIGN KEY': <function Parser.<lambda>>, 'FORMAT': <function Parser.<lambda>>, 'GENERATED': <function Parser.<lambda>>, 'IDENTITY': <function Parser.<lambda>>, 'INLINE': <function Parser.<lambda>>, 'LIKE': <function Parser.<lambda>>, 'NOT': <function Parser.<lambda>>, 'NULL': <function Parser.<lambda>>, 'ON': <function Parser.<lambda>>, 'PATH': <function Parser.<lambda>>, 'PERIOD': <function Parser.<lambda>>, 'PRIMARY KEY': <function Parser.<lambda>>, 'REFERENCES': <function Parser.<lambda>>, 'TITLE': <function Parser.<lambda>>, 'TTL': <function Parser.<lambda>>, 'UNIQUE': <function Parser.<lambda>>, 'UPPERCASE': <function Parser.<lambda>>, 'WITH': <function Parser.<lambda>>, 'INDEX': <function ClickHouse.Parser.<lambda>>, 'CODEC': <function ClickHouse.Parser.<lambda>>}
ALTER_PARSERS = {'ADD': <function Parser.<lambda>>, 'ALTER': <function Parser.<lambda>>, 'CLUSTER BY': <function Parser.<lambda>>, 'DELETE': <function Parser.<lambda>>, 'DROP': <function Parser.<lambda>>, 'RENAME': <function Parser.<lambda>>, 'SET': <function Parser.<lambda>>, 'AS': <function Parser.<lambda>>, 'REPLACE': <function ClickHouse.Parser.<lambda>>}
SCHEMA_UNNAMED_CONSTRAINTS = {'EXCLUDE', 'LIKE', 'CHECK', 'PERIOD', 'FOREIGN KEY', 'PRIMARY KEY', 'INDEX', 'UNIQUE'}
SHOW_TRIE: Dict = {}
SET_TRIE: Dict = {'GLOBAL': {0: True}, 'LOCAL': {0: True}, 'SESSION': {0: True}, 'TRANSACTION': {0: True}}
Inherited Members
sqlglot.parser.Parser
Parser
NO_PAREN_FUNCTIONS
STRUCT_TYPE_TOKENS
NESTED_TYPE_TOKENS
ENUM_TYPE_TOKENS
AGGREGATE_TYPE_TOKENS
TYPE_TOKENS
SIGNED_TO_UNSIGNED_TYPE_TOKEN
SUBQUERY_PREDICATES
DB_CREATABLES
CREATABLES
ALTERABLES
INTERVAL_VARS
ARRAY_CONSTRUCTORS
COMMENT_TABLE_ALIAS_TOKENS
UPDATE_ALIAS_TOKENS
TRIM_TYPES
CONJUNCTION
ASSIGNMENT
DISJUNCTION
EQUALITY
COMPARISON
BITWISE
TERM
FACTOR
EXPONENT
TIMES
TIMESTAMPS
SET_OPERATIONS
JOIN_METHODS
JOIN_SIDES
JOIN_HINTS
LAMBDAS
EXPRESSION_PARSERS
STATEMENT_PARSERS
UNARY_PARSERS
STRING_PARSERS
NUMERIC_PARSERS
PRIMARY_PARSERS
PLACEHOLDER_PARSERS
PROPERTY_PARSERS
ALTER_ALTER_PARSERS
INVALID_FUNC_NAME_TOKENS
KEY_VALUE_DEFINITIONS
SET_PARSERS
SHOW_PARSERS
TYPE_LITERAL_PARSERS
TYPE_CONVERTERS
DDL_SELECT_TOKENS
PRE_VOLATILE_TOKENS
TRANSACTION_KIND
TRANSACTION_CHARACTERISTICS
CONFLICT_ACTIONS
CREATE_SEQUENCE
ISOLATED_LOADING_OPTIONS
USABLES
CAST_ACTIONS
SCHEMA_BINDING_OPTIONS
KEY_CONSTRAINT_OPTIONS
INSERT_ALTERNATIVES
CLONE_KEYWORDS
HISTORICAL_DATA_PREFIX
HISTORICAL_DATA_KIND
OPCLASS_FOLLOW_KEYWORDS
OPTYPE_FOLLOW_TOKENS
TABLE_INDEX_HINT_TOKENS
VIEW_ATTRIBUTES
WINDOW_ALIAS_TOKENS
WINDOW_BEFORE_PAREN_TOKENS
WINDOW_SIDES
JSON_KEY_VALUE_SEPARATOR_TOKENS
FETCH_TOKENS
ADD_CONSTRAINT_TOKENS
DISTINCT_TOKENS
NULL_TOKENS
UNNEST_OFFSET_ALIAS_TOKENS
SELECT_START_TOKENS
COPY_INTO_VARLEN_OPTIONS
STRICT_CAST
PREFIXED_PIVOT_COLUMNS
IDENTIFY_PIVOT_STRINGS
ALTER_TABLE_ADD_REQUIRED_FOR_EACH_COLUMN
TABLESAMPLE_CSV
DEFAULT_SAMPLING_METHOD
SET_REQUIRES_ASSIGNMENT_DELIMITER
TRIM_PATTERN_FIRST
STRING_ALIASES
SET_OP_MODIFIERS
NO_PAREN_IF_COMMANDS
JSON_ARROWS_REQUIRE_JSON_TYPE
COLON_IS_VARIANT_EXTRACT
VALUES_FOLLOWED_BY_PAREN
SUPPORTS_IMPLICIT_UNNEST
SUPPORTS_PARTITION_SELECTION
error_level
error_message_context
max_errors
dialect
reset
parse
parse_into
check_errors
raise_error
expression
validate_expression
errors
sql
class ClickHouse.Generator(sqlglot.generator.Generator):
 725    class Generator(generator.Generator):
 726        QUERY_HINTS = False
 727        STRUCT_DELIMITER = ("(", ")")
 728        NVL2_SUPPORTED = False
 729        TABLESAMPLE_REQUIRES_PARENS = False
 730        TABLESAMPLE_SIZE_IS_ROWS = False
 731        TABLESAMPLE_KEYWORDS = "SAMPLE"
 732        LAST_DAY_SUPPORTS_DATE_PART = False
 733        CAN_IMPLEMENT_ARRAY_ANY = True
 734        SUPPORTS_TO_NUMBER = False
 735        JOIN_HINTS = False
 736        TABLE_HINTS = False
 737        EXPLICIT_SET_OP = True
 738        GROUPINGS_SEP = ""
 739        SET_OP_MODIFIERS = False
 740        SUPPORTS_TABLE_ALIAS_COLUMNS = False
 741        VALUES_AS_TABLE = False
 742
 743        STRING_TYPE_MAPPING = {
 744            exp.DataType.Type.CHAR: "String",
 745            exp.DataType.Type.LONGBLOB: "String",
 746            exp.DataType.Type.LONGTEXT: "String",
 747            exp.DataType.Type.MEDIUMBLOB: "String",
 748            exp.DataType.Type.MEDIUMTEXT: "String",
 749            exp.DataType.Type.TINYBLOB: "String",
 750            exp.DataType.Type.TINYTEXT: "String",
 751            exp.DataType.Type.TEXT: "String",
 752            exp.DataType.Type.VARBINARY: "String",
 753            exp.DataType.Type.VARCHAR: "String",
 754        }
 755
 756        SUPPORTED_JSON_PATH_PARTS = {
 757            exp.JSONPathKey,
 758            exp.JSONPathRoot,
 759            exp.JSONPathSubscript,
 760        }
 761
 762        TYPE_MAPPING = {
 763            **generator.Generator.TYPE_MAPPING,
 764            **STRING_TYPE_MAPPING,
 765            exp.DataType.Type.ARRAY: "Array",
 766            exp.DataType.Type.BIGINT: "Int64",
 767            exp.DataType.Type.DATE32: "Date32",
 768            exp.DataType.Type.DATETIME64: "DateTime64",
 769            exp.DataType.Type.TIMESTAMPTZ: "TIMESTAMP",
 770            exp.DataType.Type.DOUBLE: "Float64",
 771            exp.DataType.Type.ENUM: "Enum",
 772            exp.DataType.Type.ENUM8: "Enum8",
 773            exp.DataType.Type.ENUM16: "Enum16",
 774            exp.DataType.Type.FIXEDSTRING: "FixedString",
 775            exp.DataType.Type.FLOAT: "Float32",
 776            exp.DataType.Type.INT: "Int32",
 777            exp.DataType.Type.MEDIUMINT: "Int32",
 778            exp.DataType.Type.INT128: "Int128",
 779            exp.DataType.Type.INT256: "Int256",
 780            exp.DataType.Type.LOWCARDINALITY: "LowCardinality",
 781            exp.DataType.Type.MAP: "Map",
 782            exp.DataType.Type.NESTED: "Nested",
 783            exp.DataType.Type.NULLABLE: "Nullable",
 784            exp.DataType.Type.SMALLINT: "Int16",
 785            exp.DataType.Type.STRUCT: "Tuple",
 786            exp.DataType.Type.TINYINT: "Int8",
 787            exp.DataType.Type.UBIGINT: "UInt64",
 788            exp.DataType.Type.UINT: "UInt32",
 789            exp.DataType.Type.UINT128: "UInt128",
 790            exp.DataType.Type.UINT256: "UInt256",
 791            exp.DataType.Type.USMALLINT: "UInt16",
 792            exp.DataType.Type.UTINYINT: "UInt8",
 793            exp.DataType.Type.IPV4: "IPv4",
 794            exp.DataType.Type.IPV6: "IPv6",
 795            exp.DataType.Type.AGGREGATEFUNCTION: "AggregateFunction",
 796            exp.DataType.Type.SIMPLEAGGREGATEFUNCTION: "SimpleAggregateFunction",
 797        }
 798
 799        TRANSFORMS = {
 800            **generator.Generator.TRANSFORMS,
 801            exp.AnyValue: rename_func("any"),
 802            exp.ApproxDistinct: rename_func("uniq"),
 803            exp.ArrayFilter: lambda self, e: self.func("arrayFilter", e.expression, e.this),
 804            exp.ArraySize: rename_func("LENGTH"),
 805            exp.ArraySum: rename_func("arraySum"),
 806            exp.ArgMax: arg_max_or_min_no_count("argMax"),
 807            exp.ArgMin: arg_max_or_min_no_count("argMin"),
 808            exp.Array: inline_array_sql,
 809            exp.CastToStrType: rename_func("CAST"),
 810            exp.CountIf: rename_func("countIf"),
 811            exp.CompressColumnConstraint: lambda self,
 812            e: f"CODEC({self.expressions(e, key='this', flat=True)})",
 813            exp.ComputedColumnConstraint: lambda self,
 814            e: f"{'MATERIALIZED' if e.args.get('persisted') else 'ALIAS'} {self.sql(e, 'this')}",
 815            exp.CurrentDate: lambda self, e: self.func("CURRENT_DATE"),
 816            exp.DateAdd: _datetime_delta_sql("DATE_ADD"),
 817            exp.DateDiff: _datetime_delta_sql("DATE_DIFF"),
 818            exp.DateStrToDate: rename_func("toDate"),
 819            exp.DateSub: _datetime_delta_sql("DATE_SUB"),
 820            exp.Explode: rename_func("arrayJoin"),
 821            exp.Final: lambda self, e: f"{self.sql(e, 'this')} FINAL",
 822            exp.IsNan: rename_func("isNaN"),
 823            exp.JSONExtract: json_extract_segments("JSONExtractString", quoted_index=False),
 824            exp.JSONExtractScalar: json_extract_segments("JSONExtractString", quoted_index=False),
 825            exp.JSONPathKey: json_path_key_only_name,
 826            exp.JSONPathRoot: lambda *_: "",
 827            exp.Map: lambda self, e: _lower_func(var_map_sql(self, e)),
 828            exp.Nullif: rename_func("nullIf"),
 829            exp.PartitionedByProperty: lambda self, e: f"PARTITION BY {self.sql(e, 'this')}",
 830            exp.Pivot: no_pivot_sql,
 831            exp.Quantile: _quantile_sql,
 832            exp.RegexpLike: lambda self, e: self.func("match", e.this, e.expression),
 833            exp.Rand: rename_func("randCanonical"),
 834            exp.StartsWith: rename_func("startsWith"),
 835            exp.StrPosition: lambda self, e: self.func(
 836                "position", e.this, e.args.get("substr"), e.args.get("position")
 837            ),
 838            exp.TimeToStr: lambda self, e: self.func(
 839                "DATE_FORMAT", e.this, self.format_time(e), e.args.get("timezone")
 840            ),
 841            exp.TimestampAdd: _datetime_delta_sql("TIMESTAMP_ADD"),
 842            exp.TimestampSub: _datetime_delta_sql("TIMESTAMP_SUB"),
 843            exp.VarMap: lambda self, e: _lower_func(var_map_sql(self, e)),
 844            exp.Xor: lambda self, e: self.func("xor", e.this, e.expression, *e.expressions),
 845            exp.MD5Digest: rename_func("MD5"),
 846            exp.MD5: lambda self, e: self.func("LOWER", self.func("HEX", self.func("MD5", e.this))),
 847            exp.SHA: rename_func("SHA1"),
 848            exp.SHA2: sha256_sql,
 849            exp.UnixToTime: _unix_to_time_sql,
 850            exp.TimestampTrunc: timestamptrunc_sql(zone=True),
 851            exp.Variance: rename_func("varSamp"),
 852            exp.SchemaCommentProperty: lambda self, e: self.naked_property(e),
 853            exp.Stddev: rename_func("stddevSamp"),
 854        }
 855
 856        PROPERTIES_LOCATION = {
 857            **generator.Generator.PROPERTIES_LOCATION,
 858            exp.VolatileProperty: exp.Properties.Location.UNSUPPORTED,
 859            exp.PartitionedByProperty: exp.Properties.Location.POST_SCHEMA,
 860            exp.OnCluster: exp.Properties.Location.POST_NAME,
 861        }
 862
 863        # There's no list in docs, but it can be found in Clickhouse code
 864        # see `ClickHouse/src/Parsers/ParserCreate*.cpp`
 865        ON_CLUSTER_TARGETS = {
 866            "DATABASE",
 867            "TABLE",
 868            "VIEW",
 869            "DICTIONARY",
 870            "INDEX",
 871            "FUNCTION",
 872            "NAMED COLLECTION",
 873        }
 874
 875        # https://clickhouse.com/docs/en/sql-reference/data-types/nullable
 876        NON_NULLABLE_TYPES = {
 877            exp.DataType.Type.ARRAY,
 878            exp.DataType.Type.MAP,
 879            exp.DataType.Type.NULLABLE,
 880            exp.DataType.Type.STRUCT,
 881        }
 882
 883        def strtodate_sql(self, expression: exp.StrToDate) -> str:
 884            strtodate_sql = self.function_fallback_sql(expression)
 885
 886            if not isinstance(expression.parent, exp.Cast):
 887                # StrToDate returns DATEs in other dialects (eg. postgres), so
 888                # this branch aims to improve the transpilation to clickhouse
 889                return f"CAST({strtodate_sql} AS DATE)"
 890
 891            return strtodate_sql
 892
 893        def cast_sql(self, expression: exp.Cast, safe_prefix: t.Optional[str] = None) -> str:
 894            this = expression.this
 895
 896            if isinstance(this, exp.StrToDate) and expression.to == exp.DataType.build("datetime"):
 897                return self.sql(this)
 898
 899            return super().cast_sql(expression, safe_prefix=safe_prefix)
 900
 901        def trycast_sql(self, expression: exp.TryCast) -> str:
 902            dtype = expression.to
 903            if not dtype.is_type(*self.NON_NULLABLE_TYPES, check_nullable=True):
 904                # Casting x into Nullable(T) appears to behave similarly to TRY_CAST(x AS T)
 905                dtype.set("nullable", True)
 906
 907            return super().cast_sql(expression)
 908
 909        def _jsonpathsubscript_sql(self, expression: exp.JSONPathSubscript) -> str:
 910            this = self.json_path_part(expression.this)
 911            return str(int(this) + 1) if is_int(this) else this
 912
 913        def likeproperty_sql(self, expression: exp.LikeProperty) -> str:
 914            return f"AS {self.sql(expression, 'this')}"
 915
 916        def _any_to_has(
 917            self,
 918            expression: exp.EQ | exp.NEQ,
 919            default: t.Callable[[t.Any], str],
 920            prefix: str = "",
 921        ) -> str:
 922            if isinstance(expression.left, exp.Any):
 923                arr = expression.left
 924                this = expression.right
 925            elif isinstance(expression.right, exp.Any):
 926                arr = expression.right
 927                this = expression.left
 928            else:
 929                return default(expression)
 930
 931            return prefix + self.func("has", arr.this.unnest(), this)
 932
 933        def eq_sql(self, expression: exp.EQ) -> str:
 934            return self._any_to_has(expression, super().eq_sql)
 935
 936        def neq_sql(self, expression: exp.NEQ) -> str:
 937            return self._any_to_has(expression, super().neq_sql, "NOT ")
 938
 939        def regexpilike_sql(self, expression: exp.RegexpILike) -> str:
 940            # Manually add a flag to make the search case-insensitive
 941            regex = self.func("CONCAT", "'(?i)'", expression.expression)
 942            return self.func("match", expression.this, regex)
 943
 944        def datatype_sql(self, expression: exp.DataType) -> str:
 945            # String is the standard ClickHouse type, every other variant is just an alias.
 946            # Additionally, any supplied length parameter will be ignored.
 947            #
 948            # https://clickhouse.com/docs/en/sql-reference/data-types/string
 949            if expression.this in self.STRING_TYPE_MAPPING:
 950                dtype = "String"
 951            else:
 952                dtype = super().datatype_sql(expression)
 953
 954            # This section changes the type to `Nullable(...)` if the following conditions hold:
 955            # - It's marked as nullable - this ensures we won't wrap ClickHouse types with `Nullable`
 956            #   and change their semantics
 957            # - It's not the key type of a `Map`. This is because ClickHouse enforces the following
 958            #   constraint: "Type of Map key must be a type, that can be represented by integer or
 959            #   String or FixedString (possibly LowCardinality) or UUID or IPv6"
 960            # - It's not a composite type, e.g. `Nullable(Array(...))` is not a valid type
 961            parent = expression.parent
 962            if (
 963                expression.args.get("nullable") is not False
 964                and not (
 965                    isinstance(parent, exp.DataType)
 966                    and parent.is_type(exp.DataType.Type.MAP, check_nullable=True)
 967                    and expression.index in (None, 0)
 968                )
 969                and not expression.is_type(*self.NON_NULLABLE_TYPES, check_nullable=True)
 970            ):
 971                dtype = f"Nullable({dtype})"
 972
 973            return dtype
 974
 975        def cte_sql(self, expression: exp.CTE) -> str:
 976            if expression.args.get("scalar"):
 977                this = self.sql(expression, "this")
 978                alias = self.sql(expression, "alias")
 979                return f"{this} AS {alias}"
 980
 981            return super().cte_sql(expression)
 982
 983        def after_limit_modifiers(self, expression: exp.Expression) -> t.List[str]:
 984            return super().after_limit_modifiers(expression) + [
 985                (
 986                    self.seg("SETTINGS ") + self.expressions(expression, key="settings", flat=True)
 987                    if expression.args.get("settings")
 988                    else ""
 989                ),
 990                (
 991                    self.seg("FORMAT ") + self.sql(expression, "format")
 992                    if expression.args.get("format")
 993                    else ""
 994                ),
 995            ]
 996
 997        def parameterizedagg_sql(self, expression: exp.ParameterizedAgg) -> str:
 998            params = self.expressions(expression, key="params", flat=True)
 999            return self.func(expression.name, *expression.expressions) + f"({params})"
1000
1001        def anonymousaggfunc_sql(self, expression: exp.AnonymousAggFunc) -> str:
1002            return self.func(expression.name, *expression.expressions)
1003
1004        def combinedaggfunc_sql(self, expression: exp.CombinedAggFunc) -> str:
1005            return self.anonymousaggfunc_sql(expression)
1006
1007        def combinedparameterizedagg_sql(self, expression: exp.CombinedParameterizedAgg) -> str:
1008            return self.parameterizedagg_sql(expression)
1009
1010        def placeholder_sql(self, expression: exp.Placeholder) -> str:
1011            return f"{{{expression.name}: {self.sql(expression, 'kind')}}}"
1012
1013        def oncluster_sql(self, expression: exp.OnCluster) -> str:
1014            return f"ON CLUSTER {self.sql(expression, 'this')}"
1015
1016        def createable_sql(self, expression: exp.Create, locations: t.DefaultDict) -> str:
1017            if expression.kind in self.ON_CLUSTER_TARGETS and locations.get(
1018                exp.Properties.Location.POST_NAME
1019            ):
1020                this_name = self.sql(
1021                    expression.this if isinstance(expression.this, exp.Schema) else expression,
1022                    "this",
1023                )
1024                this_properties = " ".join(
1025                    [self.sql(prop) for prop in locations[exp.Properties.Location.POST_NAME]]
1026                )
1027                this_schema = self.schema_columns_sql(expression.this)
1028                return f"{this_name}{self.sep()}{this_properties}{self.sep()}{this_schema}"
1029
1030            return super().createable_sql(expression, locations)
1031
1032        def create_sql(self, expression: exp.Create) -> str:
1033            # The comment property comes last in CTAS statements, i.e. after the query
1034            query = expression.expression
1035            if isinstance(query, exp.Query):
1036                comment_prop = expression.find(exp.SchemaCommentProperty)
1037                if comment_prop:
1038                    comment_prop.pop()
1039                    query.replace(exp.paren(query))
1040            else:
1041                comment_prop = None
1042
1043            create_sql = super().create_sql(expression)
1044
1045            comment_sql = self.sql(comment_prop)
1046            comment_sql = f" {comment_sql}" if comment_sql else ""
1047
1048            return f"{create_sql}{comment_sql}"
1049
1050        def prewhere_sql(self, expression: exp.PreWhere) -> str:
1051            this = self.indent(self.sql(expression, "this"))
1052            return f"{self.seg('PREWHERE')}{self.sep()}{this}"
1053
1054        def indexcolumnconstraint_sql(self, expression: exp.IndexColumnConstraint) -> str:
1055            this = self.sql(expression, "this")
1056            this = f" {this}" if this else ""
1057            expr = self.sql(expression, "expression")
1058            expr = f" {expr}" if expr else ""
1059            index_type = self.sql(expression, "index_type")
1060            index_type = f" TYPE {index_type}" if index_type else ""
1061            granularity = self.sql(expression, "granularity")
1062            granularity = f" GRANULARITY {granularity}" if granularity else ""
1063
1064            return f"INDEX{this}{expr}{index_type}{granularity}"
1065
1066        def partition_sql(self, expression: exp.Partition) -> str:
1067            return f"PARTITION {self.expressions(expression, flat=True)}"
1068
1069        def partitionid_sql(self, expression: exp.PartitionId) -> str:
1070            return f"ID {self.sql(expression.this)}"
1071
1072        def replacepartition_sql(self, expression: exp.ReplacePartition) -> str:
1073            return (
1074                f"REPLACE {self.sql(expression.expression)} FROM {self.sql(expression, 'source')}"
1075            )
1076
1077        def projectiondef_sql(self, expression: exp.ProjectionDef) -> str:
1078            return f"PROJECTION {self.sql(expression.this)} {self.wrap(expression.expression)}"

Generator converts a given syntax tree to the corresponding SQL string.

Arguments:
  • pretty: Whether to format the produced SQL string. Default: False.
  • identify: Determines when an identifier should be quoted. Possible values are: False (default): Never quote, except in cases where it's mandatory by the dialect. True or 'always': Always quote. 'safe': Only quote identifiers that are case insensitive.
  • normalize: Whether to normalize identifiers to lowercase. Default: False.
  • pad: The pad size in a formatted string. For example, this affects the indentation of a projection in a query, relative to its nesting level. Default: 2.
  • indent: The indentation size in a formatted string. For example, this affects the indentation of subqueries and filters under a WHERE clause. Default: 2.
  • normalize_functions: How to normalize function names. Possible values are: "upper" or True (default): Convert names to uppercase. "lower": Convert names to lowercase. False: Disables function name normalization.
  • unsupported_level: Determines the generator's behavior when it encounters unsupported expressions. Default ErrorLevel.WARN.
  • max_unsupported: Maximum number of unsupported messages to include in a raised UnsupportedError. This is only relevant if unsupported_level is ErrorLevel.RAISE. Default: 3
  • leading_comma: Whether the comma is leading or trailing in select expressions. This is only relevant when generating in pretty mode. Default: False
  • max_text_width: The max number of characters in a segment before creating new lines in pretty mode. The default is on the smaller end because the length only represents a segment and not the true line length. Default: 80
  • comments: Whether to preserve comments in the output SQL code. Default: True
QUERY_HINTS = False
STRUCT_DELIMITER = ('(', ')')
NVL2_SUPPORTED = False
TABLESAMPLE_REQUIRES_PARENS = False
TABLESAMPLE_SIZE_IS_ROWS = False
TABLESAMPLE_KEYWORDS = 'SAMPLE'
LAST_DAY_SUPPORTS_DATE_PART = False
CAN_IMPLEMENT_ARRAY_ANY = True
SUPPORTS_TO_NUMBER = False
JOIN_HINTS = False
TABLE_HINTS = False
EXPLICIT_SET_OP = True
GROUPINGS_SEP = ''
SET_OP_MODIFIERS = False
SUPPORTS_TABLE_ALIAS_COLUMNS = False
VALUES_AS_TABLE = False
STRING_TYPE_MAPPING = {<Type.CHAR: 'CHAR'>: 'String', <Type.LONGBLOB: 'LONGBLOB'>: 'String', <Type.LONGTEXT: 'LONGTEXT'>: 'String', <Type.MEDIUMBLOB: 'MEDIUMBLOB'>: 'String', <Type.MEDIUMTEXT: 'MEDIUMTEXT'>: 'String', <Type.TINYBLOB: 'TINYBLOB'>: 'String', <Type.TINYTEXT: 'TINYTEXT'>: 'String', <Type.TEXT: 'TEXT'>: 'String', <Type.VARBINARY: 'VARBINARY'>: 'String', <Type.VARCHAR: 'VARCHAR'>: 'String'}
TYPE_MAPPING = {<Type.NCHAR: 'NCHAR'>: 'CHAR', <Type.NVARCHAR: 'NVARCHAR'>: 'VARCHAR', <Type.MEDIUMTEXT: 'MEDIUMTEXT'>: 'String', <Type.LONGTEXT: 'LONGTEXT'>: 'String', <Type.TINYTEXT: 'TINYTEXT'>: 'String', <Type.MEDIUMBLOB: 'MEDIUMBLOB'>: 'String', <Type.LONGBLOB: 'LONGBLOB'>: 'String', <Type.TINYBLOB: 'TINYBLOB'>: 'String', <Type.INET: 'INET'>: 'INET', <Type.ROWVERSION: 'ROWVERSION'>: 'VARBINARY', <Type.CHAR: 'CHAR'>: 'String', <Type.TEXT: 'TEXT'>: 'String', <Type.VARBINARY: 'VARBINARY'>: 'String', <Type.VARCHAR: 'VARCHAR'>: 'String', <Type.ARRAY: 'ARRAY'>: 'Array', <Type.BIGINT: 'BIGINT'>: 'Int64', <Type.DATE32: 'DATE32'>: 'Date32', <Type.DATETIME64: 'DATETIME64'>: 'DateTime64', <Type.TIMESTAMPTZ: 'TIMESTAMPTZ'>: 'TIMESTAMP', <Type.DOUBLE: 'DOUBLE'>: 'Float64', <Type.ENUM: 'ENUM'>: 'Enum', <Type.ENUM8: 'ENUM8'>: 'Enum8', <Type.ENUM16: 'ENUM16'>: 'Enum16', <Type.FIXEDSTRING: 'FIXEDSTRING'>: 'FixedString', <Type.FLOAT: 'FLOAT'>: 'Float32', <Type.INT: 'INT'>: 'Int32', <Type.MEDIUMINT: 'MEDIUMINT'>: 'Int32', <Type.INT128: 'INT128'>: 'Int128', <Type.INT256: 'INT256'>: 'Int256', <Type.LOWCARDINALITY: 'LOWCARDINALITY'>: 'LowCardinality', <Type.MAP: 'MAP'>: 'Map', <Type.NESTED: 'NESTED'>: 'Nested', <Type.NULLABLE: 'NULLABLE'>: 'Nullable', <Type.SMALLINT: 'SMALLINT'>: 'Int16', <Type.STRUCT: 'STRUCT'>: 'Tuple', <Type.TINYINT: 'TINYINT'>: 'Int8', <Type.UBIGINT: 'UBIGINT'>: 'UInt64', <Type.UINT: 'UINT'>: 'UInt32', <Type.UINT128: 'UINT128'>: 'UInt128', <Type.UINT256: 'UINT256'>: 'UInt256', <Type.USMALLINT: 'USMALLINT'>: 'UInt16', <Type.UTINYINT: 'UTINYINT'>: 'UInt8', <Type.IPV4: 'IPV4'>: 'IPv4', <Type.IPV6: 'IPV6'>: 'IPv6', <Type.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>: 'AggregateFunction', <Type.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>: 'SimpleAggregateFunction'}
TRANSFORMS = {<class 'sqlglot.expressions.JSONPathKey'>: <function json_path_key_only_name>, <class 'sqlglot.expressions.JSONPathRoot'>: <function ClickHouse.Generator.<lambda>>, <class 'sqlglot.expressions.JSONPathSubscript'>: <function <lambda>>, <class 'sqlglot.expressions.AllowedValuesProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.AutoRefreshProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.BackupProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.CaseSpecificColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.CharacterSetColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.CharacterSetProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ClusteredColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.CollateColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.CommentColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ConnectByRoot'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.CopyGrantsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.DateFormatColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.DefaultColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.DynamicProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.EmptyProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.EncodeColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.EphemeralColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ExcludeColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ExecuteAsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ExternalProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.GlobalProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.HeapProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.IcebergProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.InheritsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.InlineLengthColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.InputModelProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.IntervalSpan'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.LanguageProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.LocationProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.LogProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.MaterializedProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.NonClusteredColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.NoPrimaryIndexProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.NotForReplicationColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.OnCommitProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.OnProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.OnUpdateColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.OutputModelProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.PathColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.PivotAny'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ProjectionPolicyColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.RemoteWithConnectionModelProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ReturnsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SampleProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SecureProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SetConfigProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SetProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SettingsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SharingProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SqlReadWriteProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SqlSecurityProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.StabilityProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.Stream'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.StreamingTableProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.StrictProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.TemporaryProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.TagColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.TitleColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ToMap'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ToTableProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.TransformModelProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.TransientProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.UppercaseColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.UnloggedProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.VarMap'>: <function ClickHouse.Generator.<lambda>>, <class 'sqlglot.expressions.ViewAttributeProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.VolatileProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.WithJournalTableProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.WithSchemaBindingProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.WithOperator'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.AnyValue'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.ApproxDistinct'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.ArrayFilter'>: <function ClickHouse.Generator.<lambda>>, <class 'sqlglot.expressions.ArraySize'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.ArraySum'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.ArgMax'>: <function arg_max_or_min_no_count.<locals>._arg_max_or_min_sql>, <class 'sqlglot.expressions.ArgMin'>: <function arg_max_or_min_no_count.<locals>._arg_max_or_min_sql>, <class 'sqlglot.expressions.Array'>: <function inline_array_sql>, <class 'sqlglot.expressions.CastToStrType'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.CountIf'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.CompressColumnConstraint'>: <function ClickHouse.Generator.<lambda>>, <class 'sqlglot.expressions.ComputedColumnConstraint'>: <function ClickHouse.Generator.<lambda>>, <class 'sqlglot.expressions.CurrentDate'>: <function ClickHouse.Generator.<lambda>>, <class 'sqlglot.expressions.DateAdd'>: <function _datetime_delta_sql.<locals>._delta_sql>, <class 'sqlglot.expressions.DateDiff'>: <function _datetime_delta_sql.<locals>._delta_sql>, <class 'sqlglot.expressions.DateStrToDate'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.DateSub'>: <function _datetime_delta_sql.<locals>._delta_sql>, <class 'sqlglot.expressions.Explode'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.Final'>: <function ClickHouse.Generator.<lambda>>, <class 'sqlglot.expressions.IsNan'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.JSONExtract'>: <function json_extract_segments.<locals>._json_extract_segments>, <class 'sqlglot.expressions.JSONExtractScalar'>: <function json_extract_segments.<locals>._json_extract_segments>, <class 'sqlglot.expressions.Map'>: <function ClickHouse.Generator.<lambda>>, <class 'sqlglot.expressions.Nullif'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.PartitionedByProperty'>: <function ClickHouse.Generator.<lambda>>, <class 'sqlglot.expressions.Pivot'>: <function no_pivot_sql>, <class 'sqlglot.expressions.Quantile'>: <function _quantile_sql>, <class 'sqlglot.expressions.RegexpLike'>: <function ClickHouse.Generator.<lambda>>, <class 'sqlglot.expressions.Rand'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.StartsWith'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.StrPosition'>: <function ClickHouse.Generator.<lambda>>, <class 'sqlglot.expressions.TimeToStr'>: <function ClickHouse.Generator.<lambda>>, <class 'sqlglot.expressions.TimestampAdd'>: <function _datetime_delta_sql.<locals>._delta_sql>, <class 'sqlglot.expressions.TimestampSub'>: <function _datetime_delta_sql.<locals>._delta_sql>, <class 'sqlglot.expressions.Xor'>: <function ClickHouse.Generator.<lambda>>, <class 'sqlglot.expressions.MD5Digest'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.MD5'>: <function ClickHouse.Generator.<lambda>>, <class 'sqlglot.expressions.SHA'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.SHA2'>: <function sha256_sql>, <class 'sqlglot.expressions.UnixToTime'>: <function _unix_to_time_sql>, <class 'sqlglot.expressions.TimestampTrunc'>: <function timestamptrunc_sql.<locals>._timestamptrunc_sql>, <class 'sqlglot.expressions.Variance'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.SchemaCommentProperty'>: <function ClickHouse.Generator.<lambda>>, <class 'sqlglot.expressions.Stddev'>: <function rename_func.<locals>.<lambda>>}
PROPERTIES_LOCATION = {<class 'sqlglot.expressions.AllowedValuesProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.AlgorithmProperty'>: <Location.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.AutoIncrementProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.AutoRefreshProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.BackupProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.BlockCompressionProperty'>: <Location.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.CharacterSetProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.ChecksumProperty'>: <Location.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.CollateProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.CopyGrantsProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.Cluster'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.ClusteredByProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.DataBlocksizeProperty'>: <Location.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.DataDeletionProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.DefinerProperty'>: <Location.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.DictRange'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.DictProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.DynamicProperty'>: <Location.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.DistKeyProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.DistStyleProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.EmptyProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.EngineProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.ExecuteAsProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.ExternalProperty'>: <Location.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.FallbackProperty'>: <Location.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.FileFormatProperty'>: <Location.POST_WITH: 'POST_WITH'>, <class 'sqlglot.expressions.FreespaceProperty'>: <Location.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.GlobalProperty'>: <Location.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.HeapProperty'>: <Location.POST_WITH: 'POST_WITH'>, <class 'sqlglot.expressions.InheritsProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.IcebergProperty'>: <Location.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.InputModelProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.IsolatedLoadingProperty'>: <Location.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.JournalProperty'>: <Location.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.LanguageProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.LikeProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.LocationProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.LockProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.LockingProperty'>: <Location.POST_ALIAS: 'POST_ALIAS'>, <class 'sqlglot.expressions.LogProperty'>: <Location.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.MaterializedProperty'>: <Location.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.MergeBlockRatioProperty'>: <Location.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.NoPrimaryIndexProperty'>: <Location.POST_EXPRESSION: 'POST_EXPRESSION'>, <class 'sqlglot.expressions.OnProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.OnCommitProperty'>: <Location.POST_EXPRESSION: 'POST_EXPRESSION'>, <class 'sqlglot.expressions.Order'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.OutputModelProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.PartitionedByProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.PartitionedOfProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.PrimaryKey'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.Property'>: <Location.POST_WITH: 'POST_WITH'>, <class 'sqlglot.expressions.RemoteWithConnectionModelProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.ReturnsProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.RowFormatProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.RowFormatDelimitedProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.RowFormatSerdeProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.SampleProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.SchemaCommentProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.SecureProperty'>: <Location.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.SerdeProperties'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.Set'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.SettingsProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.SetProperty'>: <Location.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.SetConfigProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.SharingProperty'>: <Location.POST_EXPRESSION: 'POST_EXPRESSION'>, <class 'sqlglot.expressions.SequenceProperties'>: <Location.POST_EXPRESSION: 'POST_EXPRESSION'>, <class 'sqlglot.expressions.SortKeyProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.SqlReadWriteProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.SqlSecurityProperty'>: <Location.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.StabilityProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.StreamingTableProperty'>: <Location.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.StrictProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.TemporaryProperty'>: <Location.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.ToTableProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.TransientProperty'>: <Location.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.TransformModelProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.MergeTreeTTL'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.UnloggedProperty'>: <Location.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.ViewAttributeProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.VolatileProperty'>: <Location.UNSUPPORTED: 'UNSUPPORTED'>, <class 'sqlglot.expressions.WithDataProperty'>: <Location.POST_EXPRESSION: 'POST_EXPRESSION'>, <class 'sqlglot.expressions.WithJournalTableProperty'>: <Location.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.WithSchemaBindingProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.WithSystemVersioningProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.OnCluster'>: <Location.POST_NAME: 'POST_NAME'>}
ON_CLUSTER_TARGETS = {'INDEX', 'TABLE', 'VIEW', 'NAMED COLLECTION', 'DATABASE', 'DICTIONARY', 'FUNCTION'}
NON_NULLABLE_TYPES = {<Type.ARRAY: 'ARRAY'>, <Type.MAP: 'MAP'>, <Type.STRUCT: 'STRUCT'>, <Type.NULLABLE: 'NULLABLE'>}
def strtodate_sql(self, expression: sqlglot.expressions.StrToDate) -> str:
883        def strtodate_sql(self, expression: exp.StrToDate) -> str:
884            strtodate_sql = self.function_fallback_sql(expression)
885
886            if not isinstance(expression.parent, exp.Cast):
887                # StrToDate returns DATEs in other dialects (eg. postgres), so
888                # this branch aims to improve the transpilation to clickhouse
889                return f"CAST({strtodate_sql} AS DATE)"
890
891            return strtodate_sql
def cast_sql( self, expression: sqlglot.expressions.Cast, safe_prefix: Optional[str] = None) -> str:
893        def cast_sql(self, expression: exp.Cast, safe_prefix: t.Optional[str] = None) -> str:
894            this = expression.this
895
896            if isinstance(this, exp.StrToDate) and expression.to == exp.DataType.build("datetime"):
897                return self.sql(this)
898
899            return super().cast_sql(expression, safe_prefix=safe_prefix)
def trycast_sql(self, expression: sqlglot.expressions.TryCast) -> str:
901        def trycast_sql(self, expression: exp.TryCast) -> str:
902            dtype = expression.to
903            if not dtype.is_type(*self.NON_NULLABLE_TYPES, check_nullable=True):
904                # Casting x into Nullable(T) appears to behave similarly to TRY_CAST(x AS T)
905                dtype.set("nullable", True)
906
907            return super().cast_sql(expression)
def likeproperty_sql(self, expression: sqlglot.expressions.LikeProperty) -> str:
913        def likeproperty_sql(self, expression: exp.LikeProperty) -> str:
914            return f"AS {self.sql(expression, 'this')}"
def eq_sql(self, expression: sqlglot.expressions.EQ) -> str:
933        def eq_sql(self, expression: exp.EQ) -> str:
934            return self._any_to_has(expression, super().eq_sql)
def neq_sql(self, expression: sqlglot.expressions.NEQ) -> str:
936        def neq_sql(self, expression: exp.NEQ) -> str:
937            return self._any_to_has(expression, super().neq_sql, "NOT ")
def regexpilike_sql(self, expression: sqlglot.expressions.RegexpILike) -> str:
939        def regexpilike_sql(self, expression: exp.RegexpILike) -> str:
940            # Manually add a flag to make the search case-insensitive
941            regex = self.func("CONCAT", "'(?i)'", expression.expression)
942            return self.func("match", expression.this, regex)
def datatype_sql(self, expression: sqlglot.expressions.DataType) -> str:
944        def datatype_sql(self, expression: exp.DataType) -> str:
945            # String is the standard ClickHouse type, every other variant is just an alias.
946            # Additionally, any supplied length parameter will be ignored.
947            #
948            # https://clickhouse.com/docs/en/sql-reference/data-types/string
949            if expression.this in self.STRING_TYPE_MAPPING:
950                dtype = "String"
951            else:
952                dtype = super().datatype_sql(expression)
953
954            # This section changes the type to `Nullable(...)` if the following conditions hold:
955            # - It's marked as nullable - this ensures we won't wrap ClickHouse types with `Nullable`
956            #   and change their semantics
957            # - It's not the key type of a `Map`. This is because ClickHouse enforces the following
958            #   constraint: "Type of Map key must be a type, that can be represented by integer or
959            #   String or FixedString (possibly LowCardinality) or UUID or IPv6"
960            # - It's not a composite type, e.g. `Nullable(Array(...))` is not a valid type
961            parent = expression.parent
962            if (
963                expression.args.get("nullable") is not False
964                and not (
965                    isinstance(parent, exp.DataType)
966                    and parent.is_type(exp.DataType.Type.MAP, check_nullable=True)
967                    and expression.index in (None, 0)
968                )
969                and not expression.is_type(*self.NON_NULLABLE_TYPES, check_nullable=True)
970            ):
971                dtype = f"Nullable({dtype})"
972
973            return dtype
def cte_sql(self, expression: sqlglot.expressions.CTE) -> str:
975        def cte_sql(self, expression: exp.CTE) -> str:
976            if expression.args.get("scalar"):
977                this = self.sql(expression, "this")
978                alias = self.sql(expression, "alias")
979                return f"{this} AS {alias}"
980
981            return super().cte_sql(expression)
def after_limit_modifiers(self, expression: sqlglot.expressions.Expression) -> List[str]:
983        def after_limit_modifiers(self, expression: exp.Expression) -> t.List[str]:
984            return super().after_limit_modifiers(expression) + [
985                (
986                    self.seg("SETTINGS ") + self.expressions(expression, key="settings", flat=True)
987                    if expression.args.get("settings")
988                    else ""
989                ),
990                (
991                    self.seg("FORMAT ") + self.sql(expression, "format")
992                    if expression.args.get("format")
993                    else ""
994                ),
995            ]
def parameterizedagg_sql(self, expression: sqlglot.expressions.ParameterizedAgg) -> str:
997        def parameterizedagg_sql(self, expression: exp.ParameterizedAgg) -> str:
998            params = self.expressions(expression, key="params", flat=True)
999            return self.func(expression.name, *expression.expressions) + f"({params})"
def anonymousaggfunc_sql(self, expression: sqlglot.expressions.AnonymousAggFunc) -> str:
1001        def anonymousaggfunc_sql(self, expression: exp.AnonymousAggFunc) -> str:
1002            return self.func(expression.name, *expression.expressions)
def combinedaggfunc_sql(self, expression: sqlglot.expressions.CombinedAggFunc) -> str:
1004        def combinedaggfunc_sql(self, expression: exp.CombinedAggFunc) -> str:
1005            return self.anonymousaggfunc_sql(expression)
def combinedparameterizedagg_sql(self, expression: sqlglot.expressions.CombinedParameterizedAgg) -> str:
1007        def combinedparameterizedagg_sql(self, expression: exp.CombinedParameterizedAgg) -> str:
1008            return self.parameterizedagg_sql(expression)
def placeholder_sql(self, expression: sqlglot.expressions.Placeholder) -> str:
1010        def placeholder_sql(self, expression: exp.Placeholder) -> str:
1011            return f"{{{expression.name}: {self.sql(expression, 'kind')}}}"
def oncluster_sql(self, expression: sqlglot.expressions.OnCluster) -> str:
1013        def oncluster_sql(self, expression: exp.OnCluster) -> str:
1014            return f"ON CLUSTER {self.sql(expression, 'this')}"
def createable_sql( self, expression: sqlglot.expressions.Create, locations: DefaultDict) -> str:
1016        def createable_sql(self, expression: exp.Create, locations: t.DefaultDict) -> str:
1017            if expression.kind in self.ON_CLUSTER_TARGETS and locations.get(
1018                exp.Properties.Location.POST_NAME
1019            ):
1020                this_name = self.sql(
1021                    expression.this if isinstance(expression.this, exp.Schema) else expression,
1022                    "this",
1023                )
1024                this_properties = " ".join(
1025                    [self.sql(prop) for prop in locations[exp.Properties.Location.POST_NAME]]
1026                )
1027                this_schema = self.schema_columns_sql(expression.this)
1028                return f"{this_name}{self.sep()}{this_properties}{self.sep()}{this_schema}"
1029
1030            return super().createable_sql(expression, locations)
def create_sql(self, expression: sqlglot.expressions.Create) -> str:
1032        def create_sql(self, expression: exp.Create) -> str:
1033            # The comment property comes last in CTAS statements, i.e. after the query
1034            query = expression.expression
1035            if isinstance(query, exp.Query):
1036                comment_prop = expression.find(exp.SchemaCommentProperty)
1037                if comment_prop:
1038                    comment_prop.pop()
1039                    query.replace(exp.paren(query))
1040            else:
1041                comment_prop = None
1042
1043            create_sql = super().create_sql(expression)
1044
1045            comment_sql = self.sql(comment_prop)
1046            comment_sql = f" {comment_sql}" if comment_sql else ""
1047
1048            return f"{create_sql}{comment_sql}"
def prewhere_sql(self, expression: sqlglot.expressions.PreWhere) -> str:
1050        def prewhere_sql(self, expression: exp.PreWhere) -> str:
1051            this = self.indent(self.sql(expression, "this"))
1052            return f"{self.seg('PREWHERE')}{self.sep()}{this}"
def indexcolumnconstraint_sql(self, expression: sqlglot.expressions.IndexColumnConstraint) -> str:
1054        def indexcolumnconstraint_sql(self, expression: exp.IndexColumnConstraint) -> str:
1055            this = self.sql(expression, "this")
1056            this = f" {this}" if this else ""
1057            expr = self.sql(expression, "expression")
1058            expr = f" {expr}" if expr else ""
1059            index_type = self.sql(expression, "index_type")
1060            index_type = f" TYPE {index_type}" if index_type else ""
1061            granularity = self.sql(expression, "granularity")
1062            granularity = f" GRANULARITY {granularity}" if granularity else ""
1063
1064            return f"INDEX{this}{expr}{index_type}{granularity}"
def partition_sql(self, expression: sqlglot.expressions.Partition) -> str:
1066        def partition_sql(self, expression: exp.Partition) -> str:
1067            return f"PARTITION {self.expressions(expression, flat=True)}"
def partitionid_sql(self, expression: sqlglot.expressions.PartitionId) -> str:
1069        def partitionid_sql(self, expression: exp.PartitionId) -> str:
1070            return f"ID {self.sql(expression.this)}"
def replacepartition_sql(self, expression: sqlglot.expressions.ReplacePartition) -> str:
1072        def replacepartition_sql(self, expression: exp.ReplacePartition) -> str:
1073            return (
1074                f"REPLACE {self.sql(expression.expression)} FROM {self.sql(expression, 'source')}"
1075            )
def projectiondef_sql(self, expression: sqlglot.expressions.ProjectionDef) -> str:
1077        def projectiondef_sql(self, expression: exp.ProjectionDef) -> str:
1078            return f"PROJECTION {self.sql(expression.this)} {self.wrap(expression.expression)}"
SELECT_KINDS: Tuple[str, ...] = ()
TRY_SUPPORTED = False
SUPPORTS_UESCAPE = False
AFTER_HAVING_MODIFIER_TRANSFORMS = {'windows': <function Generator.<lambda>>, 'qualify': <function Generator.<lambda>>}
Inherited Members
sqlglot.generator.Generator
Generator
NULL_ORDERING_SUPPORTED
IGNORE_NULLS_IN_FUNC
LOCKING_READS_SUPPORTED
WRAP_DERIVED_VALUES
CREATE_FUNCTION_RETURN_AS
MATCHED_BY_SOURCE
SINGLE_STRING_INTERVAL
INTERVAL_ALLOWS_PLURAL_FORM
LIMIT_FETCH
LIMIT_ONLY_LITERALS
RENAME_TABLE_WITH_DB
INDEX_ON
QUERY_HINT_SEP
IS_BOOL_ALLOWED
DUPLICATE_KEY_UPDATE_WITH_SET
LIMIT_IS_TOP
RETURNING_END
EXTRACT_ALLOWS_QUOTES
TZ_TO_WITH_TIME_ZONE
ALTER_TABLE_INCLUDE_COLUMN_KEYWORD
UNNEST_WITH_ORDINALITY
AGGREGATE_FILTER_SUPPORTED
SEMI_ANTI_JOIN_WITH_SIDE
COMPUTED_COLUMN_WITH_TYPE
SUPPORTS_TABLE_COPY
TABLESAMPLE_WITH_METHOD
TABLESAMPLE_SEED_KEYWORD
COLLATE_IS_FUNC
DATA_TYPE_SPECIFIERS_ALLOWED
ENSURE_BOOLS
CTE_RECURSIVE_KEYWORD_REQUIRED
SUPPORTS_SINGLE_ARG_CONCAT
UNPIVOT_ALIASES_ARE_IDENTIFIERS
JSON_KEY_VALUE_PAIR_SEP
INSERT_OVERWRITE
SUPPORTS_SELECT_INTO
SUPPORTS_UNLOGGED_TABLES
SUPPORTS_CREATE_TABLE_LIKE
LIKE_PROPERTY_INSIDE_SCHEMA
MULTI_ARG_DISTINCT
JSON_TYPE_REQUIRED_FOR_EXTRACTION
JSON_PATH_BRACKETED_KEY_SUPPORTED
JSON_PATH_SINGLE_QUOTE_ESCAPE
COPY_PARAMS_ARE_WRAPPED
COPY_PARAMS_EQ_REQUIRED
COPY_HAS_INTO_KEYWORD
STAR_EXCEPT
HEX_FUNC
WITH_PROPERTIES_PREFIX
QUOTE_JSON_PATH
PAD_FILL_PATTERN_IS_REQUIRED
SUPPORTS_EXPLODING_PROJECTIONS
ARRAY_CONCAT_IS_VAR_LEN
SUPPORTS_CONVERT_TIMEZONE
SUPPORTS_NULLABLE_TYPES
PARSE_JSON_NAME
TIME_PART_SINGULARS
TOKEN_MAPPING
PARAMETER_TOKEN
NAMED_PLACEHOLDER_TOKEN
RESERVED_KEYWORDS
WITH_SEPARATED_COMMENTS
EXCLUDE_COMMENTS
UNWRAPPED_INTERVAL_VALUES
PARAMETERIZABLE_TEXT_TYPES
EXPRESSIONS_WITHOUT_NESTED_CTES
SENTINEL_LINE_BREAK
pretty
identify
normalize
pad
unsupported_level
max_unsupported
leading_comma
max_text_width
comments
dialect
normalize_functions
unsupported_messages
generate
preprocess
unsupported
sep
seg
pad_comment
maybe_comment
wrap
no_identify
normalize_func
indent
sql
uncache_sql
cache_sql
characterset_sql
column_parts
column_sql
columnposition_sql
columndef_sql
columnconstraint_sql
computedcolumnconstraint_sql
autoincrementcolumnconstraint_sql
compresscolumnconstraint_sql
generatedasidentitycolumnconstraint_sql
generatedasrowcolumnconstraint_sql
periodforsystemtimeconstraint_sql
notnullcolumnconstraint_sql
transformcolumnconstraint_sql
primarykeycolumnconstraint_sql
uniquecolumnconstraint_sql
sequenceproperties_sql
clone_sql
describe_sql
heredoc_sql
prepend_ctes
with_sql
tablealias_sql
bitstring_sql
hexstring_sql
bytestring_sql
unicodestring_sql
rawstring_sql
datatypeparam_sql
directory_sql
delete_sql
drop_sql
except_sql
except_op
fetch_sql
filter_sql
hint_sql
indexparameters_sql
index_sql
identifier_sql
hex_sql
lowerhex_sql
inputoutputformat_sql
national_sql
properties_sql
root_properties
properties
with_properties
locate_properties
property_name
property_sql
fallbackproperty_sql
journalproperty_sql
freespaceproperty_sql
checksumproperty_sql
mergeblockratioproperty_sql
datablocksizeproperty_sql
blockcompressionproperty_sql
isolatedloadingproperty_sql
partitionboundspec_sql
partitionedofproperty_sql
lockingproperty_sql
withdataproperty_sql
withsystemversioningproperty_sql
insert_sql
intersect_sql
intersect_op
introducer_sql
kill_sql
pseudotype_sql
objectidentifier_sql
onconflict_sql
returning_sql
rowformatdelimitedproperty_sql
withtablehint_sql
indextablehint_sql
historicaldata_sql
table_parts
table_sql
tablesample_sql
pivot_sql
version_sql
tuple_sql
update_sql
values_sql
var_sql
into_sql
from_sql
group_sql
having_sql
connect_sql
prior_sql
join_sql
lambda_sql
lateral_op
lateral_sql
limit_sql
offset_sql
setitem_sql
set_sql
pragma_sql
lock_sql
literal_sql
escape_str
loaddata_sql
null_sql
boolean_sql
order_sql
withfill_sql
cluster_sql
distribute_sql
sort_sql
ordered_sql
matchrecognizemeasure_sql
matchrecognize_sql
query_modifiers
options_modifier
queryoption_sql
offset_limit_modifiers
select_sql
schema_sql
schema_columns_sql
star_sql
parameter_sql
sessionparameter_sql
subquery_sql
qualify_sql
set_operations
union_sql
union_op
unnest_sql
where_sql
window_sql
partition_by_sql
windowspec_sql
withingroup_sql
between_sql
bracket_offset_expressions
bracket_sql
all_sql
any_sql
exists_sql
case_sql
constraint_sql
nextvaluefor_sql
extract_sql
trim_sql
convert_concat_args
concat_sql
concatws_sql
check_sql
foreignkey_sql
primarykey_sql
if_sql
matchagainst_sql
jsonkeyvalue_sql
jsonpath_sql
json_path_part
formatjson_sql
jsonobject_sql
jsonobjectagg_sql
jsonarray_sql
jsonarrayagg_sql
jsoncolumndef_sql
jsonschema_sql
jsontable_sql
openjsoncolumndef_sql
openjson_sql
in_sql
in_unnest_op
interval_sql
return_sql
reference_sql
anonymous_sql
paren_sql
neg_sql
not_sql
alias_sql
pivotalias_sql
aliases_sql
atindex_sql
attimezone_sql
fromtimezone_sql
add_sql
and_sql
or_sql
xor_sql
connector_sql
bitwiseand_sql
bitwiseleftshift_sql
bitwisenot_sql
bitwiseor_sql
bitwiserightshift_sql
bitwisexor_sql
currentdate_sql
collate_sql
command_sql
comment_sql
mergetreettlaction_sql
mergetreettl_sql
transaction_sql
commit_sql
rollback_sql
altercolumn_sql
alterdiststyle_sql
altersortkey_sql
renametable_sql
renamecolumn_sql
alterset_sql
alter_sql
add_column_sql
droppartition_sql
addconstraint_sql
distinct_sql
ignorenulls_sql
respectnulls_sql
havingmax_sql
intdiv_sql
dpipe_sql
div_sql
overlaps_sql
distance_sql
dot_sql
propertyeq_sql
escape_sql
glob_sql
gt_sql
gte_sql
ilike_sql
ilikeany_sql
is_sql
like_sql
likeany_sql
similarto_sql
lt_sql
lte_sql
mod_sql
mul_sql
nullsafeeq_sql
nullsafeneq_sql
slice_sql
sub_sql
try_sql
log_sql
use_sql
binary
function_fallback_sql
func
format_args
too_wide
format_time
expressions
op_expressions
naked_property
tag_sql
token_sql
userdefinedfunction_sql
joinhint_sql
kwarg_sql
when_sql
merge_sql
tochar_sql
tonumber_sql
dictproperty_sql
dictrange_sql
dictsubproperty_sql
clusteredbyproperty_sql
anyvalue_sql
querytransform_sql
indexconstraintoption_sql
checkcolumnconstraint_sql
nvl2_sql
comprehension_sql
columnprefix_sql
opclass_sql
predict_sql
forin_sql
refresh_sql
operator_sql
toarray_sql
tsordstotime_sql
tsordstotimestamp_sql
tsordstodate_sql
unixdate_sql
lastday_sql
dateadd_sql
arrayany_sql
struct_sql
partitionrange_sql
truncatetable_sql
convert_sql
copyparameter_sql
credentials_sql
copy_sql
semicolon_sql
datadeletionproperty_sql
maskingpolicycolumnconstraint_sql
gapfill_sql
scope_resolution
scoperesolution_sql
parsejson_sql
rand_sql
changes_sql
pad_sql
summarize_sql
explodinggenerateseries_sql
arrayconcat_sql
converttimezone_sql