Repository navigation
Skip the engine's own functions in rule 23 - #584
Merged
Merged
Conversation
STRING_SPLIT, OPENJSON, GENERATE_SERIES and every DMV and DMF run as a Table-valued function operator whose Object has no Database and no Schema. A user function always has both. Rule 23's advice (rewrite as an inline function, or stage the rows in a #temp table) is for code the user wrote, so the rule now skips an operator with neither part. The parser records the schema on PlanNode.SchemaName for the check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G625JBNh45iTR1hpT4CxNR
|
Reviewed. This is a small, well-scoped fix and I don't see correctness issues.
Nothing to flag. |
This was referenced Sep 28, 2026
Merged
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.
What does this PR do?
Rule 23 (Table-Valued Function) no longer flags functions that SQL Server supplies. Its message tells the user to rewrite a multi-statement TVF as an inline function or to stage its rows in a #temp table. That advice is for code the user wrote.
The engine's own functions run as the same operator. I captured estimated plans on SQL Server 2025 for eight of them. Each one had an
Objectelement with aTableattribute and noDatabaseorSchema:Object TableSTRING_SPLITSTRING_SPLITOPENJSONOPENJSON_DEFAULTGENERATE_SERIESGENERATE_SERIESsys.dm_exec_requestsSYSREQUESTSsys.dm_exec_sql_textFNGETSQLsys.dm_db_index_physical_statsINDEXANALYSISsys.fn_dblogDBLOGsys.fn_get_audit_fileFN_GET_AUDIT_FILEA user function has both parts, as in the
tvf_plan.sqlplanfixture (Database="[StackOverflow2013]" Schema="[dbo]"). So before this change, rule 23 warned on every query that reads a DMV and on everySTRING_SPLITorOPENJSONcall.The changes:
PlanNodehas a newSchemaNameproperty. The parser sets it from theObjectelement, next toDatabaseName.The question came from #580. That PR turned the
WHILE (SELECT ...)condition ineager_table_spool_plan.sqlplaninto its own statement, and rule 23 then flagged the condition'sINDEXANALYSISoperator. The owner decided that rule 23 must skip such functions.Which component(s) does this affect?
How was this tested?
PlanAnalyzerTests:eager_table_spool_plan.sqlplanfixture still has itsINDEXANALYSISoperator, and rule 23 no longer warns on it.tvf_plan.sqlplantest still finds the user functionGetTopPosts.WarningBaseline.txtlost one line, theINDEXANALYSISwarning. No other finding in the 60 fixture plans changed.Checklist
dotnet test)dotnet test)🤖 Generated with Claude Code
https://claude.ai/code/session_01G625JBNh45iTR1hpT4CxNR