Skip to content

Run fails with view_update_via_alter: true when view has table properties #1096

Closed

Description

@Julian96

Describe the bug

When using use_materialization_v2: true and view_update_via_alter: true for a model, the command dbt run fails, when the view has table properties set in the Unity Catalog.

This is problematic when maintaining comments on views via the UI or the SQL-Statement COMMENT ON, because these statements create the table property comment, which results in failing deployments.

Steps To Reproduce

  1. Create model with config use_materialization_v2: true and view_update_via_alter: true as view
  2. Run the model
  3. Add a comment to the view in the UI or run COMMENT ON statement
  4. Run the model

Expected behavior

The second run (step 4) does not fail and the model gets skipped

System information

The output of dbt --version:

Core:
  - installed: 1.10.3
  - latest:    1.10.3 - Up to date!

Plugins:
  - databricks: 1.10.4 - Up to date!
  - spark:      1.9.2  - Up to date!

The operating system you're using: Windows 11

The output of python --version: Python 3.13.5

Additional context

Add any other context about the problem here.

Activity

  1. benc-db commented on Jul 16, 2025

    @benc-db
    Collaborator

    @Julian96 what is the actual error you get?

  2. Julian96 commented on Jul 17, 2025

    @Julian96
    Author

    @Julian96 what is the actual error you get?

    @benc-db, the error message says "Runtime Error in model (<path_to_model>)
    main is not being called during running model". I pasted the terminal prints. In between the 2 runs I created a comment in the UI on the view I created here.

    (.venv) PS .\dbt> dbt run --select delete_me
    12:43:52 Running with dbt=1.10.3
    WARNING:thrift.transport.sslcompat:using legacy validation callback
    .\dbt.venv\Lib\site-packages\pydantic_internal_config.py:373: UserWarning: Valid config keys have changed in V2:
    'allow_population_by_field_name' has been renamed to 'validate_by_name'
    warnings.warn(message, UserWarning)
    12:44:00 Registered adapter: databricks=1.10.4
    12:44:01 Found 13 models, 12 seeds, 3 data tests, 3 sources, 803 macros
    12:44:01
    12:44:01 Concurrency: 1 threads (target='dev')
    12:44:01
    12:44:06 1 of 1 START sql view model delete_me.delete_me ................................ [RUN]
    12:44:07 1 of 1 OK created sql view model delete_me.delete_me ........................... [OK in 1.00s]
    12:44:08
    12:44:08 Finished running 1 view model in 0 hours 0 minutes and 6.60 seconds (6.60s).
    12:44:08
    12:44:08 Completed successfully
    12:44:08
    12:44:08 Done. PASS=1 WARN=0 ERROR=0 SKIP=0 NO-OP=0 TOTAL=1

    --Added Comment in the UI

    (.venv) PS .\dbt> dbt run --select delete_me
    12:44:22 Running with dbt=1.10.3
    WARNING:thrift.transport.sslcompat:using legacy validation callback
    .\dbt.venv\Lib\site-packages\pydantic_internal_config.py:373: UserWarning: Valid config keys have changed in V2:
    'allow_population_by_field_name' has been renamed to 'validate_by_name'
    warnings.warn(message, UserWarning)
    12:44:31 Registered adapter: databricks=1.10.4
    12:44:32 Found 13 models, 12 seeds, 3 data tests, 3 sources, 803 macros
    12:44:32
    12:44:32 Concurrency: 1 threads (target='dev')
    12:44:32
    12:44:36 1 of 1 START sql view model delete_me.delete_me ................................ [RUN]
    12:44:38 1 of 1 ERROR creating sql view model delete_me.delete_me ....................... [ERROR in 2.42s]
    12:44:39
    12:44:39 Finished running 1 view model in 0 hours 0 minutes and 7.21 seconds (7.21s).
    12:44:39
    12:44:39 Completed with 1 error, 0 partial successes, and 0 warnings:
    12:44:39
    12:44:39 Failure in model delete_me (models\delete_me\delete_me.sql)
    12:44:39 Runtime Error in model delete_me (models\delete_me\delete_me.sql)
    main is not being called during running mode
    l
    12:44:39
    12:44:39 compiled code at target\compiled\core\models\delete_me\delete_me.sql
    12:44:39
    12:44:39 Done. PASS=0 WARN=0 ERROR=1 SKIP=0 NO-OP=0 TOTAL=1

  3. benc-db commented on Jul 17, 2025

    @benc-db
    Collaborator

    @ericj-db merged a fix that should address that in 1.10.5, out soon.

  4. Julian96 commented on Aug 12, 2025

    @Julian96
    Author

    @benc-db, the same error still persists with newer versions.

    Core:
      - installed: 1.10.7
      - latest:    1.10.7 - Up to date!
    
    Plugins:
      - databricks: 1.10.9 - Up to date!
      - spark:      1.9.3  - Up to date!
    

    Python: Python 3.13.6

  5. ericj-db commented on Aug 13, 2025

    @ericj-db
    Contributor

    Hi @Julian96 I tried to reproduce with different variations of the following

    1. Run view model with no description/tblproperties
    2. Manually (UI and SQL) add a comment on the view / columns within the view
    3. Re-run the same model

    I was using the following config

    "flags": {"use_materialization_v2": True},
    "models": {
        "+view_update_via_alter": True,
        "+persist_docs": {
            "relation": True,
            "columns": True,
        },
    },
    

    I was not able to reproduce the issue you are describing. Could you please share more details on how your model is configured or share a minimal example I can use?

  6. Julian96 commented on Aug 13, 2025

    @Julian96
    Author

    Hi @ericj-db,
    I just tested it with your config and it worked. The difference is that we have persist_docs set to False for both relation and columns.
    When I tried again with both set to False it failed again:

    "flags": {"use_materialization_v2": True},
    "models": {
        "+view_update_via_alter": True,
        "+persist_docs": {
            "relation": False,
            "columns": False,
        },
    },
    
  7. Julian96 commented on Aug 13, 2025

    @Julian96
    Author

    I also just remembered why we wanted to have persist_docs set to false. As soon as we set this to true, instead of running an ALTER statement, it executes CREATE OR REPLACE again although use_materialization_v2 is set to true. For multiple reasons we want to avoid running CREATE OR REPLACE, one is we lose all assigned permissions to Views

  8. github-actions commented on Apr 11, 2026

    @github-actions

    This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please remove the stale label or comment on the issue.

  9. sd-db commented on Oct 24, 2026

    @sd-db
    Collaborator

    We re-tested your steps on 1.13.latest with use_materialization_v2 false and true: a view with view_update_via_alter: true and persist_docs relation/columns false, run it, COMMENT ON VIEW, run again. The second run is a no-op and the comment stays. We couldn't reproduce the "main is not being called" error on 1.10.9 or 1.10.14 either, so we can't point to the change that fixed it. Closing; please reopen with your dbt.log if you still see this on 1.13.0.

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

    StalebugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions