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

Edge case not properly handled in get_columns_and_types macro #769

Open
dlahyani opened this issue Dec 12, 2024 · 0 comments
Open

Edge case not properly handled in get_columns_and_types macro #769

dlahyani opened this issue Dec 12, 2024 · 0 comments

Comments

@dlahyani
Copy link

This is the problematic excerpt from the macro:

   {%- set relation = adapter.get_relation(
          database=database_name,
          schema=schema_name,
          identifier=table_name) -%}

    {%- set columns_from_relation = adapter.get_columns_in_relation(relation) -%}

This code is problematic in case the requested relation does not exist. In that case adapter.get_relation returns None, so we end up passing None to adapter.get_columns_in_relation which does not expects None.

When using dbt-bigquery adapter it fails with an exception and a cryptic message:

Flow run encountered an exception. 
RuntimeError: Runtime Error
  'NoneType' object has no attribute 'database'

It would be better if before calling to adapter.get_columns_in_relation the macro would check if relation is None and raise an explicit compilation error in that case with a proper error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant