dbt-labs/dbt-utils

Quoting of database name appears to be broken in get_tables_by_pattern_sql

skion opened this issue · 2 comments

Describe the bug

get_relations_by_prefix() appears to be broken on Postgres when the database name contains e.g. a hyphen.

Steps to reproduce

Use the following in a database of which the name contains a hyphen.

{% set relations = dbt_utils.get_relations_by_prefix('some_schema', 'prefix') %}

Expected results

19:03:39  Completed successfully

Actual results

18:55:53  Finished running 1 table model, 1 project hook in 0 hours 0 minutes and 2.15 seconds (2.15s).
18:55:53  
18:55:53  Completed with 1 error and 0 warnings:
18:55:53  
18:55:53    Database Error in model some_model (models/kpis.sql)
  syntax error at or near "-"
  LINE 19:         from foo-bar.information_schema.tables

System information

The contents of your packages.yml file:

packages:
  - package: dbt-labs/dbt_utils
    version: 1.1.1
  - package: calogica/dbt_expectations
    version: 0.10.1
  - package: calogica/dbt_date
    version: 0.10.0
  - package: Snowflake-Labs/dbt_constraints
    version: [">=0.6.0", "<0.7.0"]
  - package: pvcy/dbt_privacy
    version: 0.3.1

Which database are you using dbt with?

  • postgres
  • redshift
  • bigquery
  • snowflake
  • other (specify: ____________)

The output of dbt --version:

Core:
  - installed: 1.8.1
  - latest:    1.8.1 - Up to date!

Plugins:
  - postgres: 1.8.1 - Up to date!

Additional context

Are you interested in contributing the fix?

PR is here: #899

Thanks for reporting this and opening a PR @skion !

@dbeatty10 I unmarked it from draft just now...