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

Fix clustering on multiple columns (BigQuery) #1013

Closed
drewbanin opened this issue Sep 19, 2018 · 0 comments
Closed

Fix clustering on multiple columns (BigQuery) #1013

drewbanin opened this issue Sep 19, 2018 · 0 comments
Labels
bigquery bug Something isn't working
Milestone

Comments

@drewbanin
Copy link
Contributor

Issue

Issue description

dbt 0.11.1 injects SQL wrapped in parens for clustering keys:
https://github.com/fishtown-analytics/dbt/blob/dev/guion-bluford/dbt/include/global_project/macros/adapters/bigquery.sql#L14-L28

When a list of columns are provided in the cluster_by config, this evaluates to a query like:

create or replace table dbt_dbanin.orders
partition by date(created_at)
cluster by (region,order_id)    --- <--- this is incorrect
as (
    select current_timestamp as created_at, 1 as region, 2 as order_id
);

This results in an error like:

CLUSTER BY expression must be groupable, but type is STRUCT

This can be fixed by removing the parens around the cluster by clause, eg:

create or replace table dbt_dbanin.orders
partition by date(created_at)
cluster by region, order_id
...

Results

BigQuery returns the following error:

CLUSTER BY expression must be groupable, but type is STRUCT

System information

dbt 0.11.1

@drewbanin drewbanin added bug Something isn't working bigquery labels Sep 19, 2018
@drewbanin drewbanin added this to the Guion Bluford milestone Sep 19, 2018
drewbanin added a commit that referenced this issue Oct 17, 2018
…tiple

Fix clustering on multiple columns (BigQuery) (#1013)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bigquery bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant