Repository navigation
fix(#11944): SQL functions declare the arity they enforce - #12461
Conversation
About 46 SQL functions inherited the 0..MAX default arity and counted their arguments inside execute(), so the parse-time gate let a wrong count through and the caller got an IllegalArgumentException, InvalidArgumentException or CommandSQLParsingException instead of the uniform "expects N arguments" CommandSemanticException. Each now declares getMinArgs()/getMaxArgs() and calls checkArity(). ensureLabelTypes declares 1..1, and vector.dequantizeInt8 overrides checkArity so every wrong count reads "expects 1 or 3 arguments". A census in SqlParserRobustnessTest reports any function that rejects a count inside its declared range. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Walkthrough
Merge Risk:
|
|
This pull request is merged. |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
🟢 Coverage 100.00% diff coverage · -4.56% coverage variation
Metric Results Coverage variation ✅ -4.56% coverage variation Diff coverage ✅ 100.00% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (b65c0f8) 290562 256623 88.32% Head commit (60ff333) 326262 (+35700) 273267 (+16644) 83.76% (-4.56%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#12461) 170 170 100.00% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
Triage: Looks good. This PR gives about 54 SQL functions declared What I checked in the diff:
Minor, non-blocking points:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #12461 +/- ##
============================================
- Coverage 80.38% 80.07% -0.32%
- Complexity 0 198 +198
============================================
Files 2545 2578 +33
Lines 290562 292654 +2092
Branches 64129 64474 +345
============================================
+ Hits 233576 234332 +756
- Misses 33978 35316 +1338
+ Partials 23008 23006 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Closes #11944.
About 46 SQL functions inherited the default arity of
SQLFunctionAbstract(0..MAX) and then counted their arguments insideexecute(). The parse-time gate (FunctionCall->checkArity) therefore let a wrong count through, and the caller got anIllegalArgumentException, anInvalidArgumentExceptionor aCommandSQLParsingException(getSyntax())instead of the uniformCommandSemanticException"expects N arguments" from #11589. Each affected function now declaresgetMinArgs()/getMaxArgs()and callscheckArity(params)instead of its own count check, and a census inSqlParserRobustnessTestreports any function that rejects a count inside its declared range, whatever exception it throws.Behavior change (release note): some of these functions used to ignore extra arguments without saying so. They now reject them with
CommandSemanticException("expects N arguments but got M"), for exampleduration(5, 'hour', 3).Test plan
SqlParserRobustnessTest$RegistryFunctionArity:issue11944FunctionsDeclareTheArityTheyEnforce(54 functions, min-1 and max+1 through SQL)dequantizeInt8RejectsTwoArgumentsAsAnArityError(2 args, and 0 / 4 args read "1 or 3", never "1-3")ensureLabelTypesDeclaresTheOneArgumentItReads(0 and 2 args are arity errors, an empty list stays a value error)countsInsideTheDeclaredRangeAreNeverRejectedForTheirCount(census over every registered function)theArityShapeDetectorRecognisesTheShapesTheIssueNamed(control for the census)SQLFunctionDurationTest,Issue12362SqlDurationIsoFormTest,SQLFunctionTimeBucketTest,SQLFunctionPhase3Testmvn -o -pl engine -am test -Dtest='com/arcadedb/function/sql/**/*Test,SqlParserRobustnessTest,SQLFunctionTimeBucketTest,*Vector*Test,*Geo*Test,*BellmanFord*Test,*Function*Test' -DexcludedGroups=benchmark,slow: 296 classes, 4729 tests, 0 failures, 0 errorsSqlParserRobustnessTest35/35,TypeCreationTest(ensureLabelTypes callers) 113/113, vector function tests greenCoverage
issue11944FunctionsDeclareTheArityTheyEnforcetable (geo, graph, math, time, timeseries, vector)vector.add/vector.subtract(counted throughSQLFunctionVectorAbstract.validateParameterCount, now removed)vector.dequantizeInt8(1 or 3, never 2)checkArity, one message for every wrong countensureLabelTypes(0..MAX with a hidden non-empty check, extras ignored)BoolAnd,BoolOr,Average,Sysdate,Date,Set,List,UnionAll,Map)map()'s even-count check is a value check)Known gaps
sleep,load,cypher.runand two-dot names (side effects or slow). A hand-written count check above min+3 in one of those would not be caught.Scope changes
vector.add/vector.subtracthelper spelling, thevector.avg/max/min/sum/normalizeScores/fuseparams.length == 0checks, and thevector.dequantizeInt8gap.ensureLabelTypesand thevector.dequantizeInt8gate wording.Adversarial pass
ensureLabelTypesdeclares 0..MAX, refuses zero arguments insideexecute()with a message the census cannot classify, and ignores extrascheckArity; the empty-list check stays as a value check. TestensureLabelTypesDeclaresTheOneArgumentItReadsvector.dequantizeInt8told a 0- or 4-argument call "1-3 arguments", which includes the refused 2checkArity, so the gate andexecute()both say "expects 1 or 3 arguments". Asserted indequantizeInt8RejectsTwoArgumentsAsAnArityError🤖 Generated with Claude Code
Review cycles
60ff3334d0(LGTM): classify-pr verdict LGTM on 60ff333; there are no reviews or inline comments on the head, and the three minor non-blocking notes need no code change.Deferred items
duration(5, 'hour', 3)and thevector.avg/max/min/sum/normalizeScoresfamily. The PR body flags it as a release note, so please carry it into the release notes.durationand the syntax string in the vector functions. If the uniform "expects N arguments" message is not enough, consider a short hint, but this is optional.sleep,loadorcypher.run, and names with two dots. The PR body already lists these as known gaps.Final state:
clean-approvalMerge is the developer's responsibility: this workflow does not merge PRs.
Summary by CodeRabbit