Use Galaxy’s parameterization syntax, modular CTE structure, and Collections to turn any query into a reusable building block that adapts to new filters, tables, or teams in seconds.
Hard-coded filters and copy-pasted snippets slow teams down and hide logic. Reusable SQL cuts maintenance time, improves trust, and lets Galaxy’s AI Copilot optimize once for every future use.
Declare parameters at the top with an inline comment:
Galaxy renders a date-picker UI, so non-SQL users can run the same query without editing code.
The Galaxy AI Copilot rewrites legacy SQL into the parameterized, CTE-first style. It also explains each CTE in plain English so future contributors know exactly what to reuse.
dim_users
) instead of re-writing CASE logic.WITH base AS (...)
plus , filtered AS (...)
pattern to expose hook points for new filters.-- @param customer_id::int
-- @param as_of::date = CURRENT_DATE
WITH
base AS (
SELECT *
FROM fact_events fe
WHERE fe.customer_id = {{customer_id}}
),
daily AS (
SELECT DATE_TRUNC('day', occurred_at) AS day, COUNT(*) AS events
FROM base
WHERE occurred_at <= {{as_of}}
GROUP BY 1
)
SELECT day, events FROM daily ORDER BY day;
Save and endorse this template in a Galaxy Collection; teammates can now run it by supplying only customer_id
.
Start refactoring your highest-traffic queries with these conventions. Then let Galaxy’s versioning, permissions, and AI complete the loop-so your SQL stays flexible well into 2025 and beyond.
Galaxy SQL conventions; parameterized queries in Galaxy; Galaxy query templates; reusable SQL patterns with Galaxy; SQL best practices for Galaxy
Check out the hottest SQL, data engineer, and data roles at the fastest growing startups.
Check outCheck out our resources for beginners with practice exercises and more
Check outCheck out a curated list of the most common errors we see teams make!
Check out