Repository navigation
feat: ANY macro arguments, macro return types in contract checks and per-kind macro folder counts - #1240
Merged
Conversation
…n declaration layout rules
…ing SQL macro calls
…dentical inferred type
…m their returns type
…ering SQL macro branches
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Converting Python macros to SQL macros showed three gaps: an argument the body only casts had to be
VARIANTto take numbers and strings; a call declaredreturns VARCHARstill needed an outerCASTto satisfy aVARCHARcontract column (K003,SQBRCONTRACT105); and the declaration layout Rules counted a macro folder'spython/andsql/subtrees as one container, so6 + 7files read as 13.Changes
ANYargument type: any scalar expression, no type check. Lists and relations fail withP017;ANY CONST,LIST ANYandSET ANYfail withP015.DEFAULTis allowed. A runtimeANYwhere SQL needs a literal fails withP023.returnstype when the inferred type is unknown or exactly that type. Any other known type stands andK002reports it. The type flows to contracts,SQBRCONTRACT105and downstream models. Compiled SQL is unchanged; the cache key includes these types, and cache hits skip the retyping.SQBRDECLARATION302–306treatpython/andsql/under a macro folder as separate containers.306tells SQL macro files to move into a subfolder ofsql/, keeping their names.ANYversusVARIANT, call types fromreturns, per-kind folder counts.Verification
ANYparsing, declared output types, branches and names, cache hits keeping the type, kind-folder layout.ANYbuilds and misuse;returnssatisfying contracts with noK003/SQBRCONTRACT105in the main query, CTEs, joins andUNION ALLbranches, cold and warm; TIME, array, wider text, decimal and timestamptz bodies still reportK002; a conflicting union sibling still reports; unusual outer queries compile; layout Rules.make test,make check-ci,make compiler-differential(no golden changes) and the hygiene scan pass.