You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 48e4132
Browse filesBrowse the repository at this point in the historyBrowse files
fix(rules): report custom rule node findings at model file positions (#1546)
* feat(rules): give syntax tree nodes names, literal values and source extents
Rules can read a node's name, quoting and qualifier, a literal's value and
type, and where a node ends (end_line, end_column and a character span into
the document source). A relation marker reads as the call it stands for, and
offsets map back through marker names and Snowflake TABLE( ) wrappers to the
text as written. Nodes the parser records no span for have no end.
* docs(rules): report tree-reading findings at the model, not the node
ctx.finding(node=...) takes a node's query-relative position, so the docs
example and the DuckShop rule report at the model and quote the node's
authored text in the message instead.
* chore(fensu): record the source map's start and end mapping as an intentional mirror
* style: format the DuckShop quoted alias rule tests
* fix(rules): report custom rule findings at a node's place in the model file
ctx.finding(subject=model, node=...) took the node's line and column in the
model's expanded query and reported them against the model file, so a
multi-line MODEL header or a multi-line macro expansion moved the finding.
The expanded SQL document now carries where the query sits in the file, read
the way built-in model rules map positions, and the finding maps the node
through it; a node inside macro output points at the macro call. The query
place travels in the custom host payload and in the replayed sql.for_model
fact, so cached findings follow it.
* fix(rules): place a document's node findings in one pass
Each node finding rebuilt the model query's character and line tables, so
reporting every column of a wide model took time proportional to findings
times model size. A document now maps all its syntax tree node starts into
the model file once, on the first node finding, and later findings look
their node up. A node whose line or column is not an integer gets no file
position again and falls back to its own line and column.
* perf(rules): keep the custom-rule query place to a byte range and expansion passes
The place of a model's expanded query repeated the authored query text in
every model's custom-rule payload, about a sixth of the payload on a dense
3,000-model project. It now names the query by its byte range in the model
file, which the rule's SQL document already holds, and offsets are derived
only when a rule reports a node.
0 commit comments