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 2357ce2
Browse filesBrowse the repository at this point in the historyBrowse files
fix: lint SQL macro bodies as compiled and pass SQL macro expansions to Python macros intact (#1236)
* fix: lint SQL macro bodies as compiled and pass SQL macro expansions to Python macros intact
Linting a SQL macro file read a parameter followed by words and a
parenthesis, such as `@value IS NULL OR TRIM(@value) = ''`, as an
unprefixed macro call (L005), and a body opening with two parentheses
reached the native parser as a statement it rejected (rules-unevaluated).
- One rule decides an unprefixed call everywhere: `@name(` with the
parenthesis right after the name. The Python macro call scanner, the
SQL macro lexer, parameter references and the bare-call check share
it, so `@name IS NULL OR f(x)` in model SQL is no longer P014 either.
`@const`, `@enum` and `@param` stay declarations with or without a
space before their parenthesis.
- Lint replaces a SQL macro body's parameters by sentinels with the
compiler's own parameter scan, lints an expression body as the
`SELECT` the compiler parses it as, and a CTE-list body with its
ceremonial `SELECT 1` and its CTEs counted as used by the caller.
Findings in the generated frame are dropped.
- A SQL macro expansion passed to a Python macro is spliced as a
string literal with `"` written as `\x22`, which the call scanner
and the argument parser read the same way, so quotes, backslashes,
line breaks and comments reach the macro unchanged.
- An expansion ending in a line comment gets a line break only when
text would follow it on the same line, so the caller's text stays code
and calls already last on their line compile unchanged.
- A macro call the scan cannot read is a MacroArgumentError naming the
call, file, line and column instead of a location-less P001.
- Rules on a caller skip comments a SQL macro expansion generated; the
macro file is where they are judged, and compiled SQL keeps them.
Comments from Python macro output are judged as before.
* fix: build authored lint lookups after the lint batch so SQL macro comment blanking adds no peak memory
0 commit comments