This file contains hidden or 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
import requests | |
url = "endpoint" | |
payload={} | |
headers = { | |
'Authorization': 'Bearer myAccessToken' | |
} | |
response = requests.request("GET", url, headers=headers, data=payload) |
This file contains hidden or 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
import requests | |
url = "https://api.nasa.gov/planetary/apod?api_key=gHF0ZP0dNGMmUL1SFKRgZ0jVHHJxx1LgnM6GUR1I" | |
payload={} | |
headers = { | |
'apikey': 'YVETes1ZU6iw2Iu3BxzHFZNvE3A3ydLE' | |
} | |
response = requests.request("GET", url, headers=headers, data=payload) |
This file contains hidden or 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
{% test advanced_equality(model, compare_model, round_columns=None) %} | |
{% set compare_columns = adapter.get_columns_in_relation(model) | map(attribute='quoted') %} | |
{% set compare_cols_csv = compare_columns | join(', ') %} | |
{% if round_columns %} | |
{% set round_columns_enriched = [] %} | |
{% for col in round_columns %} | |
{% do round_columns_enriched.append('round('+col+')') %} | |
{% endfor %} |
This file contains hidden or 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
version: 2 | |
models: | |
- name: revenue | |
meta: | |
owner: "@xiaoxu" | |
tests: | |
- dbt_utils.equality: | |
compare_model: ref('revenue_expected') |
This file contains hidden or 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
{% macro select_table(source_table, test_table) %} | |
{% if var('unit_testing', false) == true %} | |
{{ return(test_table) }} | |
{% else %} | |
{{ return(source_table) }} |
This file contains hidden or 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', | |
tags=['revenue'] | |
) | |
}} | |
{% set import_transaction = select_table(source('user_xiaoxu','transaction'), ref('revenue_transaction')) %} | |
{% set import_vat = select_table(source('user_xiaoxu','vat'), ref('revenue_vat')) %} |
This file contains hidden or 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
-- Disable checking the Unqualified reference | |
--noqa: disable=L027 | |
{{ config | |
( | |
materialized='table', | |
tags=['revenue'] | |
) | |
}} |
This file contains hidden or 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
from functools import lru_cache, wraps | |
from datetime import datetime, timedelta | |
import time | |
def timed_lru_cache(seconds: int, maxsize: int = 128): | |
def wrapper_cache(func): | |
func = lru_cache(maxsize=maxsize)(func) | |
func.lifetime = timedelta(seconds=seconds) | |
func.expiration = datetime.utcnow() + func.lifetime |
This file contains hidden or 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
import collections | |
class Node: | |
def __init__(self, key, val): | |
self.key = key | |
self.val = val | |
self.freq = 1 | |
self.prev = None | |
self.next = None |
This file contains hidden or 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
class Node: | |
def __init__(self, key, val) -> None: | |
self.key = key | |
self.val = val | |
self.next = None | |
self.prev = None | |
class LRUCache: | |
def __init__(self, capacity) -> None: | |
self.cache = {} |