From fb4d9080a042d40455bcf631ca6a0afaacb19683 Mon Sep 17 00:00:00 2001 From: tobymao Date: Fri, 14 Jun 2024 19:00:46 -0700 Subject: [PATCH] feat(tsql): clustered index closes #3659 --- sqlglot/dialects/tsql.py | 2 ++ tests/dialects/test_tsql.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/sqlglot/dialects/tsql.py b/sqlglot/dialects/tsql.py index 7bf1da418b..7b62dd396a 100644 --- a/sqlglot/dialects/tsql.py +++ b/sqlglot/dialects/tsql.py @@ -450,6 +450,7 @@ class Tokenizer(tokens.Tokenizer): KEYWORDS = { **tokens.Tokenizer.KEYWORDS, + "CLUSTERED INDEX": TokenType.INDEX, "DATETIME2": TokenType.DATETIME, "DATETIMEOFFSET": TokenType.TIMESTAMPTZ, "DECLARE": TokenType.DECLARE, @@ -457,6 +458,7 @@ class Tokenizer(tokens.Tokenizer): "FOR SYSTEM_TIME": TokenType.TIMESTAMP_SNAPSHOT, "IMAGE": TokenType.IMAGE, "MONEY": TokenType.MONEY, + "NONCLUSTERED INDEX": TokenType.INDEX, "NTEXT": TokenType.TEXT, "OPTION": TokenType.OPTION, "OUTPUT": TokenType.RETURNING, diff --git a/tests/dialects/test_tsql.py b/tests/dialects/test_tsql.py index 9240e64278..8f62347b2f 100644 --- a/tests/dialects/test_tsql.py +++ b/tests/dialects/test_tsql.py @@ -8,6 +8,9 @@ class TestTSQL(Validator): dialect = "tsql" def test_tsql(self): + self.validate_identity( + "CREATE CLUSTERED INDEX [IX_OfficeTagDetail_TagDetailID] ON [dbo].[OfficeTagDetail]([TagDetailID] ASC)" + ) self.validate_identity( "CREATE INDEX [x] ON [y]([z] ASC) WITH (allow_page_locks=on) ON X([y])" )