-
Notifications
You must be signed in to change notification settings - Fork 178
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
Raise exception when attempting to run a model that dbt can't find #682
Comments
🤖 Hello again, @tatiana! It's good to see you contributing to our project. I appreciate the detailed issue you've raised. Rest assured, I'm going to take a close look at it and get back to you with a comprehensive response soon. |
🤖 Thank you for bringing this to our attention, Tatiana. I agree that it would be beneficial for the Currently, the To implement your proposal, we could modify the def run_command(self, command: List[str]) -> None:
result = run_dbt_command(command, self.env)
if "The selection criterion" in result.output and "does not match any nodes" in result.output:
raise AirflowException("The selection criterion does not match any dbt models")
self.log.info(result.output) This would cause the Airflow task to fail if dbt can't find a model that matches the select statement. As for the configuration option to opt out of this behavior, we could add a new parameter to the def run_command(self, command: List[str]) -> None:
result = run_dbt_command(command, self.env)
if "The selection criterion" in result.output and "does not match any nodes" in result.output:
if self.raise_on_no_match:
raise AirflowException("The selection criterion does not match any dbt models")
else:
self.log.warning("The selection criterion does not match any dbt models")
self.log.info(result.output) Please note that this is a rough sketch and the actual implementation might differ. The changes would need to be thoroughly tested to ensure they work as expected and do not introduce any regressions. I hope this helps! If you have any further questions or suggestions, please let me know. SourcesThis response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
What does DBT do in the case it doesn't match? If DBT fails in this situation i would say we should fail as a default and allow the user to turn it off. Likewise if DBT doesn't fail we should follow suit and add a toggle to enable failing. |
@MrBones757 I really like your approach to this - but I feel in this particular case, things are not as clear.
Since dbt Core users use the command line, they always see the output - regardless of the OS return code /stderr, so the error is visible. I don't have access to dbtCloud, but I'd expect them to be exposed in the UI if a model expected to run did not run. In the case of Cosmos/Airflow, we need to make a call of which scenarios represent a task failure - since we cannot rely on dbt Core return codes or the stderr. |
Hi, @tatiana, I'm helping the Cosmos team manage their backlog and am marking this issue as stale. From what I understand, the issue you raised proposed raising an exception when attempting to run a model that dbt cannot find, with the ability for users to opt out of this behavior through configuration. The issue has been resolved by modifying the Could you please confirm if this issue is still relevant to the latest version of the Cosmos repository? If it is, please let the Cosmos team know by commenting on the issue. Otherwise, feel free to close the issue yourself, or the issue will be automatically closed in 7 days. Thank you for your contribution! If you have any further questions or need assistance with anything else, feel free to reach out. |
Context
Cosmos 1.2 considers a model run task successful even if dbt finds no models for that execution, as illustrated in:
#662 (comment)
The Airflow task succeeds, but the logs say:
I'd expect us to be able to reproduce this by instantiating a
DbtRunLocalOperator
https://github.com/astronomer/astronomer-cosmos/blob/main/cosmos/operators/local.py#L433C7-L433C26 with a select statement that doesn't match any dbt models.Proposal
(I would love thoughts from the community!)
We should raise an exception if dbt's output contains "select statement that doesn't match any dbt models".
We could allow users to opt out of this behaviour via some configuration.
The text was updated successfully, but these errors were encountered: