1from__future__importannotations 2 3 4fromsqlglot.dialects.dialectimportNormalizationStrategy 5fromsqlglot.dialects.tsqlimportTSQL 6fromsqlglot.generators.fabricimportFabricGenerator 7fromsqlglot.parsers.fabricimportFabricParser 8fromsqlglot.tokensimportTokenType 91011classFabric(TSQL):12"""13 Microsoft Fabric Data Warehouse dialect that inherits from T-SQL.1415 Microsoft Fabric is a cloud-based analytics platform that provides a unified16 data warehouse experience. While it shares much of T-SQL's syntax, it has17 specific differences and limitations that this dialect addresses.1819 Key differences from T-SQL:20 - Case-sensitive identifiers (unlike T-SQL which is case-insensitive)21 - Limited data type support with mappings to supported alternatives22 - Temporal types (DATETIME2, DATETIMEOFFSET, TIME) limited to 6 digits precision23 - Certain legacy types (MONEY, SMALLMONEY, etc.) are not supported24 - Unicode types (NCHAR, NVARCHAR) are mapped to non-unicode equivalents2526 References:27 - Data Types: https://learn.microsoft.com/en-us/fabric/data-warehouse/data-types28 - T-SQL Surface Area: https://learn.microsoft.com/en-us/fabric/data-warehouse/tsql-surface-area29 """3031# Fabric is case-sensitive unlike T-SQL which is case-insensitive32NORMALIZATION_STRATEGY=NormalizationStrategy.CASE_SENSITIVE3334classTokenizer(TSQL.Tokenizer):35# Override T-SQL tokenizer to handle TIMESTAMP differently36# In T-SQL, TIMESTAMP is a synonym for ROWVERSION, but in Fabric we want it to be a datetime type37# Also add UTINYINT keyword mapping since T-SQL doesn't have it38KEYWORDS={39**TSQL.Tokenizer.KEYWORDS,40"TIMESTAMP":TokenType.TIMESTAMP,41"UTINYINT":TokenType.UTINYINT,42}4344Parser=FabricParser4546Generator=FabricGenerator
12classFabric(TSQL):13"""14 Microsoft Fabric Data Warehouse dialect that inherits from T-SQL.1516 Microsoft Fabric is a cloud-based analytics platform that provides a unified17 data warehouse experience. While it shares much of T-SQL's syntax, it has18 specific differences and limitations that this dialect addresses.1920 Key differences from T-SQL:21 - Case-sensitive identifiers (unlike T-SQL which is case-insensitive)22 - Limited data type support with mappings to supported alternatives23 - Temporal types (DATETIME2, DATETIMEOFFSET, TIME) limited to 6 digits precision24 - Certain legacy types (MONEY, SMALLMONEY, etc.) are not supported25 - Unicode types (NCHAR, NVARCHAR) are mapped to non-unicode equivalents2627 References:28 - Data Types: https://learn.microsoft.com/en-us/fabric/data-warehouse/data-types29 - T-SQL Surface Area: https://learn.microsoft.com/en-us/fabric/data-warehouse/tsql-surface-area30 """3132# Fabric is case-sensitive unlike T-SQL which is case-insensitive33NORMALIZATION_STRATEGY=NormalizationStrategy.CASE_SENSITIVE3435classTokenizer(TSQL.Tokenizer):36# Override T-SQL tokenizer to handle TIMESTAMP differently37# In T-SQL, TIMESTAMP is a synonym for ROWVERSION, but in Fabric we want it to be a datetime type38# Also add UTINYINT keyword mapping since T-SQL doesn't have it39KEYWORDS={40**TSQL.Tokenizer.KEYWORDS,41"TIMESTAMP":TokenType.TIMESTAMP,42"UTINYINT":TokenType.UTINYINT,43}4445Parser=FabricParser4647Generator=FabricGenerator
Microsoft Fabric Data Warehouse dialect that inherits from T-SQL.
Microsoft Fabric is a cloud-based analytics platform that provides a unified
data warehouse experience. While it shares much of T-SQL's syntax, it has
specific differences and limitations that this dialect addresses.
Key differences from T-SQL:
Case-sensitive identifiers (unlike T-SQL which is case-insensitive)
Limited data type support with mappings to supported alternatives
Temporal types (DATETIME2, DATETIMEOFFSET, TIME) limited to 6 digits precision
Certain legacy types (MONEY, SMALLMONEY, etc.) are not supported
Unicode types (NCHAR, NVARCHAR) are mapped to non-unicode equivalents
35classTokenizer(TSQL.Tokenizer):36# Override T-SQL tokenizer to handle TIMESTAMP differently37# In T-SQL, TIMESTAMP is a synonym for ROWVERSION, but in Fabric we want it to be a datetime type38# Also add UTINYINT keyword mapping since T-SQL doesn't have it39KEYWORDS={40**TSQL.Tokenizer.KEYWORDS,41"TIMESTAMP":TokenType.TIMESTAMP,42"UTINYINT":TokenType.UTINYINT,43}