Skip to content

Instantly share code, notes, and snippets.

View datadutch's full-sized avatar
🏠
Working from home

Johan van der Kooij datadutch

🏠
Working from home
View GitHub Profile
@gvisniuc
gvisniuc / snowflake_deduplication_procedure.sql
Last active February 15, 2021 23:19
Snowflake Deduplication Procedure
/*
This procedure will take the full path of a Snowflake table (Database, Schema and Table name) and will deduplicate it using a rotation mechanism.
To minimize waste we first check if the count of the rows of the table is the same as the unique.
If not, given a table A, we create a deduplicated version A_DEDUP.
Table A is renamed to A_ROTATE
A_DEDUP is renamed to A
@ML-engineer
ML-engineer / duckdb_bq_storage_api.py
Created July 4, 2022 22:08
Read BQ table to DuckDB directly from storage read api
import duckdb
from google.cloud import bigquery
bqclient = bigquery.Client()
table = bigquery.TableReference.from_string(
"bigquery-public-data.utility_us.country_code_iso"
)
rows = bqclient.list_rows(table)
country_code_iso = rows.to_arrow(create_bqstorage_client=True)
cursor = duckdb.connect()
@titan-teej
titan-teej / privileged_users_check.sql
Last active June 3, 2024 19:24
Audits your Snowflake account to show which users have privileged access
USE ROLE ACCOUNTADMIN;
USE WAREHOUSE <warehouse_name>;
WITH privileged_users_check AS PROCEDURE()
RETURNS TABLE()
LANGUAGE PYTHON
RUNTIME_VERSION = '3.9'
PACKAGES = ('snowflake-snowpark-python')
HANDLER = 'main'
EXECUTE AS CALLER