ScriptDom parser for Sql Server 2022 fails to parse LAG/LEAD with IGNORE NULLS clause
See original GitHub issue- DacFx Version: 161.6374.0 (Nuget)
- .NET 7
- Windows 11
Steps to Reproduce:
After https://github.com/microsoft/DacFx/issues/133, the parser can parse IGNORE|RESPECT NULLS for FIRST_VALUE/LAST_VALUE but it still doesn’t parse for LAG/LEAD
using Microsoft.SqlServer.TransactSql.ScriptDom;
var parser = new TSql160Parser(true); //sql server 2022 parser
IList<ParseError> errors;
parser.ParseExpression(new StringReader("FIRST_VALUE(col) IGNORE NULLS OVER()"), out errors);
parser.ParseExpression(new StringReader("LAST_VALUE(col) IGNORE NULLS OVER()"), out errors);
//no parsing errors
parser.ParseExpression(new StringReader("LAG(col) IGNORE NULLS OVER()"), out errors);
parser.ParseExpression(new StringReader("LEAD(col) IGNORE NULLS OVER()"), out errors);
//parsing error! "Incorrect syntax near IGNORE." This should parse succesfully
Console.ReadLine();
(p.s.: Please open source the ScriptDom lib. It is full of bugs).
Issue Analytics
- State:
- Created 7 months ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Microsoft.SqlServer.TransactSql.ScriptDom.TSqlParser ...
SqlServer.TransactSql.ScriptDom heavily to process some SQL scripts. Our understanding is that the parser is supposed to be full fidelity.
Read more >How to make LAG() ignore NULLS in SQL Server?
SQL Server 2022 added support for the ignore nulls option in window functions: yay! We can just use last_value() : select t.
Read more >Microsoft SQL Server Script DOM | Dan Guzman's Blog
Scripts are parsed by invoking the Parse method of T-SQL script DOM library TSqlParser class. The parser understands the complex T-SQL ...
Read more >Working with SQL NULL values
This article will show functions and operators for handling SQL NULL values.
Read more >Stairway to ScriptDOM Level 2 - Parsing, Tokens, and the ...
In this level of the Stairway to ScriptDOM, we examine the way the tool parses scripts and creates tokens from the text.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Completed back in https://www.nuget.org/packages/Microsoft.SqlServer.TransactSql.ScriptDom/161.8812.0
Thank you @dzsquared 😀