Last active
March 21, 2024 05:03
-
-
Save thomashandorf/0d54848ccd84448001abb2a51d48794a to your computer and use it in GitHub Desktop.
BigQuery access Google Sheets for DBT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ config(materialized = 'table') }} | |
{%- call statement('create_ext_table', fetch_result=False) -%} | |
CREATE OR REPLACE EXTERNAL TABLE {{ this.database+"."+this.schema+"."+this.table+"_ref" }} ( | |
Student_Name STRING, | |
Gender STRING, | |
Class_Level STRING, | |
Home_State STRING, | |
Major STRING, | |
Extracurricular_Activity STRING | |
) | |
OPTIONS ( | |
FORMAT = 'GOOGLE_SHEETS', | |
URIS = [ | |
'https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit' | |
], | |
MAX_BAD_RECORDS = 0, | |
--SHEET_RANGE = "Class Data", | |
SKIP_LEADING_ROWS = 1 | |
); | |
{%- endcall -%} | |
SELECT | |
Student_Name AS student_name, | |
Gender AS gender, | |
Class_Level AS class_level, | |
Home_State AS home_state, | |
Major AS major, | |
Extracurricular_Activity AS extracurricular_activity | |
FROM | |
{{ this.database+"."+this.schema+"."+this.table+"_ref" }} | |
WHERE | |
Student_Name IS NOT NULL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment