99
1010from sqlglot import exp
1111from sqlglot .dialects .bigquery import BigQuery
12- from sqlglot .tokens import TokenType
12+ from sqlglot .tokenizer_core import TokenType
1313
1414__all__ = ("Spanner" ,)
1515
@@ -41,14 +41,14 @@ def _parse_table_parts(
4141 """Parse Spanner table options including interleaving metadata."""
4242 table = super ()._parse_table_parts (schema = schema , is_db_reference = is_db_reference , wildcard = wildcard )
4343
44- if self ._match_text_seq ("INTERLEAVE" , "IN" , "PARENT" ): # type: ignore[no-untyped-call]
44+ if self ._match_text_seq ("INTERLEAVE" , "IN" , "PARENT" ):
4545 parent = cast ("exp.Expression" , self ._parse_table (schema = True , is_db_reference = True ))
4646 on_delete : str | None = None
4747
48- if self ._match_text_seq ("ON" , "DELETE" ): # type: ignore[no-untyped-call]
49- if self ._match_text_seq ("CASCADE" ): # type: ignore[no-untyped-call]
48+ if self ._match_text_seq ("ON" , "DELETE" ):
49+ if self ._match_text_seq ("CASCADE" ):
5050 on_delete = "CASCADE"
51- elif self ._match_text_seq ("NO" , "ACTION" ): # type: ignore[no-untyped-call]
51+ elif self ._match_text_seq ("NO" , "ACTION" ):
5252 on_delete = "NO ACTION"
5353
5454 table .set ("interleave_parent" , parent )
@@ -59,25 +59,25 @@ def _parse_table_parts(
5959
6060 def _parse_property (self ) -> exp .Expression :
6161 """Parse Spanner row deletion policy or PostgreSQL-style TTL."""
62- if self ._match_text_seq ("ROW" , "DELETION" , "POLICY" ): # type: ignore[no-untyped-call]
63- self ._match (TokenType .L_PAREN ) # type: ignore[no-untyped-call]
64- self ._match_text_seq ("OLDER_THAN" ) # type: ignore[no-untyped-call]
65- self ._match (TokenType .L_PAREN ) # type: ignore[no-untyped-call]
62+ if self ._match_text_seq ("ROW" , "DELETION" , "POLICY" ):
63+ self ._match (TokenType .L_PAREN )
64+ self ._match_text_seq ("OLDER_THAN" )
65+ self ._match (TokenType .L_PAREN )
6666 column = cast ("exp.Expression" , self ._parse_id_var ())
67- self ._match (TokenType .COMMA ) # type: ignore[no-untyped-call]
68- self ._match_text_seq ("INTERVAL" ) # type: ignore[no-untyped-call]
67+ self ._match (TokenType .COMMA )
68+ self ._match_text_seq ("INTERVAL" )
6969 interval = cast ("exp.Expression" , self ._parse_expression ())
70- self ._match (TokenType .R_PAREN ) # type: ignore[no-untyped-call]
71- self ._match (TokenType .R_PAREN ) # type: ignore[no-untyped-call]
70+ self ._match (TokenType .R_PAREN )
71+ self ._match (TokenType .R_PAREN )
7272
7373 return exp .Property (
7474 this = exp .Literal .string (_ROW_DELETION_NAME ), value = exp .Tuple (expressions = [column , interval ])
7575 )
7676
77- if self ._match_text_seq ("TTL" ): # type: ignore[no-untyped-call] # PostgreSQL-dialect style, keep for compatibility
78- self ._match_text_seq ("INTERVAL" ) # type: ignore[no-untyped-call]
77+ if self ._match_text_seq ("TTL" ):
78+ self ._match_text_seq ("INTERVAL" )
7979 interval = cast ("exp.Expression" , self ._parse_expression ())
80- self ._match_text_seq ("ON" ) # type: ignore[no-untyped-call]
80+ self ._match_text_seq ("ON" )
8181 column = cast ("exp.Expression" , self ._parse_id_var ())
8282
8383 return exp .Property (this = exp .Literal .string ("TTL" ), value = exp .Tuple (expressions = [interval , column ]))
0 commit comments