gouline / dbt-metabase

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

Native query parsing for exposures doesn't recognize models with qualified table names. #97

Closed jcubed111 closed 2 years ago

jcubed111 commented 2 years ago

It appears that the code to pull exposures from native queries is unable to recognize model names when they're qualified.

I'd expect the below metabase query to generate an exposure dependent on my_model, but it doesn't.

select * from db.schema.my_model

I think the bug is that the regex used to find from and join clauses doesn't allow for . or " characters, despite the subsequent code appearing to account for those cases.

I'd propose that the regex should instead allow . and " characters.

r"[FfJj][RrOo][OoIi][MmNn]\s+\b([\w.\"]+)\b"
gouline commented 2 years ago

You're welcome to create a pull request and test whether it works for you.

z3z1ma commented 2 years ago

This is ready to close @gouline