Scope VGI316 to table functions only (fix scalar/aggregate false positives)#10
Merged
Merged
Conversation
VGI316's only remedy — expose a table/relation input so callers pass a subquery `FROM …` — is structurally possible only for a table function. A scalar or aggregate function returns one value per row and cannot take a relation argument; DuckDB macros take scalar expressions, not relations. So flagging scalar/aggregate/macro functions with a nested-array argument was a false positive with no achievable fix (e.g. ortools' scalar max_flow_value). Narrow `targets` to `(TABLE_FUNCTION,)` and iterate `_iter_table_functions` in `check()`. This only ever removes findings, never adds any. Regenerated RULES.md and updated the VGI316 unit test to assert a scalar/aggregate with a matrix arg is not flagged while a table function still is. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
rustyconover
added a commit
that referenced
this pull request
Jul 12, 2026
Scope VGI316 to table functions only (#10): a scalar/aggregate/macro function with a matrix argument can never be rewritten to take a relation input, so flagging it was a false positive. Only removes findings; no worker can regress. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
VGI316 (array-argument-could-be-table) fired on scalar and aggregate functions, but its only suggested remedy — "expose it as a table function that takes a table/relation input, so callers pass a subquery (FROM …)" — is structurally impossible for a scalar/aggregate function. A scalar function returns one value per row and cannot take a relation as an argument. Flagging them was a false positive with no achievable fix.
The motivating case:
ortools.main.max_flow_value(arcs)— a SCALAR function returningBIGINT— was flagged identically to the real table-function solvers.Fix
targetsnarrowed from(SCALAR_FUNCTION, AGGREGATE, MACRO, TABLE_FUNCTION)to(TABLE_FUNCTION,).check()now iterates the existing_iter_table_functions(ctx)helper (used by every other table-function rule in the module) instead ofiter_all_functions().len(array_args) != 1continue) is unchanged.This change only ever removes findings (it narrows
targets), so it cannot introduce a new finding on any worker.Verification against
vgi-ortoolsBefore: 6 VGI316 warnings. After: 5.
max_flow_value(arcs)max_flow(arcs)solve_assignment(cost)solve_jobshop(tasks)solve_knapsack(weights)solve_tsp(distance)The 5 residual findings are genuine table-function cases (whether ortools should reshape/document them is a separate decision) — the deliverable here is that the scalar false positive is gone.
Gates
ruff format/ruff check/mypy/pydoclint/pytest(505 passed) /gen_rules_doc.py --checkall green. RULES.md regenerated; VGI316 unit test updated to assert a scalar/aggregate with a matrix arg is NOT flagged while a table function still IS.🤖 Generated with Claude Code