Skip to content

Instantly share code, notes, and snippets.

View Ecalzo's full-sized avatar
🎯
Focusing

Evan Calzolaio Ecalzo

🎯
Focusing
View GitHub Profile
@Ecalzo
Ecalzo / dev_limit.sql
Created January 20, 2022 16:55
Macro to limit rows of data queried by dbt during development and CI
{% macro dev_limit(sample_size=1000) -%}
{%- if target.name == 'prod' -%}
--if running in prod environment, run with all the records
{%- else -%}
--SAMPLE ({{ sample_size }} rows only to speedup dev/testing
SAMPLE ({{ sample_size }} ROWS)
{%- endif -%}
{%- endmacro %}
@Ecalzo
Ecalzo / dbt.py
Created November 12, 2021 21:56
Vimeo's Functions for Triggering a DBT Cloud Job via API
def run_dbt_job(
account_id: str,
job_id: str,
branch: str = None,
schema_override: str = None,
steps_override: List[str] = None,
env_name: str = "staging",
):
"""
Run a DBT job.
@Ecalzo
Ecalzo / trigger_dbt.py
Last active September 30, 2025 13:55
Vimeo's Airflow DAG to trigger a DBT Job
import logging
import time
from datetime import datetime, timedelta
from airflow.macros.bieng import get_env # internal function to detect current env
from airflow.models import DAG
from airflow.operators.python_operator import PythonOperator
from datatools.apis.dbt import get_run_status, run_dbt_job # internal package w/ API functions
default_args = {
@Ecalzo
Ecalzo / Jenkinsfile
Last active December 23, 2021 17:39
Vimeo's DBT checks Jenkinsfile
pipeline {
agent {
kubernetes {
cloud 'jenkins-k8-cloud'
yaml """
apiVersion: v1
kind: Pod
spec:
containers:
- name: bieng-dbt-checks-container
@Ecalzo
Ecalzo / generate_schema_name.sql
Created November 12, 2021 21:48
Vimeo's DBT generate_schema_name function override
{% macro generate_schema_name(custom_schema_name, node) %}
{# if this model is created in prod or staging, use the schema designated in dbt_project.yml #}
{% if target.name == 'prod' and custom_schema_name %}
{{ custom_schema_name | trim | upper }}
{% elif target.name == 'staging' and custom_schema_name %}
{{ custom_schema_name | trim | upper }}
{# else, if this is created in dev, use the default (user) schema #}
@Ecalzo
Ecalzo / Medium_SplinterTurorial.py
Created November 3, 2019 18:07
Splinter tutorial for Medium.com
from splinter import Browser
import time
# we are going to use NYC Open Data as an example
URL = 'https://opendata.cityofnewyork.us/data/'
# un-comment this if you are using Windows!
# executable_path = {'executable_path': 'chromedriver.exe'}
# browser = Browser('chrome', **executable_path)