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

check-column-desc-are-same fails with a Python error #8

Closed
MartinGuindon opened this issue Feb 22, 2021 · 5 comments · Fixed by #10
Closed

check-column-desc-are-same fails with a Python error #8

MartinGuindon opened this issue Feb 22, 2021 · 5 comments · Fixed by #10
Assignees
Labels
bug Something isn't working

Comments

@MartinGuindon
Copy link

Describe the bug
When trying to use the check-column-desc-are-same hook, I'm getting the following Python error. Other hooks I've tried so far are working:

Check column descriptions are same.......................................Failed
- hook id: check-column-desc-are-same
- exit code: 1

Traceback (most recent call last):
  File "/Users/Martin/.cache/pre-commit/repoewj3j5ob/py_env-python3.7/bin/check-column-desc-are-same", line 8, in <module>
    sys.exit(main())
  File "/Users/Martin/.cache/pre-commit/repoewj3j5ob/py_env-python3.7/lib/python3.7/site-packages/pre_commit_dbt/check_column_desc_are_same.py", line 80, in main
    return check_column_desc(paths=args.filenames, ignore=args.ignore)
  File "/Users/Martin/.cache/pre-commit/repoewj3j5ob/py_env-python3.7/lib/python3.7/site-packages/pre_commit_dbt/check_column_desc_are_same.py", line 55, in check_column_desc
    grouped = get_grouped(paths, ignore)
  File "/Users/Martin/.cache/pre-commit/repoewj3j5ob/py_env-python3.7/lib/python3.7/site-packages/pre_commit_dbt/check_column_desc_are_same.py", line 48, in get_grouped
    sorted(columns, key=lambda x: x.column_name), lambda x: x.column_name
  File "/Users/Martin/.cache/pre-commit/repoewj3j5ob/py_env-python3.7/lib/python3.7/site-packages/pre_commit_dbt/check_column_desc_are_same.py", line 29, in get_all_columns
    for item in schemas:
  File "/Users/Martin/.cache/pre-commit/repoewj3j5ob/py_env-python3.7/lib/python3.7/site-packages/pre_commit_dbt/utils.py", line 134, in get_model_schemas
    model_name = model.get("name")
AttributeError: 'str' object has no attribute 'get'

Version:
v0.1.1
Python 3.7.9

@MartinGuindon MartinGuindon added the bug Something isn't working label Feb 22, 2021
@tomsej
Copy link
Contributor

tomsej commented Feb 23, 2021

Do you think it would be possible to share your schema file? It seems that you have an invalid specification of models. Something like (without - at the beginning):

version: 2

models:
    name: <model name>
    description: <markdown_string>
    ....

or your schema file may be malformed e.g.:

version: 2

models:
    - name: <model name>
    description: <markdown_string>
    ....

In schema file models node should contain a list of models according to documentation - https://docs.getdbt.com/reference/model-properties.

But maybe it can be a good idea to check if model node is instance of Dict to prevent this.

@MartinGuindon
Copy link
Author

It's a big project and there are many schema files. As far as I know they should be correctly formed since the tests/docs are working properly.

I'll try to find which file causes the error and I'll report back with its content.

@tomsej
Copy link
Contributor

tomsej commented Feb 23, 2021

I will also try to prevent this error in the next release. Thanks Martin!

@tomsej
Copy link
Contributor

tomsej commented Feb 24, 2021

@MartinGuindon can you try to rerun this with pre-commit autoupdate --bleeding-edge?

@MartinGuindon
Copy link
Author

It works :)
Check column descriptions are same.......................................Passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants