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

Accessible dbt code in error messages #27019

Open
Auric-Manteo opened this issue Jan 10, 2025 · 2 comments
Open

Accessible dbt code in error messages #27019

Auric-Manteo opened this issue Jan 10, 2025 · 2 comments
Labels

Comments

@Auric-Manteo
Copy link

What's the use case?

Currently, the dbt errors show the path to the failed sql code, but that is not accessible if you don't have access to the relevant infrastructure and even then it might get removed eventually due to the infrastructure cleaning up old resources.
Instead it would be great if the path would link to the file and that the file contents is accessible.
So in the example screenshot it would be great if we could access unique_hourly_salesforce_account_of_account_id__c.sql so I can see the code and run it directly to figure out and fix the issue.

image

Ideas of implementation

No response

Additional information

No response

Message from the maintainers

Impacted by this issue? Give it a 👍! We factor engagement into prioritization.

@garethbrickman
Copy link
Contributor

garethbrickman commented Jan 10, 2025

It is possible to log the compiled SQL for both dbt tests and models into the run logs via the ​​run­­_results.json file​​. ­See this code example here which uses DbtCliInvocation. get­_artifact.

    # fetch run_results.json to log compiled SQL
    run_results_json = dbt_cli_task.get_artifact("run_results.json")
    for result in run_results_json["results"]:
        model_name = result.get("unique_id")
        context.log.info(f"Compiled SQL for {model_name}:\n{result['compiled_code']}")

@Auric-Manteo
Copy link
Author

Great, I'll look into that!
Any idea on how you could catch the error and get the name of the failed test to get only their code? There are a lot of them, so listing them all is not a good solution.

@garethbrickman garethbrickman added the integration: dbt Related to dagster-dbt label Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants