Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

Check if test_metadata Exists First #734

Merged
merged 1 commit into from
Oct 9, 2023
Merged

Conversation

sungchun12
Copy link
Contributor

@sungchun12 sungchun12 commented Oct 9, 2023

When running with dbt Cloud artifacts, I came across the error below.

Running with data-diff=0.9.2
10:28:28 ERROR    'NoneType' object has no attribute 'name'                                                                                                                                                                                                 __main__.py:329
Traceback (most recent call last):
  File "/Users/sung/public-api-demos/venv/bin/data-diff", line 8, in <module>
    sys.exit(main())
  File "/Users/sung/public-api-demos/venv/lib/python3.9/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/Users/sung/public-api-demos/venv/lib/python3.9/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/Users/sung/public-api-demos/venv/lib/python3.9/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/sung/public-api-demos/venv/lib/python3.9/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/Users/sung/public-api-demos/venv/lib/python3.9/site-packages/data_diff/__main__.py", line 312, in main
    dbt_diff(
  File "/Users/sung/public-api-demos/venv/lib/python3.9/site-packages/data_diff/dbt.py", line 83, in dbt_diff
    dbt_parser = DbtParser(profiles_dir_override, project_dir_override, state)
  File "/Users/sung/public-api-demos/venv/lib/python3.9/site-packages/data_diff/dbt_parser.py", line 138, in __init__
    self.unique_columns = self.get_unique_columns()
  File "/Users/sung/public-api-demos/venv/lib/python3.9/site-packages/data_diff/dbt_parser.py", line 487, in get_unique_columns
    if node.test_metadata.name == "unique":
AttributeError: 'NoneType' object has no attribute 'name'

This happens because the get_unique_columns function assumes every node has a test_metadata attribute which is optional within dbt_config_validators.py. This checks the attribute first before proceeding with the rest of the logic.

@sungchun12 sungchun12 changed the title check if test_metadata exists first Check if test_metadata Exists First Oct 9, 2023
@sungchun12 sungchun12 requested a review from dlawin October 9, 2023 17:34
@sungchun12 sungchun12 marked this pull request as ready for review October 9, 2023 17:36
@sungchun12 sungchun12 self-assigned this Oct 9, 2023
@sungchun12 sungchun12 added the bug Something isn't working label Oct 9, 2023
@sungchun12 sungchun12 merged commit 10a7e0c into master Oct 9, 2023
6 checks passed
@sungchun12 sungchun12 deleted the fix/test_metadata_error branch October 9, 2023 17:48
sungchun12 added a commit that referenced this pull request Oct 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants