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

Claires suggestions #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Claires suggestions #2

wants to merge 4 commits into from

Conversation

clrcrl
Copy link

@clrcrl clrcrl commented Feb 14, 2020

Did these in separate commits so you can take or leave what you'd like!

  1. Add a gitignore

    • As soon as I tried to run dbt, I had a ton of files I didn't want to commit, so I added a .gitignore
  2. Specify a project (database) for sources

    • Adding the database: parameter (== project on BQ) means that I can query things in your project! However, it breaks dbt docs generate since I don't have permission to read your information schema:
$ dbt docs generate
Running with dbt=0.15.2
Found 6 models, 0 tests, 0 snapshots, 0 analyses, 138 macros, 0 operations, 0 seed files, 2 sources

14:48:19 | Concurrency: 8 threads (target='dev_bigquery')
14:48:19 |
14:48:20 | Done.
14:48:20 | Building catalog
Encountered an error:
Database Error
  Access Denied: Table fh-bigquery:INFORMATION_SCHEMA.SCHEMATA: User does not have permission to query table fh-bigquery:INFORMATION_SCHEMA.SCHEMATA.
  1. Fix errant SQL

    • Once I got this to run, I found this error.
  2. Use simpler incremental logic

    • This works as expected. Not sure if there's a reason you went the other way here!

@@ -6,12 +6,6 @@ FROM {{ source('reddit_comments', '20*') }}
WHERE subreddit = 'AmItheAsshole'
AND _table_suffix > '19_'

{%- if is_incremental() -%}
{%- if execute -%}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I'm using this weird complex logic because one of these queries is much better for BigQuery:

  • SELECT * FROM * WHERE _table_suffix < '2019_01'
  • SELECT * FROM * WHERE _table_suffix < (SELECT date FROM ...)

One is a constant and will prune how much data is read. The other one is variable, and BigQuery doesn't optimize it as well.

I can get that as a constant by using run_query(). I have another option, but it doesn't work now (dbt-labs/dbt-core#2136)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants