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

Extra parentheses and spacing when creating BigQuery views #2421

Closed
1 of 5 tasks
azhard opened this issue May 8, 2020 · 2 comments · Fixed by #2422
Closed
1 of 5 tasks

Extra parentheses and spacing when creating BigQuery views #2421

azhard opened this issue May 8, 2020 · 2 comments · Fixed by #2422
Labels
bigquery enhancement New feature or request

Comments

@azhard
Copy link
Contributor

azhard commented May 8, 2020

Describe the bug

When creating views using dbt (dbt run) for a BigQuery project, the views are successfully created but with an extra set of parentheses and extra spacing.

I believe this is due to the bigquery__create_view_as macro which uses the following to create the view

  create or replace view {{ relation }}
  {{ bigquery_table_options(config, model, temporary=false) }}
  as (
    {{ sql }}
  );

Based on the BigQuery docs, views should be created like this

{CREATE VIEW | CREATE VIEW IF NOT EXISTS | CREATE OR REPLACE VIEW}
view_name
[OPTIONS(view_option_list)]
AS query_expression

The difference being no parentheses or extra spacing after the AS.

Steps To Reproduce

Create the following SQL file, names test.sql, in your models folder

SELECT 1 as column1

Run dbt run to create the view in your BigQuery project and observe that the created view in BigQuery has the following SQL:

(
    SELECT 1 as column1
  )

Expected behavior

The expected SQL for the view in BigQuery should be:

SELECT 1 as column1

Screenshots and log output

N/A

System information

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

The output of dbt --version:

installed version: 0.16.1
   latest version: 0.16.1

Up to date!

The operating system you're using:
macOS Catalina (10.15.4)

The output of python --version:

Python 3.8.1

Additional context

N/A

@jtcohen6
Copy link
Contributor

jtcohen6 commented May 8, 2020

Thanks for the issue and PR, @azhard. This change seems fine to me. I just want to confirm that this is for purely cosmetic reasons? I know that BQ displays view definitions to console users.

@azhard
Copy link
Contributor Author

azhard commented May 8, 2020

@jtcohen6 yes, purely cosmetic

@jtcohen6 jtcohen6 added enhancement New feature or request and removed bug Something isn't working labels May 8, 2020
@drewbanin drewbanin added this to the Octavius Catto milestone May 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bigquery enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants