Skip to content

Instantly share code, notes, and snippets.

View ben-nour's full-sized avatar

Ben Nour ben-nour

View GitHub Profile
@ben-nour
ben-nour / scheduling_workspace_snowflake_notebooks.md
Last active August 13, 2026 01:07
Automating Workspace noteboook execution via Snowflake Tasks

🤖 Automating Workspace noteboook execution via Snowflake Tasks

Written: 12 August 2026

From September 2026 Legacy notebook creation will be disabled and new Snowflake notebooks will need to be created via Workspaces.

Scheduling workspace notebook execution via Snowflake Task is slightly more complicated than with Legacy notebooks and this guide runs you through the steps for creating and debugging tasks that execute workspace notebooks.

Prerequisites

@ben-nour
ben-nour / uploading_third_party_packages_to_snowflake.md
Last active August 10, 2026 06:43
A guide to uploading third-party Python packages for use in Snowflake notebooks running on the warehouse

Uploading third-party Python packages to Snowflake

1. Create a stage

If you want to use a Python package within a notebook running on a warehouse and it's not available via Snowflake’s Anaconda channel of pre-approved packages you’ll need to use a stage to upload the source code of the Python packages you want to use.

You can create the stage via Snowsight (Snowflake's web interface) or via a script:

CREATE STAGE PYTHON_PACKAGES 
@ben-nour
ben-nour / automating_conda_python_script.md
Last active March 23, 2025 23:56
Automating conda Python script on an admin-locked Windows computer.
@ben-nour
ben-nour / inserting_none_into_snowflake.py
Created March 12, 2025 23:26
How to insert None objects into a Snowflake table's numeric column.
import snowflake.connector
value = None
# Won't work:
f"""INSERT INTO example_table(
visitors
) VALUES
(
'{value}',
@ben-nour
ben-nour / python_re_functions.py
Last active December 12, 2025 03:40
An overview of main functions from the Python re module.
"""
Good reference: https://www.dataquest.io/cheat-sheet/regular-expressions-cheat-sheet/
Official documentation: https://docs.python.org/3/library/re.html
"""
import re
text = "dog cat dog"
########## re.findall() ##########
@ben-nour
ben-nour / extract_fy.sql
Last active August 12, 2024 02:25
Snowflake UDF to extract FY from a date.
CREATE OR REPLACE FUNCTION extract_fy(date_to_convert varchar, date_format varchar DEFAULT 'YYYY-MM-DD')
RETURNS VARCHAR
LANGUAGE SQL
AS
$$
SELECT
CASE
WHEN MONTH(TRY_TO_DATE(date_to_convert, date_format)) >= 7 THEN
CONCAT('FY', RIGHT(YEAR(TRY_TO_DATE(date_to_convert, date_format)) + 1, 2))
ELSE CONCAT('FY', RIGHT(YEAR(TRY_TO_DATE(date_to_convert, date_format)), 2))