SqlGlot.Net 0.9.0

dotnet add package SqlGlot.Net --version 0.9.0
                    
NuGet\Install-Package SqlGlot.Net -Version 0.9.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SqlGlot.Net" Version="0.9.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SqlGlot.Net" Version="0.9.0" />
                    
Directory.Packages.props
<PackageReference Include="SqlGlot.Net" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SqlGlot.Net --version 0.9.0
                    
#r "nuget: SqlGlot.Net, 0.9.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SqlGlot.Net@0.9.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SqlGlot.Net&version=0.9.0
                    
Install as a Cake Addin
#tool nuget:?package=SqlGlot.Net&version=0.9.0
                    
Install as a Cake Tool

SqlGlot.Net

A standalone .NET port of sql-glot-rust — a SQL parser, optimizer, and transpiler library.

This project is a pure-managed C# implementation with no native dependencies, suitable for ADO.NET drivers, EF Core providers, AOT-compiled apps, Blazor WebAssembly, Azure Functions, and other .NET hosts.

Status

This is a foundational port that mirrors the Rust crate layout 1:1, so further porting is mechanical. The initial drop covers the end-to-end happy path:

Module Rust LOC .NET status
tokens/ ~2,000 ✅ Lexer ported (literals, operators, identifiers, comments, keywords)
errors/ ~30 ✅ Exception hierarchy
dialects/ ~1,000 ✅ Dialect enum + quoting rules (30 dialects)
ast/types.rs ~2,300 ✅ Statement + Expr subset (SELECT path, full operator set)
parser/sql_parser.rs ~4,000 ✅ Recursive-descent SELECT/FROM/JOIN/WHERE/GROUP BY/HAVING/ORDER BY/LIMIT
generator/sql_generator.rs ~3,300 ✅ Visitor-based emitter with dialect quoting
builder/ ~1,500 ⏳ Fluent builder API (TODO)
optimizer/ ~3,000 ⏳ TODO
executor/, planner/, schema/, diff/ ~4,000 ⏳ TODO

Roundtrips today: SELECT … FROM … [JOIN …] [WHERE …] [GROUP BY …] [HAVING …] [ORDER BY …] [LIMIT n [OFFSET n]] with full expression grammar (arithmetic, comparison, logical, IS NULL, IN, BETWEEN, LIKE, CASE, CAST, function calls, parenthesised sub-expressions, qualified columns).

Layout

sqlglot-net/
├── SqlGlot.Net.sln
├── src/
│   └── SqlGlot.Net/
│       ├── SqlGlot.Net.csproj
│       ├── SqlGlot.cs                  # public Parse / Generate / Transpile API
│       ├── Errors/
│       │   └── SqlGlotException.cs
│       ├── Dialects/
│       │   └── Dialect.cs              # 30-dialect enum + QuoteStyle helpers
│       ├── Tokens/
│       │   ├── TokenType.cs
│       │   ├── Token.cs
│       │   └── Tokenizer.cs
│       ├── Ast/
│       │   ├── Statement.cs            # Statement abstract + sub-records
│       │   ├── Expr.cs                 # Expr abstract + sub-records
│       │   └── Common.cs               # QuoteStyle, BinaryOperator, etc.
│       ├── Parser/
│       │   └── SqlParser.cs
│       └── Generator/
│           └── SqlGenerator.cs
└── tests/
    └── SqlGlot.Net.Tests/
        ├── SqlGlot.Net.Tests.csproj
        ├── TokenizerTests.cs
        ├── ParserTests.cs
        ├── GeneratorTests.cs
        └── RoundtripTests.cs

Quick start

using SqlGlot.Net;
using SqlGlot.Net.Dialects;

// Parse
var ast = SqlGlot.Parse("SELECT a, b FROM t WHERE a > 1", Dialect.Ansi);

// Generate
var sql = SqlGlot.Generate(ast, Dialect.Postgres);
// => SELECT a, b FROM t WHERE a > 1

// Transpile in one call
var tsql = SqlGlot.Transpile(
    "SELECT \"id\" FROM users",
    from: Dialect.Postgres,
    to: Dialect.Tsql);
// => SELECT [id] FROM users

Build & test

dotnet build
dotnet test
dotnet pack src/SqlGlot.Net/SqlGlot.Net.csproj -c Release

Targets net10.0. No third-party runtime dependencies.

Project health

  • CI runs on GitHub Actions for every push and pull request.
  • Community support and contribution guidance live in CONTRIBUTING.md, SECURITY.md, and SUPPORT.md.
  • The package metadata is set up for public NuGet publishing.

Porting strategy

The Rust source is the source of truth. Each .NET type carries an // Rust: <path>:<symbol> comment that points to the originating Rust item so syncing future Rust changes is a line-by-line exercise.

Roadmap order (recommended): expression grammar gaps (window functions, EXTRACT, INTERVAL) → INSERT/UPDATE/DELETE/MERGE → CREATE/ALTER/DROP → builder fluent API → optimizer passes → schema & planner → diff/executor.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.9.0 136 6/9/2026
0.1.0 126 6/9/2026