question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 7 months ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

0reactions
clement911commented, Jun 15, 2023

Thank you @dzsquared 😀

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found