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 = ctxDocs → +.project sql = ctx.tree .relative_parts( path=model .path, under="sql/models")[0] .sql if layer != "marts" or "__source(" not in sql: return [] line = sql[: sql.for_model( model) .authored .source .index("__source(")] return [ctx.count("\n") + 1 .finding( sqb compile --select daily_revenue…error[XSQBRARCH001]: Marts must read sources through staging --> sql/subject=model, line=line)] models/ | 24 | INNER JOIN __source("raw__payments") p ON o.order_id = p.order_id AND p.status = @enum("payment_status")marts/ daily_revenue .sql:24:1 .SUCCESS | ^ = help: Reference a staging model with __ref() instead. ✗ Project compiled 1 model, 0 seeds, 0 functions, 1 error, 0 warnings
# 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 = ctxDocs →.project sql = ctx.tree .relative_parts( path=model .path, under="sql/models")[0] .sql if layer != "marts" or "__source(" not in sql: return [] at = sql.for_model( model) .authored .source .index("__source(") line = sql[:at].count("\n") + 1 column = at - sql.rfind("\n", 0, at) return [ctx.finding( sqb compile --select daily_revenue…error[XSQBRARCH001]: Marts must read sources through staging --> sql/subject=model, line=line, column=column)] models/ | 24 | JOIN __source("raw__payments") p ON p.status = @enum("payment_status")marts/ daily_revenue .sql:24:6 .SUCCESS | ^ = help: Reference a staging model with __ref() instead. ✗ Project compiled 1 model, 0 seeds, 0 functions, 1 error, 0 warnings