Skip to content

Commit e509cfe

Browse files
committed
bump version to 0.1.7
1 parent 6e5e5e7 commit e509cfe

File tree

4 files changed

+28
-29
lines changed

4 files changed

+28
-29
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Changelog
22

33

4+
## 0.1.7 - 2026.04.13
5+
### Added
6+
- LATERAL JOIN support: `{INNER|LEFT|CROSS} JOIN LATERAL (subquery)` and standalone `FROM t, LATERAL (subquery)` [6e5e5e7](https://github.com/questdb/sql-parser/commit/6e5e5e7)
7+
- UNNEST support including JSON UNNEST [6e5e5e7](https://github.com/questdb/sql-parser/commit/6e5e5e7)
8+
- PARQUET column config in CREATE/ALTER table statements [6e5e5e7](https://github.com/questdb/sql-parser/commit/6e5e5e7)
9+
10+
411
## 0.1.6 - 2026.03.26
512
### Changed
613
- remove quoted identifier suppression [#17](https://github.com/questdb/sql-parser/pull/17)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@questdb/sql-parser",
3-
"version": "0.1.6",
3+
"version": "0.1.7",
44
"description": "SQL parser for QuestDB syntax using Chevrotain",
55
"type": "module",
66
"main": "dist/index.cjs",

src/parser/visitor.ts

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,17 @@ class QuestDBVisitor extends BaseVisitor {
207207
return token?.image ?? ""
208208
}
209209

210+
/** Return the image of the first token found in a single-alternative CST children record. */
211+
private firstTokenImage(ctx: CstChildrenRecord): string | undefined {
212+
for (const key of Object.keys(ctx)) {
213+
const tokens = (ctx as Record<string, IToken[]>)[key]
214+
if (Array.isArray(tokens) && tokens.length > 0 && tokens[0].image) {
215+
return tokens[0].image
216+
}
217+
}
218+
return undefined
219+
}
220+
210221
// ==========================================================================
211222
// Entry Points
212223
// ==========================================================================
@@ -599,9 +610,7 @@ class QuestDBVisitor extends BaseVisitor {
599610
unnestClause(ctx: UnnestClauseCstChildren): AST.TableRef {
600611
const unnest: AST.UnnestSource = {
601612
type: "unnest",
602-
args: ctx.unnestArg.map(
603-
(a: CstNode) => this.visit(a) as AST.UnnestArg,
604-
),
613+
args: ctx.unnestArg.map((a: CstNode) => this.visit(a) as AST.UnnestArg),
605614
}
606615
if (ctx.With && ctx.Ordinality) {
607616
unnest.withOrdinality = true
@@ -1341,7 +1350,9 @@ class QuestDBVisitor extends BaseVisitor {
13411350
parquetConfig(ctx: ParquetConfigCstChildren): AST.ParquetConfig {
13421351
const result: AST.ParquetConfig = { type: "parquetConfig" }
13431352
if (ctx.parquetEncoding) {
1344-
result.encoding = (this.visit(ctx.parquetEncoding) as string).toUpperCase()
1353+
result.encoding = (
1354+
this.visit(ctx.parquetEncoding) as string
1355+
).toUpperCase()
13451356
}
13461357
if (ctx.parquetCompression) {
13471358
result.compression = (
@@ -1358,24 +1369,11 @@ class QuestDBVisitor extends BaseVisitor {
13581369
}
13591370

13601371
parquetEncoding(ctx: ParquetEncodingCstChildren): string {
1361-
// Find the first token present in the context
1362-
for (const key of Object.keys(ctx)) {
1363-
const val = (ctx as Record<string, unknown>)[key]
1364-
if (Array.isArray(val) && val.length > 0 && val[0].image) {
1365-
return val[0].image.toUpperCase()
1366-
}
1367-
}
1368-
return "DEFAULT"
1372+
return this.firstTokenImage(ctx)?.toUpperCase() ?? "DEFAULT"
13691373
}
13701374

13711375
parquetCompression(ctx: ParquetCompressionCstChildren): string {
1372-
for (const key of Object.keys(ctx)) {
1373-
const val = (ctx as Record<string, unknown>)[key]
1374-
if (Array.isArray(val) && val.length > 0 && val[0].image) {
1375-
return val[0].image.toUpperCase()
1376-
}
1377-
}
1378-
return ""
1376+
return this.firstTokenImage(ctx)?.toUpperCase() ?? ""
13791377
}
13801378

13811379
castDefinition(ctx: CastDefinitionCstChildren): AST.CastDefinition {
@@ -1945,9 +1943,7 @@ class QuestDBVisitor extends BaseVisitor {
19451943
actionType: "alterColumn",
19461944
column,
19471945
alterType: "setParquet",
1948-
parquetConfig: this.visit(
1949-
ctx.parquetConfig,
1950-
) as AST.ParquetConfig,
1946+
parquetConfig: this.visit(ctx.parquetConfig) as AST.ParquetConfig,
19511947
} as AST.AlterColumnAction
19521948
}
19531949

tests/parser.test.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -619,9 +619,7 @@ describe("QuestDB Parser", () => {
619619
})
620620

621621
it("should parse UNNEST with bare alias and no column aliases", () => {
622-
const result = parseToAst(
623-
"SELECT u.value FROM UNNEST(ARRAY[1, 2, 3]) u",
624-
)
622+
const result = parseToAst("SELECT u.value FROM UNNEST(ARRAY[1, 2, 3]) u")
625623
expect(result.errors).toHaveLength(0)
626624
const stmt = result.ast[0]
627625
if (stmt.type === "select") {
@@ -2075,9 +2073,7 @@ describe("QuestDB Parser", () => {
20752073
"DELTA_LENGTH_BYTE_ARRAY",
20762074
)
20772075
// Column without PARQUET
2078-
expect(
2079-
result.ast[0].columns?.[3].parquetConfig,
2080-
).toBeUndefined()
2076+
expect(result.ast[0].columns?.[3].parquetConfig).toBeUndefined()
20812077
}
20822078
})
20832079

0 commit comments

Comments
 (0)