From 18154ea4d286304c15133a06b3b3c76605d9a3cb Mon Sep 17 00:00:00 2001
From: Kevin Longe <273747162+kvlonge@users.noreply.github.com>
Date: Mon, 30 Nov 2026 12:35:04 +0000
Subject: [PATCH] Point the SQLBuild rule example at its column
The custom rule now reports the column of __source( as well as its line,
so the caret in the compile error sits under it. The model's join line is
shorter, so the error fits on one line on desktop while still showing the
@enum.
---
index.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/index.html b/index.html
index e2e6c3a..a811246 100644
--- a/index.html
+++ b/index.html
@@ -102,7 +102,7 @@
# rules/layers.pyfrom sqlbuild.rules import Finding, Model, RuleContext, rule @rule( code="XSQBRARCH001", message="Marts must read sources through staging", remediation="Reference a staging model with __ref() instead.",)def marts_use_staging(*, model: Model, ctx: RuleContext) -> list[Finding]: layer = ctx.project.tree.relative_parts(path=model.path, under="sql/models")[0] sql = ctx.sql.for_model(model).authored.source if layer != "marts" or "__source(" not in sql: return [] line = sql[: sql.index("__source(")].count("\n") + 1 return [ctx.finding(subject=model, line=line)] sqb compile --select daily_revenue…error[XSQBRARCH001]: Marts must read sources through staging --> sql/models/marts/daily_revenue.sql:24:1 | 24 | INNER JOIN __source("raw__payments") p ON o.order_id = p.order_id AND p.status = @enum("payment_status").SUCCESS | ^ = help: Reference a staging model with __ref() instead. ✗ Project compiled 1 model, 0 seeds, 0 functions, 1 error, 0 warnings
Docs →
+# rules/layers.pyfrom sqlbuild.rules import Finding, Model, RuleContext, rule @rule( code="XSQBRARCH001", message="Marts must read sources through staging", remediation="Reference a staging model with __ref() instead.",)def marts_use_staging(*, model: Model, ctx: RuleContext) -> list[Finding]: layer = ctx.project.tree.relative_parts(path=model.path, under="sql/models")[0] sql = ctx.sql.for_model(model).authored.source if layer != "marts" or "__source(" not in sql: return [] at = sql.index("__source(") line = sql[:at].count("\n") + 1 column = at - sql.rfind("\n", 0, at) return [ctx.finding(subject=model, line=line, column=column)] sqb compile --select daily_revenue…error[XSQBRARCH001]: Marts must read sources through staging --> sql/models/marts/daily_revenue.sql:24:6 | 24 | JOIN __source("raw__payments") p ON p.status = @enum("payment_status").SUCCESS | ^ = help: Reference a staging model with __ref() instead. ✗ Project compiled 1 model, 0 seeds, 0 functions, 1 error, 0 warnings
Docs →