Skip to content

Commit fcf017c

Browse files
committed
Chore: rename EXPRESSION_SPEC to EXPRESSION_METADATA
1 parent d197c47 commit fcf017c

File tree

15 files changed

+42
-42
lines changed

15 files changed

+42
-42
lines changed

sqlglot/dialects/bigquery.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from sqlglot.generator import unsupported_args
3737
from sqlglot.helper import seq_get, split_num_words
3838
from sqlglot.tokens import TokenType
39-
from sqlglot.typing.bigquery import EXPRESSION_SPEC
39+
from sqlglot.typing.bigquery import EXPRESSION_METADATA
4040

4141
if t.TYPE_CHECKING:
4242
from sqlglot._typing import Lit
@@ -402,7 +402,7 @@ class BigQuery(Dialect):
402402
COERCES_TO[exp.DataType.Type.DECIMAL] |= {exp.DataType.Type.BIGDECIMAL}
403403
COERCES_TO[exp.DataType.Type.BIGINT] |= {exp.DataType.Type.BIGDECIMAL}
404404

405-
EXPRESSION_SPEC = EXPRESSION_SPEC.copy()
405+
EXPRESSION_METADATA = EXPRESSION_METADATA.copy()
406406

407407
def normalize_identifier(self, expression: E) -> E:
408408
if (

sqlglot/dialects/dialect.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from sqlglot.time import TIMEZONES, format_time, subsecond_precision
2626
from sqlglot.tokens import Token, Tokenizer, TokenType
2727
from sqlglot.trie import new_trie
28-
from sqlglot.typing import EXPRESSION_SPEC
28+
from sqlglot.typing import EXPRESSION_METADATA
2929

3030
DATE_ADD_OR_DIFF = t.Union[
3131
exp.DateAdd,
@@ -673,7 +673,7 @@ class Dialect(metaclass=_Dialect):
673673
COERCES_TO: t.Dict[exp.DataType.Type, t.Set[exp.DataType.Type]] = {}
674674

675675
# Specifies type inference & validation rules for expressions
676-
EXPRESSION_SPEC = EXPRESSION_SPEC.copy()
676+
EXPRESSION_METADATA = EXPRESSION_METADATA.copy()
677677

678678
# Determines the supported Dialect instance settings
679679
SUPPORTED_SETTINGS = {

sqlglot/dialects/hive.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
from sqlglot.tokens import TokenType
4747
from sqlglot.generator import unsupported_args
4848
from sqlglot.optimizer.annotate_types import TypeAnnotator
49-
from sqlglot.typing.hive import EXPRESSION_SPEC
49+
from sqlglot.typing.hive import EXPRESSION_METADATA
5050

5151
# (FuncType, Multiplier)
5252
DATE_DELTA_INTERVAL = {
@@ -217,7 +217,7 @@ class Hive(Dialect):
217217
# https://spark.apache.org/docs/latest/sql-ref-identifier.html#description
218218
NORMALIZATION_STRATEGY = NormalizationStrategy.CASE_INSENSITIVE
219219

220-
EXPRESSION_SPEC = EXPRESSION_SPEC.copy()
220+
EXPRESSION_METADATA = EXPRESSION_METADATA.copy()
221221

222222
# Support only the non-ANSI mode (default for Hive, Spark2, Spark)
223223
COERCES_TO = defaultdict(set, deepcopy(TypeAnnotator.COERCES_TO))

sqlglot/dialects/presto.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
from sqlglot.tokens import TokenType
4040
from sqlglot.transforms import unqualify_columns
4141
from sqlglot.generator import unsupported_args
42-
from sqlglot.typing.presto import EXPRESSION_SPEC
42+
from sqlglot.typing.presto import EXPRESSION_METADATA
4343

4444
DATE_ADD_OR_SUB = t.Union[exp.DateAdd, exp.TimestampAdd, exp.DateSub]
4545

@@ -268,7 +268,7 @@ class Presto(Dialect):
268268
# https://github.com/prestodb/presto/issues/2863
269269
NORMALIZATION_STRATEGY = NormalizationStrategy.CASE_INSENSITIVE
270270

271-
EXPRESSION_SPEC = EXPRESSION_SPEC.copy()
271+
EXPRESSION_METADATA = EXPRESSION_METADATA.copy()
272272

273273
SUPPORTED_SETTINGS = {
274274
*Dialect.SUPPORTED_SETTINGS,

sqlglot/dialects/snowflake.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from sqlglot.helper import find_new_name, flatten, is_float, is_int, seq_get
3636
from sqlglot.optimizer.scope import build_scope, find_all_in_scope
3737
from sqlglot.tokens import TokenType
38-
from sqlglot.typing.snowflake import EXPRESSION_SPEC
38+
from sqlglot.typing.snowflake import EXPRESSION_METADATA
3939

4040
if t.TYPE_CHECKING:
4141
from sqlglot._typing import E, B
@@ -554,7 +554,7 @@ class Snowflake(Dialect):
554554
ALTER_TABLE_ADD_REQUIRED_FOR_EACH_COLUMN = False
555555
TRY_CAST_REQUIRES_STRING = True
556556

557-
EXPRESSION_SPEC = EXPRESSION_SPEC.copy()
557+
EXPRESSION_METADATA = EXPRESSION_METADATA.copy()
558558

559559
TIME_MAPPING = {
560560
"YYYY": "%Y",

sqlglot/dialects/spark2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
ctas_with_tmp_tables_to_create_tmp_view,
2222
move_schema_columns_to_partitioned_by,
2323
)
24-
from sqlglot.typing.spark2 import EXPRESSION_SPEC
24+
from sqlglot.typing.spark2 import EXPRESSION_METADATA
2525

2626

2727
def _map_sql(self: Spark2.Generator, expression: exp.Map) -> str:
@@ -117,7 +117,7 @@ def temporary_storage_provider(expression: exp.Expression) -> exp.Expression:
117117
class Spark2(Hive):
118118
ALTER_TABLE_SUPPORTS_CASCADE = False
119119

120-
EXPRESSION_SPEC = EXPRESSION_SPEC.copy()
120+
EXPRESSION_METADATA = EXPRESSION_METADATA.copy()
121121

122122
class Tokenizer(Hive.Tokenizer):
123123
HEX_STRINGS = [("X'", "'"), ("x'", "'")]

sqlglot/dialects/tsql.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from sqlglot.parser import build_coalesce
2626
from sqlglot.time import format_time
2727
from sqlglot.tokens import TokenType
28-
from sqlglot.typing.tsql import EXPRESSION_SPEC
28+
from sqlglot.typing.tsql import EXPRESSION_METADATA
2929

3030
if t.TYPE_CHECKING:
3131
from sqlglot._typing import E
@@ -413,7 +413,7 @@ class TSQL(Dialect):
413413

414414
TIME_FORMAT = "'yyyy-mm-dd hh:mm:ss'"
415415

416-
EXPRESSION_SPEC = EXPRESSION_SPEC.copy()
416+
EXPRESSION_METADATA = EXPRESSION_METADATA.copy()
417417

418418
TIME_MAPPING = {
419419
"year": "%Y",

sqlglot/optimizer/annotate_types.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626
]
2727

2828
from sqlglot.dialects.dialect import DialectType
29-
from sqlglot.typing import ExpressionSpecType
29+
from sqlglot.typing import ExpressionMetadataType
3030

3131
logger = logging.getLogger("sqlglot")
3232

3333

3434
def annotate_types(
3535
expression: E,
3636
schema: t.Optional[t.Dict | Schema] = None,
37-
expression_spec: t.Optional[ExpressionSpecType] = None,
37+
expression_metadata: t.Optional[ExpressionMetadataType] = None,
3838
coerces_to: t.Optional[t.Dict[exp.DataType.Type, t.Set[exp.DataType.Type]]] = None,
3939
dialect: DialectType = None,
4040
) -> E:
@@ -61,7 +61,7 @@ def annotate_types(
6161

6262
schema = ensure_schema(schema, dialect=dialect)
6363

64-
return TypeAnnotator(schema, expression_spec, coerces_to).annotate(expression)
64+
return TypeAnnotator(schema, expression_metadata, coerces_to).annotate(expression)
6565

6666

6767
def _coerce_date_literal(l: exp.Expression, unit: t.Optional[exp.Expression]) -> exp.DataType.Type:
@@ -175,13 +175,13 @@ class TypeAnnotator(metaclass=_TypeAnnotator):
175175
def __init__(
176176
self,
177177
schema: Schema,
178-
expression_spec: t.Optional[ExpressionSpecType] = None,
178+
expression_metadata: t.Optional[ExpressionMetadataType] = None,
179179
coerces_to: t.Optional[t.Dict[exp.DataType.Type, t.Set[exp.DataType.Type]]] = None,
180180
binary_coercions: t.Optional[BinaryCoercions] = None,
181181
) -> None:
182182
self.schema = schema
183-
self.expression_spec = (
184-
expression_spec or Dialect.get_or_raise(schema.dialect).EXPRESSION_SPEC
183+
self.expression_metadata = (
184+
expression_metadata or Dialect.get_or_raise(schema.dialect).EXPRESSION_METADATA
185185
)
186186
self.coerces_to = (
187187
coerces_to or Dialect.get_or_raise(schema.dialect).COERCES_TO or self.COERCES_TO
@@ -373,7 +373,7 @@ def _maybe_annotate(self, expression: E) -> E:
373373
if id(expression) in self._visited:
374374
return expression # We've already inferred the expression's type
375375

376-
spec = self.expression_spec.get(expression.__class__)
376+
spec = self.expression_metadata.get(expression.__class__)
377377

378378
if spec and (annotator := spec.get("annotator")):
379379
return annotator(self, expression)

sqlglot/typing/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from sqlglot import exp
44
from sqlglot.helper import subclasses
55

6-
ExpressionSpecType = t.Dict[type[exp.Expression], t.Dict[str, t.Any]]
6+
ExpressionMetadataType = t.Dict[type[exp.Expression], t.Dict[str, t.Any]]
77

88
TIMESTAMP_EXPRESSIONS = {
99
exp.CurrentTimestamp,
@@ -14,7 +14,7 @@
1414
exp.UnixToTime,
1515
}
1616

17-
EXPRESSION_SPEC: ExpressionSpecType = {
17+
EXPRESSION_METADATA: ExpressionMetadataType = {
1818
**{
1919
expr_type: {"annotator": lambda self, e: self._annotate_binary(e)}
2020
for expr_type in subclasses(exp.__name__, exp.Binary)

sqlglot/typing/bigquery.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import typing as t
44

55
from sqlglot import exp
6-
from sqlglot.typing import EXPRESSION_SPEC, TIMESTAMP_EXPRESSIONS
6+
from sqlglot.typing import EXPRESSION_METADATA, TIMESTAMP_EXPRESSIONS
77

88
if t.TYPE_CHECKING:
99
from sqlglot.optimizer.annotate_types import TypeAnnotator
@@ -102,8 +102,8 @@ def _annotate_array(self: TypeAnnotator, expression: exp.Array) -> exp.Array:
102102
return self._annotate_by_args(expression, "expressions", array=True)
103103

104104

105-
EXPRESSION_SPEC = {
106-
**EXPRESSION_SPEC,
105+
EXPRESSION_METADATA = {
106+
**EXPRESSION_METADATA,
107107
**{
108108
expr_type: {"annotator": lambda self, e: _annotate_math_functions(self, e)}
109109
for expr_type in {

0 commit comments

Comments
 (0)