Skip to content

Commit 803357c

Browse files
Merge branch 'main' into fix/external-models-directory-duplicates
2 parents 8cc5abb + 9460918 commit 803357c

3 files changed

Lines changed: 16 additions & 4 deletions

File tree

sqlmesh/integrations/dlt.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,7 @@ def generate_dlt_models_and_settings(
6363
if db_type == "filesystem":
6464
connection_config = None
6565
else:
66-
if dlt.__version__ >= "1.10.0":
67-
client = pipeline.destination_client()
68-
else:
69-
client = pipeline._sql_job_client(schema) # type: ignore
66+
client = pipeline.destination_client()
7067
config = client.config
7168
credentials = config.credentials
7269
configs = {

sqlmesh/utils/date.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,8 @@ def make_exclusive(time: TimeLike) -> datetime:
344344

345345

346346
def make_ts_exclusive(time: TimeLike, dialect: DialectType) -> datetime:
347+
import pandas as pd
348+
347349
ts = to_datetime(time)
348350
if dialect == "tsql":
349351
return to_utc_timestamp(ts) - pd.Timedelta(1, unit="ns")

tests/utils/test_date.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
is_categorical_relative_expression,
1515
is_relative,
1616
make_inclusive,
17+
make_ts_exclusive,
1718
to_datetime,
1819
to_time_column,
1920
to_timestamp,
2021
to_ts,
2122
to_tstz,
23+
to_utc_timestamp,
2224
)
2325

2426

@@ -141,6 +143,17 @@ def test_make_inclusive_tsql(start_in, end_in, start_out, end_out, dialect) -> N
141143
)
142144

143145

146+
def test_make_ts_exclusive() -> None:
147+
# tsql subtracts 1ns from the UTC timestamp; must not raise NameError (pd not imported)
148+
assert make_ts_exclusive("2020-01-01 12:00:00", dialect="tsql") == to_utc_timestamp(
149+
to_datetime("2020-01-01 12:00:00")
150+
) - pd.Timedelta(1, unit="ns")
151+
# non-tsql dialects add 1 microsecond
152+
assert make_ts_exclusive("2020-01-01 12:00:00", dialect="duckdb") == to_datetime(
153+
"2020-01-01 12:00:00.000001"
154+
)
155+
156+
144157
@pytest.mark.parametrize(
145158
"expression, result",
146159
[

0 commit comments

Comments
 (0)