Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CT-2897] [Feature] Suppress stack trace when a model contract is violated #8266

Open
3 tasks done
Tracked by #7979 ...
joellabes opened this issue Aug 1, 2023 · 4 comments
Open
3 tasks done
Tracked by #7979 ...

Comments

@joellabes
Copy link
Contributor

Is this your first time submitting a feature request?

  • I have read the expectations for open source contributors
  • I have searched the existing issues, and I could not find an existing issue for this feature
  • I am requesting a straightforward extension of existing dbt functionality, rather than a Big Idea better suited to a discussion

Describe the feature

When a model contract fails, there's a lot of guff that gets in the way of seeing the actual issue, and comes dangerously close to spilling out of most consoles (Cloud IDE shown here, but I run my VS Code console smaller than this):

image
Compilation Error in model my_first_dbt_model (models/example/my_first_dbt_model.sql)
  This model has an enforced contract that failed.
  Please ensure the name, data_type, and number of columns in your contract match the columns in your model's definition.
  
  | column_name                | definition_type | contract_type | mismatch_reason       |
  | -------------------------- | --------------- | ------------- | --------------------- |
  | ID                         | TEXT            | FIXED         | data type mismatch    |
  | THIS_COLUMN_DOESNT_EXIST   |                 | TEXT          | missing in definition |
  | THIS_COLUMN_SHOULDNT_EXIST | TIMESTAMP_LTZ   |               | missing in contract   |
  
  
  > in macro assert_columns_equivalent (macros/materializations/models/table/columns_spec_ddl.sql)
  > called by macro default__get_assert_columns_equivalent (macros/materializations/models/table/columns_spec_ddl.sql)
  > called by macro get_assert_columns_equivalent (macros/materializations/models/table/columns_spec_ddl.sql)
  > called by macro snowflake__create_view_as_with_temp_flag (macros/adapters.sql)
  > called by macro snowflake__create_view_as (macros/adapters.sql)
  > called by macro create_view_as (macros/materializations/models/view/create_view_as.sql)
  > called by macro default__get_create_view_as_sql (macros/materializations/models/view/create_view_as.sql)
  > called by macro get_create_view_as_sql (macros/materializations/models/view/create_view_as.sql)
  > called by macro statement (macros/etc/statement.sql)
  > called by macro create_or_replace_view (macros/materializations/models/view/create_or_replace_view.sql)
  > called by macro materialization_view_snowflake (macros/materializations/view.sql)
  > called by model my_first_dbt_model (models/example/my_first_dbt_model.sql)
1 of 2 ERROR creating sql view model dbt_jlabes.my_first_dbt_model ............. [ERROR in 0.88s]
Finished running node model.my_new_project.my_first_dbt_model

It would be better if instead it was like this:

Compilation Error in model my_first_dbt_model (models/example/my_first_dbt_model.sql)
  This model has an enforced contract that failed.
  Please ensure the name, data_type, and number of columns in your contract match the columns in your model's definition.
  
  | column_name                | definition_type | contract_type | mismatch_reason       |
  | -------------------------- | --------------- | ------------- | --------------------- |
  | ID                         | TEXT            | FIXED         | data type mismatch    |
  | THIS_COLUMN_DOESNT_EXIST   |                 | TEXT          | missing in definition |
  | THIS_COLUMN_SHOULDNT_EXIST | TIMESTAMP_LTZ   |               | missing in contract   |
  
1 of 2 ERROR creating sql view model dbt_jlabes.my_first_dbt_model ............. [ERROR in 0.88s]
Finished running node model.my_new_project.my_first_dbt_model

Describe alternatives you've considered

No response

Who will this benefit?

People who like concise and usable error messages. I guess this is happening since it's a compiler error, and normally the macros that got us to a compilation error are highly relevant. But in this case they're 100% internal macros so it's not useful.

Are you interested in contributing this feature?

No response

Anything else?

No response

@joellabes joellabes added enhancement New feature or request triage labels Aug 1, 2023
@github-actions github-actions bot changed the title [Feature] Suppress stack trace when a model contract is violated [CT-2897] [Feature] Suppress stack trace when a model contract is violated Aug 1, 2023
@jtcohen6
Copy link
Contributor

jtcohen6 commented Aug 1, 2023

@joellabes I agree this would be nicer without the full stacktrace!

I also share your instinct that this is because it's a CompilationError, and so we're appending the macro traceback. We should look into seeing if we can have different behavior for ContractError in particular.

@graciegoheen
Copy link
Contributor

Discussed during estimation meeting - May be worth investigating why some compilation errors include a traceback, where others don't.

Copy link
Contributor

github-actions bot commented Feb 4, 2024

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 comment on the issue or else it will be closed in 7 days.

@github-actions github-actions bot added the stale Issues that have gone stale label Feb 4, 2024
@joellabes
Copy link
Contributor Author

Don't leave me

@jtcohen6 jtcohen6 removed the stale Issues that have gone stale label Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants