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

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 ( ).

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 = {}
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):
120    class Tokenizer(tokens.Tokenizer):
121        COMMENTS = ["--", "#", "#!", ("/*", "*/")]
122        IDENTIFIERS = ['"', "`"]
123        STRING_ESCAPES = ["'", "\\"]
124        BIT_STRINGS = [("0b", "")]
125        HEX_STRINGS = [("0x", ""), ("0X", "")]
126        HEREDOC_STRINGS = ["$"]
127
128        KEYWORDS = {
129            **tokens.Tokenizer.KEYWORDS,
130            "ATTACH": TokenType.COMMAND,
131            "DATE32": TokenType.DATE32,
132            "DATETIME64": TokenType.DATETIME64,
133            "DICTIONARY": TokenType.DICTIONARY,
134            "ENUM8": TokenType.ENUM8,
135            "ENUM16": TokenType.ENUM16,
136            "FINAL": TokenType.FINAL,
137            "FIXEDSTRING": TokenType.FIXEDSTRING,
138            "FLOAT32": TokenType.FLOAT,
139            "FLOAT64": TokenType.DOUBLE,
140            "GLOBAL": TokenType.GLOBAL,
141            "INT256": TokenType.INT256,
142            "LOWCARDINALITY": TokenType.LOWCARDINALITY,
143            "MAP": TokenType.MAP,
144            "NESTED": TokenType.NESTED,
145            "SAMPLE": TokenType.TABLE_SAMPLE,
146            "TUPLE": TokenType.STRUCT,
147            "UINT128": TokenType.UINT128,
148            "UINT16": TokenType.USMALLINT,
149            "UINT256": TokenType.UINT256,
150            "UINT32": TokenType.UINT,
151            "UINT64": TokenType.UBIGINT,
152            "UINT8": TokenType.UTINYINT,
153            "IPV4": TokenType.IPV4,
154            "IPV6": TokenType.IPV6,
155            "AGGREGATEFUNCTION": TokenType.AGGREGATEFUNCTION,
156            "SIMPLEAGGREGATEFUNCTION": TokenType.SIMPLEAGGREGATEFUNCTION,
157            "SYSTEM": TokenType.COMMAND,
158            "PREWHERE": TokenType.PREWHERE,
159        }
160        KEYWORDS.pop("/*+")
161
162        SINGLE_TOKENS = {
163            **tokens.Tokenizer.SINGLE_TOKENS,
164            "$": TokenType.HEREDOC_STRING,
165        }
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'>, '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):
167    class Parser(parser.Parser):
168        # Tested in ClickHouse's playground, it seems that the following two queries do the same thing
169        # * select x from t1 union all select x from t2 limit 1;
170        # * select x from t1 union all (select x from t2 limit 1);
171        MODIFIERS_ATTACHED_TO_SET_OP = False
172        INTERVAL_SPANS = False
173
174        FUNCTIONS = {
175            **parser.Parser.FUNCTIONS,
176            "ANY": exp.AnyValue.from_arg_list,
177            "ARRAYSUM": exp.ArraySum.from_arg_list,
178            "COUNTIF": _build_count_if,
179            "DATE_ADD": build_date_delta(exp.DateAdd, default_unit=None),
180            "DATEADD": build_date_delta(exp.DateAdd, default_unit=None),
181            "DATE_DIFF": build_date_delta(exp.DateDiff, default_unit=None),
182            "DATEDIFF": build_date_delta(exp.DateDiff, default_unit=None),
183            "DATE_FORMAT": _build_date_format,
184            "DATE_SUB": build_date_delta(exp.DateSub, default_unit=None),
185            "DATESUB": build_date_delta(exp.DateSub, default_unit=None),
186            "FORMATDATETIME": _build_date_format,
187            "JSONEXTRACTSTRING": build_json_extract_path(
188                exp.JSONExtractScalar, zero_based_indexing=False
189            ),
190            "MAP": parser.build_var_map,
191            "MATCH": exp.RegexpLike.from_arg_list,
192            "RANDCANONICAL": exp.Rand.from_arg_list,
193            "STR_TO_DATE": _build_str_to_date,
194            "TUPLE": exp.Struct.from_arg_list,
195            "TIMESTAMP_SUB": build_date_delta(exp.TimestampSub, default_unit=None),
196            "TIMESTAMPSUB": build_date_delta(exp.TimestampSub, default_unit=None),
197            "TIMESTAMP_ADD": build_date_delta(exp.TimestampAdd, default_unit=None),
198            "TIMESTAMPADD": build_date_delta(exp.TimestampAdd, default_unit=None),
199            "UNIQ": exp.ApproxDistinct.from_arg_list,
200            "XOR": lambda args: exp.Xor(expressions=args),
201            "MD5": exp.MD5Digest.from_arg_list,
202            "SHA256": lambda args: exp.SHA2(this=seq_get(args, 0), length=exp.Literal.number(256)),
203            "SHA512": lambda args: exp.SHA2(this=seq_get(args, 0), length=exp.Literal.number(512)),
204        }
205
206        AGG_FUNCTIONS = {
207            "count",
208            "min",
209            "max",
210            "sum",
211            "avg",
212            "any",
213            "stddevPop",
214            "stddevSamp",
215            "varPop",
216            "varSamp",
217            "corr",
218            "covarPop",
219            "covarSamp",
220            "entropy",
221            "exponentialMovingAverage",
222            "intervalLengthSum",
223            "kolmogorovSmirnovTest",
224            "mannWhitneyUTest",
225            "median",
226            "rankCorr",
227            "sumKahan",
228            "studentTTest",
229            "welchTTest",
230            "anyHeavy",
231            "anyLast",
232            "boundingRatio",
233            "first_value",
234            "last_value",
235            "argMin",
236            "argMax",
237            "avgWeighted",
238            "topK",
239            "topKWeighted",
240            "deltaSum",
241            "deltaSumTimestamp",
242            "groupArray",
243            "groupArrayLast",
244            "groupUniqArray",
245            "groupArrayInsertAt",
246            "groupArrayMovingAvg",
247            "groupArrayMovingSum",
248            "groupArraySample",
249            "groupBitAnd",
250            "groupBitOr",
251            "groupBitXor",
252            "groupBitmap",
253            "groupBitmapAnd",
254            "groupBitmapOr",
255            "groupBitmapXor",
256            "sumWithOverflow",
257            "sumMap",
258            "minMap",
259            "maxMap",
260            "skewSamp",
261            "skewPop",
262            "kurtSamp",
263            "kurtPop",
264            "uniq",
265            "uniqExact",
266            "uniqCombined",
267            "uniqCombined64",
268            "uniqHLL12",
269            "uniqTheta",
270            "quantile",
271            "quantiles",
272            "quantileExact",
273            "quantilesExact",
274            "quantileExactLow",
275            "quantilesExactLow",
276            "quantileExactHigh",
277            "quantilesExactHigh",
278            "quantileExactWeighted",
279            "quantilesExactWeighted",
280            "quantileTiming",
281            "quantilesTiming",
282            "quantileTimingWeighted",
283            "quantilesTimingWeighted",
284            "quantileDeterministic",
285            "quantilesDeterministic",
286            "quantileTDigest",
287            "quantilesTDigest",
288            "quantileTDigestWeighted",
289            "quantilesTDigestWeighted",
290            "quantileBFloat16",
291            "quantilesBFloat16",
292            "quantileBFloat16Weighted",
293            "quantilesBFloat16Weighted",
294            "simpleLinearRegression",
295            "stochasticLinearRegression",
296            "stochasticLogisticRegression",
297            "categoricalInformationValue",
298            "contingency",
299            "cramersV",
300            "cramersVBiasCorrected",
301            "theilsU",
302            "maxIntersections",
303            "maxIntersectionsPosition",
304            "meanZTest",
305            "quantileInterpolatedWeighted",
306            "quantilesInterpolatedWeighted",
307            "quantileGK",
308            "quantilesGK",
309            "sparkBar",
310            "sumCount",
311            "largestTriangleThreeBuckets",
312            "histogram",
313            "sequenceMatch",
314            "sequenceCount",
315            "windowFunnel",
316            "retention",
317            "uniqUpTo",
318            "sequenceNextNode",
319            "exponentialTimeDecayedAvg",
320        }
321
322        AGG_FUNCTIONS_SUFFIXES = [
323            "If",
324            "Array",
325            "ArrayIf",
326            "Map",
327            "SimpleState",
328            "State",
329            "Merge",
330            "MergeState",
331            "ForEach",
332            "Distinct",
333            "OrDefault",
334            "OrNull",
335            "Resample",
336            "ArgMin",
337            "ArgMax",
338        ]
339
340        FUNC_TOKENS = {
341            *parser.Parser.FUNC_TOKENS,
342            TokenType.SET,
343        }
344
345        RESERVED_TOKENS = parser.Parser.RESERVED_TOKENS - {TokenType.SELECT}
346
347        ID_VAR_TOKENS = {
348            *parser.Parser.ID_VAR_TOKENS,
349            TokenType.LIKE,
350        }
351
352        AGG_FUNC_MAPPING = (
353            lambda functions, suffixes: {
354                f"{f}{sfx}": (f, sfx) for sfx in (suffixes + [""]) for f in functions
355            }
356        )(AGG_FUNCTIONS, AGG_FUNCTIONS_SUFFIXES)
357
358        FUNCTIONS_WITH_ALIASED_ARGS = {*parser.Parser.FUNCTIONS_WITH_ALIASED_ARGS, "TUPLE"}
359
360        FUNCTION_PARSERS = {
361            **parser.Parser.FUNCTION_PARSERS,
362            "ARRAYJOIN": lambda self: self.expression(exp.Explode, this=self._parse_expression()),
363            "QUANTILE": lambda self: self._parse_quantile(),
364        }
365
366        FUNCTION_PARSERS.pop("MATCH")
367
368        NO_PAREN_FUNCTION_PARSERS = parser.Parser.NO_PAREN_FUNCTION_PARSERS.copy()
369        NO_PAREN_FUNCTION_PARSERS.pop("ANY")
370
371        RANGE_PARSERS = {
372            **parser.Parser.RANGE_PARSERS,
373            TokenType.GLOBAL: lambda self, this: self._match(TokenType.IN)
374            and self._parse_in(this, is_global=True),
375        }
376
377        # The PLACEHOLDER entry is popped because 1) it doesn't affect Clickhouse (it corresponds to
378        # the postgres-specific JSONBContains parser) and 2) it makes parsing the ternary op simpler.
379        COLUMN_OPERATORS = parser.Parser.COLUMN_OPERATORS.copy()
380        COLUMN_OPERATORS.pop(TokenType.PLACEHOLDER)
381
382        JOIN_KINDS = {
383            *parser.Parser.JOIN_KINDS,
384            TokenType.ANY,
385            TokenType.ASOF,
386            TokenType.ARRAY,
387        }
388
389        TABLE_ALIAS_TOKENS = parser.Parser.TABLE_ALIAS_TOKENS - {
390            TokenType.ANY,
391            TokenType.ARRAY,
392            TokenType.FINAL,
393            TokenType.FORMAT,
394            TokenType.SETTINGS,
395        }
396
397        ALIAS_TOKENS = parser.Parser.ALIAS_TOKENS - {
398            TokenType.FORMAT,
399        }
400
401        LOG_DEFAULTS_TO_LN = True
402
403        QUERY_MODIFIER_PARSERS = {
404            **parser.Parser.QUERY_MODIFIER_PARSERS,
405            TokenType.SETTINGS: lambda self: (
406                "settings",
407                self._advance() or self._parse_csv(self._parse_assignment),
408            ),
409            TokenType.FORMAT: lambda self: ("format", self._advance() or self._parse_id_var()),
410        }
411
412        CONSTRAINT_PARSERS = {
413            **parser.Parser.CONSTRAINT_PARSERS,
414            "INDEX": lambda self: self._parse_index_constraint(),
415            "CODEC": lambda self: self._parse_compress(),
416        }
417
418        ALTER_PARSERS = {
419            **parser.Parser.ALTER_PARSERS,
420            "REPLACE": lambda self: self._parse_alter_table_replace(),
421        }
422
423        SCHEMA_UNNAMED_CONSTRAINTS = {
424            *parser.Parser.SCHEMA_UNNAMED_CONSTRAINTS,
425            "INDEX",
426        }
427
428        def _parse_extract(self) -> exp.Extract | exp.Anonymous:
429            index = self._index
430            this = self._parse_bitwise()
431            if self._match(TokenType.FROM):
432                self._retreat(index)
433                return super()._parse_extract()
434
435            # We return Anonymous here because extract and regexpExtract have different semantics,
436            # so parsing extract(foo, bar) into RegexpExtract can potentially break queries. E.g.,
437            # `extract('foobar', 'b')` works, but CH crashes for `regexpExtract('foobar', 'b')`.
438            #
439            # TODO: can we somehow convert the former into an equivalent `regexpExtract` call?
440            self._match(TokenType.COMMA)
441            return self.expression(
442                exp.Anonymous, this="extract", expressions=[this, self._parse_bitwise()]
443            )
444
445        def _parse_assignment(self) -> t.Optional[exp.Expression]:
446            this = super()._parse_assignment()
447
448            if self._match(TokenType.PLACEHOLDER):
449                return self.expression(
450                    exp.If,
451                    this=this,
452                    true=self._parse_assignment(),
453                    false=self._match(TokenType.COLON) and self._parse_assignment(),
454                )
455
456            return this
457
458        def _parse_placeholder(self) -> t.Optional[exp.Expression]:
459            """
460            Parse a placeholder expression like SELECT {abc: UInt32} or FROM {table: Identifier}
461            https://clickhouse.com/docs/en/sql-reference/syntax#defining-and-using-query-parameters
462            """
463            if not self._match(TokenType.L_BRACE):
464                return None
465
466            this = self._parse_id_var()
467            self._match(TokenType.COLON)
468            kind = self._parse_types(check_func=False, allow_identifiers=False) or (
469                self._match_text_seq("IDENTIFIER") and "Identifier"
470            )
471
472            if not kind:
473                self.raise_error("Expecting a placeholder type or 'Identifier' for tables")
474            elif not self._match(TokenType.R_BRACE):
475                self.raise_error("Expecting }")
476
477            return self.expression(exp.Placeholder, this=this, kind=kind)
478
479        def _parse_in(self, this: t.Optional[exp.Expression], is_global: bool = False) -> exp.In:
480            this = super()._parse_in(this)
481            this.set("is_global", is_global)
482            return this
483
484        def _parse_table(
485            self,
486            schema: bool = False,
487            joins: bool = False,
488            alias_tokens: t.Optional[t.Collection[TokenType]] = None,
489            parse_bracket: bool = False,
490            is_db_reference: bool = False,
491            parse_partition: bool = False,
492        ) -> t.Optional[exp.Expression]:
493            this = super()._parse_table(
494                schema=schema,
495                joins=joins,
496                alias_tokens=alias_tokens,
497                parse_bracket=parse_bracket,
498                is_db_reference=is_db_reference,
499            )
500
501            if self._match(TokenType.FINAL):
502                this = self.expression(exp.Final, this=this)
503
504            return this
505
506        def _parse_position(self, haystack_first: bool = False) -> exp.StrPosition:
507            return super()._parse_position(haystack_first=True)
508
509        # https://clickhouse.com/docs/en/sql-reference/statements/select/with/
510        def _parse_cte(self) -> exp.CTE:
511            # WITH <identifier> AS <subquery expression>
512            cte: t.Optional[exp.CTE] = self._try_parse(super()._parse_cte)
513
514            if not cte:
515                # WITH <expression> AS <identifier>
516                cte = self.expression(
517                    exp.CTE,
518                    this=self._parse_assignment(),
519                    alias=self._parse_table_alias(),
520                    scalar=True,
521                )
522
523            return cte
524
525        def _parse_join_parts(
526            self,
527        ) -> t.Tuple[t.Optional[Token], t.Optional[Token], t.Optional[Token]]:
528            is_global = self._match(TokenType.GLOBAL) and self._prev
529            kind_pre = self._match_set(self.JOIN_KINDS, advance=False) and self._prev
530
531            if kind_pre:
532                kind = self._match_set(self.JOIN_KINDS) and self._prev
533                side = self._match_set(self.JOIN_SIDES) and self._prev
534                return is_global, side, kind
535
536            return (
537                is_global,
538                self._match_set(self.JOIN_SIDES) and self._prev,
539                self._match_set(self.JOIN_KINDS) and self._prev,
540            )
541
542        def _parse_join(
543            self, skip_join_token: bool = False, parse_bracket: bool = False
544        ) -> t.Optional[exp.Join]:
545            join = super()._parse_join(skip_join_token=skip_join_token, parse_bracket=True)
546            if join:
547                join.set("global", join.args.pop("method", None))
548
549            return join
550
551        def _parse_function(
552            self,
553            functions: t.Optional[t.Dict[str, t.Callable]] = None,
554            anonymous: bool = False,
555            optional_parens: bool = True,
556            any_token: bool = False,
557        ) -> t.Optional[exp.Expression]:
558            expr = super()._parse_function(
559                functions=functions,
560                anonymous=anonymous,
561                optional_parens=optional_parens,
562                any_token=any_token,
563            )
564
565            func = expr.this if isinstance(expr, exp.Window) else expr
566
567            # Aggregate functions can be split in 2 parts: <func_name><suffix>
568            parts = (
569                self.AGG_FUNC_MAPPING.get(func.this) if isinstance(func, exp.Anonymous) else None
570            )
571
572            if parts:
573                params = self._parse_func_params(func)
574
575                kwargs = {
576                    "this": func.this,
577                    "expressions": func.expressions,
578                }
579                if parts[1]:
580                    kwargs["parts"] = parts
581                    exp_class = exp.CombinedParameterizedAgg if params else exp.CombinedAggFunc
582                else:
583                    exp_class = exp.ParameterizedAgg if params else exp.AnonymousAggFunc
584
585                kwargs["exp_class"] = exp_class
586                if params:
587                    kwargs["params"] = params
588
589                func = self.expression(**kwargs)
590
591                if isinstance(expr, exp.Window):
592                    # The window's func was parsed as Anonymous in base parser, fix its
593                    # type to be CH style CombinedAnonymousAggFunc / AnonymousAggFunc
594                    expr.set("this", func)
595                elif params:
596                    # Params have blocked super()._parse_function() from parsing the following window
597                    # (if that exists) as they're standing between the function call and the window spec
598                    expr = self._parse_window(func)
599                else:
600                    expr = func
601
602            return expr
603
604        def _parse_func_params(
605            self, this: t.Optional[exp.Func] = None
606        ) -> t.Optional[t.List[exp.Expression]]:
607            if self._match_pair(TokenType.R_PAREN, TokenType.L_PAREN):
608                return self._parse_csv(self._parse_lambda)
609
610            if self._match(TokenType.L_PAREN):
611                params = self._parse_csv(self._parse_lambda)
612                self._match_r_paren(this)
613                return params
614
615            return None
616
617        def _parse_quantile(self) -> exp.Quantile:
618            this = self._parse_lambda()
619            params = self._parse_func_params()
620            if params:
621                return self.expression(exp.Quantile, this=params[0], quantile=this)
622            return self.expression(exp.Quantile, this=this, quantile=exp.Literal.number(0.5))
623
624        def _parse_wrapped_id_vars(self, optional: bool = False) -> t.List[exp.Expression]:
625            return super()._parse_wrapped_id_vars(optional=True)
626
627        def _parse_primary_key(
628            self, wrapped_optional: bool = False, in_props: bool = False
629        ) -> exp.PrimaryKeyColumnConstraint | exp.PrimaryKey:
630            return super()._parse_primary_key(
631                wrapped_optional=wrapped_optional or in_props, in_props=in_props
632            )
633
634        def _parse_on_property(self) -> t.Optional[exp.Expression]:
635            index = self._index
636            if self._match_text_seq("CLUSTER"):
637                this = self._parse_id_var()
638                if this:
639                    return self.expression(exp.OnCluster, this=this)
640                else:
641                    self._retreat(index)
642            return None
643
644        def _parse_index_constraint(
645            self, kind: t.Optional[str] = None
646        ) -> exp.IndexColumnConstraint:
647            # INDEX name1 expr TYPE type1(args) GRANULARITY value
648            this = self._parse_id_var()
649            expression = self._parse_assignment()
650
651            index_type = self._match_text_seq("TYPE") and (
652                self._parse_function() or self._parse_var()
653            )
654
655            granularity = self._match_text_seq("GRANULARITY") and self._parse_term()
656
657            return self.expression(
658                exp.IndexColumnConstraint,
659                this=this,
660                expression=expression,
661                index_type=index_type,
662                granularity=granularity,
663            )
664
665        def _parse_partition(self) -> t.Optional[exp.Partition]:
666            # https://clickhouse.com/docs/en/sql-reference/statements/alter/partition#how-to-set-partition-expression
667            if not self._match(TokenType.PARTITION):
668                return None
669
670            if self._match_text_seq("ID"):
671                # Corresponds to the PARTITION ID <string_value> syntax
672                expressions: t.List[exp.Expression] = [
673                    self.expression(exp.PartitionId, this=self._parse_string())
674                ]
675            else:
676                expressions = self._parse_expressions()
677
678            return self.expression(exp.Partition, expressions=expressions)
679
680        def _parse_alter_table_replace(self) -> t.Optional[exp.Expression]:
681            partition = self._parse_partition()
682
683            if not partition or not self._match(TokenType.FROM):
684                return None
685
686            return self.expression(
687                exp.ReplacePartition, expression=partition, source=self._parse_table_parts()
688            )
689
690        def _parse_projection_def(self) -> t.Optional[exp.ProjectionDef]:
691            if not self._match_text_seq("PROJECTION"):
692                return None
693
694            return self.expression(
695                exp.ProjectionDef,
696                this=self._parse_id_var(),
697                expression=self._parse_wrapped(self._parse_statement),
698            )
699
700        def _parse_constraint(self) -> t.Optional[exp.Expression]:
701            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': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Array'>>, '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'>>, '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'>>, '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': <bound method Func.from_arg_list of <class 'sqlglot.expressions.GenerateDateArray'>>, 'GENERATE_SERIES': <bound method Func.from_arg_list of <class 'sqlglot.expressions.GenerateSeries'>>, '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 = {'stddevPop', 'covarPop', 'quantileExactLow', 'uniqExact', 'groupArrayMovingSum', 'histogram', 'deltaSumTimestamp', 'groupArrayInsertAt', 'quantileExactHigh', 'anyLast', 'categoricalInformationValue', 'sumKahan', 'varPop', 'quantileTiming', 'theilsU', 'quantileInterpolatedWeighted', 'quantilesExactWeighted', 'last_value', 'sequenceNextNode', 'min', 'sumCount', 'median', 'groupArray', 'anyHeavy', 'sparkBar', 'quantilesExactHigh', 'largestTriangleThreeBuckets', 'varSamp', 'argMin', 'quantilesExactLow', 'uniqCombined64', 'uniq', 'count', 'corr', 'sequenceMatch', 'quantileDeterministic', 'quantiles', 'minMap', 'uniqHLL12', 'uniqTheta', 'topK', 'maxIntersectionsPosition', 'first_value', 'quantilesTDigestWeighted', 'entropy', 'meanZTest', 'groupArrayLast', 'max', 'simpleLinearRegression', 'quantileExact', 'quantileTDigestWeighted', 'welchTTest', 'retention', 'cramersV', 'kolmogorovSmirnovTest', 'groupBitXor', 'groupBitAnd', 'exponentialMovingAverage', 'groupArraySample', 'kurtSamp', 'sum', 'uniqCombined', 'groupBitOr', 'kurtPop', 'stochasticLinearRegression', 'boundingRatio', 'intervalLengthSum', 'covarSamp', 'quantilesDeterministic', 'groupBitmap', 'quantileExactWeighted', 'windowFunnel', 'quantileBFloat16', 'sequenceCount', 'maxMap', 'mannWhitneyUTest', 'groupUniqArray', 'groupBitmapAnd', 'quantilesBFloat16Weighted', 'topKWeighted', 'quantileTimingWeighted', 'quantile', 'quantilesBFloat16', 'sumWithOverflow', 'quantilesTimingWeighted', 'groupBitmapOr', 'quantilesExact', 'avgWeighted', 'groupBitmapXor', 'quantileBFloat16Weighted', 'stddevSamp', 'groupArrayMovingAvg', 'quantilesTDigest', 'quantileTDigest', 'quantilesInterpolatedWeighted', 'cramersVBiasCorrected', 'deltaSum', 'skewPop', 'maxIntersections', 'quantileGK', 'argMax', 'rankCorr', 'quantilesGK', 'exponentialTimeDecayedAvg', 'any', 'skewSamp', 'quantilesTiming', 'avg', 'studentTTest', 'stochasticLogisticRegression', 'contingency', 'uniqUpTo', 'sumMap'}
AGG_FUNCTIONS_SUFFIXES = ['If', 'Array', 'ArrayIf', 'Map', 'SimpleState', 'State', 'Merge', 'MergeState', 'ForEach', 'Distinct', 'OrDefault', 'OrNull', 'Resample', 'ArgMin', 'ArgMax']
FUNC_TOKENS = {<TokenType.REPLACE: 'REPLACE'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.UINT256: 'UINT256'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.SOME: 'SOME'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.FILTER: 'FILTER'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.XML: 'XML'>, <TokenType.UUID: 'UUID'>, <TokenType.RIGHT: 'RIGHT'>, <TokenType.MONEY: 'MONEY'>, <TokenType.ENUM: 'ENUM'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.DATE: 'DATE'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.FIRST: 'FIRST'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.CHAR: 'CHAR'>, <TokenType.SUPER: 'SUPER'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.INT: 'INT'>, <TokenType.DATE32: 'DATE32'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.IDENTIFIER: 'IDENTIFIER'>, <TokenType.UINT128: 'UINT128'>, <TokenType.ILIKE: 'ILIKE'>, <TokenType.IPV6: 'IPV6'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.PRIMARY_KEY: 'PRIMARY_KEY'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.JSON: 'JSON'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.COMMAND: 'COMMAND'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.TEXT: 'TEXT'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.SET: 'SET'>, <TokenType.VAR: 'VAR'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.TIME: 'TIME'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.ALL: 'ALL'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.BINARY: 'BINARY'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.TABLE: 'TABLE'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.UNNEST: 'UNNEST'>, <TokenType.UNIQUEIDENTIFIER: 'UNIQUEIDENTIFIER'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.INSERT: 'INSERT'>, <TokenType.INT256: 'INT256'>, <TokenType.MERGE: 'MERGE'>, <TokenType.RLIKE: 'RLIKE'>, <TokenType.WINDOW: 'WINDOW'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.IPV4: 'IPV4'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.FORMAT: 'FORMAT'>, <TokenType.BIT: 'BIT'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.LIST: 'LIST'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.TRUNCATE: 'TRUNCATE'>, <TokenType.RANGE: 'RANGE'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.YEAR: 'YEAR'>, <TokenType.NESTED: 'NESTED'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.INT128: 'INT128'>, <TokenType.GLOB: 'GLOB'>, <TokenType.MAP: 'MAP'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.INDEX: 'INDEX'>, <TokenType.LEFT: 'LEFT'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.JSONB: 'JSONB'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.UINT: 'UINT'>, <TokenType.TDIGEST: 'TDIGEST'>, <TokenType.LIKE: 'LIKE'>, <TokenType.NAME: 'NAME'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.ROW: 'ROW'>, <TokenType.INET: 'INET'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.ANY: 'ANY'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.VECTOR: 'VECTOR'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.NULL: 'NULL'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.SEQUENCE: 'SEQUENCE'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.XOR: 'XOR'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.OFFSET: 'OFFSET'>}
RESERVED_TOKENS = {<TokenType.SLASH: 'SLASH'>, <TokenType.NOT: 'NOT'>, <TokenType.DOT: 'DOT'>, <TokenType.R_PAREN: 'R_PAREN'>, <TokenType.AMP: 'AMP'>, <TokenType.COLON: 'COLON'>, <TokenType.L_BRACKET: 'L_BRACKET'>, <TokenType.GT: 'GT'>, <TokenType.MOD: 'MOD'>, <TokenType.STAR: 'STAR'>, <TokenType.EQ: 'EQ'>, <TokenType.TILDA: 'TILDA'>, <TokenType.L_PAREN: 'L_PAREN'>, <TokenType.PLUS: 'PLUS'>, <TokenType.PARAMETER: 'PARAMETER'>, <TokenType.BACKSLASH: 'BACKSLASH'>, <TokenType.DASH: 'DASH'>, <TokenType.HASH: 'HASH'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.COMMA: 'COMMA'>, <TokenType.PLACEHOLDER: 'PLACEHOLDER'>, <TokenType.CARET: 'CARET'>, <TokenType.PIPE: 'PIPE'>, <TokenType.LT: 'LT'>, <TokenType.SEMICOLON: 'SEMICOLON'>, <TokenType.R_BRACKET: 'R_BRACKET'>, <TokenType.L_BRACE: 'L_BRACE'>, <TokenType.R_BRACE: 'R_BRACE'>}
ID_VAR_TOKENS = {<TokenType.ESCAPE: 'ESCAPE'>, <TokenType.REPLACE: 'REPLACE'>, <TokenType.DESC: 'DESC'>, <TokenType.TOP: 'TOP'>, <TokenType.USE: 'USE'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.KEEP: 'KEEP'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.UINT256: 'UINT256'>, <TokenType.ANTI: 'ANTI'>, <TokenType.LOAD: 'LOAD'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.SOME: 'SOME'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.FILTER: 'FILTER'>, <TokenType.DATABASE: 'DATABASE'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.XML: 'XML'>, <TokenType.DIV: 'DIV'>, <TokenType.UUID: 'UUID'>, <TokenType.RIGHT: 'RIGHT'>, <TokenType.MONEY: 'MONEY'>, <TokenType.ENUM: 'ENUM'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.KILL: 'KILL'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.DELETE: 'DELETE'>, <TokenType.DATE: 'DATE'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.FALSE: 'FALSE'>, <TokenType.ORDINALITY: 'ORDINALITY'>, <TokenType.ASOF: 'ASOF'>, <TokenType.IS: 'IS'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.FIRST: 'FIRST'>, <TokenType.STORAGE_INTEGRATION: 'STORAGE_INTEGRATION'>, <TokenType.BEGIN: 'BEGIN'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.CHAR: 'CHAR'>, <TokenType.ROWS: 'ROWS'>, <TokenType.SUPER: 'SUPER'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.INT: 'INT'>, <TokenType.DATE32: 'DATE32'>, <TokenType.SETTINGS: 'SETTINGS'>, <TokenType.MODEL: 'MODEL'>, <TokenType.IDENTIFIER: 'IDENTIFIER'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.UINT128: 'UINT128'>, <TokenType.SCHEMA: 'SCHEMA'>, <TokenType.IPV6: 'IPV6'>, <TokenType.COPY: 'COPY'>, <TokenType.SEMI: 'SEMI'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.UNPIVOT: 'UNPIVOT'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.CASE: 'CASE'>, <TokenType.VIEW: 'VIEW'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.FINAL: 'FINAL'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.SHOW: 'SHOW'>, <TokenType.NEXT: 'NEXT'>, <TokenType.RECURSIVE: 'RECURSIVE'>, <TokenType.PERCENT: 'PERCENT'>, <TokenType.COLUMN: 'COLUMN'>, <TokenType.REFERENCES: 'REFERENCES'>, <TokenType.OVERWRITE: 'OVERWRITE'>, <TokenType.OPERATOR: 'OPERATOR'>, <TokenType.DEFAULT: 'DEFAULT'>, <TokenType.JSON: 'JSON'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.COMMAND: 'COMMAND'>, <TokenType.TEMPORARY: 'TEMPORARY'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.TEXT: 'TEXT'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.SET: 'SET'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.VAR: 'VAR'>, <TokenType.ASC: 'ASC'>, <TokenType.PARTITION: 'PARTITION'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.TIME: 'TIME'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.ALL: 'ALL'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.CUBE: 'CUBE'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.BINARY: 'BINARY'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.TABLE: 'TABLE'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.PROCEDURE: 'PROCEDURE'>, <TokenType.UNNEST: 'UNNEST'>, <TokenType.UNIQUEIDENTIFIER: 'UNIQUEIDENTIFIER'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.DICTIONARY: 'DICTIONARY'>, <TokenType.INT256: 'INT256'>, <TokenType.COMMENT: 'COMMENT'>, <TokenType.MERGE: 'MERGE'>, <TokenType.WINDOW: 'WINDOW'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.IPV4: 'IPV4'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.UNIQUE: 'UNIQUE'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.FORMAT: 'FORMAT'>, <TokenType.COMMIT: 'COMMIT'>, <TokenType.NATURAL: 'NATURAL'>, <TokenType.BIT: 'BIT'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.STRAIGHT_JOIN: 'STRAIGHT_JOIN'>, <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.LIST: 'LIST'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.TRUNCATE: 'TRUNCATE'>, <TokenType.RANGE: 'RANGE'>, <TokenType.PIVOT: 'PIVOT'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.YEAR: 'YEAR'>, <TokenType.NESTED: 'NESTED'>, <TokenType.VOLATILE: 'VOLATILE'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.INT128: 'INT128'>, <TokenType.TRUE: 'TRUE'>, <TokenType.MAP: 'MAP'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.INDEX: 'INDEX'>, <TokenType.LEFT: 'LEFT'>, <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.JSONB: 'JSONB'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.CONSTRAINT: 'CONSTRAINT'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.REFRESH: 'REFRESH'>, <TokenType.STREAMLIT: 'STREAMLIT'>, <TokenType.END: 'END'>, <TokenType.FULL: 'FULL'>, <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, <TokenType.DESCRIBE: 'DESCRIBE'>, <TokenType.UINT: 'UINT'>, <TokenType.TDIGEST: 'TDIGEST'>, <TokenType.APPLY: 'APPLY'>, <TokenType.NAME: 'NAME'>, <TokenType.LIKE: 'LIKE'>, <TokenType.OVERLAPS: 'OVERLAPS'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.PRAGMA: 'PRAGMA'>, <TokenType.ROW: 'ROW'>, <TokenType.ROLLUP: 'ROLLUP'>, <TokenType.INET: 'INET'>, <TokenType.FUNCTION: 'FUNCTION'>, <TokenType.ANY: 'ANY'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.VECTOR: 'VECTOR'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.EXECUTE: 'EXECUTE'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.NULL: 'NULL'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.UPDATE: 'UPDATE'>, <TokenType.TAG: 'TAG'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.CACHE: 'CACHE'>, <TokenType.SEQUENCE: 'SEQUENCE'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.WAREHOUSE: 'WAREHOUSE'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.OFFSET: 'OFFSET'>}
AGG_FUNC_MAPPING = {'stddevPopIf': ('stddevPop', 'If'), 'covarPopIf': ('covarPop', 'If'), 'quantileExactLowIf': ('quantileExactLow', 'If'), 'uniqExactIf': ('uniqExact', 'If'), 'groupArrayMovingSumIf': ('groupArrayMovingSum', 'If'), 'histogramIf': ('histogram', 'If'), 'deltaSumTimestampIf': ('deltaSumTimestamp', 'If'), 'groupArrayInsertAtIf': ('groupArrayInsertAt', 'If'), 'quantileExactHighIf': ('quantileExactHigh', 'If'), 'anyLastIf': ('anyLast', 'If'), 'categoricalInformationValueIf': ('categoricalInformationValue', 'If'), 'sumKahanIf': ('sumKahan', 'If'), 'varPopIf': ('varPop', 'If'), 'quantileTimingIf': ('quantileTiming', 'If'), 'theilsUIf': ('theilsU', 'If'), 'quantileInterpolatedWeightedIf': ('quantileInterpolatedWeighted', 'If'), 'quantilesExactWeightedIf': ('quantilesExactWeighted', 'If'), 'last_valueIf': ('last_value', 'If'), 'sequenceNextNodeIf': ('sequenceNextNode', 'If'), 'minIf': ('min', 'If'), 'sumCountIf': ('sumCount', 'If'), 'medianIf': ('median', 'If'), 'groupArrayIf': ('groupArray', 'If'), 'anyHeavyIf': ('anyHeavy', 'If'), 'sparkBarIf': ('sparkBar', 'If'), 'quantilesExactHighIf': ('quantilesExactHigh', 'If'), 'largestTriangleThreeBucketsIf': ('largestTriangleThreeBuckets', 'If'), 'varSampIf': ('varSamp', 'If'), 'argMinIf': ('argMin', 'If'), 'quantilesExactLowIf': ('quantilesExactLow', 'If'), 'uniqCombined64If': ('uniqCombined64', 'If'), 'uniqIf': ('uniq', 'If'), 'countIf': ('count', 'If'), 'corrIf': ('corr', 'If'), 'sequenceMatchIf': ('sequenceMatch', 'If'), 'quantileDeterministicIf': ('quantileDeterministic', 'If'), 'quantilesIf': ('quantiles', 'If'), 'minMapIf': ('minMap', 'If'), 'uniqHLL12If': ('uniqHLL12', 'If'), 'uniqThetaIf': ('uniqTheta', 'If'), 'topKIf': ('topK', 'If'), 'maxIntersectionsPositionIf': ('maxIntersectionsPosition', 'If'), 'first_valueIf': ('first_value', 'If'), 'quantilesTDigestWeightedIf': ('quantilesTDigestWeighted', 'If'), 'entropyIf': ('entropy', 'If'), 'meanZTestIf': ('meanZTest', 'If'), 'groupArrayLastIf': ('groupArrayLast', 'If'), 'maxIf': ('max', 'If'), 'simpleLinearRegressionIf': ('simpleLinearRegression', 'If'), 'quantileExactIf': ('quantileExact', 'If'), 'quantileTDigestWeightedIf': ('quantileTDigestWeighted', 'If'), 'welchTTestIf': ('welchTTest', 'If'), 'retentionIf': ('retention', 'If'), 'cramersVIf': ('cramersV', 'If'), 'kolmogorovSmirnovTestIf': ('kolmogorovSmirnovTest', 'If'), 'groupBitXorIf': ('groupBitXor', 'If'), 'groupBitAndIf': ('groupBitAnd', 'If'), 'exponentialMovingAverageIf': ('exponentialMovingAverage', 'If'), 'groupArraySampleIf': ('groupArraySample', 'If'), 'kurtSampIf': ('kurtSamp', 'If'), 'sumIf': ('sum', 'If'), 'uniqCombinedIf': ('uniqCombined', 'If'), 'groupBitOrIf': ('groupBitOr', 'If'), 'kurtPopIf': ('kurtPop', 'If'), 'stochasticLinearRegressionIf': ('stochasticLinearRegression', 'If'), 'boundingRatioIf': ('boundingRatio', 'If'), 'intervalLengthSumIf': ('intervalLengthSum', 'If'), 'covarSampIf': ('covarSamp', 'If'), 'quantilesDeterministicIf': ('quantilesDeterministic', 'If'), 'groupBitmapIf': ('groupBitmap', 'If'), 'quantileExactWeightedIf': ('quantileExactWeighted', 'If'), 'windowFunnelIf': ('windowFunnel', 'If'), 'quantileBFloat16If': ('quantileBFloat16', 'If'), 'sequenceCountIf': ('sequenceCount', 'If'), 'maxMapIf': ('maxMap', 'If'), 'mannWhitneyUTestIf': ('mannWhitneyUTest', 'If'), 'groupUniqArrayIf': ('groupUniqArray', 'If'), 'groupBitmapAndIf': ('groupBitmapAnd', 'If'), 'quantilesBFloat16WeightedIf': ('quantilesBFloat16Weighted', 'If'), 'topKWeightedIf': ('topKWeighted', 'If'), 'quantileTimingWeightedIf': ('quantileTimingWeighted', 'If'), 'quantileIf': ('quantile', 'If'), 'quantilesBFloat16If': ('quantilesBFloat16', 'If'), 'sumWithOverflowIf': ('sumWithOverflow', 'If'), 'quantilesTimingWeightedIf': ('quantilesTimingWeighted', 'If'), 'groupBitmapOrIf': ('groupBitmapOr', 'If'), 'quantilesExactIf': ('quantilesExact', 'If'), 'avgWeightedIf': ('avgWeighted', 'If'), 'groupBitmapXorIf': ('groupBitmapXor', 'If'), 'quantileBFloat16WeightedIf': ('quantileBFloat16Weighted', 'If'), 'stddevSampIf': ('stddevSamp', 'If'), 'groupArrayMovingAvgIf': ('groupArrayMovingAvg', 'If'), 'quantilesTDigestIf': ('quantilesTDigest', 'If'), 'quantileTDigestIf': ('quantileTDigest', 'If'), 'quantilesInterpolatedWeightedIf': ('quantilesInterpolatedWeighted', 'If'), 'cramersVBiasCorrectedIf': ('cramersVBiasCorrected', 'If'), 'deltaSumIf': ('deltaSum', 'If'), 'skewPopIf': ('skewPop', 'If'), 'maxIntersectionsIf': ('maxIntersections', 'If'), 'quantileGKIf': ('quantileGK', 'If'), 'argMaxIf': ('argMax', 'If'), 'rankCorrIf': ('rankCorr', 'If'), 'quantilesGKIf': ('quantilesGK', 'If'), 'exponentialTimeDecayedAvgIf': ('exponentialTimeDecayedAvg', 'If'), 'anyIf': ('any', 'If'), 'skewSampIf': ('skewSamp', 'If'), 'quantilesTimingIf': ('quantilesTiming', 'If'), 'avgIf': ('avg', 'If'), 'studentTTestIf': ('studentTTest', 'If'), 'stochasticLogisticRegressionIf': ('stochasticLogisticRegression', 'If'), 'contingencyIf': ('contingency', 'If'), 'uniqUpToIf': ('uniqUpTo', 'If'), 'sumMapIf': ('sumMap', 'If'), 'stddevPopArray': ('stddevPop', 'Array'), 'covarPopArray': ('covarPop', 'Array'), 'quantileExactLowArray': ('quantileExactLow', 'Array'), 'uniqExactArray': ('uniqExact', 'Array'), 'groupArrayMovingSumArray': ('groupArrayMovingSum', 'Array'), 'histogramArray': ('histogram', 'Array'), 'deltaSumTimestampArray': ('deltaSumTimestamp', 'Array'), 'groupArrayInsertAtArray': ('groupArrayInsertAt', 'Array'), 'quantileExactHighArray': ('quantileExactHigh', 'Array'), 'anyLastArray': ('anyLast', 'Array'), 'categoricalInformationValueArray': ('categoricalInformationValue', 'Array'), 'sumKahanArray': ('sumKahan', 'Array'), 'varPopArray': ('varPop', 'Array'), 'quantileTimingArray': ('quantileTiming', 'Array'), 'theilsUArray': ('theilsU', 'Array'), 'quantileInterpolatedWeightedArray': ('quantileInterpolatedWeighted', 'Array'), 'quantilesExactWeightedArray': ('quantilesExactWeighted', 'Array'), 'last_valueArray': ('last_value', 'Array'), 'sequenceNextNodeArray': ('sequenceNextNode', 'Array'), 'minArray': ('min', 'Array'), 'sumCountArray': ('sumCount', 'Array'), 'medianArray': ('median', 'Array'), 'groupArrayArray': ('groupArray', 'Array'), 'anyHeavyArray': ('anyHeavy', 'Array'), 'sparkBarArray': ('sparkBar', 'Array'), 'quantilesExactHighArray': ('quantilesExactHigh', 'Array'), 'largestTriangleThreeBucketsArray': ('largestTriangleThreeBuckets', 'Array'), 'varSampArray': ('varSamp', 'Array'), 'argMinArray': ('argMin', 'Array'), 'quantilesExactLowArray': ('quantilesExactLow', 'Array'), 'uniqCombined64Array': ('uniqCombined64', 'Array'), 'uniqArray': ('uniq', 'Array'), 'countArray': ('count', 'Array'), 'corrArray': ('corr', 'Array'), 'sequenceMatchArray': ('sequenceMatch', 'Array'), 'quantileDeterministicArray': ('quantileDeterministic', 'Array'), 'quantilesArray': ('quantiles', 'Array'), 'minMapArray': ('minMap', 'Array'), 'uniqHLL12Array': ('uniqHLL12', 'Array'), 'uniqThetaArray': ('uniqTheta', 'Array'), 'topKArray': ('topK', 'Array'), 'maxIntersectionsPositionArray': ('maxIntersectionsPosition', 'Array'), 'first_valueArray': ('first_value', 'Array'), 'quantilesTDigestWeightedArray': ('quantilesTDigestWeighted', 'Array'), 'entropyArray': ('entropy', 'Array'), 'meanZTestArray': ('meanZTest', 'Array'), 'groupArrayLastArray': ('groupArrayLast', 'Array'), 'maxArray': ('max', 'Array'), 'simpleLinearRegressionArray': ('simpleLinearRegression', 'Array'), 'quantileExactArray': ('quantileExact', 'Array'), 'quantileTDigestWeightedArray': ('quantileTDigestWeighted', 'Array'), 'welchTTestArray': ('welchTTest', 'Array'), 'retentionArray': ('retention', 'Array'), 'cramersVArray': ('cramersV', 'Array'), 'kolmogorovSmirnovTestArray': ('kolmogorovSmirnovTest', 'Array'), 'groupBitXorArray': ('groupBitXor', 'Array'), 'groupBitAndArray': ('groupBitAnd', 'Array'), 'exponentialMovingAverageArray': ('exponentialMovingAverage', 'Array'), 'groupArraySampleArray': ('groupArraySample', 'Array'), 'kurtSampArray': ('kurtSamp', 'Array'), 'sumArray': ('sum', 'Array'), 'uniqCombinedArray': ('uniqCombined', 'Array'), 'groupBitOrArray': ('groupBitOr', 'Array'), 'kurtPopArray': ('kurtPop', 'Array'), 'stochasticLinearRegressionArray': ('stochasticLinearRegression', 'Array'), 'boundingRatioArray': ('boundingRatio', 'Array'), 'intervalLengthSumArray': ('intervalLengthSum', 'Array'), 'covarSampArray': ('covarSamp', 'Array'), 'quantilesDeterministicArray': ('quantilesDeterministic', 'Array'), 'groupBitmapArray': ('groupBitmap', 'Array'), 'quantileExactWeightedArray': ('quantileExactWeighted', 'Array'), 'windowFunnelArray': ('windowFunnel', 'Array'), 'quantileBFloat16Array': ('quantileBFloat16', 'Array'), 'sequenceCountArray': ('sequenceCount', 'Array'), 'maxMapArray': ('maxMap', 'Array'), 'mannWhitneyUTestArray': ('mannWhitneyUTest', 'Array'), 'groupUniqArrayArray': ('groupUniqArray', 'Array'), 'groupBitmapAndArray': ('groupBitmapAnd', 'Array'), 'quantilesBFloat16WeightedArray': ('quantilesBFloat16Weighted', 'Array'), 'topKWeightedArray': ('topKWeighted', 'Array'), 'quantileTimingWeightedArray': ('quantileTimingWeighted', 'Array'), 'quantileArray': ('quantile', 'Array'), 'quantilesBFloat16Array': ('quantilesBFloat16', 'Array'), 'sumWithOverflowArray': ('sumWithOverflow', 'Array'), 'quantilesTimingWeightedArray': ('quantilesTimingWeighted', 'Array'), 'groupBitmapOrArray': ('groupBitmapOr', 'Array'), 'quantilesExactArray': ('quantilesExact', 'Array'), 'avgWeightedArray': ('avgWeighted', 'Array'), 'groupBitmapXorArray': ('groupBitmapXor', 'Array'), 'quantileBFloat16WeightedArray': ('quantileBFloat16Weighted', 'Array'), 'stddevSampArray': ('stddevSamp', 'Array'), 'groupArrayMovingAvgArray': ('groupArrayMovingAvg', 'Array'), 'quantilesTDigestArray': ('quantilesTDigest', 'Array'), 'quantileTDigestArray': ('quantileTDigest', 'Array'), 'quantilesInterpolatedWeightedArray': ('quantilesInterpolatedWeighted', 'Array'), 'cramersVBiasCorrectedArray': ('cramersVBiasCorrected', 'Array'), 'deltaSumArray': ('deltaSum', 'Array'), 'skewPopArray': ('skewPop', 'Array'), 'maxIntersectionsArray': ('maxIntersections', 'Array'), 'quantileGKArray': ('quantileGK', 'Array'), 'argMaxArray': ('argMax', 'Array'), 'rankCorrArray': ('rankCorr', 'Array'), 'quantilesGKArray': ('quantilesGK', 'Array'), 'exponentialTimeDecayedAvgArray': ('exponentialTimeDecayedAvg', 'Array'), 'anyArray': ('any', 'Array'), 'skewSampArray': ('skewSamp', 'Array'), 'quantilesTimingArray': ('quantilesTiming', 'Array'), 'avgArray': ('avg', 'Array'), 'studentTTestArray': ('studentTTest', 'Array'), 'stochasticLogisticRegressionArray': ('stochasticLogisticRegression', 'Array'), 'contingencyArray': ('contingency', 'Array'), 'uniqUpToArray': ('uniqUpTo', 'Array'), 'sumMapArray': ('sumMap', 'Array'), 'stddevPopArrayIf': ('stddevPop', 'ArrayIf'), 'covarPopArrayIf': ('covarPop', 'ArrayIf'), 'quantileExactLowArrayIf': ('quantileExactLow', 'ArrayIf'), 'uniqExactArrayIf': ('uniqExact', 'ArrayIf'), 'groupArrayMovingSumArrayIf': ('groupArrayMovingSum', 'ArrayIf'), 'histogramArrayIf': ('histogram', 'ArrayIf'), 'deltaSumTimestampArrayIf': ('deltaSumTimestamp', 'ArrayIf'), 'groupArrayInsertAtArrayIf': ('groupArrayInsertAt', 'ArrayIf'), 'quantileExactHighArrayIf': ('quantileExactHigh', 'ArrayIf'), 'anyLastArrayIf': ('anyLast', 'ArrayIf'), 'categoricalInformationValueArrayIf': ('categoricalInformationValue', 'ArrayIf'), 'sumKahanArrayIf': ('sumKahan', 'ArrayIf'), 'varPopArrayIf': ('varPop', 'ArrayIf'), 'quantileTimingArrayIf': ('quantileTiming', 'ArrayIf'), 'theilsUArrayIf': ('theilsU', 'ArrayIf'), 'quantileInterpolatedWeightedArrayIf': ('quantileInterpolatedWeighted', 'ArrayIf'), 'quantilesExactWeightedArrayIf': ('quantilesExactWeighted', 'ArrayIf'), 'last_valueArrayIf': ('last_value', 'ArrayIf'), 'sequenceNextNodeArrayIf': ('sequenceNextNode', 'ArrayIf'), 'minArrayIf': ('min', 'ArrayIf'), 'sumCountArrayIf': ('sumCount', 'ArrayIf'), 'medianArrayIf': ('median', 'ArrayIf'), 'groupArrayArrayIf': ('groupArray', 'ArrayIf'), 'anyHeavyArrayIf': ('anyHeavy', 'ArrayIf'), 'sparkBarArrayIf': ('sparkBar', 'ArrayIf'), 'quantilesExactHighArrayIf': ('quantilesExactHigh', 'ArrayIf'), 'largestTriangleThreeBucketsArrayIf': ('largestTriangleThreeBuckets', 'ArrayIf'), 'varSampArrayIf': ('varSamp', 'ArrayIf'), 'argMinArrayIf': ('argMin', 'ArrayIf'), 'quantilesExactLowArrayIf': ('quantilesExactLow', 'ArrayIf'), 'uniqCombined64ArrayIf': ('uniqCombined64', 'ArrayIf'), 'uniqArrayIf': ('uniq', 'ArrayIf'), 'countArrayIf': ('count', 'ArrayIf'), 'corrArrayIf': ('corr', 'ArrayIf'), 'sequenceMatchArrayIf': ('sequenceMatch', 'ArrayIf'), 'quantileDeterministicArrayIf': ('quantileDeterministic', 'ArrayIf'), 'quantilesArrayIf': ('quantiles', 'ArrayIf'), 'minMapArrayIf': ('minMap', 'ArrayIf'), 'uniqHLL12ArrayIf': ('uniqHLL12', 'ArrayIf'), 'uniqThetaArrayIf': ('uniqTheta', 'ArrayIf'), 'topKArrayIf': ('topK', 'ArrayIf'), 'maxIntersectionsPositionArrayIf': ('maxIntersectionsPosition', 'ArrayIf'), 'first_valueArrayIf': ('first_value', 'ArrayIf'), 'quantilesTDigestWeightedArrayIf': ('quantilesTDigestWeighted', 'ArrayIf'), 'entropyArrayIf': ('entropy', 'ArrayIf'), 'meanZTestArrayIf': ('meanZTest', 'ArrayIf'), 'groupArrayLastArrayIf': ('groupArrayLast', 'ArrayIf'), 'maxArrayIf': ('max', 'ArrayIf'), 'simpleLinearRegressionArrayIf': ('simpleLinearRegression', 'ArrayIf'), 'quantileExactArrayIf': ('quantileExact', 'ArrayIf'), 'quantileTDigestWeightedArrayIf': ('quantileTDigestWeighted', 'ArrayIf'), 'welchTTestArrayIf': ('welchTTest', 'ArrayIf'), 'retentionArrayIf': ('retention', 'ArrayIf'), 'cramersVArrayIf': ('cramersV', 'ArrayIf'), 'kolmogorovSmirnovTestArrayIf': ('kolmogorovSmirnovTest', 'ArrayIf'), 'groupBitXorArrayIf': ('groupBitXor', 'ArrayIf'), 'groupBitAndArrayIf': ('groupBitAnd', 'ArrayIf'), 'exponentialMovingAverageArrayIf': ('exponentialMovingAverage', 'ArrayIf'), 'groupArraySampleArrayIf': ('groupArraySample', 'ArrayIf'), 'kurtSampArrayIf': ('kurtSamp', 'ArrayIf'), 'sumArrayIf': ('sum', 'ArrayIf'), 'uniqCombinedArrayIf': ('uniqCombined', 'ArrayIf'), 'groupBitOrArrayIf': ('groupBitOr', 'ArrayIf'), 'kurtPopArrayIf': ('kurtPop', 'ArrayIf'), 'stochasticLinearRegressionArrayIf': ('stochasticLinearRegression', 'ArrayIf'), 'boundingRatioArrayIf': ('boundingRatio', 'ArrayIf'), 'intervalLengthSumArrayIf': ('intervalLengthSum', 'ArrayIf'), 'covarSampArrayIf': ('covarSamp', 'ArrayIf'), 'quantilesDeterministicArrayIf': ('quantilesDeterministic', 'ArrayIf'), 'groupBitmapArrayIf': ('groupBitmap', 'ArrayIf'), 'quantileExactWeightedArrayIf': ('quantileExactWeighted', 'ArrayIf'), 'windowFunnelArrayIf': ('windowFunnel', 'ArrayIf'), 'quantileBFloat16ArrayIf': ('quantileBFloat16', 'ArrayIf'), 'sequenceCountArrayIf': ('sequenceCount', 'ArrayIf'), 'maxMapArrayIf': ('maxMap', 'ArrayIf'), 'mannWhitneyUTestArrayIf': ('mannWhitneyUTest', 'ArrayIf'), 'groupUniqArrayArrayIf': ('groupUniqArray', 'ArrayIf'), 'groupBitmapAndArrayIf': ('groupBitmapAnd', 'ArrayIf'), 'quantilesBFloat16WeightedArrayIf': ('quantilesBFloat16Weighted', 'ArrayIf'), 'topKWeightedArrayIf': ('topKWeighted', 'ArrayIf'), 'quantileTimingWeightedArrayIf': ('quantileTimingWeighted', 'ArrayIf'), 'quantileArrayIf': ('quantile', 'ArrayIf'), 'quantilesBFloat16ArrayIf': ('quantilesBFloat16', 'ArrayIf'), 'sumWithOverflowArrayIf': ('sumWithOverflow', 'ArrayIf'), 'quantilesTimingWeightedArrayIf': ('quantilesTimingWeighted', 'ArrayIf'), 'groupBitmapOrArrayIf': ('groupBitmapOr', 'ArrayIf'), 'quantilesExactArrayIf': ('quantilesExact', 'ArrayIf'), 'avgWeightedArrayIf': ('avgWeighted', 'ArrayIf'), 'groupBitmapXorArrayIf': ('groupBitmapXor', 'ArrayIf'), 'quantileBFloat16WeightedArrayIf': ('quantileBFloat16Weighted', 'ArrayIf'), 'stddevSampArrayIf': ('stddevSamp', 'ArrayIf'), 'groupArrayMovingAvgArrayIf': ('groupArrayMovingAvg', 'ArrayIf'), 'quantilesTDigestArrayIf': ('quantilesTDigest', 'ArrayIf'), 'quantileTDigestArrayIf': ('quantileTDigest', 'ArrayIf'), 'quantilesInterpolatedWeightedArrayIf': ('quantilesInterpolatedWeighted', 'ArrayIf'), 'cramersVBiasCorrectedArrayIf': ('cramersVBiasCorrected', 'ArrayIf'), 'deltaSumArrayIf': ('deltaSum', 'ArrayIf'), 'skewPopArrayIf': ('skewPop', 'ArrayIf'), 'maxIntersectionsArrayIf': ('maxIntersections', 'ArrayIf'), 'quantileGKArrayIf': ('quantileGK', 'ArrayIf'), 'argMaxArrayIf': ('argMax', 'ArrayIf'), 'rankCorrArrayIf': ('rankCorr', 'ArrayIf'), 'quantilesGKArrayIf': ('quantilesGK', 'ArrayIf'), 'exponentialTimeDecayedAvgArrayIf': ('exponentialTimeDecayedAvg', 'ArrayIf'), 'anyArrayIf': ('any', 'ArrayIf'), 'skewSampArrayIf': ('skewSamp', 'ArrayIf'), 'quantilesTimingArrayIf': ('quantilesTiming', 'ArrayIf'), 'avgArrayIf': ('avg', 'ArrayIf'), 'studentTTestArrayIf': ('studentTTest', 'ArrayIf'), 'stochasticLogisticRegressionArrayIf': ('stochasticLogisticRegression', 'ArrayIf'), 'contingencyArrayIf': ('contingency', 'ArrayIf'), 'uniqUpToArrayIf': ('uniqUpTo', 'ArrayIf'), 'sumMapArrayIf': ('sumMap', 'ArrayIf'), 'stddevPopMap': ('stddevPop', 'Map'), 'covarPopMap': ('covarPop', 'Map'), 'quantileExactLowMap': ('quantileExactLow', 'Map'), 'uniqExactMap': ('uniqExact', 'Map'), 'groupArrayMovingSumMap': ('groupArrayMovingSum', 'Map'), 'histogramMap': ('histogram', 'Map'), 'deltaSumTimestampMap': ('deltaSumTimestamp', 'Map'), 'groupArrayInsertAtMap': ('groupArrayInsertAt', 'Map'), 'quantileExactHighMap': ('quantileExactHigh', 'Map'), 'anyLastMap': ('anyLast', 'Map'), 'categoricalInformationValueMap': ('categoricalInformationValue', 'Map'), 'sumKahanMap': ('sumKahan', 'Map'), 'varPopMap': ('varPop', 'Map'), 'quantileTimingMap': ('quantileTiming', 'Map'), 'theilsUMap': ('theilsU', 'Map'), 'quantileInterpolatedWeightedMap': ('quantileInterpolatedWeighted', 'Map'), 'quantilesExactWeightedMap': ('quantilesExactWeighted', 'Map'), 'last_valueMap': ('last_value', 'Map'), 'sequenceNextNodeMap': ('sequenceNextNode', 'Map'), 'minMap': ('minMap', ''), 'sumCountMap': ('sumCount', 'Map'), 'medianMap': ('median', 'Map'), 'groupArrayMap': ('groupArray', 'Map'), 'anyHeavyMap': ('anyHeavy', 'Map'), 'sparkBarMap': ('sparkBar', 'Map'), 'quantilesExactHighMap': ('quantilesExactHigh', 'Map'), 'largestTriangleThreeBucketsMap': ('largestTriangleThreeBuckets', 'Map'), 'varSampMap': ('varSamp', 'Map'), 'argMinMap': ('argMin', 'Map'), 'quantilesExactLowMap': ('quantilesExactLow', 'Map'), 'uniqCombined64Map': ('uniqCombined64', 'Map'), 'uniqMap': ('uniq', 'Map'), 'countMap': ('count', 'Map'), 'corrMap': ('corr', 'Map'), 'sequenceMatchMap': ('sequenceMatch', 'Map'), 'quantileDeterministicMap': ('quantileDeterministic', 'Map'), 'quantilesMap': ('quantiles', 'Map'), 'minMapMap': ('minMap', 'Map'), 'uniqHLL12Map': ('uniqHLL12', 'Map'), 'uniqThetaMap': ('uniqTheta', 'Map'), 'topKMap': ('topK', 'Map'), 'maxIntersectionsPositionMap': ('maxIntersectionsPosition', 'Map'), 'first_valueMap': ('first_value', 'Map'), 'quantilesTDigestWeightedMap': ('quantilesTDigestWeighted', 'Map'), 'entropyMap': ('entropy', 'Map'), 'meanZTestMap': ('meanZTest', 'Map'), 'groupArrayLastMap': ('groupArrayLast', 'Map'), 'maxMap': ('maxMap', ''), 'simpleLinearRegressionMap': ('simpleLinearRegression', 'Map'), 'quantileExactMap': ('quantileExact', 'Map'), 'quantileTDigestWeightedMap': ('quantileTDigestWeighted', 'Map'), 'welchTTestMap': ('welchTTest', 'Map'), 'retentionMap': ('retention', 'Map'), 'cramersVMap': ('cramersV', 'Map'), 'kolmogorovSmirnovTestMap': ('kolmogorovSmirnovTest', 'Map'), 'groupBitXorMap': ('groupBitXor', 'Map'), 'groupBitAndMap': ('groupBitAnd', 'Map'), 'exponentialMovingAverageMap': ('exponentialMovingAverage', 'Map'), 'groupArraySampleMap': ('groupArraySample', 'Map'), 'kurtSampMap': ('kurtSamp', 'Map'), 'sumMap': ('sumMap', ''), 'uniqCombinedMap': ('uniqCombined', 'Map'), 'groupBitOrMap': ('groupBitOr', 'Map'), 'kurtPopMap': ('kurtPop', 'Map'), 'stochasticLinearRegressionMap': ('stochasticLinearRegression', 'Map'), 'boundingRatioMap': ('boundingRatio', 'Map'), 'intervalLengthSumMap': ('intervalLengthSum', 'Map'), 'covarSampMap': ('covarSamp', 'Map'), 'quantilesDeterministicMap': ('quantilesDeterministic', 'Map'), 'groupBitmapMap': ('groupBitmap', 'Map'), 'quantileExactWeightedMap': ('quantileExactWeighted', 'Map'), 'windowFunnelMap': ('windowFunnel', 'Map'), 'quantileBFloat16Map': ('quantileBFloat16', 'Map'), 'sequenceCountMap': ('sequenceCount', 'Map'), 'maxMapMap': ('maxMap', 'Map'), 'mannWhitneyUTestMap': ('mannWhitneyUTest', 'Map'), 'groupUniqArrayMap': ('groupUniqArray', 'Map'), 'groupBitmapAndMap': ('groupBitmapAnd', 'Map'), 'quantilesBFloat16WeightedMap': ('quantilesBFloat16Weighted', 'Map'), 'topKWeightedMap': ('topKWeighted', 'Map'), 'quantileTimingWeightedMap': ('quantileTimingWeighted', 'Map'), 'quantileMap': ('quantile', 'Map'), 'quantilesBFloat16Map': ('quantilesBFloat16', 'Map'), 'sumWithOverflowMap': ('sumWithOverflow', 'Map'), 'quantilesTimingWeightedMap': ('quantilesTimingWeighted', 'Map'), 'groupBitmapOrMap': ('groupBitmapOr', 'Map'), 'quantilesExactMap': ('quantilesExact', 'Map'), 'avgWeightedMap': ('avgWeighted', 'Map'), 'groupBitmapXorMap': ('groupBitmapXor', 'Map'), 'quantileBFloat16WeightedMap': ('quantileBFloat16Weighted', 'Map'), 'stddevSampMap': ('stddevSamp', 'Map'), 'groupArrayMovingAvgMap': ('groupArrayMovingAvg', 'Map'), 'quantilesTDigestMap': ('quantilesTDigest', 'Map'), 'quantileTDigestMap': ('quantileTDigest', 'Map'), 'quantilesInterpolatedWeightedMap': ('quantilesInterpolatedWeighted', 'Map'), 'cramersVBiasCorrectedMap': ('cramersVBiasCorrected', 'Map'), 'deltaSumMap': ('deltaSum', 'Map'), 'skewPopMap': ('skewPop', 'Map'), 'maxIntersectionsMap': ('maxIntersections', 'Map'), 'quantileGKMap': ('quantileGK', 'Map'), 'argMaxMap': ('argMax', 'Map'), 'rankCorrMap': ('rankCorr', 'Map'), 'quantilesGKMap': ('quantilesGK', 'Map'), 'exponentialTimeDecayedAvgMap': ('exponentialTimeDecayedAvg', 'Map'), 'anyMap': ('any', 'Map'), 'skewSampMap': ('skewSamp', 'Map'), 'quantilesTimingMap': ('quantilesTiming', 'Map'), 'avgMap': ('avg', 'Map'), 'studentTTestMap': ('studentTTest', 'Map'), 'stochasticLogisticRegressionMap': ('stochasticLogisticRegression', 'Map'), 'contingencyMap': ('contingency', 'Map'), 'uniqUpToMap': ('uniqUpTo', 'Map'), 'sumMapMap': ('sumMap', 'Map'), 'stddevPopSimpleState': ('stddevPop', 'SimpleState'), 'covarPopSimpleState': ('covarPop', 'SimpleState'), 'quantileExactLowSimpleState': ('quantileExactLow', 'SimpleState'), 'uniqExactSimpleState': ('uniqExact', 'SimpleState'), 'groupArrayMovingSumSimpleState': ('groupArrayMovingSum', 'SimpleState'), 'histogramSimpleState': ('histogram', 'SimpleState'), 'deltaSumTimestampSimpleState': ('deltaSumTimestamp', 'SimpleState'), 'groupArrayInsertAtSimpleState': ('groupArrayInsertAt', 'SimpleState'), 'quantileExactHighSimpleState': ('quantileExactHigh', 'SimpleState'), 'anyLastSimpleState': ('anyLast', 'SimpleState'), 'categoricalInformationValueSimpleState': ('categoricalInformationValue', 'SimpleState'), 'sumKahanSimpleState': ('sumKahan', 'SimpleState'), 'varPopSimpleState': ('varPop', 'SimpleState'), 'quantileTimingSimpleState': ('quantileTiming', 'SimpleState'), 'theilsUSimpleState': ('theilsU', 'SimpleState'), 'quantileInterpolatedWeightedSimpleState': ('quantileInterpolatedWeighted', 'SimpleState'), 'quantilesExactWeightedSimpleState': ('quantilesExactWeighted', 'SimpleState'), 'last_valueSimpleState': ('last_value', 'SimpleState'), 'sequenceNextNodeSimpleState': ('sequenceNextNode', 'SimpleState'), 'minSimpleState': ('min', 'SimpleState'), 'sumCountSimpleState': ('sumCount', 'SimpleState'), 'medianSimpleState': ('median', 'SimpleState'), 'groupArraySimpleState': ('groupArray', 'SimpleState'), 'anyHeavySimpleState': ('anyHeavy', 'SimpleState'), 'sparkBarSimpleState': ('sparkBar', 'SimpleState'), 'quantilesExactHighSimpleState': ('quantilesExactHigh', 'SimpleState'), 'largestTriangleThreeBucketsSimpleState': ('largestTriangleThreeBuckets', 'SimpleState'), 'varSampSimpleState': ('varSamp', 'SimpleState'), 'argMinSimpleState': ('argMin', 'SimpleState'), 'quantilesExactLowSimpleState': ('quantilesExactLow', 'SimpleState'), 'uniqCombined64SimpleState': ('uniqCombined64', 'SimpleState'), 'uniqSimpleState': ('uniq', 'SimpleState'), 'countSimpleState': ('count', 'SimpleState'), 'corrSimpleState': ('corr', 'SimpleState'), 'sequenceMatchSimpleState': ('sequenceMatch', 'SimpleState'), 'quantileDeterministicSimpleState': ('quantileDeterministic', 'SimpleState'), 'quantilesSimpleState': ('quantiles', 'SimpleState'), 'minMapSimpleState': ('minMap', 'SimpleState'), 'uniqHLL12SimpleState': ('uniqHLL12', 'SimpleState'), 'uniqThetaSimpleState': ('uniqTheta', 'SimpleState'), 'topKSimpleState': ('topK', 'SimpleState'), 'maxIntersectionsPositionSimpleState': ('maxIntersectionsPosition', 'SimpleState'), 'first_valueSimpleState': ('first_value', 'SimpleState'), 'quantilesTDigestWeightedSimpleState': ('quantilesTDigestWeighted', 'SimpleState'), 'entropySimpleState': ('entropy', 'SimpleState'), 'meanZTestSimpleState': ('meanZTest', 'SimpleState'), 'groupArrayLastSimpleState': ('groupArrayLast', 'SimpleState'), 'maxSimpleState': ('max', 'SimpleState'), 'simpleLinearRegressionSimpleState': ('simpleLinearRegression', 'SimpleState'), 'quantileExactSimpleState': ('quantileExact', 'SimpleState'), 'quantileTDigestWeightedSimpleState': ('quantileTDigestWeighted', 'SimpleState'), 'welchTTestSimpleState': ('welchTTest', 'SimpleState'), 'retentionSimpleState': ('retention', 'SimpleState'), 'cramersVSimpleState': ('cramersV', 'SimpleState'), 'kolmogorovSmirnovTestSimpleState': ('kolmogorovSmirnovTest', 'SimpleState'), 'groupBitXorSimpleState': ('groupBitXor', 'SimpleState'), 'groupBitAndSimpleState': ('groupBitAnd', 'SimpleState'), 'exponentialMovingAverageSimpleState': ('exponentialMovingAverage', 'SimpleState'), 'groupArraySampleSimpleState': ('groupArraySample', 'SimpleState'), 'kurtSampSimpleState': ('kurtSamp', 'SimpleState'), 'sumSimpleState': ('sum', 'SimpleState'), 'uniqCombinedSimpleState': ('uniqCombined', 'SimpleState'), 'groupBitOrSimpleState': ('groupBitOr', 'SimpleState'), 'kurtPopSimpleState': ('kurtPop', 'SimpleState'), 'stochasticLinearRegressionSimpleState': ('stochasticLinearRegression', 'SimpleState'), 'boundingRatioSimpleState': ('boundingRatio', 'SimpleState'), 'intervalLengthSumSimpleState': ('intervalLengthSum', 'SimpleState'), 'covarSampSimpleState': ('covarSamp', 'SimpleState'), 'quantilesDeterministicSimpleState': ('quantilesDeterministic', 'SimpleState'), 'groupBitmapSimpleState': ('groupBitmap', 'SimpleState'), 'quantileExactWeightedSimpleState': ('quantileExactWeighted', 'SimpleState'), 'windowFunnelSimpleState': ('windowFunnel', 'SimpleState'), 'quantileBFloat16SimpleState': ('quantileBFloat16', 'SimpleState'), 'sequenceCountSimpleState': ('sequenceCount', 'SimpleState'), 'maxMapSimpleState': ('maxMap', 'SimpleState'), 'mannWhitneyUTestSimpleState': ('mannWhitneyUTest', 'SimpleState'), 'groupUniqArraySimpleState': ('groupUniqArray', 'SimpleState'), 'groupBitmapAndSimpleState': ('groupBitmapAnd', 'SimpleState'), 'quantilesBFloat16WeightedSimpleState': ('quantilesBFloat16Weighted', 'SimpleState'), 'topKWeightedSimpleState': ('topKWeighted', 'SimpleState'), 'quantileTimingWeightedSimpleState': ('quantileTimingWeighted', 'SimpleState'), 'quantileSimpleState': ('quantile', 'SimpleState'), 'quantilesBFloat16SimpleState': ('quantilesBFloat16', 'SimpleState'), 'sumWithOverflowSimpleState': ('sumWithOverflow', 'SimpleState'), 'quantilesTimingWeightedSimpleState': ('quantilesTimingWeighted', 'SimpleState'), 'groupBitmapOrSimpleState': ('groupBitmapOr', 'SimpleState'), 'quantilesExactSimpleState': ('quantilesExact', 'SimpleState'), 'avgWeightedSimpleState': ('avgWeighted', 'SimpleState'), 'groupBitmapXorSimpleState': ('groupBitmapXor', 'SimpleState'), 'quantileBFloat16WeightedSimpleState': ('quantileBFloat16Weighted', 'SimpleState'), 'stddevSampSimpleState': ('stddevSamp', 'SimpleState'), 'groupArrayMovingAvgSimpleState': ('groupArrayMovingAvg', 'SimpleState'), 'quantilesTDigestSimpleState': ('quantilesTDigest', 'SimpleState'), 'quantileTDigestSimpleState': ('quantileTDigest', 'SimpleState'), 'quantilesInterpolatedWeightedSimpleState': ('quantilesInterpolatedWeighted', 'SimpleState'), 'cramersVBiasCorrectedSimpleState': ('cramersVBiasCorrected', 'SimpleState'), 'deltaSumSimpleState': ('deltaSum', 'SimpleState'), 'skewPopSimpleState': ('skewPop', 'SimpleState'), 'maxIntersectionsSimpleState': ('maxIntersections', 'SimpleState'), 'quantileGKSimpleState': ('quantileGK', 'SimpleState'), 'argMaxSimpleState': ('argMax', 'SimpleState'), 'rankCorrSimpleState': ('rankCorr', 'SimpleState'), 'quantilesGKSimpleState': ('quantilesGK', 'SimpleState'), 'exponentialTimeDecayedAvgSimpleState': ('exponentialTimeDecayedAvg', 'SimpleState'), 'anySimpleState': ('any', 'SimpleState'), 'skewSampSimpleState': ('skewSamp', 'SimpleState'), 'quantilesTimingSimpleState': ('quantilesTiming', 'SimpleState'), 'avgSimpleState': ('avg', 'SimpleState'), 'studentTTestSimpleState': ('studentTTest', 'SimpleState'), 'stochasticLogisticRegressionSimpleState': ('stochasticLogisticRegression', 'SimpleState'), 'contingencySimpleState': ('contingency', 'SimpleState'), 'uniqUpToSimpleState': ('uniqUpTo', 'SimpleState'), 'sumMapSimpleState': ('sumMap', 'SimpleState'), 'stddevPopState': ('stddevPop', 'State'), 'covarPopState': ('covarPop', 'State'), 'quantileExactLowState': ('quantileExactLow', 'State'), 'uniqExactState': ('uniqExact', 'State'), 'groupArrayMovingSumState': ('groupArrayMovingSum', 'State'), 'histogramState': ('histogram', 'State'), 'deltaSumTimestampState': ('deltaSumTimestamp', 'State'), 'groupArrayInsertAtState': ('groupArrayInsertAt', 'State'), 'quantileExactHighState': ('quantileExactHigh', 'State'), 'anyLastState': ('anyLast', 'State'), 'categoricalInformationValueState': ('categoricalInformationValue', 'State'), 'sumKahanState': ('sumKahan', 'State'), 'varPopState': ('varPop', 'State'), 'quantileTimingState': ('quantileTiming', 'State'), 'theilsUState': ('theilsU', 'State'), 'quantileInterpolatedWeightedState': ('quantileInterpolatedWeighted', 'State'), 'quantilesExactWeightedState': ('quantilesExactWeighted', 'State'), 'last_valueState': ('last_value', 'State'), 'sequenceNextNodeState': ('sequenceNextNode', 'State'), 'minState': ('min', 'State'), 'sumCountState': ('sumCount', 'State'), 'medianState': ('median', 'State'), 'groupArrayState': ('groupArray', 'State'), 'anyHeavyState': ('anyHeavy', 'State'), 'sparkBarState': ('sparkBar', 'State'), 'quantilesExactHighState': ('quantilesExactHigh', 'State'), 'largestTriangleThreeBucketsState': ('largestTriangleThreeBuckets', 'State'), 'varSampState': ('varSamp', 'State'), 'argMinState': ('argMin', 'State'), 'quantilesExactLowState': ('quantilesExactLow', 'State'), 'uniqCombined64State': ('uniqCombined64', 'State'), 'uniqState': ('uniq', 'State'), 'countState': ('count', 'State'), 'corrState': ('corr', 'State'), 'sequenceMatchState': ('sequenceMatch', 'State'), 'quantileDeterministicState': ('quantileDeterministic', 'State'), 'quantilesState': ('quantiles', 'State'), 'minMapState': ('minMap', 'State'), 'uniqHLL12State': ('uniqHLL12', 'State'), 'uniqThetaState': ('uniqTheta', 'State'), 'topKState': ('topK', 'State'), 'maxIntersectionsPositionState': ('maxIntersectionsPosition', 'State'), 'first_valueState': ('first_value', 'State'), 'quantilesTDigestWeightedState': ('quantilesTDigestWeighted', 'State'), 'entropyState': ('entropy', 'State'), 'meanZTestState': ('meanZTest', 'State'), 'groupArrayLastState': ('groupArrayLast', 'State'), 'maxState': ('max', 'State'), 'simpleLinearRegressionState': ('simpleLinearRegression', 'State'), 'quantileExactState': ('quantileExact', 'State'), 'quantileTDigestWeightedState': ('quantileTDigestWeighted', 'State'), 'welchTTestState': ('welchTTest', 'State'), 'retentionState': ('retention', 'State'), 'cramersVState': ('cramersV', 'State'), 'kolmogorovSmirnovTestState': ('kolmogorovSmirnovTest', 'State'), 'groupBitXorState': ('groupBitXor', 'State'), 'groupBitAndState': ('groupBitAnd', 'State'), 'exponentialMovingAverageState': ('exponentialMovingAverage', 'State'), 'groupArraySampleState': ('groupArraySample', 'State'), 'kurtSampState': ('kurtSamp', 'State'), 'sumState': ('sum', 'State'), 'uniqCombinedState': ('uniqCombined', 'State'), 'groupBitOrState': ('groupBitOr', 'State'), 'kurtPopState': ('kurtPop', 'State'), 'stochasticLinearRegressionState': ('stochasticLinearRegression', 'State'), 'boundingRatioState': ('boundingRatio', 'State'), 'intervalLengthSumState': ('intervalLengthSum', 'State'), 'covarSampState': ('covarSamp', 'State'), 'quantilesDeterministicState': ('quantilesDeterministic', 'State'), 'groupBitmapState': ('groupBitmap', 'State'), 'quantileExactWeightedState': ('quantileExactWeighted', 'State'), 'windowFunnelState': ('windowFunnel', 'State'), 'quantileBFloat16State': ('quantileBFloat16', 'State'), 'sequenceCountState': ('sequenceCount', 'State'), 'maxMapState': ('maxMap', 'State'), 'mannWhitneyUTestState': ('mannWhitneyUTest', 'State'), 'groupUniqArrayState': ('groupUniqArray', 'State'), 'groupBitmapAndState': ('groupBitmapAnd', 'State'), 'quantilesBFloat16WeightedState': ('quantilesBFloat16Weighted', 'State'), 'topKWeightedState': ('topKWeighted', 'State'), 'quantileTimingWeightedState': ('quantileTimingWeighted', 'State'), 'quantileState': ('quantile', 'State'), 'quantilesBFloat16State': ('quantilesBFloat16', 'State'), 'sumWithOverflowState': ('sumWithOverflow', 'State'), 'quantilesTimingWeightedState': ('quantilesTimingWeighted', 'State'), 'groupBitmapOrState': ('groupBitmapOr', 'State'), 'quantilesExactState': ('quantilesExact', 'State'), 'avgWeightedState': ('avgWeighted', 'State'), 'groupBitmapXorState': ('groupBitmapXor', 'State'), 'quantileBFloat16WeightedState': ('quantileBFloat16Weighted', 'State'), 'stddevSampState': ('stddevSamp', 'State'), 'groupArrayMovingAvgState': ('groupArrayMovingAvg', 'State'), 'quantilesTDigestState': ('quantilesTDigest', 'State'), 'quantileTDigestState': ('quantileTDigest', 'State'), 'quantilesInterpolatedWeightedState': ('quantilesInterpolatedWeighted', 'State'), 'cramersVBiasCorrectedState': ('cramersVBiasCorrected', 'State'), 'deltaSumState': ('deltaSum', 'State'), 'skewPopState': ('skewPop', 'State'), 'maxIntersectionsState': ('maxIntersections', 'State'), 'quantileGKState': ('quantileGK', 'State'), 'argMaxState': ('argMax', 'State'), 'rankCorrState': ('rankCorr', 'State'), 'quantilesGKState': ('quantilesGK', 'State'), 'exponentialTimeDecayedAvgState': ('exponentialTimeDecayedAvg', 'State'), 'anyState': ('any', 'State'), 'skewSampState': ('skewSamp', 'State'), 'quantilesTimingState': ('quantilesTiming', 'State'), 'avgState': ('avg', 'State'), 'studentTTestState': ('studentTTest', 'State'), 'stochasticLogisticRegressionState': ('stochasticLogisticRegression', 'State'), 'contingencyState': ('contingency', 'State'), 'uniqUpToState': ('uniqUpTo', 'State'), 'sumMapState': ('sumMap', 'State'), 'stddevPopMerge': ('stddevPop', 'Merge'), 'covarPopMerge': ('covarPop', 'Merge'), 'quantileExactLowMerge': ('quantileExactLow', 'Merge'), 'uniqExactMerge': ('uniqExact', 'Merge'), 'groupArrayMovingSumMerge': ('groupArrayMovingSum', 'Merge'), 'histogramMerge': ('histogram', 'Merge'), 'deltaSumTimestampMerge': ('deltaSumTimestamp', 'Merge'), 'groupArrayInsertAtMerge': ('groupArrayInsertAt', 'Merge'), 'quantileExactHighMerge': ('quantileExactHigh', 'Merge'), 'anyLastMerge': ('anyLast', 'Merge'), 'categoricalInformationValueMerge': ('categoricalInformationValue', 'Merge'), 'sumKahanMerge': ('sumKahan', 'Merge'), 'varPopMerge': ('varPop', 'Merge'), 'quantileTimingMerge': ('quantileTiming', 'Merge'), 'theilsUMerge': ('theilsU', 'Merge'), 'quantileInterpolatedWeightedMerge': ('quantileInterpolatedWeighted', 'Merge'), 'quantilesExactWeightedMerge': ('quantilesExactWeighted', 'Merge'), 'last_valueMerge': ('last_value', 'Merge'), 'sequenceNextNodeMerge': ('sequenceNextNode', 'Merge'), 'minMerge': ('min', 'Merge'), 'sumCountMerge': ('sumCount', 'Merge'), 'medianMerge': ('median', 'Merge'), 'groupArrayMerge': ('groupArray', 'Merge'), 'anyHeavyMerge': ('anyHeavy', 'Merge'), 'sparkBarMerge': ('sparkBar', 'Merge'), 'quantilesExactHighMerge': ('quantilesExactHigh', 'Merge'), 'largestTriangleThreeBucketsMerge': ('largestTriangleThreeBuckets', 'Merge'), 'varSampMerge': ('varSamp', 'Merge'), 'argMinMerge': ('argMin', 'Merge'), 'quantilesExactLowMerge': ('quantilesExactLow', 'Merge'), 'uniqCombined64Merge': ('uniqCombined64', 'Merge'), 'uniqMerge': ('uniq', 'Merge'), 'countMerge': ('count', 'Merge'), 'corrMerge': ('corr', 'Merge'), 'sequenceMatchMerge': ('sequenceMatch', 'Merge'), 'quantileDeterministicMerge': ('quantileDeterministic', 'Merge'), 'quantilesMerge': ('quantiles', 'Merge'), 'minMapMerge': ('minMap', 'Merge'), 'uniqHLL12Merge': ('uniqHLL12', 'Merge'), 'uniqThetaMerge': ('uniqTheta', 'Merge'), 'topKMerge': ('topK', 'Merge'), 'maxIntersectionsPositionMerge': ('maxIntersectionsPosition', 'Merge'), 'first_valueMerge': ('first_value', 'Merge'), 'quantilesTDigestWeightedMerge': ('quantilesTDigestWeighted', 'Merge'), 'entropyMerge': ('entropy', 'Merge'), 'meanZTestMerge': ('meanZTest', 'Merge'), 'groupArrayLastMerge': ('groupArrayLast', 'Merge'), 'maxMerge': ('max', 'Merge'), 'simpleLinearRegressionMerge': ('simpleLinearRegression', 'Merge'), 'quantileExactMerge': ('quantileExact', 'Merge'), 'quantileTDigestWeightedMerge': ('quantileTDigestWeighted', 'Merge'), 'welchTTestMerge': ('welchTTest', 'Merge'), 'retentionMerge': ('retention', 'Merge'), 'cramersVMerge': ('cramersV', 'Merge'), 'kolmogorovSmirnovTestMerge': ('kolmogorovSmirnovTest', 'Merge'), 'groupBitXorMerge': ('groupBitXor', 'Merge'), 'groupBitAndMerge': ('groupBitAnd', 'Merge'), 'exponentialMovingAverageMerge': ('exponentialMovingAverage', 'Merge'), 'groupArraySampleMerge': ('groupArraySample', 'Merge'), 'kurtSampMerge': ('kurtSamp', 'Merge'), 'sumMerge': ('sum', 'Merge'), 'uniqCombinedMerge': ('uniqCombined', 'Merge'), 'groupBitOrMerge': ('groupBitOr', 'Merge'), 'kurtPopMerge': ('kurtPop', 'Merge'), 'stochasticLinearRegressionMerge': ('stochasticLinearRegression', 'Merge'), 'boundingRatioMerge': ('boundingRatio', 'Merge'), 'intervalLengthSumMerge': ('intervalLengthSum', 'Merge'), 'covarSampMerge': ('covarSamp', 'Merge'), 'quantilesDeterministicMerge': ('quantilesDeterministic', 'Merge'), 'groupBitmapMerge': ('groupBitmap', 'Merge'), 'quantileExactWeightedMerge': ('quantileExactWeighted', 'Merge'), 'windowFunnelMerge': ('windowFunnel', 'Merge'), 'quantileBFloat16Merge': ('quantileBFloat16', 'Merge'), 'sequenceCountMerge': ('sequenceCount', 'Merge'), 'maxMapMerge': ('maxMap', 'Merge'), 'mannWhitneyUTestMerge': ('mannWhitneyUTest', 'Merge'), 'groupUniqArrayMerge': ('groupUniqArray', 'Merge'), 'groupBitmapAndMerge': ('groupBitmapAnd', 'Merge'), 'quantilesBFloat16WeightedMerge': ('quantilesBFloat16Weighted', 'Merge'), 'topKWeightedMerge': ('topKWeighted', 'Merge'), 'quantileTimingWeightedMerge': ('quantileTimingWeighted', 'Merge'), 'quantileMerge': ('quantile', 'Merge'), 'quantilesBFloat16Merge': ('quantilesBFloat16', 'Merge'), 'sumWithOverflowMerge': ('sumWithOverflow', 'Merge'), 'quantilesTimingWeightedMerge': ('quantilesTimingWeighted', 'Merge'), 'groupBitmapOrMerge': ('groupBitmapOr', 'Merge'), 'quantilesExactMerge': ('quantilesExact', 'Merge'), 'avgWeightedMerge': ('avgWeighted', 'Merge'), 'groupBitmapXorMerge': ('groupBitmapXor', 'Merge'), 'quantileBFloat16WeightedMerge': ('quantileBFloat16Weighted', 'Merge'), 'stddevSampMerge': ('stddevSamp', 'Merge'), 'groupArrayMovingAvgMerge': ('groupArrayMovingAvg', 'Merge'), 'quantilesTDigestMerge': ('quantilesTDigest', 'Merge'), 'quantileTDigestMerge': ('quantileTDigest', 'Merge'), 'quantilesInterpolatedWeightedMerge': ('quantilesInterpolatedWeighted', 'Merge'), 'cramersVBiasCorrectedMerge': ('cramersVBiasCorrected', 'Merge'), 'deltaSumMerge': ('deltaSum', 'Merge'), 'skewPopMerge': ('skewPop', 'Merge'), 'maxIntersectionsMerge': ('maxIntersections', 'Merge'), 'quantileGKMerge': ('quantileGK', 'Merge'), 'argMaxMerge': ('argMax', 'Merge'), 'rankCorrMerge': ('rankCorr', 'Merge'), 'quantilesGKMerge': ('quantilesGK', 'Merge'), 'exponentialTimeDecayedAvgMerge': ('exponentialTimeDecayedAvg', 'Merge'), 'anyMerge': ('any', 'Merge'), 'skewSampMerge': ('skewSamp', 'Merge'), 'quantilesTimingMerge': ('quantilesTiming', 'Merge'), 'avgMerge': ('avg', 'Merge'), 'studentTTestMerge': ('studentTTest', 'Merge'), 'stochasticLogisticRegressionMerge': ('stochasticLogisticRegression', 'Merge'), 'contingencyMerge': ('contingency', 'Merge'), 'uniqUpToMerge': ('uniqUpTo', 'Merge'), 'sumMapMerge': ('sumMap', 'Merge'), 'stddevPopMergeState': ('stddevPop', 'MergeState'), 'covarPopMergeState': ('covarPop', 'MergeState'), 'quantileExactLowMergeState': ('quantileExactLow', 'MergeState'), 'uniqExactMergeState': ('uniqExact', 'MergeState'), 'groupArrayMovingSumMergeState': ('groupArrayMovingSum', 'MergeState'), 'histogramMergeState': ('histogram', 'MergeState'), 'deltaSumTimestampMergeState': ('deltaSumTimestamp', 'MergeState'), 'groupArrayInsertAtMergeState': ('groupArrayInsertAt', 'MergeState'), 'quantileExactHighMergeState': ('quantileExactHigh', 'MergeState'), 'anyLastMergeState': ('anyLast', 'MergeState'), 'categoricalInformationValueMergeState': ('categoricalInformationValue', 'MergeState'), 'sumKahanMergeState': ('sumKahan', 'MergeState'), 'varPopMergeState': ('varPop', 'MergeState'), 'quantileTimingMergeState': ('quantileTiming', 'MergeState'), 'theilsUMergeState': ('theilsU', 'MergeState'), 'quantileInterpolatedWeightedMergeState': ('quantileInterpolatedWeighted', 'MergeState'), 'quantilesExactWeightedMergeState': ('quantilesExactWeighted', 'MergeState'), 'last_valueMergeState': ('last_value', 'MergeState'), 'sequenceNextNodeMergeState': ('sequenceNextNode', 'MergeState'), 'minMergeState': ('min', 'MergeState'), 'sumCountMergeState': ('sumCount', 'MergeState'), 'medianMergeState': ('median', 'MergeState'), 'groupArrayMergeState': ('groupArray', 'MergeState'), 'anyHeavyMergeState': ('anyHeavy', 'MergeState'), 'sparkBarMergeState': ('sparkBar', 'MergeState'), 'quantilesExactHighMergeState': ('quantilesExactHigh', 'MergeState'), 'largestTriangleThreeBucketsMergeState': ('largestTriangleThreeBuckets', 'MergeState'), 'varSampMergeState': ('varSamp', 'MergeState'), 'argMinMergeState': ('argMin', 'MergeState'), 'quantilesExactLowMergeState': ('quantilesExactLow', 'MergeState'), 'uniqCombined64MergeState': ('uniqCombined64', 'MergeState'), 'uniqMergeState': ('uniq', 'MergeState'), 'countMergeState': ('count', 'MergeState'), 'corrMergeState': ('corr', 'MergeState'), 'sequenceMatchMergeState': ('sequenceMatch', 'MergeState'), 'quantileDeterministicMergeState': ('quantileDeterministic', 'MergeState'), 'quantilesMergeState': ('quantiles', 'MergeState'), 'minMapMergeState': ('minMap', 'MergeState'), 'uniqHLL12MergeState': ('uniqHLL12', 'MergeState'), 'uniqThetaMergeState': ('uniqTheta', 'MergeState'), 'topKMergeState': ('topK', 'MergeState'), 'maxIntersectionsPositionMergeState': ('maxIntersectionsPosition', 'MergeState'), 'first_valueMergeState': ('first_value', 'MergeState'), 'quantilesTDigestWeightedMergeState': ('quantilesTDigestWeighted', 'MergeState'), 'entropyMergeState': ('entropy', 'MergeState'), 'meanZTestMergeState': ('meanZTest', 'MergeState'), 'groupArrayLastMergeState': ('groupArrayLast', 'MergeState'), 'maxMergeState': ('max', 'MergeState'), 'simpleLinearRegressionMergeState': ('simpleLinearRegression', 'MergeState'), 'quantileExactMergeState': ('quantileExact', 'MergeState'), 'quantileTDigestWeightedMergeState': ('quantileTDigestWeighted', 'MergeState'), 'welchTTestMergeState': ('welchTTest', 'MergeState'), 'retentionMergeState': ('retention', 'MergeState'), 'cramersVMergeState': ('cramersV', 'MergeState'), 'kolmogorovSmirnovTestMergeState': ('kolmogorovSmirnovTest', 'MergeState'), 'groupBitXorMergeState': ('groupBitXor', 'MergeState'), 'groupBitAndMergeState': ('groupBitAnd', 'MergeState'), 'exponentialMovingAverageMergeState': ('exponentialMovingAverage', 'MergeState'), 'groupArraySampleMergeState': ('groupArraySample', 'MergeState'), 'kurtSampMergeState': ('kurtSamp', 'MergeState'), 'sumMergeState': ('sum', 'MergeState'), 'uniqCombinedMergeState': ('uniqCombined', 'MergeState'), 'groupBitOrMergeState': ('groupBitOr', 'MergeState'), 'kurtPopMergeState': ('kurtPop', 'MergeState'), 'stochasticLinearRegressionMergeState': ('stochasticLinearRegression', 'MergeState'), 'boundingRatioMergeState': ('boundingRatio', 'MergeState'), 'intervalLengthSumMergeState': ('intervalLengthSum', 'MergeState'), 'covarSampMergeState': ('covarSamp', 'MergeState'), 'quantilesDeterministicMergeState': ('quantilesDeterministic', 'MergeState'), 'groupBitmapMergeState': ('groupBitmap', 'MergeState'), 'quantileExactWeightedMergeState': ('quantileExactWeighted', 'MergeState'), 'windowFunnelMergeState': ('windowFunnel', 'MergeState'), 'quantileBFloat16MergeState': ('quantileBFloat16', 'MergeState'), 'sequenceCountMergeState': ('sequenceCount', 'MergeState'), 'maxMapMergeState': ('maxMap', 'MergeState'), 'mannWhitneyUTestMergeState': ('mannWhitneyUTest', 'MergeState'), 'groupUniqArrayMergeState': ('groupUniqArray', 'MergeState'), 'groupBitmapAndMergeState': ('groupBitmapAnd', 'MergeState'), 'quantilesBFloat16WeightedMergeState': ('quantilesBFloat16Weighted', 'MergeState'), 'topKWeightedMergeState': ('topKWeighted', 'MergeState'), 'quantileTimingWeightedMergeState': ('quantileTimingWeighted', 'MergeState'), 'quantileMergeState': ('quantile', 'MergeState'), 'quantilesBFloat16MergeState': ('quantilesBFloat16', 'MergeState'), 'sumWithOverflowMergeState': ('sumWithOverflow', 'MergeState'), 'quantilesTimingWeightedMergeState': ('quantilesTimingWeighted', 'MergeState'), 'groupBitmapOrMergeState': ('groupBitmapOr', 'MergeState'), 'quantilesExactMergeState': ('quantilesExact', 'MergeState'), 'avgWeightedMergeState': ('avgWeighted', 'MergeState'), 'groupBitmapXorMergeState': ('groupBitmapXor', 'MergeState'), 'quantileBFloat16WeightedMergeState': ('quantileBFloat16Weighted', 'MergeState'), 'stddevSampMergeState': ('stddevSamp', 'MergeState'), 'groupArrayMovingAvgMergeState': ('groupArrayMovingAvg', 'MergeState'), 'quantilesTDigestMergeState': ('quantilesTDigest', 'MergeState'), 'quantileTDigestMergeState': ('quantileTDigest', 'MergeState'), 'quantilesInterpolatedWeightedMergeState': ('quantilesInterpolatedWeighted', 'MergeState'), 'cramersVBiasCorrectedMergeState': ('cramersVBiasCorrected', 'MergeState'), 'deltaSumMergeState': ('deltaSum', 'MergeState'), 'skewPopMergeState': ('skewPop', 'MergeState'), 'maxIntersectionsMergeState': ('maxIntersections', 'MergeState'), 'quantileGKMergeState': ('quantileGK', 'MergeState'), 'argMaxMergeState': ('argMax', 'MergeState'), 'rankCorrMergeState': ('rankCorr', 'MergeState'), 'quantilesGKMergeState': ('quantilesGK', 'MergeState'), 'exponentialTimeDecayedAvgMergeState': ('exponentialTimeDecayedAvg', 'MergeState'), 'anyMergeState': ('any', 'MergeState'), 'skewSampMergeState': ('skewSamp', 'MergeState'), 'quantilesTimingMergeState': ('quantilesTiming', 'MergeState'), 'avgMergeState': ('avg', 'MergeState'), 'studentTTestMergeState': ('studentTTest', 'MergeState'), 'stochasticLogisticRegressionMergeState': ('stochasticLogisticRegression', 'MergeState'), 'contingencyMergeState': ('contingency', 'MergeState'), 'uniqUpToMergeState': ('uniqUpTo', 'MergeState'), 'sumMapMergeState': ('sumMap', 'MergeState'), 'stddevPopForEach': ('stddevPop', 'ForEach'), 'covarPopForEach': ('covarPop', 'ForEach'), 'quantileExactLowForEach': ('quantileExactLow', 'ForEach'), 'uniqExactForEach': ('uniqExact', 'ForEach'), 'groupArrayMovingSumForEach': ('groupArrayMovingSum', 'ForEach'), 'histogramForEach': ('histogram', 'ForEach'), 'deltaSumTimestampForEach': ('deltaSumTimestamp', 'ForEach'), 'groupArrayInsertAtForEach': ('groupArrayInsertAt', 'ForEach'), 'quantileExactHighForEach': ('quantileExactHigh', 'ForEach'), 'anyLastForEach': ('anyLast', 'ForEach'), 'categoricalInformationValueForEach': ('categoricalInformationValue', 'ForEach'), 'sumKahanForEach': ('sumKahan', 'ForEach'), 'varPopForEach': ('varPop', 'ForEach'), 'quantileTimingForEach': ('quantileTiming', 'ForEach'), 'theilsUForEach': ('theilsU', 'ForEach'), 'quantileInterpolatedWeightedForEach': ('quantileInterpolatedWeighted', 'ForEach'), 'quantilesExactWeightedForEach': ('quantilesExactWeighted', 'ForEach'), 'last_valueForEach': ('last_value', 'ForEach'), 'sequenceNextNodeForEach': ('sequenceNextNode', 'ForEach'), 'minForEach': ('min', 'ForEach'), 'sumCountForEach': ('sumCount', 'ForEach'), 'medianForEach': ('median', 'ForEach'), 'groupArrayForEach': ('groupArray', 'ForEach'), 'anyHeavyForEach': ('anyHeavy', 'ForEach'), 'sparkBarForEach': ('sparkBar', 'ForEach'), 'quantilesExactHighForEach': ('quantilesExactHigh', 'ForEach'), 'largestTriangleThreeBucketsForEach': ('largestTriangleThreeBuckets', 'ForEach'), 'varSampForEach': ('varSamp', 'ForEach'), 'argMinForEach': ('argMin', 'ForEach'), 'quantilesExactLowForEach': ('quantilesExactLow', 'ForEach'), 'uniqCombined64ForEach': ('uniqCombined64', 'ForEach'), 'uniqForEach': ('uniq', 'ForEach'), 'countForEach': ('count', 'ForEach'), 'corrForEach': ('corr', 'ForEach'), 'sequenceMatchForEach': ('sequenceMatch', 'ForEach'), 'quantileDeterministicForEach': ('quantileDeterministic', 'ForEach'), 'quantilesForEach': ('quantiles', 'ForEach'), 'minMapForEach': ('minMap', 'ForEach'), 'uniqHLL12ForEach': ('uniqHLL12', 'ForEach'), 'uniqThetaForEach': ('uniqTheta', 'ForEach'), 'topKForEach': ('topK', 'ForEach'), 'maxIntersectionsPositionForEach': ('maxIntersectionsPosition', 'ForEach'), 'first_valueForEach': ('first_value', 'ForEach'), 'quantilesTDigestWeightedForEach': ('quantilesTDigestWeighted', 'ForEach'), 'entropyForEach': ('entropy', 'ForEach'), 'meanZTestForEach': ('meanZTest', 'ForEach'), 'groupArrayLastForEach': ('groupArrayLast', 'ForEach'), 'maxForEach': ('max', 'ForEach'), 'simpleLinearRegressionForEach': ('simpleLinearRegression', 'ForEach'), 'quantileExactForEach': ('quantileExact', 'ForEach'), 'quantileTDigestWeightedForEach': ('quantileTDigestWeighted', 'ForEach'), 'welchTTestForEach': ('welchTTest', 'ForEach'), 'retentionForEach': ('retention', 'ForEach'), 'cramersVForEach': ('cramersV', 'ForEach'), 'kolmogorovSmirnovTestForEach': ('kolmogorovSmirnovTest', 'ForEach'), 'groupBitXorForEach': ('groupBitXor', 'ForEach'), 'groupBitAndForEach': ('groupBitAnd', 'ForEach'), 'exponentialMovingAverageForEach': ('exponentialMovingAverage', 'ForEach'), 'groupArraySampleForEach': ('groupArraySample', 'ForEach'), 'kurtSampForEach': ('kurtSamp', 'ForEach'), 'sumForEach': ('sum', 'ForEach'), 'uniqCombinedForEach': ('uniqCombined', 'ForEach'), 'groupBitOrForEach': ('groupBitOr', 'ForEach'), 'kurtPopForEach': ('kurtPop', 'ForEach'), 'stochasticLinearRegressionForEach': ('stochasticLinearRegression', 'ForEach'), 'boundingRatioForEach': ('boundingRatio', 'ForEach'), 'intervalLengthSumForEach': ('intervalLengthSum', 'ForEach'), 'covarSampForEach': ('covarSamp', 'ForEach'), 'quantilesDeterministicForEach': ('quantilesDeterministic', 'ForEach'), 'groupBitmapForEach': ('groupBitmap', 'ForEach'), 'quantileExactWeightedForEach': ('quantileExactWeighted', 'ForEach'), 'windowFunnelForEach': ('windowFunnel', 'ForEach'), 'quantileBFloat16ForEach': ('quantileBFloat16', 'ForEach'), 'sequenceCountForEach': ('sequenceCount', 'ForEach'), 'maxMapForEach': ('maxMap', 'ForEach'), 'mannWhitneyUTestForEach': ('mannWhitneyUTest', 'ForEach'), 'groupUniqArrayForEach': ('groupUniqArray', 'ForEach'), 'groupBitmapAndForEach': ('groupBitmapAnd', 'ForEach'), 'quantilesBFloat16WeightedForEach': ('quantilesBFloat16Weighted', 'ForEach'), 'topKWeightedForEach': ('topKWeighted', 'ForEach'), 'quantileTimingWeightedForEach': ('quantileTimingWeighted', 'ForEach'), 'quantileForEach': ('quantile', 'ForEach'), 'quantilesBFloat16ForEach': ('quantilesBFloat16', 'ForEach'), 'sumWithOverflowForEach': ('sumWithOverflow', 'ForEach'), 'quantilesTimingWeightedForEach': ('quantilesTimingWeighted', 'ForEach'), 'groupBitmapOrForEach': ('groupBitmapOr', 'ForEach'), 'quantilesExactForEach': ('quantilesExact', 'ForEach'), 'avgWeightedForEach': ('avgWeighted', 'ForEach'), 'groupBitmapXorForEach': ('groupBitmapXor', 'ForEach'), 'quantileBFloat16WeightedForEach': ('quantileBFloat16Weighted', 'ForEach'), 'stddevSampForEach': ('stddevSamp', 'ForEach'), 'groupArrayMovingAvgForEach': ('groupArrayMovingAvg', 'ForEach'), 'quantilesTDigestForEach': ('quantilesTDigest', 'ForEach'), 'quantileTDigestForEach': ('quantileTDigest', 'ForEach'), 'quantilesInterpolatedWeightedForEach': ('quantilesInterpolatedWeighted', 'ForEach'), 'cramersVBiasCorrectedForEach': ('cramersVBiasCorrected', 'ForEach'), 'deltaSumForEach': ('deltaSum', 'ForEach'), 'skewPopForEach': ('skewPop', 'ForEach'), 'maxIntersectionsForEach': ('maxIntersections', 'ForEach'), 'quantileGKForEach': ('quantileGK', 'ForEach'), 'argMaxForEach': ('argMax', 'ForEach'), 'rankCorrForEach': ('rankCorr', 'ForEach'), 'quantilesGKForEach': ('quantilesGK', 'ForEach'), 'exponentialTimeDecayedAvgForEach': ('exponentialTimeDecayedAvg', 'ForEach'), 'anyForEach': ('any', 'ForEach'), 'skewSampForEach': ('skewSamp', 'ForEach'), 'quantilesTimingForEach': ('quantilesTiming', 'ForEach'), 'avgForEach': ('avg', 'ForEach'), 'studentTTestForEach': ('studentTTest', 'ForEach'), 'stochasticLogisticRegressionForEach': ('stochasticLogisticRegression', 'ForEach'), 'contingencyForEach': ('contingency', 'ForEach'), 'uniqUpToForEach': ('uniqUpTo', 'ForEach'), 'sumMapForEach': ('sumMap', 'ForEach'), 'stddevPopDistinct': ('stddevPop', 'Distinct'), 'covarPopDistinct': ('covarPop', 'Distinct'), 'quantileExactLowDistinct': ('quantileExactLow', 'Distinct'), 'uniqExactDistinct': ('uniqExact', 'Distinct'), 'groupArrayMovingSumDistinct': ('groupArrayMovingSum', 'Distinct'), 'histogramDistinct': ('histogram', 'Distinct'), 'deltaSumTimestampDistinct': ('deltaSumTimestamp', 'Distinct'), 'groupArrayInsertAtDistinct': ('groupArrayInsertAt', 'Distinct'), 'quantileExactHighDistinct': ('quantileExactHigh', 'Distinct'), 'anyLastDistinct': ('anyLast', 'Distinct'), 'categoricalInformationValueDistinct': ('categoricalInformationValue', 'Distinct'), 'sumKahanDistinct': ('sumKahan', 'Distinct'), 'varPopDistinct': ('varPop', 'Distinct'), 'quantileTimingDistinct': ('quantileTiming', 'Distinct'), 'theilsUDistinct': ('theilsU', 'Distinct'), 'quantileInterpolatedWeightedDistinct': ('quantileInterpolatedWeighted', 'Distinct'), 'quantilesExactWeightedDistinct': ('quantilesExactWeighted', 'Distinct'), 'last_valueDistinct': ('last_value', 'Distinct'), 'sequenceNextNodeDistinct': ('sequenceNextNode', 'Distinct'), 'minDistinct': ('min', 'Distinct'), 'sumCountDistinct': ('sumCount', 'Distinct'), 'medianDistinct': ('median', 'Distinct'), 'groupArrayDistinct': ('groupArray', 'Distinct'), 'anyHeavyDistinct': ('anyHeavy', 'Distinct'), 'sparkBarDistinct': ('sparkBar', 'Distinct'), 'quantilesExactHighDistinct': ('quantilesExactHigh', 'Distinct'), 'largestTriangleThreeBucketsDistinct': ('largestTriangleThreeBuckets', 'Distinct'), 'varSampDistinct': ('varSamp', 'Distinct'), 'argMinDistinct': ('argMin', 'Distinct'), 'quantilesExactLowDistinct': ('quantilesExactLow', 'Distinct'), 'uniqCombined64Distinct': ('uniqCombined64', 'Distinct'), 'uniqDistinct': ('uniq', 'Distinct'), 'countDistinct': ('count', 'Distinct'), 'corrDistinct': ('corr', 'Distinct'), 'sequenceMatchDistinct': ('sequenceMatch', 'Distinct'), 'quantileDeterministicDistinct': ('quantileDeterministic', 'Distinct'), 'quantilesDistinct': ('quantiles', 'Distinct'), 'minMapDistinct': ('minMap', 'Distinct'), 'uniqHLL12Distinct': ('uniqHLL12', 'Distinct'), 'uniqThetaDistinct': ('uniqTheta', 'Distinct'), 'topKDistinct': ('topK', 'Distinct'), 'maxIntersectionsPositionDistinct': ('maxIntersectionsPosition', 'Distinct'), 'first_valueDistinct': ('first_value', 'Distinct'), 'quantilesTDigestWeightedDistinct': ('quantilesTDigestWeighted', 'Distinct'), 'entropyDistinct': ('entropy', 'Distinct'), 'meanZTestDistinct': ('meanZTest', 'Distinct'), 'groupArrayLastDistinct': ('groupArrayLast', 'Distinct'), 'maxDistinct': ('max', 'Distinct'), 'simpleLinearRegressionDistinct': ('simpleLinearRegression', 'Distinct'), 'quantileExactDistinct': ('quantileExact', 'Distinct'), 'quantileTDigestWeightedDistinct': ('quantileTDigestWeighted', 'Distinct'), 'welchTTestDistinct': ('welchTTest', 'Distinct'), 'retentionDistinct': ('retention', 'Distinct'), 'cramersVDistinct': ('cramersV', 'Distinct'), 'kolmogorovSmirnovTestDistinct': ('kolmogorovSmirnovTest', 'Distinct'), 'groupBitXorDistinct': ('groupBitXor', 'Distinct'), 'groupBitAndDistinct': ('groupBitAnd', 'Distinct'), 'exponentialMovingAverageDistinct': ('exponentialMovingAverage', 'Distinct'), 'groupArraySampleDistinct': ('groupArraySample', 'Distinct'), 'kurtSampDistinct': ('kurtSamp', 'Distinct'), 'sumDistinct': ('sum', 'Distinct'), 'uniqCombinedDistinct': ('uniqCombined', 'Distinct'), 'groupBitOrDistinct': ('groupBitOr', 'Distinct'), 'kurtPopDistinct': ('kurtPop', 'Distinct'), 'stochasticLinearRegressionDistinct': ('stochasticLinearRegression', 'Distinct'), 'boundingRatioDistinct': ('boundingRatio', 'Distinct'), 'intervalLengthSumDistinct': ('intervalLengthSum', 'Distinct'), 'covarSampDistinct': ('covarSamp', 'Distinct'), 'quantilesDeterministicDistinct': ('quantilesDeterministic', 'Distinct'), 'groupBitmapDistinct': ('groupBitmap', 'Distinct'), 'quantileExactWeightedDistinct': ('quantileExactWeighted', 'Distinct'), 'windowFunnelDistinct': ('windowFunnel', 'Distinct'), 'quantileBFloat16Distinct': ('quantileBFloat16', 'Distinct'), 'sequenceCountDistinct': ('sequenceCount', 'Distinct'), 'maxMapDistinct': ('maxMap', 'Distinct'), 'mannWhitneyUTestDistinct': ('mannWhitneyUTest', 'Distinct'), 'groupUniqArrayDistinct': ('groupUniqArray', 'Distinct'), 'groupBitmapAndDistinct': ('groupBitmapAnd', 'Distinct'), 'quantilesBFloat16WeightedDistinct': ('quantilesBFloat16Weighted', 'Distinct'), 'topKWeightedDistinct': ('topKWeighted', 'Distinct'), 'quantileTimingWeightedDistinct': ('quantileTimingWeighted', 'Distinct'), 'quantileDistinct': ('quantile', 'Distinct'), 'quantilesBFloat16Distinct': ('quantilesBFloat16', 'Distinct'), 'sumWithOverflowDistinct': ('sumWithOverflow', 'Distinct'), 'quantilesTimingWeightedDistinct': ('quantilesTimingWeighted', 'Distinct'), 'groupBitmapOrDistinct': ('groupBitmapOr', 'Distinct'), 'quantilesExactDistinct': ('quantilesExact', 'Distinct'), 'avgWeightedDistinct': ('avgWeighted', 'Distinct'), 'groupBitmapXorDistinct': ('groupBitmapXor', 'Distinct'), 'quantileBFloat16WeightedDistinct': ('quantileBFloat16Weighted', 'Distinct'), 'stddevSampDistinct': ('stddevSamp', 'Distinct'), 'groupArrayMovingAvgDistinct': ('groupArrayMovingAvg', 'Distinct'), 'quantilesTDigestDistinct': ('quantilesTDigest', 'Distinct'), 'quantileTDigestDistinct': ('quantileTDigest', 'Distinct'), 'quantilesInterpolatedWeightedDistinct': ('quantilesInterpolatedWeighted', 'Distinct'), 'cramersVBiasCorrectedDistinct': ('cramersVBiasCorrected', 'Distinct'), 'deltaSumDistinct': ('deltaSum', 'Distinct'), 'skewPopDistinct': ('skewPop', 'Distinct'), 'maxIntersectionsDistinct': ('maxIntersections', 'Distinct'), 'quantileGKDistinct': ('quantileGK', 'Distinct'), 'argMaxDistinct': ('argMax', 'Distinct'), 'rankCorrDistinct': ('rankCorr', 'Distinct'), 'quantilesGKDistinct': ('quantilesGK', 'Distinct'), 'exponentialTimeDecayedAvgDistinct': ('exponentialTimeDecayedAvg', 'Distinct'), 'anyDistinct': ('any', 'Distinct'), 'skewSampDistinct': ('skewSamp', 'Distinct'), 'quantilesTimingDistinct': ('quantilesTiming', 'Distinct'), 'avgDistinct': ('avg', 'Distinct'), 'studentTTestDistinct': ('studentTTest', 'Distinct'), 'stochasticLogisticRegressionDistinct': ('stochasticLogisticRegression', 'Distinct'), 'contingencyDistinct': ('contingency', 'Distinct'), 'uniqUpToDistinct': ('uniqUpTo', 'Distinct'), 'sumMapDistinct': ('sumMap', 'Distinct'), 'stddevPopOrDefault': ('stddevPop', 'OrDefault'), 'covarPopOrDefault': ('covarPop', 'OrDefault'), 'quantileExactLowOrDefault': ('quantileExactLow', 'OrDefault'), 'uniqExactOrDefault': ('uniqExact', 'OrDefault'), 'groupArrayMovingSumOrDefault': ('groupArrayMovingSum', 'OrDefault'), 'histogramOrDefault': ('histogram', 'OrDefault'), 'deltaSumTimestampOrDefault': ('deltaSumTimestamp', 'OrDefault'), 'groupArrayInsertAtOrDefault': ('groupArrayInsertAt', 'OrDefault'), 'quantileExactHighOrDefault': ('quantileExactHigh', 'OrDefault'), 'anyLastOrDefault': ('anyLast', 'OrDefault'), 'categoricalInformationValueOrDefault': ('categoricalInformationValue', 'OrDefault'), 'sumKahanOrDefault': ('sumKahan', 'OrDefault'), 'varPopOrDefault': ('varPop', 'OrDefault'), 'quantileTimingOrDefault': ('quantileTiming', 'OrDefault'), 'theilsUOrDefault': ('theilsU', 'OrDefault'), 'quantileInterpolatedWeightedOrDefault': ('quantileInterpolatedWeighted', 'OrDefault'), 'quantilesExactWeightedOrDefault': ('quantilesExactWeighted', 'OrDefault'), 'last_valueOrDefault': ('last_value', 'OrDefault'), 'sequenceNextNodeOrDefault': ('sequenceNextNode', 'OrDefault'), 'minOrDefault': ('min', 'OrDefault'), 'sumCountOrDefault': ('sumCount', 'OrDefault'), 'medianOrDefault': ('median', 'OrDefault'), 'groupArrayOrDefault': ('groupArray', 'OrDefault'), 'anyHeavyOrDefault': ('anyHeavy', 'OrDefault'), 'sparkBarOrDefault': ('sparkBar', 'OrDefault'), 'quantilesExactHighOrDefault': ('quantilesExactHigh', 'OrDefault'), 'largestTriangleThreeBucketsOrDefault': ('largestTriangleThreeBuckets', 'OrDefault'), 'varSampOrDefault': ('varSamp', 'OrDefault'), 'argMinOrDefault': ('argMin', 'OrDefault'), 'quantilesExactLowOrDefault': ('quantilesExactLow', 'OrDefault'), 'uniqCombined64OrDefault': ('uniqCombined64', 'OrDefault'), 'uniqOrDefault': ('uniq', 'OrDefault'), 'countOrDefault': ('count', 'OrDefault'), 'corrOrDefault': ('corr', 'OrDefault'), 'sequenceMatchOrDefault': ('sequenceMatch', 'OrDefault'), 'quantileDeterministicOrDefault': ('quantileDeterministic', 'OrDefault'), 'quantilesOrDefault': ('quantiles', 'OrDefault'), 'minMapOrDefault': ('minMap', 'OrDefault'), 'uniqHLL12OrDefault': ('uniqHLL12', 'OrDefault'), 'uniqThetaOrDefault': ('uniqTheta', 'OrDefault'), 'topKOrDefault': ('topK', 'OrDefault'), 'maxIntersectionsPositionOrDefault': ('maxIntersectionsPosition', 'OrDefault'), 'first_valueOrDefault': ('first_value', 'OrDefault'), 'quantilesTDigestWeightedOrDefault': ('quantilesTDigestWeighted', 'OrDefault'), 'entropyOrDefault': ('entropy', 'OrDefault'), 'meanZTestOrDefault': ('meanZTest', 'OrDefault'), 'groupArrayLastOrDefault': ('groupArrayLast', 'OrDefault'), 'maxOrDefault': ('max', 'OrDefault'), 'simpleLinearRegressionOrDefault': ('simpleLinearRegression', 'OrDefault'), 'quantileExactOrDefault': ('quantileExact', 'OrDefault'), 'quantileTDigestWeightedOrDefault': ('quantileTDigestWeighted', 'OrDefault'), 'welchTTestOrDefault': ('welchTTest', 'OrDefault'), 'retentionOrDefault': ('retention', 'OrDefault'), 'cramersVOrDefault': ('cramersV', 'OrDefault'), 'kolmogorovSmirnovTestOrDefault': ('kolmogorovSmirnovTest', 'OrDefault'), 'groupBitXorOrDefault': ('groupBitXor', 'OrDefault'), 'groupBitAndOrDefault': ('groupBitAnd', 'OrDefault'), 'exponentialMovingAverageOrDefault': ('exponentialMovingAverage', 'OrDefault'), 'groupArraySampleOrDefault': ('groupArraySample', 'OrDefault'), 'kurtSampOrDefault': ('kurtSamp', 'OrDefault'), 'sumOrDefault': ('sum', 'OrDefault'), 'uniqCombinedOrDefault': ('uniqCombined', 'OrDefault'), 'groupBitOrOrDefault': ('groupBitOr', 'OrDefault'), 'kurtPopOrDefault': ('kurtPop', 'OrDefault'), 'stochasticLinearRegressionOrDefault': ('stochasticLinearRegression', 'OrDefault'), 'boundingRatioOrDefault': ('boundingRatio', 'OrDefault'), 'intervalLengthSumOrDefault': ('intervalLengthSum', 'OrDefault'), 'covarSampOrDefault': ('covarSamp', 'OrDefault'), 'quantilesDeterministicOrDefault': ('quantilesDeterministic', 'OrDefault'), 'groupBitmapOrDefault': ('groupBitmap', 'OrDefault'), 'quantileExactWeightedOrDefault': ('quantileExactWeighted', 'OrDefault'), 'windowFunnelOrDefault': ('windowFunnel', 'OrDefault'), 'quantileBFloat16OrDefault': ('quantileBFloat16', 'OrDefault'), 'sequenceCountOrDefault': ('sequenceCount', 'OrDefault'), 'maxMapOrDefault': ('maxMap', 'OrDefault'), 'mannWhitneyUTestOrDefault': ('mannWhitneyUTest', 'OrDefault'), 'groupUniqArrayOrDefault': ('groupUniqArray', 'OrDefault'), 'groupBitmapAndOrDefault': ('groupBitmapAnd', 'OrDefault'), 'quantilesBFloat16WeightedOrDefault': ('quantilesBFloat16Weighted', 'OrDefault'), 'topKWeightedOrDefault': ('topKWeighted', 'OrDefault'), 'quantileTimingWeightedOrDefault': ('quantileTimingWeighted', 'OrDefault'), 'quantileOrDefault': ('quantile', 'OrDefault'), 'quantilesBFloat16OrDefault': ('quantilesBFloat16', 'OrDefault'), 'sumWithOverflowOrDefault': ('sumWithOverflow', 'OrDefault'), 'quantilesTimingWeightedOrDefault': ('quantilesTimingWeighted', 'OrDefault'), 'groupBitmapOrOrDefault': ('groupBitmapOr', 'OrDefault'), 'quantilesExactOrDefault': ('quantilesExact', 'OrDefault'), 'avgWeightedOrDefault': ('avgWeighted', 'OrDefault'), 'groupBitmapXorOrDefault': ('groupBitmapXor', 'OrDefault'), 'quantileBFloat16WeightedOrDefault': ('quantileBFloat16Weighted', 'OrDefault'), 'stddevSampOrDefault': ('stddevSamp', 'OrDefault'), 'groupArrayMovingAvgOrDefault': ('groupArrayMovingAvg', 'OrDefault'), 'quantilesTDigestOrDefault': ('quantilesTDigest', 'OrDefault'), 'quantileTDigestOrDefault': ('quantileTDigest', 'OrDefault'), 'quantilesInterpolatedWeightedOrDefault': ('quantilesInterpolatedWeighted', 'OrDefault'), 'cramersVBiasCorrectedOrDefault': ('cramersVBiasCorrected', 'OrDefault'), 'deltaSumOrDefault': ('deltaSum', 'OrDefault'), 'skewPopOrDefault': ('skewPop', 'OrDefault'), 'maxIntersectionsOrDefault': ('maxIntersections', 'OrDefault'), 'quantileGKOrDefault': ('quantileGK', 'OrDefault'), 'argMaxOrDefault': ('argMax', 'OrDefault'), 'rankCorrOrDefault': ('rankCorr', 'OrDefault'), 'quantilesGKOrDefault': ('quantilesGK', 'OrDefault'), 'exponentialTimeDecayedAvgOrDefault': ('exponentialTimeDecayedAvg', 'OrDefault'), 'anyOrDefault': ('any', 'OrDefault'), 'skewSampOrDefault': ('skewSamp', 'OrDefault'), 'quantilesTimingOrDefault': ('quantilesTiming', 'OrDefault'), 'avgOrDefault': ('avg', 'OrDefault'), 'studentTTestOrDefault': ('studentTTest', 'OrDefault'), 'stochasticLogisticRegressionOrDefault': ('stochasticLogisticRegression', 'OrDefault'), 'contingencyOrDefault': ('contingency', 'OrDefault'), 'uniqUpToOrDefault': ('uniqUpTo', 'OrDefault'), 'sumMapOrDefault': ('sumMap', 'OrDefault'), 'stddevPopOrNull': ('stddevPop', 'OrNull'), 'covarPopOrNull': ('covarPop', 'OrNull'), 'quantileExactLowOrNull': ('quantileExactLow', 'OrNull'), 'uniqExactOrNull': ('uniqExact', 'OrNull'), 'groupArrayMovingSumOrNull': ('groupArrayMovingSum', 'OrNull'), 'histogramOrNull': ('histogram', 'OrNull'), 'deltaSumTimestampOrNull': ('deltaSumTimestamp', 'OrNull'), 'groupArrayInsertAtOrNull': ('groupArrayInsertAt', 'OrNull'), 'quantileExactHighOrNull': ('quantileExactHigh', 'OrNull'), 'anyLastOrNull': ('anyLast', 'OrNull'), 'categoricalInformationValueOrNull': ('categoricalInformationValue', 'OrNull'), 'sumKahanOrNull': ('sumKahan', 'OrNull'), 'varPopOrNull': ('varPop', 'OrNull'), 'quantileTimingOrNull': ('quantileTiming', 'OrNull'), 'theilsUOrNull': ('theilsU', 'OrNull'), 'quantileInterpolatedWeightedOrNull': ('quantileInterpolatedWeighted', 'OrNull'), 'quantilesExactWeightedOrNull': ('quantilesExactWeighted', 'OrNull'), 'last_valueOrNull': ('last_value', 'OrNull'), 'sequenceNextNodeOrNull': ('sequenceNextNode', 'OrNull'), 'minOrNull': ('min', 'OrNull'), 'sumCountOrNull': ('sumCount', 'OrNull'), 'medianOrNull': ('median', 'OrNull'), 'groupArrayOrNull': ('groupArray', 'OrNull'), 'anyHeavyOrNull': ('anyHeavy', 'OrNull'), 'sparkBarOrNull': ('sparkBar', 'OrNull'), 'quantilesExactHighOrNull': ('quantilesExactHigh', 'OrNull'), 'largestTriangleThreeBucketsOrNull': ('largestTriangleThreeBuckets', 'OrNull'), 'varSampOrNull': ('varSamp', 'OrNull'), 'argMinOrNull': ('argMin', 'OrNull'), 'quantilesExactLowOrNull': ('quantilesExactLow', 'OrNull'), 'uniqCombined64OrNull': ('uniqCombined64', 'OrNull'), 'uniqOrNull': ('uniq', 'OrNull'), 'countOrNull': ('count', 'OrNull'), 'corrOrNull': ('corr', 'OrNull'), 'sequenceMatchOrNull': ('sequenceMatch', 'OrNull'), 'quantileDeterministicOrNull': ('quantileDeterministic', 'OrNull'), 'quantilesOrNull': ('quantiles', 'OrNull'), 'minMapOrNull': ('minMap', 'OrNull'), 'uniqHLL12OrNull': ('uniqHLL12', 'OrNull'), 'uniqThetaOrNull': ('uniqTheta', 'OrNull'), 'topKOrNull': ('topK', 'OrNull'), 'maxIntersectionsPositionOrNull': ('maxIntersectionsPosition', 'OrNull'), 'first_valueOrNull': ('first_value', 'OrNull'), 'quantilesTDigestWeightedOrNull': ('quantilesTDigestWeighted', 'OrNull'), 'entropyOrNull': ('entropy', 'OrNull'), 'meanZTestOrNull': ('meanZTest', 'OrNull'), 'groupArrayLastOrNull': ('groupArrayLast', 'OrNull'), 'maxOrNull': ('max', 'OrNull'), 'simpleLinearRegressionOrNull': ('simpleLinearRegression', 'OrNull'), 'quantileExactOrNull': ('quantileExact', 'OrNull'), 'quantileTDigestWeightedOrNull': ('quantileTDigestWeighted', 'OrNull'), 'welchTTestOrNull': ('welchTTest', 'OrNull'), 'retentionOrNull': ('retention', 'OrNull'), 'cramersVOrNull': ('cramersV', 'OrNull'), 'kolmogorovSmirnovTestOrNull': ('kolmogorovSmirnovTest', 'OrNull'), 'groupBitXorOrNull': ('groupBitXor', 'OrNull'), 'groupBitAndOrNull': ('groupBitAnd', 'OrNull'), 'exponentialMovingAverageOrNull': ('exponentialMovingAverage', 'OrNull'), 'groupArraySampleOrNull': ('groupArraySample', 'OrNull'), 'kurtSampOrNull': ('kurtSamp', 'OrNull'), 'sumOrNull': ('sum', 'OrNull'), 'uniqCombinedOrNull': ('uniqCombined', 'OrNull'), 'groupBitOrOrNull': ('groupBitOr', 'OrNull'), 'kurtPopOrNull': ('kurtPop', 'OrNull'), 'stochasticLinearRegressionOrNull': ('stochasticLinearRegression', 'OrNull'), 'boundingRatioOrNull': ('boundingRatio', 'OrNull'), 'intervalLengthSumOrNull': ('intervalLengthSum', 'OrNull'), 'covarSampOrNull': ('covarSamp', 'OrNull'), 'quantilesDeterministicOrNull': ('quantilesDeterministic', 'OrNull'), 'groupBitmapOrNull': ('groupBitmap', 'OrNull'), 'quantileExactWeightedOrNull': ('quantileExactWeighted', 'OrNull'), 'windowFunnelOrNull': ('windowFunnel', 'OrNull'), 'quantileBFloat16OrNull': ('quantileBFloat16', 'OrNull'), 'sequenceCountOrNull': ('sequenceCount', 'OrNull'), 'maxMapOrNull': ('maxMap', 'OrNull'), 'mannWhitneyUTestOrNull': ('mannWhitneyUTest', 'OrNull'), 'groupUniqArrayOrNull': ('groupUniqArray', 'OrNull'), 'groupBitmapAndOrNull': ('groupBitmapAnd', 'OrNull'), 'quantilesBFloat16WeightedOrNull': ('quantilesBFloat16Weighted', 'OrNull'), 'topKWeightedOrNull': ('topKWeighted', 'OrNull'), 'quantileTimingWeightedOrNull': ('quantileTimingWeighted', 'OrNull'), 'quantileOrNull': ('quantile', 'OrNull'), 'quantilesBFloat16OrNull': ('quantilesBFloat16', 'OrNull'), 'sumWithOverflowOrNull': ('sumWithOverflow', 'OrNull'), 'quantilesTimingWeightedOrNull': ('quantilesTimingWeighted', 'OrNull'), 'groupBitmapOrOrNull': ('groupBitmapOr', 'OrNull'), 'quantilesExactOrNull': ('quantilesExact', 'OrNull'), 'avgWeightedOrNull': ('avgWeighted', 'OrNull'), 'groupBitmapXorOrNull': ('groupBitmapXor', 'OrNull'), 'quantileBFloat16WeightedOrNull': ('quantileBFloat16Weighted', 'OrNull'), 'stddevSampOrNull': ('stddevSamp', 'OrNull'), 'groupArrayMovingAvgOrNull': ('groupArrayMovingAvg', 'OrNull'), 'quantilesTDigestOrNull': ('quantilesTDigest', 'OrNull'), 'quantileTDigestOrNull': ('quantileTDigest', 'OrNull'), 'quantilesInterpolatedWeightedOrNull': ('quantilesInterpolatedWeighted', 'OrNull'), 'cramersVBiasCorrectedOrNull': ('cramersVBiasCorrected', 'OrNull'), 'deltaSumOrNull': ('deltaSum', 'OrNull'), 'skewPopOrNull': ('skewPop', 'OrNull'), 'maxIntersectionsOrNull': ('maxIntersections', 'OrNull'), 'quantileGKOrNull': ('quantileGK', 'OrNull'), 'argMaxOrNull': ('argMax', 'OrNull'), 'rankCorrOrNull': ('rankCorr', 'OrNull'), 'quantilesGKOrNull': ('quantilesGK', 'OrNull'), 'exponentialTimeDecayedAvgOrNull': ('exponentialTimeDecayedAvg', 'OrNull'), 'anyOrNull': ('any', 'OrNull'), 'skewSampOrNull': ('skewSamp', 'OrNull'), 'quantilesTimingOrNull': ('quantilesTiming', 'OrNull'), 'avgOrNull': ('avg', 'OrNull'), 'studentTTestOrNull': ('studentTTest', 'OrNull'), 'stochasticLogisticRegressionOrNull': ('stochasticLogisticRegression', 'OrNull'), 'contingencyOrNull': ('contingency', 'OrNull'), 'uniqUpToOrNull': ('uniqUpTo', 'OrNull'), 'sumMapOrNull': ('sumMap', 'OrNull'), 'stddevPopResample': ('stddevPop', 'Resample'), 'covarPopResample': ('covarPop', 'Resample'), 'quantileExactLowResample': ('quantileExactLow', 'Resample'), 'uniqExactResample': ('uniqExact', 'Resample'), 'groupArrayMovingSumResample': ('groupArrayMovingSum', 'Resample'), 'histogramResample': ('histogram', 'Resample'), 'deltaSumTimestampResample': ('deltaSumTimestamp', 'Resample'), 'groupArrayInsertAtResample': ('groupArrayInsertAt', 'Resample'), 'quantileExactHighResample': ('quantileExactHigh', 'Resample'), 'anyLastResample': ('anyLast', 'Resample'), 'categoricalInformationValueResample': ('categoricalInformationValue', 'Resample'), 'sumKahanResample': ('sumKahan', 'Resample'), 'varPopResample': ('varPop', 'Resample'), 'quantileTimingResample': ('quantileTiming', 'Resample'), 'theilsUResample': ('theilsU', 'Resample'), 'quantileInterpolatedWeightedResample': ('quantileInterpolatedWeighted', 'Resample'), 'quantilesExactWeightedResample': ('quantilesExactWeighted', 'Resample'), 'last_valueResample': ('last_value', 'Resample'), 'sequenceNextNodeResample': ('sequenceNextNode', 'Resample'), 'minResample': ('min', 'Resample'), 'sumCountResample': ('sumCount', 'Resample'), 'medianResample': ('median', 'Resample'), 'groupArrayResample': ('groupArray', 'Resample'), 'anyHeavyResample': ('anyHeavy', 'Resample'), 'sparkBarResample': ('sparkBar', 'Resample'), 'quantilesExactHighResample': ('quantilesExactHigh', 'Resample'), 'largestTriangleThreeBucketsResample': ('largestTriangleThreeBuckets', 'Resample'), 'varSampResample': ('varSamp', 'Resample'), 'argMinResample': ('argMin', 'Resample'), 'quantilesExactLowResample': ('quantilesExactLow', 'Resample'), 'uniqCombined64Resample': ('uniqCombined64', 'Resample'), 'uniqResample': ('uniq', 'Resample'), 'countResample': ('count', 'Resample'), 'corrResample': ('corr', 'Resample'), 'sequenceMatchResample': ('sequenceMatch', 'Resample'), 'quantileDeterministicResample': ('quantileDeterministic', 'Resample'), 'quantilesResample': ('quantiles', 'Resample'), 'minMapResample': ('minMap', 'Resample'), 'uniqHLL12Resample': ('uniqHLL12', 'Resample'), 'uniqThetaResample': ('uniqTheta', 'Resample'), 'topKResample': ('topK', 'Resample'), 'maxIntersectionsPositionResample': ('maxIntersectionsPosition', 'Resample'), 'first_valueResample': ('first_value', 'Resample'), 'quantilesTDigestWeightedResample': ('quantilesTDigestWeighted', 'Resample'), 'entropyResample': ('entropy', 'Resample'), 'meanZTestResample': ('meanZTest', 'Resample'), 'groupArrayLastResample': ('groupArrayLast', 'Resample'), 'maxResample': ('max', 'Resample'), 'simpleLinearRegressionResample': ('simpleLinearRegression', 'Resample'), 'quantileExactResample': ('quantileExact', 'Resample'), 'quantileTDigestWeightedResample': ('quantileTDigestWeighted', 'Resample'), 'welchTTestResample': ('welchTTest', 'Resample'), 'retentionResample': ('retention', 'Resample'), 'cramersVResample': ('cramersV', 'Resample'), 'kolmogorovSmirnovTestResample': ('kolmogorovSmirnovTest', 'Resample'), 'groupBitXorResample': ('groupBitXor', 'Resample'), 'groupBitAndResample': ('groupBitAnd', 'Resample'), 'exponentialMovingAverageResample': ('exponentialMovingAverage', 'Resample'), 'groupArraySampleResample': ('groupArraySample', 'Resample'), 'kurtSampResample': ('kurtSamp', 'Resample'), 'sumResample': ('sum', 'Resample'), 'uniqCombinedResample': ('uniqCombined', 'Resample'), 'groupBitOrResample': ('groupBitOr', 'Resample'), 'kurtPopResample': ('kurtPop', 'Resample'), 'stochasticLinearRegressionResample': ('stochasticLinearRegression', 'Resample'), 'boundingRatioResample': ('boundingRatio', 'Resample'), 'intervalLengthSumResample': ('intervalLengthSum', 'Resample'), 'covarSampResample': ('covarSamp', 'Resample'), 'quantilesDeterministicResample': ('quantilesDeterministic', 'Resample'), 'groupBitmapResample': ('groupBitmap', 'Resample'), 'quantileExactWeightedResample': ('quantileExactWeighted', 'Resample'), 'windowFunnelResample': ('windowFunnel', 'Resample'), 'quantileBFloat16Resample': ('quantileBFloat16', 'Resample'), 'sequenceCountResample': ('sequenceCount', 'Resample'), 'maxMapResample': ('maxMap', 'Resample'), 'mannWhitneyUTestResample': ('mannWhitneyUTest', 'Resample'), 'groupUniqArrayResample': ('groupUniqArray', 'Resample'), 'groupBitmapAndResample': ('groupBitmapAnd', 'Resample'), 'quantilesBFloat16WeightedResample': ('quantilesBFloat16Weighted', 'Resample'), 'topKWeightedResample': ('topKWeighted', 'Resample'), 'quantileTimingWeightedResample': ('quantileTimingWeighted', 'Resample'), 'quantileResample': ('quantile', 'Resample'), 'quantilesBFloat16Resample': ('quantilesBFloat16', 'Resample'), 'sumWithOverflowResample': ('sumWithOverflow', 'Resample'), 'quantilesTimingWeightedResample': ('quantilesTimingWeighted', 'Resample'), 'groupBitmapOrResample': ('groupBitmapOr', 'Resample'), 'quantilesExactResample': ('quantilesExact', 'Resample'), 'avgWeightedResample': ('avgWeighted', 'Resample'), 'groupBitmapXorResample': ('groupBitmapXor', 'Resample'), 'quantileBFloat16WeightedResample': ('quantileBFloat16Weighted', 'Resample'), 'stddevSampResample': ('stddevSamp', 'Resample'), 'groupArrayMovingAvgResample': ('groupArrayMovingAvg', 'Resample'), 'quantilesTDigestResample': ('quantilesTDigest', 'Resample'), 'quantileTDigestResample': ('quantileTDigest', 'Resample'), 'quantilesInterpolatedWeightedResample': ('quantilesInterpolatedWeighted', 'Resample'), 'cramersVBiasCorrectedResample': ('cramersVBiasCorrected', 'Resample'), 'deltaSumResample': ('deltaSum', 'Resample'), 'skewPopResample': ('skewPop', 'Resample'), 'maxIntersectionsResample': ('maxIntersections', 'Resample'), 'quantileGKResample': ('quantileGK', 'Resample'), 'argMaxResample': ('argMax', 'Resample'), 'rankCorrResample': ('rankCorr', 'Resample'), 'quantilesGKResample': ('quantilesGK', 'Resample'), 'exponentialTimeDecayedAvgResample': ('exponentialTimeDecayedAvg', 'Resample'), 'anyResample': ('any', 'Resample'), 'skewSampResample': ('skewSamp', 'Resample'), 'quantilesTimingResample': ('quantilesTiming', 'Resample'), 'avgResample': ('avg', 'Resample'), 'studentTTestResample': ('studentTTest', 'Resample'), 'stochasticLogisticRegressionResample': ('stochasticLogisticRegression', 'Resample'), 'contingencyResample': ('contingency', 'Resample'), 'uniqUpToResample': ('uniqUpTo', 'Resample'), 'sumMapResample': ('sumMap', 'Resample'), 'stddevPopArgMin': ('stddevPop', 'ArgMin'), 'covarPopArgMin': ('covarPop', 'ArgMin'), 'quantileExactLowArgMin': ('quantileExactLow', 'ArgMin'), 'uniqExactArgMin': ('uniqExact', 'ArgMin'), 'groupArrayMovingSumArgMin': ('groupArrayMovingSum', 'ArgMin'), 'histogramArgMin': ('histogram', 'ArgMin'), 'deltaSumTimestampArgMin': ('deltaSumTimestamp', 'ArgMin'), 'groupArrayInsertAtArgMin': ('groupArrayInsertAt', 'ArgMin'), 'quantileExactHighArgMin': ('quantileExactHigh', 'ArgMin'), 'anyLastArgMin': ('anyLast', 'ArgMin'), 'categoricalInformationValueArgMin': ('categoricalInformationValue', 'ArgMin'), 'sumKahanArgMin': ('sumKahan', 'ArgMin'), 'varPopArgMin': ('varPop', 'ArgMin'), 'quantileTimingArgMin': ('quantileTiming', 'ArgMin'), 'theilsUArgMin': ('theilsU', 'ArgMin'), 'quantileInterpolatedWeightedArgMin': ('quantileInterpolatedWeighted', 'ArgMin'), 'quantilesExactWeightedArgMin': ('quantilesExactWeighted', 'ArgMin'), 'last_valueArgMin': ('last_value', 'ArgMin'), 'sequenceNextNodeArgMin': ('sequenceNextNode', 'ArgMin'), 'minArgMin': ('min', 'ArgMin'), 'sumCountArgMin': ('sumCount', 'ArgMin'), 'medianArgMin': ('median', 'ArgMin'), 'groupArrayArgMin': ('groupArray', 'ArgMin'), 'anyHeavyArgMin': ('anyHeavy', 'ArgMin'), 'sparkBarArgMin': ('sparkBar', 'ArgMin'), 'quantilesExactHighArgMin': ('quantilesExactHigh', 'ArgMin'), 'largestTriangleThreeBucketsArgMin': ('largestTriangleThreeBuckets', 'ArgMin'), 'varSampArgMin': ('varSamp', 'ArgMin'), 'argMinArgMin': ('argMin', 'ArgMin'), 'quantilesExactLowArgMin': ('quantilesExactLow', 'ArgMin'), 'uniqCombined64ArgMin': ('uniqCombined64', 'ArgMin'), 'uniqArgMin': ('uniq', 'ArgMin'), 'countArgMin': ('count', 'ArgMin'), 'corrArgMin': ('corr', 'ArgMin'), 'sequenceMatchArgMin': ('sequenceMatch', 'ArgMin'), 'quantileDeterministicArgMin': ('quantileDeterministic', 'ArgMin'), 'quantilesArgMin': ('quantiles', 'ArgMin'), 'minMapArgMin': ('minMap', 'ArgMin'), 'uniqHLL12ArgMin': ('uniqHLL12', 'ArgMin'), 'uniqThetaArgMin': ('uniqTheta', 'ArgMin'), 'topKArgMin': ('topK', 'ArgMin'), 'maxIntersectionsPositionArgMin': ('maxIntersectionsPosition', 'ArgMin'), 'first_valueArgMin': ('first_value', 'ArgMin'), 'quantilesTDigestWeightedArgMin': ('quantilesTDigestWeighted', 'ArgMin'), 'entropyArgMin': ('entropy', 'ArgMin'), 'meanZTestArgMin': ('meanZTest', 'ArgMin'), 'groupArrayLastArgMin': ('groupArrayLast', 'ArgMin'), 'maxArgMin': ('max', 'ArgMin'), 'simpleLinearRegressionArgMin': ('simpleLinearRegression', 'ArgMin'), 'quantileExactArgMin': ('quantileExact', 'ArgMin'), 'quantileTDigestWeightedArgMin': ('quantileTDigestWeighted', 'ArgMin'), 'welchTTestArgMin': ('welchTTest', 'ArgMin'), 'retentionArgMin': ('retention', 'ArgMin'), 'cramersVArgMin': ('cramersV', 'ArgMin'), 'kolmogorovSmirnovTestArgMin': ('kolmogorovSmirnovTest', 'ArgMin'), 'groupBitXorArgMin': ('groupBitXor', 'ArgMin'), 'groupBitAndArgMin': ('groupBitAnd', 'ArgMin'), 'exponentialMovingAverageArgMin': ('exponentialMovingAverage', 'ArgMin'), 'groupArraySampleArgMin': ('groupArraySample', 'ArgMin'), 'kurtSampArgMin': ('kurtSamp', 'ArgMin'), 'sumArgMin': ('sum', 'ArgMin'), 'uniqCombinedArgMin': ('uniqCombined', 'ArgMin'), 'groupBitOrArgMin': ('groupBitOr', 'ArgMin'), 'kurtPopArgMin': ('kurtPop', 'ArgMin'), 'stochasticLinearRegressionArgMin': ('stochasticLinearRegression', 'ArgMin'), 'boundingRatioArgMin': ('boundingRatio', 'ArgMin'), 'intervalLengthSumArgMin': ('intervalLengthSum', 'ArgMin'), 'covarSampArgMin': ('covarSamp', 'ArgMin'), 'quantilesDeterministicArgMin': ('quantilesDeterministic', 'ArgMin'), 'groupBitmapArgMin': ('groupBitmap', 'ArgMin'), 'quantileExactWeightedArgMin': ('quantileExactWeighted', 'ArgMin'), 'windowFunnelArgMin': ('windowFunnel', 'ArgMin'), 'quantileBFloat16ArgMin': ('quantileBFloat16', 'ArgMin'), 'sequenceCountArgMin': ('sequenceCount', 'ArgMin'), 'maxMapArgMin': ('maxMap', 'ArgMin'), 'mannWhitneyUTestArgMin': ('mannWhitneyUTest', 'ArgMin'), 'groupUniqArrayArgMin': ('groupUniqArray', 'ArgMin'), 'groupBitmapAndArgMin': ('groupBitmapAnd', 'ArgMin'), 'quantilesBFloat16WeightedArgMin': ('quantilesBFloat16Weighted', 'ArgMin'), 'topKWeightedArgMin': ('topKWeighted', 'ArgMin'), 'quantileTimingWeightedArgMin': ('quantileTimingWeighted', 'ArgMin'), 'quantileArgMin': ('quantile', 'ArgMin'), 'quantilesBFloat16ArgMin': ('quantilesBFloat16', 'ArgMin'), 'sumWithOverflowArgMin': ('sumWithOverflow', 'ArgMin'), 'quantilesTimingWeightedArgMin': ('quantilesTimingWeighted', 'ArgMin'), 'groupBitmapOrArgMin': ('groupBitmapOr', 'ArgMin'), 'quantilesExactArgMin': ('quantilesExact', 'ArgMin'), 'avgWeightedArgMin': ('avgWeighted', 'ArgMin'), 'groupBitmapXorArgMin': ('groupBitmapXor', 'ArgMin'), 'quantileBFloat16WeightedArgMin': ('quantileBFloat16Weighted', 'ArgMin'), 'stddevSampArgMin': ('stddevSamp', 'ArgMin'), 'groupArrayMovingAvgArgMin': ('groupArrayMovingAvg', 'ArgMin'), 'quantilesTDigestArgMin': ('quantilesTDigest', 'ArgMin'), 'quantileTDigestArgMin': ('quantileTDigest', 'ArgMin'), 'quantilesInterpolatedWeightedArgMin': ('quantilesInterpolatedWeighted', 'ArgMin'), 'cramersVBiasCorrectedArgMin': ('cramersVBiasCorrected', 'ArgMin'), 'deltaSumArgMin': ('deltaSum', 'ArgMin'), 'skewPopArgMin': ('skewPop', 'ArgMin'), 'maxIntersectionsArgMin': ('maxIntersections', 'ArgMin'), 'quantileGKArgMin': ('quantileGK', 'ArgMin'), 'argMaxArgMin': ('argMax', 'ArgMin'), 'rankCorrArgMin': ('rankCorr', 'ArgMin'), 'quantilesGKArgMin': ('quantilesGK', 'ArgMin'), 'exponentialTimeDecayedAvgArgMin': ('exponentialTimeDecayedAvg', 'ArgMin'), 'anyArgMin': ('any', 'ArgMin'), 'skewSampArgMin': ('skewSamp', 'ArgMin'), 'quantilesTimingArgMin': ('quantilesTiming', 'ArgMin'), 'avgArgMin': ('avg', 'ArgMin'), 'studentTTestArgMin': ('studentTTest', 'ArgMin'), 'stochasticLogisticRegressionArgMin': ('stochasticLogisticRegression', 'ArgMin'), 'contingencyArgMin': ('contingency', 'ArgMin'), 'uniqUpToArgMin': ('uniqUpTo', 'ArgMin'), 'sumMapArgMin': ('sumMap', 'ArgMin'), 'stddevPopArgMax': ('stddevPop', 'ArgMax'), 'covarPopArgMax': ('covarPop', 'ArgMax'), 'quantileExactLowArgMax': ('quantileExactLow', 'ArgMax'), 'uniqExactArgMax': ('uniqExact', 'ArgMax'), 'groupArrayMovingSumArgMax': ('groupArrayMovingSum', 'ArgMax'), 'histogramArgMax': ('histogram', 'ArgMax'), 'deltaSumTimestampArgMax': ('deltaSumTimestamp', 'ArgMax'), 'groupArrayInsertAtArgMax': ('groupArrayInsertAt', 'ArgMax'), 'quantileExactHighArgMax': ('quantileExactHigh', 'ArgMax'), 'anyLastArgMax': ('anyLast', 'ArgMax'), 'categoricalInformationValueArgMax': ('categoricalInformationValue', 'ArgMax'), 'sumKahanArgMax': ('sumKahan', 'ArgMax'), 'varPopArgMax': ('varPop', 'ArgMax'), 'quantileTimingArgMax': ('quantileTiming', 'ArgMax'), 'theilsUArgMax': ('theilsU', 'ArgMax'), 'quantileInterpolatedWeightedArgMax': ('quantileInterpolatedWeighted', 'ArgMax'), 'quantilesExactWeightedArgMax': ('quantilesExactWeighted', 'ArgMax'), 'last_valueArgMax': ('last_value', 'ArgMax'), 'sequenceNextNodeArgMax': ('sequenceNextNode', 'ArgMax'), 'minArgMax': ('min', 'ArgMax'), 'sumCountArgMax': ('sumCount', 'ArgMax'), 'medianArgMax': ('median', 'ArgMax'), 'groupArrayArgMax': ('groupArray', 'ArgMax'), 'anyHeavyArgMax': ('anyHeavy', 'ArgMax'), 'sparkBarArgMax': ('sparkBar', 'ArgMax'), 'quantilesExactHighArgMax': ('quantilesExactHigh', 'ArgMax'), 'largestTriangleThreeBucketsArgMax': ('largestTriangleThreeBuckets', 'ArgMax'), 'varSampArgMax': ('varSamp', 'ArgMax'), 'argMinArgMax': ('argMin', 'ArgMax'), 'quantilesExactLowArgMax': ('quantilesExactLow', 'ArgMax'), 'uniqCombined64ArgMax': ('uniqCombined64', 'ArgMax'), 'uniqArgMax': ('uniq', 'ArgMax'), 'countArgMax': ('count', 'ArgMax'), 'corrArgMax': ('corr', 'ArgMax'), 'sequenceMatchArgMax': ('sequenceMatch', 'ArgMax'), 'quantileDeterministicArgMax': ('quantileDeterministic', 'ArgMax'), 'quantilesArgMax': ('quantiles', 'ArgMax'), 'minMapArgMax': ('minMap', 'ArgMax'), 'uniqHLL12ArgMax': ('uniqHLL12', 'ArgMax'), 'uniqThetaArgMax': ('uniqTheta', 'ArgMax'), 'topKArgMax': ('topK', 'ArgMax'), 'maxIntersectionsPositionArgMax': ('maxIntersectionsPosition', 'ArgMax'), 'first_valueArgMax': ('first_value', 'ArgMax'), 'quantilesTDigestWeightedArgMax': ('quantilesTDigestWeighted', 'ArgMax'), 'entropyArgMax': ('entropy', 'ArgMax'), 'meanZTestArgMax': ('meanZTest', 'ArgMax'), 'groupArrayLastArgMax': ('groupArrayLast', 'ArgMax'), 'maxArgMax': ('max', 'ArgMax'), 'simpleLinearRegressionArgMax': ('simpleLinearRegression', 'ArgMax'), 'quantileExactArgMax': ('quantileExact', 'ArgMax'), 'quantileTDigestWeightedArgMax': ('quantileTDigestWeighted', 'ArgMax'), 'welchTTestArgMax': ('welchTTest', 'ArgMax'), 'retentionArgMax': ('retention', 'ArgMax'), 'cramersVArgMax': ('cramersV', 'ArgMax'), 'kolmogorovSmirnovTestArgMax': ('kolmogorovSmirnovTest', 'ArgMax'), 'groupBitXorArgMax': ('groupBitXor', 'ArgMax'), 'groupBitAndArgMax': ('groupBitAnd', 'ArgMax'), 'exponentialMovingAverageArgMax': ('exponentialMovingAverage', 'ArgMax'), 'groupArraySampleArgMax': ('groupArraySample', 'ArgMax'), 'kurtSampArgMax': ('kurtSamp', 'ArgMax'), 'sumArgMax': ('sum', 'ArgMax'), 'uniqCombinedArgMax': ('uniqCombined', 'ArgMax'), 'groupBitOrArgMax': ('groupBitOr', 'ArgMax'), 'kurtPopArgMax': ('kurtPop', 'ArgMax'), 'stochasticLinearRegressionArgMax': ('stochasticLinearRegression', 'ArgMax'), 'boundingRatioArgMax': ('boundingRatio', 'ArgMax'), 'intervalLengthSumArgMax': ('intervalLengthSum', 'ArgMax'), 'covarSampArgMax': ('covarSamp', 'ArgMax'), 'quantilesDeterministicArgMax': ('quantilesDeterministic', 'ArgMax'), 'groupBitmapArgMax': ('groupBitmap', 'ArgMax'), 'quantileExactWeightedArgMax': ('quantileExactWeighted', 'ArgMax'), 'windowFunnelArgMax': ('windowFunnel', 'ArgMax'), 'quantileBFloat16ArgMax': ('quantileBFloat16', 'ArgMax'), 'sequenceCountArgMax': ('sequenceCount', 'ArgMax'), 'maxMapArgMax': ('maxMap', 'ArgMax'), 'mannWhitneyUTestArgMax': ('mannWhitneyUTest', 'ArgMax'), 'groupUniqArrayArgMax': ('groupUniqArray', 'ArgMax'), 'groupBitmapAndArgMax': ('groupBitmapAnd', 'ArgMax'), 'quantilesBFloat16WeightedArgMax': ('quantilesBFloat16Weighted', 'ArgMax'), 'topKWeightedArgMax': ('topKWeighted', 'ArgMax'), 'quantileTimingWeightedArgMax': ('quantileTimingWeighted', 'ArgMax'), 'quantileArgMax': ('quantile', 'ArgMax'), 'quantilesBFloat16ArgMax': ('quantilesBFloat16', 'ArgMax'), 'sumWithOverflowArgMax': ('sumWithOverflow', 'ArgMax'), 'quantilesTimingWeightedArgMax': ('quantilesTimingWeighted', 'ArgMax'), 'groupBitmapOrArgMax': ('groupBitmapOr', 'ArgMax'), 'quantilesExactArgMax': ('quantilesExact', 'ArgMax'), 'avgWeightedArgMax': ('avgWeighted', 'ArgMax'), 'groupBitmapXorArgMax': ('groupBitmapXor', 'ArgMax'), 'quantileBFloat16WeightedArgMax': ('quantileBFloat16Weighted', 'ArgMax'), 'stddevSampArgMax': ('stddevSamp', 'ArgMax'), 'groupArrayMovingAvgArgMax': ('groupArrayMovingAvg', 'ArgMax'), 'quantilesTDigestArgMax': ('quantilesTDigest', 'ArgMax'), 'quantileTDigestArgMax': ('quantileTDigest', 'ArgMax'), 'quantilesInterpolatedWeightedArgMax': ('quantilesInterpolatedWeighted', 'ArgMax'), 'cramersVBiasCorrectedArgMax': ('cramersVBiasCorrected', 'ArgMax'), 'deltaSumArgMax': ('deltaSum', 'ArgMax'), 'skewPopArgMax': ('skewPop', 'ArgMax'), 'maxIntersectionsArgMax': ('maxIntersections', 'ArgMax'), 'quantileGKArgMax': ('quantileGK', 'ArgMax'), 'argMaxArgMax': ('argMax', 'ArgMax'), 'rankCorrArgMax': ('rankCorr', 'ArgMax'), 'quantilesGKArgMax': ('quantilesGK', 'ArgMax'), 'exponentialTimeDecayedAvgArgMax': ('exponentialTimeDecayedAvg', 'ArgMax'), 'anyArgMax': ('any', 'ArgMax'), 'skewSampArgMax': ('skewSamp', 'ArgMax'), 'quantilesTimingArgMax': ('quantilesTiming', 'ArgMax'), 'avgArgMax': ('avg', 'ArgMax'), 'studentTTestArgMax': ('studentTTest', 'ArgMax'), 'stochasticLogisticRegressionArgMax': ('stochasticLogisticRegression', 'ArgMax'), 'contingencyArgMax': ('contingency', 'ArgMax'), 'uniqUpToArgMax': ('uniqUpTo', 'ArgMax'), 'sumMapArgMax': ('sumMap', 'ArgMax'), 'stddevPop': ('stddevPop', ''), 'covarPop': ('covarPop', ''), 'quantileExactLow': ('quantileExactLow', ''), 'uniqExact': ('uniqExact', ''), 'groupArrayMovingSum': ('groupArrayMovingSum', ''), 'histogram': ('histogram', ''), 'deltaSumTimestamp': ('deltaSumTimestamp', ''), 'groupArrayInsertAt': ('groupArrayInsertAt', ''), 'quantileExactHigh': ('quantileExactHigh', ''), 'anyLast': ('anyLast', ''), 'categoricalInformationValue': ('categoricalInformationValue', ''), 'sumKahan': ('sumKahan', ''), 'varPop': ('varPop', ''), 'quantileTiming': ('quantileTiming', ''), 'theilsU': ('theilsU', ''), 'quantileInterpolatedWeighted': ('quantileInterpolatedWeighted', ''), 'quantilesExactWeighted': ('quantilesExactWeighted', ''), 'last_value': ('last_value', ''), 'sequenceNextNode': ('sequenceNextNode', ''), 'min': ('min', ''), 'sumCount': ('sumCount', ''), 'median': ('median', ''), 'groupArray': ('groupArray', ''), 'anyHeavy': ('anyHeavy', ''), 'sparkBar': ('sparkBar', ''), 'quantilesExactHigh': ('quantilesExactHigh', ''), 'largestTriangleThreeBuckets': ('largestTriangleThreeBuckets', ''), 'varSamp': ('varSamp', ''), 'argMin': ('argMin', ''), 'quantilesExactLow': ('quantilesExactLow', ''), 'uniqCombined64': ('uniqCombined64', ''), 'uniq': ('uniq', ''), 'count': ('count', ''), 'corr': ('corr', ''), 'sequenceMatch': ('sequenceMatch', ''), 'quantileDeterministic': ('quantileDeterministic', ''), 'quantiles': ('quantiles', ''), 'uniqHLL12': ('uniqHLL12', ''), 'uniqTheta': ('uniqTheta', ''), 'topK': ('topK', ''), 'maxIntersectionsPosition': ('maxIntersectionsPosition', ''), 'first_value': ('first_value', ''), 'quantilesTDigestWeighted': ('quantilesTDigestWeighted', ''), 'entropy': ('entropy', ''), 'meanZTest': ('meanZTest', ''), 'groupArrayLast': ('groupArrayLast', ''), 'max': ('max', ''), 'simpleLinearRegression': ('simpleLinearRegression', ''), 'quantileExact': ('quantileExact', ''), 'quantileTDigestWeighted': ('quantileTDigestWeighted', ''), 'welchTTest': ('welchTTest', ''), 'retention': ('retention', ''), 'cramersV': ('cramersV', ''), 'kolmogorovSmirnovTest': ('kolmogorovSmirnovTest', ''), 'groupBitXor': ('groupBitXor', ''), 'groupBitAnd': ('groupBitAnd', ''), 'exponentialMovingAverage': ('exponentialMovingAverage', ''), 'groupArraySample': ('groupArraySample', ''), 'kurtSamp': ('kurtSamp', ''), 'sum': ('sum', ''), 'uniqCombined': ('uniqCombined', ''), 'groupBitOr': ('groupBitOr', ''), 'kurtPop': ('kurtPop', ''), 'stochasticLinearRegression': ('stochasticLinearRegression', ''), 'boundingRatio': ('boundingRatio', ''), 'intervalLengthSum': ('intervalLengthSum', ''), 'covarSamp': ('covarSamp', ''), 'quantilesDeterministic': ('quantilesDeterministic', ''), 'groupBitmap': ('groupBitmap', ''), 'quantileExactWeighted': ('quantileExactWeighted', ''), 'windowFunnel': ('windowFunnel', ''), 'quantileBFloat16': ('quantileBFloat16', ''), 'sequenceCount': ('sequenceCount', ''), 'mannWhitneyUTest': ('mannWhitneyUTest', ''), 'groupUniqArray': ('groupUniqArray', ''), 'groupBitmapAnd': ('groupBitmapAnd', ''), 'quantilesBFloat16Weighted': ('quantilesBFloat16Weighted', ''), 'topKWeighted': ('topKWeighted', ''), 'quantileTimingWeighted': ('quantileTimingWeighted', ''), 'quantile': ('quantile', ''), 'quantilesBFloat16': ('quantilesBFloat16', ''), 'sumWithOverflow': ('sumWithOverflow', ''), 'quantilesTimingWeighted': ('quantilesTimingWeighted', ''), 'groupBitmapOr': ('groupBitmapOr', ''), 'quantilesExact': ('quantilesExact', ''), 'avgWeighted': ('avgWeighted', ''), 'groupBitmapXor': ('groupBitmapXor', ''), 'quantileBFloat16Weighted': ('quantileBFloat16Weighted', ''), 'stddevSamp': ('stddevSamp', ''), 'groupArrayMovingAvg': ('groupArrayMovingAvg', ''), 'quantilesTDigest': ('quantilesTDigest', ''), 'quantileTDigest': ('quantileTDigest', ''), 'quantilesInterpolatedWeighted': ('quantilesInterpolatedWeighted', ''), 'cramersVBiasCorrected': ('cramersVBiasCorrected', ''), 'deltaSum': ('deltaSum', ''), 'skewPop': ('skewPop', ''), 'maxIntersections': ('maxIntersections', ''), 'quantileGK': ('quantileGK', ''), 'argMax': ('argMax', ''), 'rankCorr': ('rankCorr', ''), 'quantilesGK': ('quantilesGK', ''), 'exponentialTimeDecayedAvg': ('exponentialTimeDecayedAvg', ''), 'any': ('any', ''), 'skewSamp': ('skewSamp', ''), 'quantilesTiming': ('quantilesTiming', ''), 'avg': ('avg', ''), 'studentTTest': ('studentTTest', ''), 'stochasticLogisticRegression': ('stochasticLogisticRegression', ''), 'contingency': ('contingency', ''), 'uniqUpTo': ('uniqUpTo', '')}
FUNCTIONS_WITH_ALIASED_ARGS = {'STRUCT', 'TUPLE'}
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.ANY: 'ANY'>, <TokenType.OUTER: 'OUTER'>, <TokenType.INNER: 'INNER'>, <TokenType.STRAIGHT_JOIN: 'STRAIGHT_JOIN'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.SEMI: 'SEMI'>, <TokenType.CROSS: 'CROSS'>, <TokenType.ANTI: 'ANTI'>, <TokenType.ASOF: 'ASOF'>}
TABLE_ALIAS_TOKENS = {<TokenType.ESCAPE: 'ESCAPE'>, <TokenType.REPLACE: 'REPLACE'>, <TokenType.DESC: 'DESC'>, <TokenType.TOP: 'TOP'>, <TokenType.USE: 'USE'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.KEEP: 'KEEP'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.UINT256: 'UINT256'>, <TokenType.LOAD: 'LOAD'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.SOME: 'SOME'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.FILTER: 'FILTER'>, <TokenType.DATABASE: 'DATABASE'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.XML: 'XML'>, <TokenType.DIV: 'DIV'>, <TokenType.UUID: 'UUID'>, <TokenType.MONEY: 'MONEY'>, <TokenType.ENUM: 'ENUM'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.KILL: 'KILL'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.DELETE: 'DELETE'>, <TokenType.DATE: 'DATE'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.FALSE: 'FALSE'>, <TokenType.ORDINALITY: 'ORDINALITY'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.IS: 'IS'>, <TokenType.FIRST: 'FIRST'>, <TokenType.STORAGE_INTEGRATION: 'STORAGE_INTEGRATION'>, <TokenType.BEGIN: 'BEGIN'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.CHAR: 'CHAR'>, <TokenType.ROWS: 'ROWS'>, <TokenType.SUPER: 'SUPER'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.INT: 'INT'>, <TokenType.DATE32: 'DATE32'>, <TokenType.MODEL: 'MODEL'>, <TokenType.IDENTIFIER: 'IDENTIFIER'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.UINT128: 'UINT128'>, <TokenType.SCHEMA: 'SCHEMA'>, <TokenType.IPV6: 'IPV6'>, <TokenType.COPY: 'COPY'>, <TokenType.UNPIVOT: 'UNPIVOT'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.CASE: 'CASE'>, <TokenType.VIEW: 'VIEW'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.SHOW: 'SHOW'>, <TokenType.NEXT: 'NEXT'>, <TokenType.RECURSIVE: 'RECURSIVE'>, <TokenType.PERCENT: 'PERCENT'>, <TokenType.COLUMN: 'COLUMN'>, <TokenType.REFERENCES: 'REFERENCES'>, <TokenType.OVERWRITE: 'OVERWRITE'>, <TokenType.OPERATOR: 'OPERATOR'>, <TokenType.DEFAULT: 'DEFAULT'>, <TokenType.JSON: 'JSON'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.COMMAND: 'COMMAND'>, <TokenType.TEMPORARY: 'TEMPORARY'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.TEXT: 'TEXT'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.SET: 'SET'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.VAR: 'VAR'>, <TokenType.ASC: 'ASC'>, <TokenType.PARTITION: 'PARTITION'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.TIME: 'TIME'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.ALL: 'ALL'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.CUBE: 'CUBE'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.BINARY: 'BINARY'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.TABLE: 'TABLE'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.PROCEDURE: 'PROCEDURE'>, <TokenType.UNNEST: 'UNNEST'>, <TokenType.UNIQUEIDENTIFIER: 'UNIQUEIDENTIFIER'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.DICTIONARY: 'DICTIONARY'>, <TokenType.INT256: 'INT256'>, <TokenType.COMMENT: 'COMMENT'>, <TokenType.MERGE: 'MERGE'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.IPV4: 'IPV4'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.UNIQUE: 'UNIQUE'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.COMMIT: 'COMMIT'>, <TokenType.BIT: 'BIT'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.STRAIGHT_JOIN: 'STRAIGHT_JOIN'>, <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.LIST: 'LIST'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.TRUNCATE: 'TRUNCATE'>, <TokenType.RANGE: 'RANGE'>, <TokenType.PIVOT: 'PIVOT'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.YEAR: 'YEAR'>, <TokenType.NESTED: 'NESTED'>, <TokenType.VOLATILE: 'VOLATILE'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.INT128: 'INT128'>, <TokenType.TRUE: 'TRUE'>, <TokenType.MAP: 'MAP'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.INDEX: 'INDEX'>, <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.JSONB: 'JSONB'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.CONSTRAINT: 'CONSTRAINT'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.REFRESH: 'REFRESH'>, <TokenType.STREAMLIT: 'STREAMLIT'>, <TokenType.END: 'END'>, <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, <TokenType.DESCRIBE: 'DESCRIBE'>, <TokenType.UINT: 'UINT'>, <TokenType.TDIGEST: 'TDIGEST'>, <TokenType.NAME: 'NAME'>, <TokenType.OVERLAPS: 'OVERLAPS'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.PRAGMA: 'PRAGMA'>, <TokenType.ROW: 'ROW'>, <TokenType.ROLLUP: 'ROLLUP'>, <TokenType.INET: 'INET'>, <TokenType.FUNCTION: 'FUNCTION'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.VECTOR: 'VECTOR'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.EXECUTE: 'EXECUTE'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.NULL: 'NULL'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.UPDATE: 'UPDATE'>, <TokenType.TAG: 'TAG'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.CACHE: 'CACHE'>, <TokenType.SEQUENCE: 'SEQUENCE'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.WAREHOUSE: 'WAREHOUSE'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>}
ALIAS_TOKENS = {<TokenType.ESCAPE: 'ESCAPE'>, <TokenType.REPLACE: 'REPLACE'>, <TokenType.DESC: 'DESC'>, <TokenType.TOP: 'TOP'>, <TokenType.USE: 'USE'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.KEEP: 'KEEP'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.UINT256: 'UINT256'>, <TokenType.ANTI: 'ANTI'>, <TokenType.LOAD: 'LOAD'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.SOME: 'SOME'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.FILTER: 'FILTER'>, <TokenType.DATABASE: 'DATABASE'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.XML: 'XML'>, <TokenType.DIV: 'DIV'>, <TokenType.UUID: 'UUID'>, <TokenType.RIGHT: 'RIGHT'>, <TokenType.MONEY: 'MONEY'>, <TokenType.ENUM: 'ENUM'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.KILL: 'KILL'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.DELETE: 'DELETE'>, <TokenType.DATE: 'DATE'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.FALSE: 'FALSE'>, <TokenType.ORDINALITY: 'ORDINALITY'>, <TokenType.ASOF: 'ASOF'>, <TokenType.IS: 'IS'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.FIRST: 'FIRST'>, <TokenType.STORAGE_INTEGRATION: 'STORAGE_INTEGRATION'>, <TokenType.BEGIN: 'BEGIN'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.CHAR: 'CHAR'>, <TokenType.ROWS: 'ROWS'>, <TokenType.SUPER: 'SUPER'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.INT: 'INT'>, <TokenType.DATE32: 'DATE32'>, <TokenType.SETTINGS: 'SETTINGS'>, <TokenType.MODEL: 'MODEL'>, <TokenType.IDENTIFIER: 'IDENTIFIER'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.UINT128: 'UINT128'>, <TokenType.SCHEMA: 'SCHEMA'>, <TokenType.IPV6: 'IPV6'>, <TokenType.COPY: 'COPY'>, <TokenType.SEMI: 'SEMI'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.UNPIVOT: 'UNPIVOT'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.CASE: 'CASE'>, <TokenType.VIEW: 'VIEW'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.FINAL: 'FINAL'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.SHOW: 'SHOW'>, <TokenType.NEXT: 'NEXT'>, <TokenType.RECURSIVE: 'RECURSIVE'>, <TokenType.PERCENT: 'PERCENT'>, <TokenType.COLUMN: 'COLUMN'>, <TokenType.REFERENCES: 'REFERENCES'>, <TokenType.OVERWRITE: 'OVERWRITE'>, <TokenType.OPERATOR: 'OPERATOR'>, <TokenType.DEFAULT: 'DEFAULT'>, <TokenType.JSON: 'JSON'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.COMMAND: 'COMMAND'>, <TokenType.TEMPORARY: 'TEMPORARY'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.TEXT: 'TEXT'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.SET: 'SET'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.VAR: 'VAR'>, <TokenType.ASC: 'ASC'>, <TokenType.PARTITION: 'PARTITION'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.TIME: 'TIME'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.ALL: 'ALL'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.CUBE: 'CUBE'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.BINARY: 'BINARY'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.TABLE: 'TABLE'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.PROCEDURE: 'PROCEDURE'>, <TokenType.UNNEST: 'UNNEST'>, <TokenType.UNIQUEIDENTIFIER: 'UNIQUEIDENTIFIER'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.DICTIONARY: 'DICTIONARY'>, <TokenType.INT256: 'INT256'>, <TokenType.COMMENT: 'COMMENT'>, <TokenType.MERGE: 'MERGE'>, <TokenType.WINDOW: 'WINDOW'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.IPV4: 'IPV4'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.UNIQUE: 'UNIQUE'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.COMMIT: 'COMMIT'>, <TokenType.NATURAL: 'NATURAL'>, <TokenType.BIT: 'BIT'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.LIST: 'LIST'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.TRUNCATE: 'TRUNCATE'>, <TokenType.RANGE: 'RANGE'>, <TokenType.PIVOT: 'PIVOT'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.YEAR: 'YEAR'>, <TokenType.NESTED: 'NESTED'>, <TokenType.VOLATILE: 'VOLATILE'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.INT128: 'INT128'>, <TokenType.TRUE: 'TRUE'>, <TokenType.MAP: 'MAP'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.INDEX: 'INDEX'>, <TokenType.LEFT: 'LEFT'>, <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.JSONB: 'JSONB'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.CONSTRAINT: 'CONSTRAINT'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.REFRESH: 'REFRESH'>, <TokenType.STREAMLIT: 'STREAMLIT'>, <TokenType.END: 'END'>, <TokenType.FULL: 'FULL'>, <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, <TokenType.DESCRIBE: 'DESCRIBE'>, <TokenType.UINT: 'UINT'>, <TokenType.TDIGEST: 'TDIGEST'>, <TokenType.APPLY: 'APPLY'>, <TokenType.NAME: 'NAME'>, <TokenType.OVERLAPS: 'OVERLAPS'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.PRAGMA: 'PRAGMA'>, <TokenType.ROW: 'ROW'>, <TokenType.ROLLUP: 'ROLLUP'>, <TokenType.INET: 'INET'>, <TokenType.FUNCTION: 'FUNCTION'>, <TokenType.ANY: 'ANY'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.VECTOR: 'VECTOR'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.EXECUTE: 'EXECUTE'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.NULL: 'NULL'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.UPDATE: 'UPDATE'>, <TokenType.TAG: 'TAG'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.CACHE: 'CACHE'>, <TokenType.SEQUENCE: 'SEQUENCE'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.WAREHOUSE: 'WAREHOUSE'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.OFFSET: 'OFFSET'>}
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>>, 'REPLACE': <function ClickHouse.Parser.<lambda>>}
SCHEMA_UNNAMED_CONSTRAINTS = {'PRIMARY KEY', 'INDEX', 'PERIOD', 'CHECK', 'UNIQUE', 'LIKE', 'EXCLUDE', 'FOREIGN KEY'}
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
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):
703    class Generator(generator.Generator):
704        QUERY_HINTS = False
705        STRUCT_DELIMITER = ("(", ")")
706        NVL2_SUPPORTED = False
707        TABLESAMPLE_REQUIRES_PARENS = False
708        TABLESAMPLE_SIZE_IS_ROWS = False
709        TABLESAMPLE_KEYWORDS = "SAMPLE"
710        LAST_DAY_SUPPORTS_DATE_PART = False
711        CAN_IMPLEMENT_ARRAY_ANY = True
712        SUPPORTS_TO_NUMBER = False
713        JOIN_HINTS = False
714        TABLE_HINTS = False
715        EXPLICIT_SET_OP = True
716        GROUPINGS_SEP = ""
717        SET_OP_MODIFIERS = False
718        SUPPORTS_TABLE_ALIAS_COLUMNS = False
719
720        STRING_TYPE_MAPPING = {
721            exp.DataType.Type.CHAR: "String",
722            exp.DataType.Type.LONGBLOB: "String",
723            exp.DataType.Type.LONGTEXT: "String",
724            exp.DataType.Type.MEDIUMBLOB: "String",
725            exp.DataType.Type.MEDIUMTEXT: "String",
726            exp.DataType.Type.TINYBLOB: "String",
727            exp.DataType.Type.TINYTEXT: "String",
728            exp.DataType.Type.TEXT: "String",
729            exp.DataType.Type.VARBINARY: "String",
730            exp.DataType.Type.VARCHAR: "String",
731        }
732
733        SUPPORTED_JSON_PATH_PARTS = {
734            exp.JSONPathKey,
735            exp.JSONPathRoot,
736            exp.JSONPathSubscript,
737        }
738
739        TYPE_MAPPING = {
740            **generator.Generator.TYPE_MAPPING,
741            **STRING_TYPE_MAPPING,
742            exp.DataType.Type.ARRAY: "Array",
743            exp.DataType.Type.BIGINT: "Int64",
744            exp.DataType.Type.DATE32: "Date32",
745            exp.DataType.Type.DATETIME64: "DateTime64",
746            exp.DataType.Type.DOUBLE: "Float64",
747            exp.DataType.Type.ENUM: "Enum",
748            exp.DataType.Type.ENUM8: "Enum8",
749            exp.DataType.Type.ENUM16: "Enum16",
750            exp.DataType.Type.FIXEDSTRING: "FixedString",
751            exp.DataType.Type.FLOAT: "Float32",
752            exp.DataType.Type.INT: "Int32",
753            exp.DataType.Type.MEDIUMINT: "Int32",
754            exp.DataType.Type.INT128: "Int128",
755            exp.DataType.Type.INT256: "Int256",
756            exp.DataType.Type.LOWCARDINALITY: "LowCardinality",
757            exp.DataType.Type.MAP: "Map",
758            exp.DataType.Type.NESTED: "Nested",
759            exp.DataType.Type.NULLABLE: "Nullable",
760            exp.DataType.Type.SMALLINT: "Int16",
761            exp.DataType.Type.STRUCT: "Tuple",
762            exp.DataType.Type.TINYINT: "Int8",
763            exp.DataType.Type.UBIGINT: "UInt64",
764            exp.DataType.Type.UINT: "UInt32",
765            exp.DataType.Type.UINT128: "UInt128",
766            exp.DataType.Type.UINT256: "UInt256",
767            exp.DataType.Type.USMALLINT: "UInt16",
768            exp.DataType.Type.UTINYINT: "UInt8",
769            exp.DataType.Type.IPV4: "IPv4",
770            exp.DataType.Type.IPV6: "IPv6",
771            exp.DataType.Type.AGGREGATEFUNCTION: "AggregateFunction",
772            exp.DataType.Type.SIMPLEAGGREGATEFUNCTION: "SimpleAggregateFunction",
773        }
774
775        TRANSFORMS = {
776            **generator.Generator.TRANSFORMS,
777            exp.AnyValue: rename_func("any"),
778            exp.ApproxDistinct: rename_func("uniq"),
779            exp.ArrayFilter: lambda self, e: self.func("arrayFilter", e.expression, e.this),
780            exp.ArraySize: rename_func("LENGTH"),
781            exp.ArraySum: rename_func("arraySum"),
782            exp.ArgMax: arg_max_or_min_no_count("argMax"),
783            exp.ArgMin: arg_max_or_min_no_count("argMin"),
784            exp.Array: inline_array_sql,
785            exp.CastToStrType: rename_func("CAST"),
786            exp.CountIf: rename_func("countIf"),
787            exp.CompressColumnConstraint: lambda self,
788            e: f"CODEC({self.expressions(e, key='this', flat=True)})",
789            exp.ComputedColumnConstraint: lambda self,
790            e: f"{'MATERIALIZED' if e.args.get('persisted') else 'ALIAS'} {self.sql(e, 'this')}",
791            exp.CurrentDate: lambda self, e: self.func("CURRENT_DATE"),
792            exp.DateAdd: _datetime_delta_sql("DATE_ADD"),
793            exp.DateDiff: _datetime_delta_sql("DATE_DIFF"),
794            exp.DateSub: _datetime_delta_sql("DATE_SUB"),
795            exp.Explode: rename_func("arrayJoin"),
796            exp.Final: lambda self, e: f"{self.sql(e, 'this')} FINAL",
797            exp.IsNan: rename_func("isNaN"),
798            exp.JSONExtract: json_extract_segments("JSONExtractString", quoted_index=False),
799            exp.JSONExtractScalar: json_extract_segments("JSONExtractString", quoted_index=False),
800            exp.JSONPathKey: json_path_key_only_name,
801            exp.JSONPathRoot: lambda *_: "",
802            exp.Map: lambda self, e: _lower_func(var_map_sql(self, e)),
803            exp.Nullif: rename_func("nullIf"),
804            exp.PartitionedByProperty: lambda self, e: f"PARTITION BY {self.sql(e, 'this')}",
805            exp.Pivot: no_pivot_sql,
806            exp.Quantile: _quantile_sql,
807            exp.RegexpLike: lambda self, e: self.func("match", e.this, e.expression),
808            exp.Rand: rename_func("randCanonical"),
809            exp.StartsWith: rename_func("startsWith"),
810            exp.StrPosition: lambda self, e: self.func(
811                "position", e.this, e.args.get("substr"), e.args.get("position")
812            ),
813            exp.TimeToStr: lambda self, e: self.func(
814                "DATE_FORMAT", e.this, self.format_time(e), e.args.get("timezone")
815            ),
816            exp.TimestampAdd: _datetime_delta_sql("TIMESTAMP_ADD"),
817            exp.TimestampSub: _datetime_delta_sql("TIMESTAMP_SUB"),
818            exp.VarMap: lambda self, e: _lower_func(var_map_sql(self, e)),
819            exp.Xor: lambda self, e: self.func("xor", e.this, e.expression, *e.expressions),
820            exp.MD5Digest: rename_func("MD5"),
821            exp.MD5: lambda self, e: self.func("LOWER", self.func("HEX", self.func("MD5", e.this))),
822            exp.SHA: rename_func("SHA1"),
823            exp.SHA2: sha256_sql,
824            exp.UnixToTime: _unix_to_time_sql,
825            exp.TimestampTrunc: timestamptrunc_sql(zone=True),
826            exp.Variance: rename_func("varSamp"),
827            exp.Stddev: rename_func("stddevSamp"),
828        }
829
830        PROPERTIES_LOCATION = {
831            **generator.Generator.PROPERTIES_LOCATION,
832            exp.VolatileProperty: exp.Properties.Location.UNSUPPORTED,
833            exp.PartitionedByProperty: exp.Properties.Location.POST_SCHEMA,
834            exp.OnCluster: exp.Properties.Location.POST_NAME,
835        }
836
837        # there's no list in docs, but it can be found in Clickhouse code
838        # see `ClickHouse/src/Parsers/ParserCreate*.cpp`
839        ON_CLUSTER_TARGETS = {
840            "DATABASE",
841            "TABLE",
842            "VIEW",
843            "DICTIONARY",
844            "INDEX",
845            "FUNCTION",
846            "NAMED COLLECTION",
847        }
848
849        def strtodate_sql(self, expression: exp.StrToDate) -> str:
850            strtodate_sql = self.function_fallback_sql(expression)
851
852            if not isinstance(expression.parent, exp.Cast):
853                # StrToDate returns DATEs in other dialects (eg. postgres), so
854                # this branch aims to improve the transpilation to clickhouse
855                return f"CAST({strtodate_sql} AS DATE)"
856
857            return strtodate_sql
858
859        def cast_sql(self, expression: exp.Cast, safe_prefix: t.Optional[str] = None) -> str:
860            this = expression.this
861
862            if isinstance(this, exp.StrToDate) and expression.to == exp.DataType.build("datetime"):
863                return self.sql(this)
864
865            return super().cast_sql(expression, safe_prefix=safe_prefix)
866
867        def _jsonpathsubscript_sql(self, expression: exp.JSONPathSubscript) -> str:
868            this = self.json_path_part(expression.this)
869            return str(int(this) + 1) if is_int(this) else this
870
871        def likeproperty_sql(self, expression: exp.LikeProperty) -> str:
872            return f"AS {self.sql(expression, 'this')}"
873
874        def _any_to_has(
875            self,
876            expression: exp.EQ | exp.NEQ,
877            default: t.Callable[[t.Any], str],
878            prefix: str = "",
879        ) -> str:
880            if isinstance(expression.left, exp.Any):
881                arr = expression.left
882                this = expression.right
883            elif isinstance(expression.right, exp.Any):
884                arr = expression.right
885                this = expression.left
886            else:
887                return default(expression)
888
889            return prefix + self.func("has", arr.this.unnest(), this)
890
891        def eq_sql(self, expression: exp.EQ) -> str:
892            return self._any_to_has(expression, super().eq_sql)
893
894        def neq_sql(self, expression: exp.NEQ) -> str:
895            return self._any_to_has(expression, super().neq_sql, "NOT ")
896
897        def regexpilike_sql(self, expression: exp.RegexpILike) -> str:
898            # Manually add a flag to make the search case-insensitive
899            regex = self.func("CONCAT", "'(?i)'", expression.expression)
900            return self.func("match", expression.this, regex)
901
902        def datatype_sql(self, expression: exp.DataType) -> str:
903            # String is the standard ClickHouse type, every other variant is just an alias.
904            # Additionally, any supplied length parameter will be ignored.
905            #
906            # https://clickhouse.com/docs/en/sql-reference/data-types/string
907            if expression.this in self.STRING_TYPE_MAPPING:
908                return "String"
909
910            return super().datatype_sql(expression)
911
912        def cte_sql(self, expression: exp.CTE) -> str:
913            if expression.args.get("scalar"):
914                this = self.sql(expression, "this")
915                alias = self.sql(expression, "alias")
916                return f"{this} AS {alias}"
917
918            return super().cte_sql(expression)
919
920        def after_limit_modifiers(self, expression: exp.Expression) -> t.List[str]:
921            return super().after_limit_modifiers(expression) + [
922                (
923                    self.seg("SETTINGS ") + self.expressions(expression, key="settings", flat=True)
924                    if expression.args.get("settings")
925                    else ""
926                ),
927                (
928                    self.seg("FORMAT ") + self.sql(expression, "format")
929                    if expression.args.get("format")
930                    else ""
931                ),
932            ]
933
934        def parameterizedagg_sql(self, expression: exp.ParameterizedAgg) -> str:
935            params = self.expressions(expression, key="params", flat=True)
936            return self.func(expression.name, *expression.expressions) + f"({params})"
937
938        def anonymousaggfunc_sql(self, expression: exp.AnonymousAggFunc) -> str:
939            return self.func(expression.name, *expression.expressions)
940
941        def combinedaggfunc_sql(self, expression: exp.CombinedAggFunc) -> str:
942            return self.anonymousaggfunc_sql(expression)
943
944        def combinedparameterizedagg_sql(self, expression: exp.CombinedParameterizedAgg) -> str:
945            return self.parameterizedagg_sql(expression)
946
947        def placeholder_sql(self, expression: exp.Placeholder) -> str:
948            return f"{{{expression.name}: {self.sql(expression, 'kind')}}}"
949
950        def oncluster_sql(self, expression: exp.OnCluster) -> str:
951            return f"ON CLUSTER {self.sql(expression, 'this')}"
952
953        def createable_sql(self, expression: exp.Create, locations: t.DefaultDict) -> str:
954            if expression.kind in self.ON_CLUSTER_TARGETS and locations.get(
955                exp.Properties.Location.POST_NAME
956            ):
957                this_name = self.sql(expression.this, "this")
958                this_properties = " ".join(
959                    [self.sql(prop) for prop in locations[exp.Properties.Location.POST_NAME]]
960                )
961                this_schema = self.schema_columns_sql(expression.this)
962                return f"{this_name}{self.sep()}{this_properties}{self.sep()}{this_schema}"
963
964            return super().createable_sql(expression, locations)
965
966        def prewhere_sql(self, expression: exp.PreWhere) -> str:
967            this = self.indent(self.sql(expression, "this"))
968            return f"{self.seg('PREWHERE')}{self.sep()}{this}"
969
970        def indexcolumnconstraint_sql(self, expression: exp.IndexColumnConstraint) -> str:
971            this = self.sql(expression, "this")
972            this = f" {this}" if this else ""
973            expr = self.sql(expression, "expression")
974            expr = f" {expr}" if expr else ""
975            index_type = self.sql(expression, "index_type")
976            index_type = f" TYPE {index_type}" if index_type else ""
977            granularity = self.sql(expression, "granularity")
978            granularity = f" GRANULARITY {granularity}" if granularity else ""
979
980            return f"INDEX{this}{expr}{index_type}{granularity}"
981
982        def partition_sql(self, expression: exp.Partition) -> str:
983            return f"PARTITION {self.expressions(expression, flat=True)}"
984
985        def partitionid_sql(self, expression: exp.PartitionId) -> str:
986            return f"ID {self.sql(expression.this)}"
987
988        def replacepartition_sql(self, expression: exp.ReplacePartition) -> str:
989            return (
990                f"REPLACE {self.sql(expression.expression)} FROM {self.sql(expression, 'source')}"
991            )
992
993        def projectiondef_sql(self, expression: exp.ProjectionDef) -> str:
994            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
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.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.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.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.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.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.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.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.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 = {'DICTIONARY', 'DATABASE', 'FUNCTION', 'VIEW', 'NAMED COLLECTION', 'TABLE', 'INDEX'}
def strtodate_sql(self, expression: sqlglot.expressions.StrToDate) -> str:
849        def strtodate_sql(self, expression: exp.StrToDate) -> str:
850            strtodate_sql = self.function_fallback_sql(expression)
851
852            if not isinstance(expression.parent, exp.Cast):
853                # StrToDate returns DATEs in other dialects (eg. postgres), so
854                # this branch aims to improve the transpilation to clickhouse
855                return f"CAST({strtodate_sql} AS DATE)"
856
857            return strtodate_sql
def cast_sql( self, expression: sqlglot.expressions.Cast, safe_prefix: Optional[str] = None) -> str:
859        def cast_sql(self, expression: exp.Cast, safe_prefix: t.Optional[str] = None) -> str:
860            this = expression.this
861
862            if isinstance(this, exp.StrToDate) and expression.to == exp.DataType.build("datetime"):
863                return self.sql(this)
864
865            return super().cast_sql(expression, safe_prefix=safe_prefix)
def likeproperty_sql(self, expression: sqlglot.expressions.LikeProperty) -> str:
871        def likeproperty_sql(self, expression: exp.LikeProperty) -> str:
872            return f"AS {self.sql(expression, 'this')}"
def eq_sql(self, expression: sqlglot.expressions.EQ) -> str:
891        def eq_sql(self, expression: exp.EQ) -> str:
892            return self._any_to_has(expression, super().eq_sql)
def neq_sql(self, expression: sqlglot.expressions.NEQ) -> str:
894        def neq_sql(self, expression: exp.NEQ) -> str:
895            return self._any_to_has(expression, super().neq_sql, "NOT ")
def regexpilike_sql(self, expression: sqlglot.expressions.RegexpILike) -> str:
897        def regexpilike_sql(self, expression: exp.RegexpILike) -> str:
898            # Manually add a flag to make the search case-insensitive
899            regex = self.func("CONCAT", "'(?i)'", expression.expression)
900            return self.func("match", expression.this, regex)
def datatype_sql(self, expression: sqlglot.expressions.DataType) -> str:
902        def datatype_sql(self, expression: exp.DataType) -> str:
903            # String is the standard ClickHouse type, every other variant is just an alias.
904            # Additionally, any supplied length parameter will be ignored.
905            #
906            # https://clickhouse.com/docs/en/sql-reference/data-types/string
907            if expression.this in self.STRING_TYPE_MAPPING:
908                return "String"
909
910            return super().datatype_sql(expression)
def cte_sql(self, expression: sqlglot.expressions.CTE) -> str:
912        def cte_sql(self, expression: exp.CTE) -> str:
913            if expression.args.get("scalar"):
914                this = self.sql(expression, "this")
915                alias = self.sql(expression, "alias")
916                return f"{this} AS {alias}"
917
918            return super().cte_sql(expression)
def after_limit_modifiers(self, expression: sqlglot.expressions.Expression) -> List[str]:
920        def after_limit_modifiers(self, expression: exp.Expression) -> t.List[str]:
921            return super().after_limit_modifiers(expression) + [
922                (
923                    self.seg("SETTINGS ") + self.expressions(expression, key="settings", flat=True)
924                    if expression.args.get("settings")
925                    else ""
926                ),
927                (
928                    self.seg("FORMAT ") + self.sql(expression, "format")
929                    if expression.args.get("format")
930                    else ""
931                ),
932            ]
def parameterizedagg_sql(self, expression: sqlglot.expressions.ParameterizedAgg) -> str:
934        def parameterizedagg_sql(self, expression: exp.ParameterizedAgg) -> str:
935            params = self.expressions(expression, key="params", flat=True)
936            return self.func(expression.name, *expression.expressions) + f"({params})"
def anonymousaggfunc_sql(self, expression: sqlglot.expressions.AnonymousAggFunc) -> str:
938        def anonymousaggfunc_sql(self, expression: exp.AnonymousAggFunc) -> str:
939            return self.func(expression.name, *expression.expressions)
def combinedaggfunc_sql(self, expression: sqlglot.expressions.CombinedAggFunc) -> str:
941        def combinedaggfunc_sql(self, expression: exp.CombinedAggFunc) -> str:
942            return self.anonymousaggfunc_sql(expression)
def combinedparameterizedagg_sql(self, expression: sqlglot.expressions.CombinedParameterizedAgg) -> str:
944        def combinedparameterizedagg_sql(self, expression: exp.CombinedParameterizedAgg) -> str:
945            return self.parameterizedagg_sql(expression)
def placeholder_sql(self, expression: sqlglot.expressions.Placeholder) -> str:
947        def placeholder_sql(self, expression: exp.Placeholder) -> str:
948            return f"{{{expression.name}: {self.sql(expression, 'kind')}}}"
def oncluster_sql(self, expression: sqlglot.expressions.OnCluster) -> str:
950        def oncluster_sql(self, expression: exp.OnCluster) -> str:
951            return f"ON CLUSTER {self.sql(expression, 'this')}"
def createable_sql( self, expression: sqlglot.expressions.Create, locations: DefaultDict) -> str:
953        def createable_sql(self, expression: exp.Create, locations: t.DefaultDict) -> str:
954            if expression.kind in self.ON_CLUSTER_TARGETS and locations.get(
955                exp.Properties.Location.POST_NAME
956            ):
957                this_name = self.sql(expression.this, "this")
958                this_properties = " ".join(
959                    [self.sql(prop) for prop in locations[exp.Properties.Location.POST_NAME]]
960                )
961                this_schema = self.schema_columns_sql(expression.this)
962                return f"{this_name}{self.sep()}{this_properties}{self.sep()}{this_schema}"
963
964            return super().createable_sql(expression, locations)
def prewhere_sql(self, expression: sqlglot.expressions.PreWhere) -> str:
966        def prewhere_sql(self, expression: exp.PreWhere) -> str:
967            this = self.indent(self.sql(expression, "this"))
968            return f"{self.seg('PREWHERE')}{self.sep()}{this}"
def indexcolumnconstraint_sql(self, expression: sqlglot.expressions.IndexColumnConstraint) -> str:
970        def indexcolumnconstraint_sql(self, expression: exp.IndexColumnConstraint) -> str:
971            this = self.sql(expression, "this")
972            this = f" {this}" if this else ""
973            expr = self.sql(expression, "expression")
974            expr = f" {expr}" if expr else ""
975            index_type = self.sql(expression, "index_type")
976            index_type = f" TYPE {index_type}" if index_type else ""
977            granularity = self.sql(expression, "granularity")
978            granularity = f" GRANULARITY {granularity}" if granularity else ""
979
980            return f"INDEX{this}{expr}{index_type}{granularity}"
def partition_sql(self, expression: sqlglot.expressions.Partition) -> str:
982        def partition_sql(self, expression: exp.Partition) -> str:
983            return f"PARTITION {self.expressions(expression, flat=True)}"
def partitionid_sql(self, expression: sqlglot.expressions.PartitionId) -> str:
985        def partitionid_sql(self, expression: exp.PartitionId) -> str:
986            return f"ID {self.sql(expression.this)}"
def replacepartition_sql(self, expression: sqlglot.expressions.ReplacePartition) -> str:
988        def replacepartition_sql(self, expression: exp.ReplacePartition) -> str:
989            return (
990                f"REPLACE {self.sql(expression.expression)} FROM {self.sql(expression, 'source')}"
991            )
def projectiondef_sql(self, expression: sqlglot.expressions.ProjectionDef) -> str:
993        def projectiondef_sql(self, expression: exp.ProjectionDef) -> str:
994            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
VALUES_AS_TABLE
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
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
create_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
altertable_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
trycast_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