Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Using filter list with Jinja on metrics and metric input measures causes error when running dbt parse #9582

Closed
2 tasks done
courtneyholcomb opened this issue Feb 15, 2024 · 0 comments · Fixed by #9709
Assignees
Labels
bug Something isn't working semantic Issues related to the semantic layer

Comments

@courtneyholcomb
Copy link
Contributor

Is this a new bug in dbt-core?

  • I believe this is a new bug in dbt-core
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

When you define a metric or metric input measure with a filter list and include Jinja in the list, dbt parse triggers an error. Example YAML:

metrics:
  - name: new_customer
    description: Unique count of new customers.
    label: New Customers
    type: simple
    type_params:
      measure: customers_with_orders
    filter:
      - "{{ Dimension('customer__customer_type') }}  = 'new'"

Running dbt parse in a repo with that metric definition triggers this error:

Compilation Error
  Could not render {{ Dimension('customer__customer_type') }}  = 'new': 'Dimension' is undefined

Meanwhile, if you apply the same filter as a string (example below), no error will be triggered.

metrics:
  - name: new_customer
    description: Unique count of new customers.
    label: New Customers
    type: simple
    type_params:
      measure: customers_with_orders
    filter: "{{ Dimension('customer__customer_type') }}  = 'new'"

Expected Behavior

Applying the filter in a list should have the same impact as applying it as a string. Currently this limitation will prevent users from using multiple filters on metrics and metric input measures.

Steps To Reproduce

  1. Add a list-type filter on a metric or a metric input measure in a dbt project
  2. Run dbt parse in the repo

Relevant log output

Output when running dbt parse:

21:05:56  Running with dbt=1.7.3
21:05:56  Registered adapter: duckdb=1.7.0
21:05:56  Encountered an error:
Compilation Error
  Could not render {{ Dimension('customer__customer_type') }}  = 'new': 'Dimension' is undefined

Environment

- OS: Mac OSX 13.4.1
- Python: 3.9.16
- dbt: 1.7.3

Which database adapter are you using with dbt?

other (mention it in "Additional Context")

Additional Context

DuckDB

@courtneyholcomb courtneyholcomb added bug Something isn't working triage labels Feb 15, 2024
@courtneyholcomb courtneyholcomb self-assigned this Feb 15, 2024
@dbeatty10 dbeatty10 added semantic Issues related to the semantic layer and removed triage labels Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working semantic Issues related to the semantic layer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants