Skip to content

Commit 9b871d5

Browse files
committed
Clean up clickhouse engine property refactor
1 parent 1b3ea34 commit 9b871d5

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

sqlglot/dialects/clickhouse.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
from sqlglot.tokens import Token, TokenType
2828
from sqlglot.generator import unsupported_args
2929

30-
if t.TYPE_CHECKING:
31-
from sqlglot._typing import E
32-
3330
DATEΤΙΜΕ_DELTA = t.Union[exp.DateAdd, exp.DateDiff, exp.DateSub, exp.TimestampSub, exp.TimestampAdd]
3431

3532

@@ -501,7 +498,10 @@ class Parser(parser.Parser):
501498

502499
FUNCTION_PARSERS.pop("MATCH")
503500

504-
PROPERTY_PARSERS = parser.Parser.PROPERTY_PARSERS.copy()
501+
PROPERTY_PARSERS = {
502+
**parser.Parser.PROPERTY_PARSERS,
503+
"ENGINE": lambda self: self._parse_engine_property(),
504+
}
505505
PROPERTY_PARSERS.pop("DYNAMIC")
506506

507507
NO_PAREN_FUNCTION_PARSERS = parser.Parser.NO_PAREN_FUNCTION_PARSERS.copy()
@@ -571,11 +571,12 @@ class Parser(parser.Parser):
571571
TokenType.L_BRACE: lambda self: self._parse_query_parameter(),
572572
}
573573

574-
def _parse_property_assignment(self, exp_class: t.Type[E], **kwargs: t.Any) -> E:
575-
this = super()._parse_property_assignment(exp_class, **kwargs)
576-
if isinstance(this, exp.EngineProperty) and isinstance(this.this, exp.Null):
577-
this.this.replace(exp.Anonymous(this="Null"))
578-
return this
574+
def _parse_engine_property(self) -> exp.EngineProperty:
575+
self._match(TokenType.EQ)
576+
return self.expression(
577+
exp.EngineProperty,
578+
this=self._parse_field(any_token=True, anonymous_func=True),
579+
)
579580

580581
# https://clickhouse.com/docs/en/sql-reference/statements/create/function
581582
def _parse_user_defined_function_expression(self) -> t.Optional[exp.Expression]:

0 commit comments

Comments
 (0)