-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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-3227] [Bug] KeyError: 'my_project://models/metrics.yml' after deleting YAML files related to semantic layer #8860
Comments
WorkaroundThe easiest workaround is do a dbt clean More detailed workaroundHere's a workaround that may work in the meantime: Use dbt --no-partial-parse compile Alternatively, delete the |
The key thing to triggering this error was defining a ratio metric, parsing the project, and then deleting the file it appears within: metrics:
- name: average_value_per_opportunity
description: The average value per opportunity
type: ratio
label: Average Value per Opportunity
type_params:
numerator: total_value
denominator: total_opportunities
|
@dbeatty10 Is this only affecting 1.6 and 1.7? |
I didn't check 1.5 since the reprex was using @graciegoheen Do you think we should try out a similar non-MetricFlow |
Got it - let's contain this issue to |
We had hoped this was resolved by some related work we did. However I just tried the reproduction with 1.7.latest and the error is still occurring. |
The error specifically happens when a yaml file which contains definitions for both semantic models and metrics is deleted |
But also it only does it sometimes... |
…etrics It was raised in #8860 that an error is being raised during partial parsing when files containing metrics/semantic models are deleted. In further testing it looks like this error specifically happens when a file containing both semantic models and metrics is deleted. If the deleted file contains just semantic models or metrics there seems to be no issue. The next commit should contain the fix.
* Add test around deleting a YAML file containing semantic models and metrics It was raised in #8860 that an error is being raised during partial parsing when files containing metrics/semantic models are deleted. In further testing it looks like this error specifically happens when a file containing both semantic models and metrics is deleted. If the deleted file contains just semantic models or metrics there seems to be no issue. The next commit should contain the fix. * Skip deleted schema files when scheduling files during partial parsing Waaaay back (in 7563b99) deleted schema files started being separated out from deleted non-schema files. However ever since, when it came to scheduling files for reparsing, we've only done so for deleted non-schema files. We even missed this when we refactored the scheduling code in b37e5b5. This change updates `_schedule_for_parsing` which is used by `schedule_nodes_for_parsing` to begin skipping deleted schema files in addition to deleted non schema files. * Update `add_to_pp_files` to ignore `deleted_schema_files` As noted in the previous commit, we started separating out deleted schema files from deleted non-schema files a looong time ago. However, this whole time we've been adding `deleted_schema_files` to the list of files to be parsed. This change corrects for that. * Add changie doc for partial parsing KeyError fix
* Add test around deleting a YAML file containing semantic models and metrics It was raised in #8860 that an error is being raised during partial parsing when files containing metrics/semantic models are deleted. In further testing it looks like this error specifically happens when a file containing both semantic models and metrics is deleted. If the deleted file contains just semantic models or metrics there seems to be no issue. The next commit should contain the fix. * Skip deleted schema files when scheduling files during partial parsing Waaaay back (in 7563b99) deleted schema files started being separated out from deleted non-schema files. However ever since, when it came to scheduling files for reparsing, we've only done so for deleted non-schema files. We even missed this when we refactored the scheduling code in b37e5b5. This change updates `_schedule_for_parsing` which is used by `schedule_nodes_for_parsing` to begin skipping deleted schema files in addition to deleted non schema files. * Update `add_to_pp_files` to ignore `deleted_schema_files` As noted in the previous commit, we started separating out deleted schema files from deleted non-schema files a looong time ago. However, this whole time we've been adding `deleted_schema_files` to the list of files to be parsed. This change corrects for that. * Add changie doc for partial parsing KeyError fix (cherry picked from commit deedeeb)
* Stop trying to parse deleted schema files (#9722) * Add test around deleting a YAML file containing semantic models and metrics It was raised in #8860 that an error is being raised during partial parsing when files containing metrics/semantic models are deleted. In further testing it looks like this error specifically happens when a file containing both semantic models and metrics is deleted. If the deleted file contains just semantic models or metrics there seems to be no issue. The next commit should contain the fix. * Skip deleted schema files when scheduling files during partial parsing Waaaay back (in 7563b99) deleted schema files started being separated out from deleted non-schema files. However ever since, when it came to scheduling files for reparsing, we've only done so for deleted non-schema files. We even missed this when we refactored the scheduling code in b37e5b5. This change updates `_schedule_for_parsing` which is used by `schedule_nodes_for_parsing` to begin skipping deleted schema files in addition to deleted non schema files. * Update `add_to_pp_files` to ignore `deleted_schema_files` As noted in the previous commit, we started separating out deleted schema files from deleted non-schema files a looong time ago. However, this whole time we've been adding `deleted_schema_files` to the list of files to be parsed. This change corrects for that. * Add changie doc for partial parsing KeyError fix (cherry picked from commit deedeeb) * Empty commit to trigger github actions --------- Co-authored-by: Quigley Malcolm <[email protected]> Co-authored-by: Quigley Malcolm <[email protected]>
Is this a new bug in dbt-core?
Current Behavior
Failure with long stacktrace after deleting YAML files related to semantic models and/or metrics.
Workaround
The easiest workaround is do a
dbt clean
:More detailed workaround
Here's a workaround that may work in the meantime:
Use
--no-partial-parse
to disable partial parsing:Alternatively, delete the
partial_parse.msgpack
file from yourtarget
directory (for example, viadbt clean
).Expected Behavior
Either no failure or at least no stacktrace.
Steps To Reproduce
dbt parse
dbt parse
Relevant log output
Environment
Which database adapter are you using with dbt?
snowflake
Additional Context
Maybe be related (or a duplicate of):
The text was updated successfully, but these errors were encountered: