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

INSERT INTO statement for stg_metrics fails for cumulative metrics #401

Closed
1 of 6 tasks
waligob opened this issue Dec 11, 2023 · 1 comment · Fixed by #402
Closed
1 of 6 tasks

INSERT INTO statement for stg_metrics fails for cumulative metrics #401

waligob opened this issue Dec 11, 2023 · 1 comment · Fixed by #402
Labels
bug Something isn't working

Comments

@waligob
Copy link

waligob commented Dec 11, 2023

Describe the bug

The load to stg_metrics fails with the message:

00:30:50    Database Error in model stg_metrics (models/staging/graph/stg_metrics.sql)
  Syntax error: Expected ")" or "," but got identifier "count" at [305:4]
  compiled Code at target/run/dbt_project_evaluator/models/staging/graph/stg_metrics.sql

Steps to reproduce

The metric that triggers the failure is configured like so:

  - name: total_sessions_rolling_30day
    type: cumulative
    label: Total Sessions, 30 day rolling sum
    type_params:
      measure: total_sessions
      window: 30 days

Expected results

A successful dbt build run

Actual results

The command fails because of unescaped quotation marks in the value for metric_window:

/* {"app": "dbt", "dbt_version": "1.7.3", "profile_name": "user", "target_name": "prod", "node_id": "model.dbt_project_evaluator.stg_metrics"} */
insert into `inq-warehouse`.`analytics`.`stg_metrics` values 

('metric.inquirer_dbt.total_sessions_rolling_30day', 
'total_sessions_rolling_30day', 
'metric', 
'models/marts/core/intermediate/int_sessions.yml', 
cast(True as boolean), 
'cumulative', 
'Total Sessions, 30 day rolling sum', 
'inquirer_dbt', 
'null', 
'total_sessions', 
cast(NULL as string), 
'null', 
'null', 
cast(NULL as string), 
'{'count': 30, 'granularity': 'day'}',  -- this is the failing value
cast(NULL as string), 
'{}')

System information

The contents of your packages.yml file:

packages:
  - package: dbt-labs/dbt_utils
    version: [">=1.1.0", "<1.2.0"]
  - package: calogica/dbt_expectations
    version: [">=0.10.0", "<0.11.0"]
  - package: dbt-labs/codegen
    version: [">=0.11.0", "<0.12.0"]
  - package: data-mie/dbt_profiler
    version: [">=0.8.0", "<0.9.0"]
  - package: dbt-labs/dbt_project_evaluator
    version: [">=0.8.0", "<0.9.0"]
  - package: brooklyn-data/dbt_artifacts
    version: [">=2.3.0", "<2.4.0"]
  - package: elementary-data/elementary
    version: [">=0.11.0", "<0.12.0"]
  - package: dbt-labs/audit_helper
    version: [">=0.9.0", "<1.0.0"]

Which database are you using dbt with?

  • postgres
  • redshift
  • bigquery
  • snowflake
  • trino/starburst
  • other (specify: ____________)

The output of dbt --version:

$ dbt --version
Core:
  - installed: 1.7.3
  - latest:    1.7.3 - Up to date!

Plugins:
  - bigquery: 1.7.2 - Up to date!

Additional context

Are you interested in contributing the fix?

@waligob waligob added the bug Something isn't working label Dec 11, 2023
@b-per
Copy link
Collaborator

b-per commented Dec 12, 2023

Thanks for raising it! I have a fix for it and we will most likely do a new release in the next days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants