microsoft / dbt-fabric

MIT License
79 stars 28 forks source link

dbt-utils macro get_tables_by_pattern_sql not supported #158

Closed simon-sandell-swedavia-se closed 7 months ago

simon-sandell-swedavia-se commented 7 months ago

The macro get_tables_by_pattern_sql is not supported in dbt-fabric since the default implementation uses ilike and lowercase {{ database }}.information_schema.tables. This implementation works for me:

{% macro fabric__get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude='', database=target.database) %}

        select distinct
            table_schema as {{ adapter.quote('table_schema') }},
            table_name as {{ adapter.quote('table_name') }},
            {{ dbt_utils.get_table_types_sql() }}
        from {{ database }}.INFORMATION_SCHEMA.TABLES
        where table_schema like '{{ schema_pattern }}'
        and table_name like '{{ table_pattern }}'
        and table_name not like '{{ exclude }}'

{% endmacro %}
prdpsvs commented 7 months ago

I merged this today. Please open the issue again if you come across something...