Skip to content

Instantly share code, notes, and snippets.

View anatolec's full-sized avatar
📚
Learning

Anatole anatolec

📚
Learning
View GitHub Profile
@anatolec
anatolec / add_metadata_to_metabase_questions.py
Created December 19, 2023 10:04
A script to add a comment containing the Question ID on every Metabase question
import requests
METABASE_URL = '<YOUR_METABASE_URL>'
METABASE_USERNAME = '<YOUR_METABASE_USERNAME>'
METABASE_PASSWORD = '<YOUR_METABASE_PASSWORD>'
PREFIX = "-- METABASE_QUESTION_ID = "
SUFFIX = " - DO NOT CHANGE THIS LINE\n"
def login():
@anatolec
anatolec / roc_auc.sql
Created December 8, 2023 21:09
A BigQuery UDF to compute ROC AUC given 2 arrays of scores and labels
CREATE OR REPLACE FUNCTION `<project-id>.<dataset-id>.roc_auc`(scores ARRAY<FLOAT64>, labels ARRAY<BOOL>)
RETURNS FLOAT64 AS (
(
with input_data as (
select scores.score, labels.label
from(
SELECT *, row_number() over () as row_num
FROM UNNEST(scores) as score) scores
join(
SELECT *, row_number() over () as row_num
@anatolec
anatolec / get_latest_column_changes_per_table.sql
Last active December 8, 2023 21:10
A DBT analysis to retrieve schema change from Airbyte internal data
{% set relations = dbt_utils.get_relations_by_prefix('<<YOUR_DATASET_NAME>>', '') %}
with base as (
{% for relation in relations %}
(select
"{{ relation.identifier }}" as table,
array_to_string(array(select col from unnest(bigfunctions.eu.json_keys(_airbyte_data)) as col order by col), ',') as columns,
min(_airbyte_extracted_at) as min_date,
max(_airbyte_extracted_at) as max_date,
from airbyte_internal.<<YOUR_DATASET_NAME>>_raw__stream_{{ relation.identifier }}