Skip to content

Commit 385f118

Browse files
committed
feedback
1 parent 5b627ea commit 385f118

4 files changed

Lines changed: 9 additions & 9 deletions

File tree

sqlmesh/core/dialect.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
if t.TYPE_CHECKING:
2929
import pandas as pd
30+
from pandas.core.frame import _PandasNamedTuple
3031

3132
from sqlglot._typing import E
3233

@@ -1073,7 +1074,7 @@ def extend_sqlglot() -> None:
10731074

10741075

10751076
def select_from_values(
1076-
values: t.List[t.Tuple[t.Any, ...]],
1077+
values: t.List[_PandasNamedTuple],
10771078
columns_to_types: t.Dict[str, exp.DataType],
10781079
batch_size: int = 0,
10791080
alias: str = "t",
@@ -1103,7 +1104,7 @@ def select_from_values(
11031104

11041105

11051106
def select_from_values_for_batch_range(
1106-
values: t.List[t.Tuple[t.Any, ...]],
1107+
values: t.List[_PandasNamedTuple],
11071108
columns_to_types: t.Dict[str, exp.DataType],
11081109
batch_start: int,
11091110
batch_end: int,

sqlmesh/core/engine_adapter/base.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151

5252
if t.TYPE_CHECKING:
5353
import pandas as pd
54+
from pandas.core.frame import _PandasNamedTuple
5455

5556
from sqlmesh.core._typing import SchemaName, SessionProperties, TableName
5657
from sqlmesh.core.engine_adapter._typing import (
@@ -262,7 +263,7 @@ def _df_to_source_queries(
262263
SourceQuery(
263264
query_factory=partial(
264265
self._values_to_sql,
265-
values=values, # type: ignore
266+
values=values,
266267
columns_to_types=columns_to_types,
267268
batch_start=i,
268269
batch_end=min(i + batch_size, num_rows),
@@ -1021,9 +1022,7 @@ def create_view(
10211022
query_or_df = self._native_df_to_pandas_df(query_or_df)
10221023

10231024
if isinstance(query_or_df, pd.DataFrame):
1024-
values: t.List[t.Tuple[t.Any, ...]] = list(
1025-
query_or_df.itertuples(index=False, name=None)
1026-
)
1025+
values = list(query_or_df.itertuples(index=False, name=None))
10271026
columns_to_types = columns_to_types or self._columns_to_types(query_or_df)
10281027
if not columns_to_types:
10291028
raise SQLMeshError("columns_to_types must be provided for dataframes")
@@ -1343,7 +1342,7 @@ def _insert_overwrite_by_time_partition(
13431342

13441343
def _values_to_sql(
13451344
self,
1346-
values: t.List[t.Tuple[t.Any, ...]],
1345+
values: t.List[_PandasNamedTuple],
13471346
columns_to_types: t.Dict[str, exp.DataType],
13481347
batch_start: int,
13491348
batch_end: int,

sqlmesh/core/table_diff.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def __new__(cls, *args: t.Any, **kwargs: t.Any) -> RowDiff:
8585

8686
@classmethod
8787
def _resolve_types(cls) -> None:
88-
"""Pandas is imported by type checking so we need to resolve the types with the real import before instantiating."""
88+
# Pandas is imported by type checking so we need to resolve the types with the real import before instantiating
8989
import pandas as pd # noqa
9090

9191
cls.model_rebuild()

0 commit comments

Comments
 (0)