Skip to content

fduseless/sqlglot-ts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@fduseless/sqlglot-ts

TypeScript port of sqlglot, the SQL parser, transpiler, optimizer, and engine created by @tobymao.

Credit

All core ideas, architecture, and implementation logic belong to the original sqlglot project:

This package is only a TypeScript translation of that work. We did not design the SQL engine, parser architecture, optimizer rules, or dialect behavior. The goal of this repository is to port the Python implementation as faithfully as possible.

What This Package Is

@fduseless/sqlglot-ts provides a TypeScript build of sqlglot for JavaScript and TypeScript environments.

It includes:

  • SQL parsing
  • SQL generation
  • Cross-dialect transpilation
  • Expression tree utilities
  • Optimizer and type annotation utilities
  • A growing set of dialect-specific parser and generator behaviors

Install

npm install @fduseless/sqlglot-ts

Quick Start

import { parseOne, transpile } from '@fduseless/sqlglot-ts';

const expression = parseOne('SELECT a + 1 FROM x');

console.log(expression.sql());
// SELECT a + 1 FROM x

console.log(expression.sql('spark'));
// SELECT a + 1 FROM x

console.log(
  transpile('SELECT CAST(a AS SIGNED) FROM t', {
    read: 'mysql',
    write: 'postgres',
  })[0],
);
// SELECT CAST(a AS BIGINT) FROM t

API Shape

The public API is intended to closely follow the Python project where practical in TypeScript. Common entry points include:

  • parse
  • parseOne
  • transpile
  • expression classes from src/expressions
  • optimizer utilities such as annotateTypes

Project Status

This project is an active port, not an independent reimplementation. Behavior is continuously aligned against upstream Python sqlglot.

That means:

  • some areas may still lag upstream
  • names and behavior are chosen for parity first
  • changes are often driven by upstream diff syncing rather than local redesign

Upstream First

If you need the canonical implementation, complete feature coverage, or want to understand the original design decisions, use or read the upstream Python project first:

https://github.com/tobymao/sqlglot

License

This repository is published under the MIT license. Please also review the license and notices of the upstream sqlglot project.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors