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 IGNORE NULLS clause

See original GitHub issue
  • SqlPackage or DacFx Version: 160.6266.0-preview
  • .NET Framework (Windows-only) or .NET Core: .NET 6.0 (Core)
  • Environment (local platform and source/target platforms): N/A

Steps to Reproduce:

  1. Create a new C# Console Project
  2. Add latest Nuget package for Microsoft.SqlServer.DacFx (160.6266.0-preview)
  3. Run code below
using Microsoft.SqlServer.TransactSql.ScriptDom;

var parser = new TSql160Parser(true); //sql server 2022 parser
IList<ParseError> errors;

parser.ParseExpression(new StringReader("LAST_VALUE(Measure) OVER()"), out errors);
//no parsing errors

parser.ParseExpression(new StringReader("LAST_VALUE(Measure) IGNORE NULLS OVER()"), out errors);
//parsing error! "Incorrect syntax near IGNORE." This should parse succesfully

Console.ReadLine();

Did this occur in prior versions? If not - which version(s) did it work in? Not applicable because the Sql Server 2022 parser (TSQL 160 didn’t exist in prior versions).

Documentation about the support for IGNORE NULLS / RESPECT NULLS in Sql Server 2022 is here: https://docs.microsoft.com/en-us/sql/t-sql/functions/last-value-transact-sql?view=sql-server-ver16#-ignore-nulls--respect-nulls-

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
clement911commented, Oct 26, 2022

@zijchen I can confirm that parsing of the expression above now works on version 161.6337.0-preview.

However, I find the object model weird. Why is the IgnoreRespectNulls property a list of Identifiers?

public IList<Identifier> IgnoreRespectNulls { get; }

We would expect a proper Fragment class IgnoreRespectNullsClause or maybe a simple a simple enum

Maybe something along the following lines?

public enum IgnoreRespectNulls
{
  NotSpecified,
  IgnoreNulls,
  RespectNulls
}

p.s.: I also tested a long standing bug causing the parser to fail to parse nested IIF calls. I’m pleased to see this appears to be fixed!

0reactions
clement911commented, Nov 17, 2022

I see a new stable version of the package was released yet this is still not fixed

Read more comments on GitHub >

github_iconTop Results From Across the Web

ScriptDom parser for Sql Server 2022 fails to parse LAG/ ...
ScriptDom parser for Sql Server 2022 fails to parse LAG/LEAD with IGNORE NULLS clause #213 ... After #133, the parser can parse IGNORE|RESPECT...
Read more >
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 >
Dan Guzman's Blog | Microsoft SQL Server Technical Articles
Parsing Overview. Scripts are parsed by invoking the Parse method of T-SQL script DOM library TSqlParser class. The parser understands the ...
Read more >
sql - NULL values are excluded. Why?
The answer, as pointed by Martin Smith and Sumo is that it is supposed to exclude NULL, because NULL is not a value....
Read more >
Working with SQL NULL values
This article will show functions and operators for handling SQL NULL values.
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