Skip to content

Instantly share code, notes, and snippets.

View JerryNixon's full-sized avatar
🤔
Trying to make a living.

Jerry Nixon JerryNixon

🤔
Trying to make a living.
View GitHub Profile
@JerryNixon
JerryNixon / data_lake_delta_tables.py
Last active November 4, 2021 19:31
Snoop all the delta tables in your data lake
# Databricks notebook source
# COMMAND ----------
%py
def recurse(path: str) -> [str]:
def is_delta_path_valid(path: str) -> bool:
try:
return [] != [x for x in dbutils.fs.ls(path) if x.isDir() and x.name == "_delta_log/"]
@JerryNixon
JerryNixon / CreateExternalTables.py
Created August 31, 2021 21:29
Databricks reusable routine to create External tables
class Data(dict):
__getattr__, __setattr__ = dict.get, dict.__setitem__
tables = [
Data(
path = "abfss://name@acct/path1",
database = "my_db",
table = "table1",
),
Data(
public class Program
{
static void Main()
{
BenchmarkRunner.Run<Harness>();
}
}
public class Harness
{
public class Program
{
static void Main()
{
BenchmarkRunner.Run<Harness>();
}
}
public class Harness
{
WITH tables AS
(
SELECT
schemas.name AS schema_name
, tables.name AS table_name
, CONCAT(schemas.name, '.', tables.name) AS full_name
FROM sys.tables
JOIN sys.schemas
ON tables.schema_id = schemas.schema_id
WHERE tables.type = 'U'
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@JerryNixon
JerryNixon / PoorMansShortestWeightedPath.sql
Last active October 14, 2025 15:43
This is a variant of Dijkstra's algorithm for SQL Graph, written in T-SQL.
/*
This script implements a two-hop variant of Dijkstra’s algorithm using SQL Server graph features.
It creates a graph with 1500 nodes and edges, then finds the shortest two-edge paths
between 5 source and 5 destination nodes. Execution time is measured using a stopwatch.
*/
SET NOCOUNT ON
WHILE (@@TRANCOUNT > 0) ROLLBACK TRANSACTION
BEGIN TRANSACTION
@JerryNixon
JerryNixon / readme.md
Last active December 29, 2025 10:36
A stopwatch for SQL Server

STOPWATCH is used to simply measure queries, especially long, complex ones. This is not a replacement for set statistics time on but it's a handy way to measure query behavior in a way that feels comfortable to C# developers, especially. STOPWATCH uses the system time to calculate elapsed durations.

Note: STOPWATCH uses SQL Server's session_context to persist the start time.

Example usage

EXEC STOPWATCH_START
SELECT * FROM USERS
EXEC STOPWATCH_READ
@JerryNixon
JerryNixon / Assert.sql
Last active May 18, 2022 23:36
An Assert framework for SQL Server
CREATE SCHEMA assert;
GO
/*
assert.Contain
Ensure fragment is inside string.
@fragment: String to search for
@string: String to search in
@msg: (optional) Append custom error message - default: NULL
@JerryNixon
JerryNixon / RandomList.cs
Created January 26, 2021 17:40
Generate a randomized list of integers.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
public class Program
{
public static void Main()
{
var count = 20000;