You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I searched the issues and found no similar issues.
What Happened
When parsing T-SQL code like:
MERGE INTO dbo.target USING ( SELECT 1 AS i ) AS source ON source.i = target.i WHEN MATCHED THEN UPDATE SET target.i = source.i;
I'm getting parsing error:
L: 1 | P: 2 | PRS | Line 1, Position 2: Found unparsable section: 'MERGE | INTO dbo.target USING \n\t(\tSELECT 1...'
If I add alias to target table, everything is good:
MERGE INTO dbo.target t USING ( SELECT 1 AS i ) AS source ON source.i = target.i WHEN MATCHED THEN UPDATE SET target.i = source.i;
T-SQL dialect supports both options, and I see that in the SQL Fluff code it's configured correctly as well ("Ref("AliasExpressionSegment", optional=True)") in dialect_tsql.py, MergeStatementSegment class.
However, looks like this "optional" value is being ignored in this particular case. If I just delete this "Ref" line - it parses the code well.
Expected Behaviour
No parsing error for this MERGE statement
Observed Behaviour
`L: 1 | P: 2 | PRS | Line 1, Position 2: Found unparsable section: 'MERGE
| INTO dbo.target USING \n\t(\tSELECT 1...'
How to reproduce
run sqlfluff parse --dialect tsql 'script_for_sqlfluff.sql'
script_for_sqlfluff.sql:
MERGE INTO dbo.target USING ( SELECT 1 AS i ) AS source ON source.i = target.i WHEN MATCHED THEN UPDATE SET target.i = source.i;
Dialect
T-SQL
Version
Python 3.11.9, SQL Fluff 3.0.7
Configuration
default config, no extra files
Are you willing to work on and submit a PR to address the issue?
Search before asking
What Happened
When parsing T-SQL code like:
MERGE INTO dbo.target USING ( SELECT 1 AS i ) AS source ON source.i = target.i WHEN MATCHED THEN UPDATE SET target.i = source.i;
I'm getting parsing error:
L: 1 | P: 2 | PRS | Line 1, Position 2: Found unparsable section: 'MERGE | INTO dbo.target USING \n\t(\tSELECT 1...'
If I add alias to target table, everything is good:
MERGE INTO dbo.target t USING ( SELECT 1 AS i ) AS source ON source.i = target.i WHEN MATCHED THEN UPDATE SET target.i = source.i;
T-SQL dialect supports both options, and I see that in the SQL Fluff code it's configured correctly as well ("Ref("AliasExpressionSegment", optional=True)") in dialect_tsql.py, MergeStatementSegment class.
However, looks like this "optional" value is being ignored in this particular case. If I just delete this "Ref" line - it parses the code well.
Expected Behaviour
No parsing error for this MERGE statement
Observed Behaviour
`L: 1 | P: 2 | PRS | Line 1, Position 2: Found unparsable section: 'MERGE
| INTO dbo.target USING \n\t(\tSELECT 1...'
How to reproduce
run
sqlfluff parse --dialect tsql 'script_for_sqlfluff.sql'
script_for_sqlfluff.sql:
MERGE INTO dbo.target USING ( SELECT 1 AS i ) AS source ON source.i = target.i WHEN MATCHED THEN UPDATE SET target.i = source.i;
Dialect
T-SQL
Version
Python 3.11.9, SQL Fluff 3.0.7
Configuration
default config, no extra files
Are you willing to work on and submit a PR to address the issue?
Code of Conduct
The text was updated successfully, but these errors were encountered: