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-2322] [Feature] Side-by-side diff when an enforced model contract fails #7209

Closed
3 tasks done
Tracked by #6747
dbeatty10 opened this issue Mar 22, 2023 · 2 comments · Fixed by #7319
Closed
3 tasks done
Tracked by #6747

[CT-2322] [Feature] Side-by-side diff when an enforced model contract fails #7209

dbeatty10 opened this issue Mar 22, 2023 · 2 comments · Fixed by #7319
Assignees
Labels
enhancement New feature or request good_first_issue Straightforward + self-contained changes, good for new contributors!

Comments

@dbeatty10
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

See this Loom starting at 12:50 for context of this feature proposal:
https://www.loom.com/share/f436e5e336e4433695dc63d53ee72fcf?t=770

Two things:

  • Update "Contracts are enabled for this model." to "This model has an enforced contract."
  • Do a side-by-side diff rather than a stacked listing of column names

Where a preflight check fails for a model contract, could the output look more like this?

image

Right now, the output looks like this:

image snip...
image

Describe alternatives you've considered

Sometimes the status quo is the way to go ...
... and sometimes it isn't 😉

Who will this benefit?

This will benefit folks that:

  • are using enforced model contracts
  • there is a mismatch in the contract leading to a preflight failure
  • have a model with tons of columns (or even just a few!)

Are you interested in contributing this feature?

No response

Anything else?

No response

@dbeatty10 dbeatty10 added enhancement New feature or request triage good_first_issue Straightforward + self-contained changes, good for new contributors! and removed triage labels Mar 22, 2023
@github-actions github-actions bot changed the title [Feature] Side-by-side diff when an enforced model contract fails [CT-2322] [Feature] Side-by-side diff when an enforced model contract fails Mar 22, 2023
@jtcohen6
Copy link
Contributor

This change wants to happen here:

class ContractError(CompilationError):
def __init__(self, yaml_columns, sql_columns):
self.yaml_columns = yaml_columns
self.sql_columns = sql_columns
super().__init__(msg=self.get_message())
def get_message(self) -> str:
msg = (
"Contracts are enabled for this model. "
"Please ensure the name, data_type, and number of columns in your `yml` file "
"match the columns in your SQL file.\n"
f"Schema File Columns: {self.yaml_columns}\n"
f"SQL File Columns: {self.sql_columns}"
)
return msg

This would also require updating a few tests, which currently expect to see some specific text in the logs. It's definitely worth doing for the UX improvement :)

@kentkr
Copy link
Contributor

kentkr commented Mar 26, 2023

Created a PR for this with some questions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good_first_issue Straightforward + self-contained changes, good for new contributors!
Projects
None yet
3 participants