|
41 | 41 | from sqlmesh.utils import rich as srich |
42 | 42 | from sqlmesh.utils import Verbosity |
43 | 43 | from sqlmesh.utils.concurrency import NodeExecutionFailedError |
44 | | -from sqlmesh.utils.date import time_like_to_str, to_date, yesterday_ds, to_ds, to_datetime |
| 44 | +from sqlmesh.utils.date import time_like_to_str, to_date, yesterday_ds, to_ds, make_inclusive |
45 | 45 | from sqlmesh.utils.errors import ( |
46 | 46 | PythonModelEvalError, |
47 | 47 | NodeAuditsErrors, |
@@ -3119,10 +3119,13 @@ def _format_evaluation_model_interval(snapshot: Snapshot, interval: Interval) -> |
3119 | 3119 | or snapshot.model.kind.is_managed |
3120 | 3120 | or snapshot.model.kind.is_custom |
3121 | 3121 | ): |
3122 | | - # include time if interval < 1 day |
3123 | | - if (interval[1] - interval[0]) < datetime.timedelta(days=1).total_seconds() * 1000: |
3124 | | - return f"insert {to_ds(interval[0])} {to_datetime(interval[0]).strftime('%H:%M:%S')}-{to_datetime(interval[1]).strftime('%H:%M:%S')}" |
3125 | | - return f"insert {to_ds(interval[0])} - {to_ds(interval[1])}" |
| 3122 | + inclusive_interval = make_inclusive(interval[0], interval[1]) |
| 3123 | + if snapshot.model.interval_unit.is_date_granularity: |
| 3124 | + return f"insert {to_ds(inclusive_interval[0])} - {to_ds(inclusive_interval[1])}" |
| 3125 | + # omit end date if interval start/end on same day |
| 3126 | + if inclusive_interval[0].date() == inclusive_interval[1].date(): |
| 3127 | + return f"insert {to_ds(inclusive_interval[0])} {inclusive_interval[0].strftime('%H:%M:%S')}-{inclusive_interval[1].strftime('%H:%M:%S')}" |
| 3128 | + return f"insert {inclusive_interval[0].strftime('%Y-%m-%d %H:%M:%S')} - {inclusive_interval[1].strftime('%Y-%m-%d %H:%M:%S')}" |
3126 | 3129 | return "" |
3127 | 3130 |
|
3128 | 3131 |
|
|
0 commit comments