Skip to content

Instantly share code, notes, and snippets.

View sungchun12's full-sized avatar
🧃
Juicin' up these open source contributor muscles in full force!

Sung Won Chung sungchun12

🧃
Juicin' up these open source contributor muscles in full force!
View GitHub Profile
/*
Welcome to your first dbt model!
Did you know that you can also configure models directly within SQL files?
This will override configurations stated in dbt_project.yml
Try changing "table" to "view" below
*/
-- force a dependency
-- depends_on: analytics.dbt_demo_account_sung.fct_orders
select *
from -- Need this here, since the actual ref is nested within loops/conditions:
-- depends on: analytics.dbt_demo_account_sung.dbt_metrics_default_calendar
(with source_query as (
select
@sungchun12
sungchun12 / table_constraints_demo.sql
Created May 10, 2022 21:03
BigQuery: Table with Constraints Custom Materialization
{{
config(
materialized = "table_with_constraints"
)
}}
select
1 as id,
'blue' as color,
cast('2019-01-01' as date) as date_day
{% macro clone_prod_to_target(from) %}
{% set sql -%}
create schema if not exists {{ target.database }}.{{ target.schema }} clone {{ from }};
{%- endset %}
{{ dbt_utils.log_info("Cloning schema " ~ from ~ " into target schema.") }}
{% do run_query(sql) %}
@sungchun12
sungchun12 / drop_dbt_cloud_pull_request_schemas.sql
Last active May 17, 2021 19:28
drop dbt Cloud pull request schemas to cleanup your snowflake database organization
--Run this command in your terminal: dbt run-operation drop_dbt_cloud_pull_request_schemas
--Write this as a file in your dbt project directory: macros/drop_dbt_cloud_pull_request_schemas.sql
--Original Source: https://github.com/randypitcherii/hashmap_randy_pitcher_workspace/blob/master/dbt/macros/cleanup/drop_old_relations.sql
{% macro drop_dbt_cloud_pull_request_schemas() %}
{% set cleanup_query %}
-- CTE to query the snowflake information schema to get all the tables and views in scope for cleanup
WITH
@sungchun12
sungchun12 / cloudSettings
Last active July 8, 2019 21:42
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-07-08T21:42:32.794Z","extensionVersion":"v3.3.1"}