Skip to content

Conversation

peterbud
Copy link
Contributor

@peterbud peterbud commented Jun 16, 2025

Brief summary of the change made

This PR is adding support for graph tables in TSQL. These use special syntax at table creation and a specific constraint for such tables.

  • Add required keywords
  • Add graph table syntax variation with AS NODE and AS EDGE reusing as much as possible
  • Add related constraints

PS: My first contribution to this repo, happy to take advice on further improvements in this PR.

Are there any other side effects of this change that we should be aware of?

No

Pull Request checklist

  • Please confirm you have completed any of the necessary steps below.

  • Included test cases to demonstrate any code changes, which may be one or more of the following:

    • .yml rule test cases in test/fixtures/rules/std_rule_cases.
    • .sql/.yml parser test cases in test/fixtures/dialects (note YML files can be auto generated with tox -e generate-fixture-yml).
    • Full autofix test cases in test/fixtures/linter/autofix.
    • Other.
  • Added appropriate documentation for the change.

  • Created GitHub issues for any relevant followup/future enhancements if appropriate.

* Add required keywords
* Add graph table syntax variation with AS NODE and AS EDGE reusing as much as possible
* Add related constraints
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

Added support for Microsoft SQL Server's graph table feature in the TSQL dialect, enabling parsing of CREATE TABLE statements with graph-specific syntax and constraints.

  • Added graph table keywords ('CONNECTION', 'EDGE', 'NODE') in src/sqlfluff/dialects/dialect_tsql_keywords.py
  • Implemented ConnectionConstraintGrammar and GraphTableConstraintSegment in src/sqlfluff/dialects/dialect_tsql.py for graph relationships
  • Added CreateTableGraphStatementSegment to support 'AS NODE' and 'AS EDGE' table declarations
  • Created comprehensive test cases in test/fixtures/dialects/tsql/create_table_graph.sql covering various graph table scenarios

4 files reviewed, 1 comment
Edit PR Review Bot Settings | Greptile

Copy link
Contributor

@keraion keraion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, this is a good change. Some of the logic can be simplified, and it might make sense to consolidate the table constraint segments together.

Copy link
Contributor

Coverage Results ✅

Name    Stmts   Miss  Cover   Missing
-------------------------------------
TOTAL   19760      0   100%

249 files skipped due to complete coverage.

Copy link
Contributor

@keraion keraion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. LGTM. Thanks for updating the CreateTableStatementSegment too!

@keraion keraion added this pull request to the merge queue Jun 18, 2025
Merged via the queue into sqlfluff:main with commit 3844292 Jun 18, 2025
28 checks passed
@peterbud peterbud deleted the graph branch June 18, 2025 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants