-
Notifications
You must be signed in to change notification settings - Fork 496
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
dbt_utils.pivot function fails on empty table #280
Comments
@aadityahippo I'm going to transfer this issue to the dbt-utils repository, where the code defining |
I can take this on! |
@aadityahippo I imagine you get an error like in the screenshot below. What's the use case for silently passing without error? Would it be more helpful to raise an error message? See example below. Compilation Error in model dim_suppliers_empty_pivot (models/marts/core/dim_suppliers_empty_pivot.sql)
Cannot pivot an empty table/view. Ensure the upstream dependency has populated rows.
> in macro pivot (macros/sql/pivot.sql)
> called by macro default__pivot (macros/sql/pivot.sql)
> called by model dim_suppliers_empty_pivot (models/marts/core/dim_suppliers_empty_pivot.sql) |
Hi @sungchun12 I would expect dbt-utils to behave similarly to any other model created with dbt, in that if you try to create a model from another model/table, which is already empty, the resultant model should be an empty table. I am running 100s of dbt models across multiple environments, some of them will, and are expected to produce empty tables where certain scenarios are not met. We only expect dbt to fail in the case of SQL/DB errors. Raising an error here marks our dbt task as failed within the airflow DAG, and we do not continue on to downstream tasks. Please could you help me here and provide some method for us to use the handy dbt_utils.pivot function, but expect to deal with empty tables. |
Any update on this? Running in to the same issue with my models and would just want the function to create an empty table instead of give a compilation error. Thanks in advance. |
This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days. |
Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest. Just add a comment to notify the maintainers. |
Hi all, did we find a fix for this. I am encountering this issue and would appreciate any help to fix it. Thanks. |
Is there a solve for this? |
Having the same issue |
Describe the bug
dbt_utils.pivot function does expect at least one record to be populated in the source table. If there is no record in source table, this function fails with a nonetype object error as it does not found values to loop through.
Steps To Reproduce
Use dbt_utils.pivot function/macro for an empty table and do the run.
Expected behavior
Function should silently pass with no records generated. It should not fail.
System information
Which database are you using dbt with?
The output of
dbt --version
:The operating system you're using:
Mac
The output of
python --version
:Python 3.7.3
The text was updated successfully, but these errors were encountered: