Skip to content

Instantly share code, notes, and snippets.

View camsaul's full-sized avatar
💭
I am Cam

Cam Saul camsaul

💭
I am Cam
View GitHub Profile
@camsaul
camsaul / mbql5.json
Created March 31, 2026 22:01
MBQL 5 JSON Schema (First pass)
{
"$ref" : "#/components/schemas/metabase.lib.schema.query",
"definitions" : {
"metabase.lib.schema.metadata.stage" : {
"description" : "Metadata about the columns returned by a particular stage of a pMBQL query. For example a single-stage native query\n like\n\n {:database 1\n :lib/type :mbql/query\n :stages [{:lib/type :mbql.stage/mbql\n :native \"SELECT id, name FROM VENUES;\"}]}\n\n might have stage metadata like\n\n {:columns [{:name \"id\", :base-type :type/Integer}\n {:name \"name\", :base-type :type/Text}]}\n\n associated with the query's lone stage.\n\n At some point in the near future we will hopefully attach this metadata directly to each stage in a query, so a\n multi-stage query will have `:lib/stage-metadata` for each stage. The main goal is to facilitate things like\n returning lists of visible or filterable columns for a given stage of a query. This is TBD, see #28717 for a WIP\n implementation of this idea.\n\n This is the
@camsaul
camsaul / channel_deps.edn
Created November 10, 2025 23:31
Channel Dependencies
{actions [analytics session request embedding public-sharing],
analytics [],
analyze [analytics session request embedding public-sharing actions warehouses sync],
api [],
api-keys [analytics session request embedding server],
app-db [],
appearance [],
audit-app [analytics session request embedding public-sharing actions search],
auth-provider [app-db],
batch-processing [analytics session request embedding queries view-log],
@camsaul
camsaul / analytics_deps.edn
Created November 10, 2025 23:29
Analytics dependencies
{actions [channel collections queries public-sharing],
analytics [channel],
analyze [channel collections api-keys users enterprise/advanced-permissions warehouses sync],
api [],
api-keys [channel collections],
app-db [],
appearance [],
audit-app [channel collections],
auth-provider [app-db],
batch-processing [channel collections api-keys users],
@camsaul
camsaul / parse_test_output.clj
Last active October 7, 2025 20:11
Parse Test errors and failures from test logs
(ns parse-test-output
(:require
[clojure.string]))
(defn x []
(let [files ["https://productionresultssa12.blob.core.windows.net/actions-results/ff158da9-6207-4ca8-b2ac-bdc5aa49f855/workflow-job-run-991d6487-d703-5cca-92c6-1c67eaf3db9d/logs/job/job-logs.txt?rsct=text%2Fplain&se=2025-10-03T18%3A47%3A21Z&sig=e6iMXbt%2FecC1uhMsSbwk%2BLZO2TpzizqvVxM3fKEfOus%3D&ske=2025-10-04T02%3A42%3A25Z&skoid=ca7593d4-ee42-46cd-af88-8b886a2f84eb&sks=b&skt=2025-10-03T14%3A42%3A25Z&sktid=398a6654-997b-47e9-b12b-9515b896b4de&skv=2025-11-05&sp=r&spr=https&sr=b&st=2025-10-03T18%3A37%3A16Z&sv=2025-11-05"
"/home/cam/x.txt"]]
(into (sorted-set)
(comp (map slurp)
(mapcat clojure.string/split-lines)
@camsaul
camsaul / split_tests.clj
Created August 18, 2025 20:21
Split tests
(defn split-tests [[_deftest test-name & args]]
(into []
(comp (mapcat (fn split* [expr]
(case (first expr)
is (let [[_is assert-expr message] expr]
[(if message
(list 'testing message
(list 'is assert-expr))
(list 'is assert-expr))])
@camsaul
camsaul / preprocess.clj
Created July 25, 2025 20:43
Simple QP debugging
(def ^:dynamic *depth* -1)
(defn- middleware-fn-name [middleware-fn]
(if-let [fn-name (:name (meta middleware-fn))]
(if-let [fn-ns (:ns (meta middleware-fn))]
(symbol (format "%s/%s [%d]" (ns-name fn-ns) fn-name *depth*))
fn-name)
middleware-fn))
(defn- print-query-diff [middleware-fn before after]
@camsaul
camsaul / profile.clj
Last active July 2, 2025 18:04
Map normalization profiling
(ns metabase.lib.schema.profile
(:require
[clojure.pprint]
[clojure.set]
[criterium.core]
[metabase.util :as u]
[metabase.util.malli.registry :as mr]
[metabase.util.memoize :as u.memo]))
(defn normalize-map-no-kebab-case
@camsaul
camsaul / modules.graphviz
Created May 14, 2025 20:22
Backend Modules
digraph {
"actions" -> "analytics"
"actions" -> "api"
"actions" -> "collections"
"actions" -> "driver"
"actions" -> "legacy-mbql"
"actions" -> "lib"
"actions" -> "model-persistence"
"actions" -> "models"
"actions" -> "queries"
@camsaul
camsaul / x.mermaid
Created May 14, 2025 20:04
Module deps
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@camsaul
camsaul / rewrite_defendpoint.clj
Created February 12, 2025 07:01
Rewrite defendpoint
(ns dev.rewrite-defendpoint-1
(:require
[clojure.string :as str]
[flatland.ordered.map :as ordered-map]
[metabase.util.malli :as mu]
[metabase.util.malli.registry :as mr]
[rewrite-clj.node :as n]
[rewrite-clj.parser :as r.parser]
[rewrite-clj.zip :as z]))