gouline / dbt-metabase

dbt + Metabase integration
https://pypi.org/project/dbt-metabase/
MIT License
448 stars 64 forks source link

NoneType' object has no attribute 'upper' #40

Closed edbizarro closed 3 years ago

edbizarro commented 3 years ago

Hi, i'm trying to use this awesome project with my dbt setup (bigquery) but keep getting this AttributeError: 'NoneType' object has no attribute 'upper'.

I'm running on dbt v0.20.0 and Metabase 0.40.1

Traceback (most recent call last):
  File "/home/edbizarro/.pyenv/versions/analytics-venv-3.7.8/bin/dbt-metabase", line 6, in <module>
    dbtmetabase.main(sys.argv[1:])
  File "/home/edbizarro/.pyenv/versions/3.7.8/envs/analytics-venv-3.7.8/lib/python3.7/site-packages/dbtmetabase/__init__.py", line 248, in main
    include_tags=parsed.include_tags,
  File "/home/edbizarro/.pyenv/versions/3.7.8/envs/analytics-venv-3.7.8/lib/python3.7/site-packages/dbtmetabase/__init__.py", line 114, in export
    mbc.export_models(metabase_database, models, reader.catch_aliases)
  File "/home/edbizarro/.pyenv/versions/3.7.8/envs/analytics-venv-3.7.8/lib/python3.7/site-packages/dbtmetabase/metabase.py", line 156, in export_models
    table_lookup, field_lookup = self.build_metadata_lookups(database_id)
  File "/home/edbizarro/.pyenv/versions/3.7.8/envs/analytics-venv-3.7.8/lib/python3.7/site-packages/dbtmetabase/metabase.py", line 377, in build_metadata_lookups
    table_schema = table.get("schema", "public").upper()
AttributeError: 'NoneType' object has no attribute 'upper'

Command I'm using to test

dbt-metabase export \
    --dbt_manifest_path ./analytics/target/manifest.json \
    --dbt_database analytics \
    --metabase_host ...\
    --metabase_user ... \
    --metabase_password "..." \
    --metabase_database "Analytics" \
    --schema public
z3z1ma commented 3 years ago

Hi @edbizarro

Thanks for the post! Hmm looking at that, the only way its possible to get a None object would be if the schema key is actually present in the API response as expected but the value is null.

I am curious as to how many tables you have returning null for schema key in metadata dict. Would be very insightful to know. I think we can account for it regardless though.

gouline commented 3 years ago

From memory, BigQuery has no concept of schema, this was raised a while back in #5 and #7. Possibly related?

gouline commented 3 years ago

Fix released as v0.8.0-rc2. Give it another go @edbizarro.

edbizarro commented 3 years ago

Wow that was fast!