@hdnax/sqlingo.js 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +26 -40
- package/README.npm.md +26 -40
- package/README.repo.md +32 -11
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +33 -4
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
# sqlingo.js
|
|
2
2
|
|
|
3
|
-
](https://www.npmjs.com/package/@hdnax/sqlingo.js)
|
|
4
|
+
[](https://github.com/huydo862003/sqlingo.js/blob/master/LICENSE)
|
|
5
|
+
[](https://bundlephobia.com/package/@hdnax/sqlingo.js)
|
|
6
|
+

|
|
7
7
|
|
|
8
|
-
A JavaScript port of [SQLGlot](https://github.com/tobymao/sqlglot)
|
|
8
|
+
A JavaScript/TypeScript port of [SQLGlot](https://github.com/tobymao/sqlglot), which is a comprehensive SQL parser, transpiler, optimizer, and engine.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
This package allows you to parse, transpile, optimize, and execute SQL across **33+ dialects** in JavaScript, with no other setup.
|
|
11
|
+
|
|
12
|
+
Supports TypeScript & CJS/ESM. Works in Node.js and the browser.
|
|
13
|
+
|
|
14
|
+
- [GitHub](https://github.com/huydo862003/sqlingo.js)
|
|
15
|
+
- [Issues](https://github.com/huydo862003/sqlingo.js/issues)
|
|
16
|
+
- [Changelog](https://github.com/huydo862003/sqlingo.js/blob/master/CHANGELOG.md)
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- 33+ SQL dialects: Postgres, MySQL, BigQuery, Snowflake, DuckDB, ClickHouse, Redshift, Athena, Spark, and many more
|
|
21
|
+
- Full SQLGlot feature set: parsing, transpilation, optimization, column lineage, SQL diffing, and execution
|
|
22
|
+
- Pure JavaScript: no need for WASM or anything.
|
|
23
|
+
- TypeScript-first: full type definitions included
|
|
11
24
|
|
|
12
25
|
## Installation
|
|
13
26
|
|
|
@@ -118,41 +131,14 @@ Based on [SQLGlot](https://github.com/tobymao/sqlglot) by Toby Mao (MIT). See [C
|
|
|
118
131
|
|
|
119
132
|
## Copyright Notice
|
|
120
133
|
|
|
121
|
-
|
|
122
|
-
This project incorporates code from the following sources:
|
|
123
|
-
|
|
124
|
-
===============================================================================
|
|
134
|
+
Check [License](./LICENSE).
|
|
125
135
|
|
|
126
|
-
|
|
127
|
-
Copyright (c) 2026 Huy DNA
|
|
128
|
-
Licensed under the MIT License
|
|
136
|
+
## CDN Usage
|
|
129
137
|
|
|
130
|
-
|
|
138
|
+
Use sqlingo.js directly in the browser via CDN:
|
|
131
139
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
137
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
138
|
-
in the Software without restriction, including without limitation the rights
|
|
139
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
140
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
141
|
-
furnished to do so, subject to the following conditions:
|
|
142
|
-
|
|
143
|
-
The above copyright notice and this permission notice shall be included in all
|
|
144
|
-
copies or substantial portions of the Software.
|
|
145
|
-
|
|
146
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
147
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
148
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
149
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
150
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
151
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
152
|
-
SOFTWARE.
|
|
140
|
+
```html
|
|
141
|
+
<script type="module">
|
|
142
|
+
import { transpile } from "https://esm.sh/@hdnax/sqlingo.js";
|
|
143
|
+
</script>
|
|
153
144
|
```
|
|
154
|
-
|
|
155
|
-
## Links
|
|
156
|
-
|
|
157
|
-
- [GitHub](https://github.com/huydo862003/sqlingo.js)
|
|
158
|
-
- [Issues](https://github.com/huydo862003/sqlingo.js/issues)
|
package/README.npm.md
CHANGED
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
# sqlingo.js
|
|
2
2
|
|
|
3
|
-
](https://www.npmjs.com/package/@hdnax/sqlingo.js)
|
|
4
|
+
[](https://github.com/huydo862003/sqlingo.js/blob/master/LICENSE)
|
|
5
|
+
[](https://bundlephobia.com/package/@hdnax/sqlingo.js)
|
|
6
|
+

|
|
7
7
|
|
|
8
|
-
A JavaScript port of [SQLGlot](https://github.com/tobymao/sqlglot)
|
|
8
|
+
A JavaScript/TypeScript port of [SQLGlot](https://github.com/tobymao/sqlglot), which is a comprehensive SQL parser, transpiler, optimizer, and engine.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
This package allows you to parse, transpile, optimize, and execute SQL across **33+ dialects** in JavaScript, with no other setup.
|
|
11
|
+
|
|
12
|
+
Supports TypeScript & CJS/ESM. Works in Node.js and the browser.
|
|
13
|
+
|
|
14
|
+
- [GitHub](https://github.com/huydo862003/sqlingo.js)
|
|
15
|
+
- [Issues](https://github.com/huydo862003/sqlingo.js/issues)
|
|
16
|
+
- [Changelog](https://github.com/huydo862003/sqlingo.js/blob/master/CHANGELOG.md)
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- 33+ SQL dialects: Postgres, MySQL, BigQuery, Snowflake, DuckDB, ClickHouse, Redshift, Athena, Spark, and many more
|
|
21
|
+
- Full SQLGlot feature set: parsing, transpilation, optimization, column lineage, SQL diffing, and execution
|
|
22
|
+
- Pure JavaScript: no need for WASM or anything.
|
|
23
|
+
- TypeScript-first: full type definitions included
|
|
11
24
|
|
|
12
25
|
## Installation
|
|
13
26
|
|
|
@@ -118,41 +131,14 @@ Based on [SQLGlot](https://github.com/tobymao/sqlglot) by Toby Mao (MIT). See [C
|
|
|
118
131
|
|
|
119
132
|
## Copyright Notice
|
|
120
133
|
|
|
121
|
-
|
|
122
|
-
This project incorporates code from the following sources:
|
|
123
|
-
|
|
124
|
-
===============================================================================
|
|
134
|
+
Check [License](./LICENSE).
|
|
125
135
|
|
|
126
|
-
|
|
127
|
-
Copyright (c) 2026 Huy DNA
|
|
128
|
-
Licensed under the MIT License
|
|
136
|
+
## CDN Usage
|
|
129
137
|
|
|
130
|
-
|
|
138
|
+
Use sqlingo.js directly in the browser via CDN:
|
|
131
139
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
137
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
138
|
-
in the Software without restriction, including without limitation the rights
|
|
139
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
140
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
141
|
-
furnished to do so, subject to the following conditions:
|
|
142
|
-
|
|
143
|
-
The above copyright notice and this permission notice shall be included in all
|
|
144
|
-
copies or substantial portions of the Software.
|
|
145
|
-
|
|
146
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
147
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
148
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
149
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
150
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
151
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
152
|
-
SOFTWARE.
|
|
140
|
+
```html
|
|
141
|
+
<script type="module">
|
|
142
|
+
import { transpile } from "https://esm.sh/@hdnax/sqlingo.js";
|
|
143
|
+
</script>
|
|
153
144
|
```
|
|
154
|
-
|
|
155
|
-
## Links
|
|
156
|
-
|
|
157
|
-
- [GitHub](https://github.com/huydo862003/sqlingo.js)
|
|
158
|
-
- [Issues](https://github.com/huydo862003/sqlingo.js/issues)
|
package/README.repo.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# sqlingo.js
|
|
2
2
|
|
|
3
|
-
](https://www.npmjs.com/package/@hdnax/sqlingo.js)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](https://bundlephobia.com/package/@hdnax/sqlingo.js)
|
|
6
|
+

|
|
7
7
|
|
|
8
|
-
A JavaScript port of [SQLGlot](https://github.com/tobymao/sqlglot), a SQL parser, transpiler, optimizer, and engine.
|
|
8
|
+
A JavaScript/TypeScript port of [SQLGlot](https://github.com/tobymao/sqlglot), which is a comprehensive SQL parser, transpiler, optimizer, and engine.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
This package allows you to parse, transpile, optimize, and execute SQL across **33+ dialects** in JavaScript, with no other setup.
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
Supports TypeScript & CJS/ESM. Works in Node.js and the browser.
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
> There's also an alternative [polyglot](https://github.com/tobilg/polyglot) library - check it out!
|
|
15
15
|
|
|
16
16
|
## Installation
|
|
17
17
|
|
|
@@ -23,9 +23,27 @@ pnpm add @hdnax/sqlingo.js
|
|
|
23
23
|
yarn add @hdnax/sqlingo.js
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
##
|
|
26
|
+
## Quick Start
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
```ts
|
|
29
|
+
import { parse, transpile } from "@hdnax/sqlingo.js";
|
|
30
|
+
|
|
31
|
+
// Parse SQL into an AST
|
|
32
|
+
const [ast] = parse("SELECT a, b FROM t WHERE a > 1");
|
|
33
|
+
|
|
34
|
+
// Transpile between dialects
|
|
35
|
+
const [result] = transpile("SELECT EPOCH_MS(1618088028295)", {
|
|
36
|
+
read: "duckdb",
|
|
37
|
+
write: "hive",
|
|
38
|
+
});
|
|
39
|
+
// => "SELECT FROM_UNIXTIME(1618088028295 / POW(10, 3))"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
See the [Usage Guide](./README.npm.md) for full API documentation and examples.
|
|
43
|
+
|
|
44
|
+
## Supported Dialects
|
|
45
|
+
|
|
46
|
+
Athena, BigQuery, ClickHouse, Databricks, Doris, Dremio, Drill, Druid, DuckDB, Dune, Exasol, Fabric, Hive, Materialize, MySQL, Oracle, Postgres, Presto, PRQL, Redshift, RisingWave, SingleStore, Snowflake, Solr, Spark, Spark2, SQLite, StarRocks, Tableau, Teradata, Trino, TSQL
|
|
29
47
|
|
|
30
48
|
## Goals (& Non-goals)
|
|
31
49
|
|
|
@@ -34,6 +52,7 @@ The main goal is that sqlingo.js should be a close mirror to SQLGlot. This way,
|
|
|
34
52
|
Another goal is to stay true to Typescript convention (check [CONVENTION.md](./CONVENTION.md)).
|
|
35
53
|
|
|
36
54
|
Currently, these are non-goals:
|
|
55
|
+
|
|
37
56
|
- Optimized performance.
|
|
38
57
|
- Optimized bundle size.
|
|
39
58
|
- Compatibility with SQLGlot (but it should be trivial to make the two compatible)
|
|
@@ -41,12 +60,13 @@ Currently, these are non-goals:
|
|
|
41
60
|
## Backstory
|
|
42
61
|
|
|
43
62
|
I'm currenly maintaining [@dbml/core](https://github.com/holistics/dbml), a library that supports converting between DBML and SQL. Under the hood it uses ANTLR for parsing, and honestly it's been a mess:
|
|
63
|
+
|
|
44
64
|
- `@dbml/core` is **33MB**, which is quite insane to be honest. It actually broke our CI with OOM errors.
|
|
45
65
|
- We can't add more dialects without making the bundle even larger.
|
|
46
66
|
- The parser is feature-incomplete and spits out user-unfriendly error messages like `No viable alternative at...`.
|
|
47
67
|
- After all that, we only support **5 dialects**.
|
|
48
68
|
|
|
49
|
-
At a hackathon, I was poking around [Dagster](https://dagster.io/) and stumbled upon SQLGlot. I thought it was amazing that there was a library like this. SQLGlot seems to be trusted by a lots of tools in the Python ecosystems.
|
|
69
|
+
At a hackathon, I was poking around [Dagster](https://dagster.io/) and stumbled upon SQLGlot. I thought it was amazing that there was a library like this. SQLGlot seems to be trusted by a lots of tools in the Python ecosystems.
|
|
50
70
|
|
|
51
71
|
Since then, I was looking for an alternative in Javascript, because I want to run it on the browser. Sadly, at the time, there was none that I knew of.
|
|
52
72
|
|
|
@@ -59,6 +79,7 @@ Therefore, I decided to port it. At 2 weeks into my porting process, [polyglot](
|
|
|
59
79
|
### Prerequisites
|
|
60
80
|
|
|
61
81
|
Make sure these are installed on your machine:
|
|
82
|
+
|
|
62
83
|
- [`node`](https://nodejs.org/)@^20 - [Installation Guide](https://nodejs.org/en/download/package-manager)
|
|
63
84
|
- [`pnpm`](https://pnpm.io/)@^10.26.1 - [Installation Guide](https://pnpm.io/installation)
|
|
64
85
|
|