https://github.com/dbt-labs/dbt-utils/blob/09382f23693f2e8bc1dca275cc39638129e4c683/macros/sql/get_tables_by_pattern_sql.sql#L12 {{ database }} should be replaced with {{ adapter.quote(database) }}