Engine: PostgreSQL
Changing simple conditions (e.g. a WHERE statement) leads to drop and create a model view. For example permissions are gone (in this case) or the object_id is changes. (for Microsoft SQL Server this would also happen, but I didn't tried it out, yet). (I'm aware of on_virtual_update, where it is possible to handle permissions. it is just an example).
Example:
Initial model
MODEL (
name analysis.airports_per_timezone_gt_10,
grain timezone,
);
SELECT
*
FROM analysis.airports_per_timezone apt
WHERE cnt_per_timezone>0
;
This generates:
sqlmesh__analysis.analysis__airports_per_timezone_gt_10__1111111111
analysis.analysis__airports_per_timezone_gt_10 which uses sqlmesh__analysis.analysis__airports_per_timezone_gt_10__1111111111
model change
MODEL (
name analysis.airports_per_timezone_gt_10,
grain timezone,
);
SELECT
*
FROM analysis.airports_per_timezone apt
WHERE cnt_per_timezone>10 -- changed
;
This generates:
sqlmesh__analysis.analysis__airports_per_timezone_gt_10__222222222
- DROP and CREATE
analysis.analysis__airports_per_timezone_gt_10 which uses sqlmesh__analysis.analysis__airports_per_timezone_gt_10__222222222
If no columns are changed (altered positions, renamings, deletions), then PostgreSQL can replace the view. Just replacing the source view only needs CREATE AND REPLACE and not DROP + CREATE.
Can this be avoided somehow? (without creating a "Custom materialization")
Engine: PostgreSQL
Changing simple conditions (e.g. a WHERE statement) leads to drop and create a model view. For example permissions are gone (in this case) or the object_id is changes. (for Microsoft SQL Server this would also happen, but I didn't tried it out, yet). (I'm aware of on_virtual_update, where it is possible to handle permissions. it is just an example).
Example:
Initial model
This generates:
sqlmesh__analysis.analysis__airports_per_timezone_gt_10__1111111111analysis.analysis__airports_per_timezone_gt_10which usessqlmesh__analysis.analysis__airports_per_timezone_gt_10__1111111111model change
This generates:
sqlmesh__analysis.analysis__airports_per_timezone_gt_10__222222222analysis.analysis__airports_per_timezone_gt_10which usessqlmesh__analysis.analysis__airports_per_timezone_gt_10__222222222If no columns are changed (altered positions, renamings, deletions), then PostgreSQL can replace the view. Just replacing the source view only needs
CREATE AND REPLACEand not DROP + CREATE.Can this be avoided somehow? (without creating a "Custom materialization")