Skip to content

Commit a35cdd8

Browse files
committed
sten and horizon non-reserved keywords
1 parent bbd60de commit a35cdd8

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

src/parser/tokens.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,8 @@ export const IDENTIFIER_KEYWORD_NAMES = new globalThis.Set([
336336
"Every",
337337
"Prev",
338338
"Linear",
339+
"Horizon",
340+
"Step",
339341
])
340342

341343
for (const name of IDENTIFIER_KEYWORD_NAMES) {

tests/parser.test.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5814,4 +5814,46 @@ orders PIVOT (sum(amount) FOR status IN ('open'))`
58145814
expect(result.errors).toHaveLength(0)
58155815
})
58165816
})
5817+
5818+
describe("'horizon' and 'step' as non-reserved identifier keywords", () => {
5819+
it("should parse 'horizon' as a table name", () => {
5820+
const result = parseToAst("SELECT * FROM horizon")
5821+
expect(result.errors).toHaveLength(0)
5822+
const stmt = result.ast[0] as AST.SelectStatement
5823+
const tableRef = stmt.from?.[0] as AST.TableRef
5824+
expect((tableRef.table as AST.QualifiedName).parts).toEqual(["horizon"])
5825+
})
5826+
5827+
it("should parse 'step' as a column name", () => {
5828+
const result = parseToAst("SELECT step FROM trades")
5829+
expect(result.errors).toHaveLength(0)
5830+
})
5831+
5832+
it("should parse 'horizon' as a column name", () => {
5833+
const result = parseToAst("SELECT horizon FROM trades")
5834+
expect(result.errors).toHaveLength(0)
5835+
})
5836+
5837+
it("should parse 'step' as a table name", () => {
5838+
const result = parseToAst("SELECT * FROM step")
5839+
expect(result.errors).toHaveLength(0)
5840+
const stmt = result.ast[0] as AST.SelectStatement
5841+
const tableRef = stmt.from?.[0] as AST.TableRef
5842+
expect((tableRef.table as AST.QualifiedName).parts).toEqual(["step"])
5843+
})
5844+
5845+
it("should round-trip 'horizon' through toSql", () => {
5846+
const sql = "SELECT * FROM horizon"
5847+
const result = parseToAst(sql)
5848+
expect(result.errors).toHaveLength(0)
5849+
expect(toSql(result.ast[0])).toBe(sql)
5850+
})
5851+
5852+
it("should round-trip 'step' through toSql", () => {
5853+
const sql = "SELECT step FROM trades"
5854+
const result = parseToAst(sql)
5855+
expect(result.errors).toHaveLength(0)
5856+
expect(toSql(result.ast[0])).toBe(sql)
5857+
})
5858+
})
58175859
})

0 commit comments

Comments
 (0)