ClickHouse / dbt-clickhouse

The Clickhouse plugin for dbt (data build tool)
Apache License 2.0
253 stars 113 forks source link

Projections crashes with syntax error when adding multiple projections. #348

Closed stephen-up closed 2 months ago

stephen-up commented 2 months ago

Describe the bug

When using the new projections support, it crashes if you try and add more than one projection.

I can see it works when adding a single projection, and works much better than using a post_hook. It doesn't re-run unnecessarily.

Steps to reproduce

  1. Add multiple projections to a model.
    projections=[
    {
      'name': 'max_r_n',
      'query': 'select max(received_ts)'
    },
    {
      'name': 'pd_r',
      'query': 'select project_id, domain order by received_ts'
    }
    ],
  2. Run it with dbt run

Expected behaviour

Expected to create the projections.

Error

Syntax error: failed at position 346 ('ALTER') ...

It seems like the statements to add the projections are incorrectly being executed as one statement, rather than independently.

Configuration

Environment