You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/concepts/models/model_kinds.md
+19
Original file line number
Diff line number
Diff line change
@@ -408,6 +408,25 @@ WHERE
408
408
AND event_date BETWEEN @start_ds AND @end_ds; -- `event_date` time column filter automatically added by SQLMesh
409
409
```
410
410
411
+
### Partitioning
412
+
413
+
By default, we ensure that the `time_column` is part of the [partitioned_by](./overview.md#partitioned_by) property of the model so that it forms part of the partition key and allows the database engine to do partition pruning. If it is not explicitly listed in the Model definition, we will automatically add it.
414
+
415
+
However, this may be undesirable if you want to exclusively partition on another column or you want to partition on something like `month(time_column)` but the engine you're using doesnt support partitioning based on expressions.
416
+
417
+
To opt out of this behaviour, you can set `partition_by_time_column false` like so:
418
+
419
+
```sql linenums="1" hl_lines="5"
420
+
MODEL (
421
+
name db.events,
422
+
kind INCREMENTAL_BY_TIME_RANGE (
423
+
time_column event_date,
424
+
partition_by_time_column false
425
+
),
426
+
partitioned_by (other_col) -- event_date will no longer be automatically added here and the partition key will just be 'other_col'
427
+
);
428
+
```
429
+
411
430
### Idempotency
412
431
We recommend making sure incremental by time range model queries are [idempotent](../glossary.md#idempotency) to prevent unexpected results during data [restatement](../plans.md#restatement-plans).
0 commit comments