Skip to content

sqlmesh plan --restate-model requires model files to be present #3260

Open

Description

@giovannipcarvalho

Hi!

Since v0.119.0 sqlmesh run does not require any model definitions in the models/ to refresh model data.

While clearing some confusion I had about sqlmesh plan --restate-model's behavior, it was pointed out to me that it should only refresh data, but not update models' definitions (like a regular plan would).

So I expected that a restatement should also not require the definitions, if it only refreshes data. But when testing the behavior it does not seem to be the case.

repro

setup

$ uv venv && uv pip install sqlmesh && . .venv/bin/activate
$ sqlmesh --version
0.127.1

t.sh -- helper script

#!/usr/bin/env bash
function remove_definitions {
    rm -rf models seeds tests audits macros logs .cache
}

remove_definitions

rm -rf config.yaml db.db
sqlmesh init duckdb
sqlmesh plan --auto-apply >/dev/null

remove_definitions

I believe a restatement shouldn't require model definitions in order to only refresh data, similar to run.

$ ./t.sh && sqlmesh plan -r sqlmesh_example.full_model -s '' -e '' --auto-apply
Error: `('/tmp/sqlmesh-tmp',)` doesn't seem to have any models... cd into the proper directory or specify the path(s) with -p.

Defining a dummy full_model makes it work:

$ mkdir models && echo 'MODEL (name sqlmesh_example.full_model); select 1 as foo' > models/full_model.sql
$ sqlmesh plan -r sqlmesh_example.full_model -s '' -e '' --auto-apply
No differences when compared to `prod`
Models needing backfill (missing dates):
└── sqlmesh_example.full_model: 2024-10-15 - 2024-10-15
[...]
The target environment has been updated successfully

And the original model definition is not replaced by the dummy that was introduced, as expected:

$ duckdb -c 'select * from sqlmesh_example.full_model' db.db 
┌─────────┬────────────┐
│ item_id │ num_orders │
│  int32  │   int64    │
├─────────┼────────────┤
│       2 │          1 │
│       1 │          5 │
│       3 │          1 │
└─────────┴────────────┘

Am I misguided here?

Thanks in advance.


For completeness sake, to demonstrate that sqlmesh run behaves like this since v0.119:

$ uv pip install -U sqlmesh==0.118.0 && ./t.sh && sqlmesh run
[...]
Error: `('/tmp/sqlmesh-tmp',)` doesn't seem to have any models... cd into the proper directory or specify the path(s) with -p.
$ uv pip install -U sqlmesh==0.119.0 && ./t.sh && sqlmesh run
[...]
Run finished for environment 'prod'

Activity

  1. georgesittas commented on Oct 18, 2024

    @georgesittas
    Collaborator

    This does look like a bug, @izeigerman can you verify?

  2. izeigerman commented on Oct 24, 2024

    @izeigerman
    Collaborator

    Yes, restatements shouldn't require model files now that we purposefully ignore local changes when doing the restatement.

  3. hardeybisey commented on Nov 9, 2024

    @hardeybisey

    @izeigerman can you assign this to me. Thanks.

  4. yadrielsamir commented on Nov 14, 2026

    @yadrielsamir

    @hardeybisey, are you still working on this? If not, I'd like to pick it up.

    I reproduced it on 0.236.4 (macOS, Python 3.9.6): with the model files removed, sqlmesh plan -r sqlmesh_example.full_model -s '' -e '' --auto-apply still fails with "doesn't seem to have any models", and adding a dummy model still makes the restatement succeed.

  5. yadrielsamir commented on Nov 14, 2026

    @yadrielsamir

    I see @mokashang opened #6219 for this just before my comment, so I'll step back from this one. In case it helps review, I also reproduced the bug on the 0.236.4 release on macOS with the same "doesn't seem to have any models" error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions