microsoft / SqlParser

Provides basic syntax parsing and binding for the TSQL language for many versions and editions of Microsoft SQL Server and Azure SQL Database.
MIT License
8 stars 1 forks source link

Missing syntax support for certain Graph Table queries/keywords #5

Open lamdacomplex opened 2 years ago

lamdacomplex commented 2 years ago

Issue Type: Bug

Start a new query and type out a CREATE TABLE statement for an edge table with a CONNECTION constraint.

For example:

CREATE TABLE [core].[isClass] (
    CONSTRAINT [EC_thing_is_classification] CONNECTION ([core].[thing] TO [core].[classification])
) AS EDGE;

The syntax parser reports the following errors:

"Incorrect syntax near 'CONNECTION'.
"Incorrect syntax near '[core]'.  Expecting '(', or SELECT."

Additionally, writing a valid SELECT query using MATCH & SHORTEST_PATH also causes syntax errors.

For example:

SELECT *
  FROM [core].[thing] [thing]
     , [core].[isClass] FOR PATH [isClass]
     , [core].[classification] FOR PATH [classification]
 WHERE MATCH(SHORTEST_PATH([thing](-([isClass])->[classification])+))

Shows these syntax errors:

"Incorrect syntax near 'PATH'."
"Incorrect syntax near 'SHORTEST_PATH'.  Expecting '(', or SELECT."
"Incorrect syntax near '[thing]'.  Expecting '(', or SELECT."
"Incorrect syntax near '-'.  Expecting '(', or SELECT."
"Incorrect syntax near '[isClass]'.  Expecting '(', or SELECT."

Azure Data Studio version: azuredatastudio 1.34.0 (83a4316cf89cbf961a0f09a72c861379cfd01fa9, 2021-12-15T20:47:33.863Z) OS version: Windows_NT x64 10.0.18363 Restricted Mode: No

System Info |Item|Value| |---|---| |CPUs|AMD Ryzen 7 PRO 4750U with Radeon Graphics (16 x 1697)| |GPU Status|2d_canvas: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|undefined| |Memory (System)|31.33GB (16.02GB free)| |Process Argv|| |Screen Reader|no| |VM|0%|
Extensions (6) Extension|Author (truncated)|Version ---|---|--- admin-pack|Mic|0.0.2 admin-tool-ext-win|Mic|0.0.3 agent|Mic|0.48.0 dacpac|Mic|1.8.0 import|Mic|1.5.0 profiler|Mic|0.11.0
lamdacomplex commented 2 years ago

Sorry, meant to also include a link to the documentation for Edge constraints and SHORTEST_PATH which include examples of valid syntax.

https://docs.microsoft.com/en-us/sql/relational-databases/tables/graph-edge-constraints?view=sql-server-ver15

https://docs.microsoft.com/en-us/sql/relational-databases/graphs/sql-graph-shortest-path?view=sql-server-ver15#examples

alanrenmsft commented 2 years ago

looks like SSMS is also having the issue.

lamdacomplex commented 2 years ago

Ops Clicked the close by accident. Meant to just reply.

I've had mixed results in SSMS. I have a query right now that uses similar queries with the same syntax but no errors are showing. On my work PC I get similar syntax errors but at home I don't. Might simply be a difference in SSMS versions (18.8 vs 18.10).

alanrenmsft commented 2 years ago

@caohai I wanted to get this fixed but didn't get a chance, could you please pick up this one? you can check with @Charles-Gagnon to see whether this is documented.

it actually goes beyond this particular issue, I think in general we need to refresh our syntax library version.

caohai commented 2 years ago

@caohai I wanted to get this fixed but didn't get a chance, could you please pick up this one? you can check with @Charles-Gagnon to see whether this is documented.

it actually goes beyond this particular issue, I think in general we need to refresh our syntax library version.

Sure I can pick this one up. I'll take a look.

Charles-Gagnon commented 2 years ago

For what it's worth - language service stuff was something I'm planning on taking up here for the next work cycle. So I'll be triaging/fixing all these kinds of issues when we get that started. Always happy to have others helping out though 😁

caohai commented 1 year ago

This issue is confirmed to be a bug in SqlParser, I've filed a bug internally and I'll move this issue to backlog for now.