@questdb/sql-parser 0.1.2 → 0.1.3

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 CHANGED
@@ -1,6 +1,11 @@
1
1
  # Changelog
2
2
 
3
3
 
4
+ ## 0.1.3 - 2026.03.04
5
+ ### Added
6
+ - horizon join support [#9](https://github.com/questdb/sql-parser/pull/9)
7
+
8
+
4
9
  ## 0.1.2 - 2026.02.25
5
10
  ### Fixed
6
11
  - Prioritize tables with mentioned columns in the suggestions [#6](https://github.com/questdb/sql-parser/pull/6)
@@ -349,12 +349,16 @@ var functions = [
349
349
  "approx_percentile",
350
350
  "arg_max",
351
351
  "arg_min",
352
+ "array_agg",
352
353
  "array_avg",
354
+ "array_build",
353
355
  "array_count",
354
356
  "array_cum_sum",
355
357
  "array_max",
356
358
  "array_min",
357
359
  "array_position",
360
+ "array_reverse",
361
+ "array_sort",
358
362
  "array_stddev",
359
363
  "array_stddev_pop",
360
364
  "array_stddev_samp",
@@ -319,12 +319,16 @@ var functions = [
319
319
  "approx_percentile",
320
320
  "arg_max",
321
321
  "arg_min",
322
+ "array_agg",
322
323
  "array_avg",
324
+ "array_build",
323
325
  "array_count",
324
326
  "array_cum_sum",
325
327
  "array_max",
326
328
  "array_min",
327
329
  "array_position",
330
+ "array_reverse",
331
+ "array_sort",
328
332
  "array_stddev",
329
333
  "array_stddev_pop",
330
334
  "array_stddev_samp",
package/dist/index.cjs CHANGED
@@ -529,9 +529,9 @@ var IDENTIFIER_KEYWORD_NAMES = new globalThis.Set([
529
529
  "Capacity",
530
530
  "Cancel",
531
531
  "Prevailing",
532
+ "Range",
532
533
  "Writer",
533
534
  "Materialized",
534
- "Range",
535
535
  "Snapshot",
536
536
  "Unlock",
537
537
  "Refresh",
@@ -650,7 +650,6 @@ var IDENTIFIER_KEYWORD_NAMES = new globalThis.Set([
650
650
  "Every",
651
651
  "Prev",
652
652
  "Linear",
653
- "Horizon",
654
653
  "Step"
655
654
  ]);
656
655
  for (const name of IDENTIFIER_KEYWORD_NAMES) {
@@ -755,6 +754,7 @@ var Grant = getToken("Grant");
755
754
  var Group = getToken("Group");
756
755
  var Groups = getToken("Groups");
757
756
  var Header = getToken("Header");
757
+ var Horizon = getToken("Horizon");
758
758
  var Http = getToken("Http");
759
759
  var If = getToken("If");
760
760
  var Ignore = getToken("Ignore");
@@ -855,6 +855,7 @@ var Snapshot = getToken("Snapshot");
855
855
  var Splice = getToken("Splice");
856
856
  var Squash = getToken("Squash");
857
857
  var StandardConformingStrings = getToken("StandardConformingStrings");
858
+ var Step = getToken("Step");
858
859
  var Start = getToken("Start");
859
860
  var StatisticsEnabled = getToken("StatisticsEnabled");
860
861
  var Suspend = getToken("Suspend");
@@ -1533,6 +1534,7 @@ var QuestDBParser = class extends import_chevrotain3.CstParser {
1533
1534
  { ALT: () => this.SUBRULE(this.asofLtJoin) },
1534
1535
  { ALT: () => this.SUBRULE(this.spliceJoin) },
1535
1536
  { ALT: () => this.SUBRULE(this.windowJoin) },
1537
+ { ALT: () => this.SUBRULE(this.horizonJoin) },
1536
1538
  { ALT: () => this.SUBRULE(this.standardJoin) }
1537
1539
  ]);
1538
1540
  });
@@ -1590,6 +1592,69 @@ var QuestDBParser = class extends import_chevrotain3.CstParser {
1590
1592
  this.CONSUME1(Prevailing);
1591
1593
  });
1592
1594
  });
1595
+ // HORIZON JOIN: tableName alias [ON expr] (RANGE FROM/TO/STEP | LIST (...)) AS alias
1596
+ // Uses tableName + custom alias instead of tableRef to avoid ambiguity
1597
+ // between implicit keyword aliases and RANGE/LIST/ON keywords.
1598
+ this.horizonJoin = this.RULE("horizonJoin", () => {
1599
+ this.CONSUME(Horizon);
1600
+ this.CONSUME(Join);
1601
+ this.SUBRULE(this.tableName);
1602
+ this.OR1([
1603
+ {
1604
+ ALT: () => {
1605
+ this.CONSUME(As);
1606
+ this.SUBRULE(this.identifier);
1607
+ }
1608
+ },
1609
+ {
1610
+ // Implicit alias: only base Identifier, never keywords like RANGE/LIST
1611
+ ALT: () => this.CONSUME(Identifier)
1612
+ }
1613
+ ]);
1614
+ this.OPTION(() => {
1615
+ this.CONSUME(On);
1616
+ this.SUBRULE(this.expression);
1617
+ });
1618
+ this.OR2([
1619
+ {
1620
+ // RANGE FROM <offset> TO <offset> STEP <offset> AS <alias>
1621
+ ALT: () => {
1622
+ this.CONSUME(Range);
1623
+ this.CONSUME(From);
1624
+ this.SUBRULE(this.horizonOffset);
1625
+ this.CONSUME(To);
1626
+ this.SUBRULE1(this.horizonOffset);
1627
+ this.CONSUME(Step);
1628
+ this.SUBRULE2(this.horizonOffset);
1629
+ this.CONSUME1(As);
1630
+ this.SUBRULE1(this.identifier);
1631
+ }
1632
+ },
1633
+ {
1634
+ // LIST (<offset>, ...) AS <alias>
1635
+ ALT: () => {
1636
+ this.CONSUME(List);
1637
+ this.CONSUME(LParen);
1638
+ this.SUBRULE3(this.horizonOffset);
1639
+ this.MANY(() => {
1640
+ this.CONSUME(Comma);
1641
+ this.SUBRULE4(this.horizonOffset);
1642
+ });
1643
+ this.CONSUME(RParen);
1644
+ this.CONSUME2(As);
1645
+ this.SUBRULE2(this.identifier);
1646
+ }
1647
+ }
1648
+ ]);
1649
+ });
1650
+ // Horizon offset value: optional minus sign + DurationLiteral | NumberLiteral
1651
+ this.horizonOffset = this.RULE("horizonOffset", () => {
1652
+ this.OPTION(() => this.CONSUME(Minus));
1653
+ this.OR([
1654
+ { ALT: () => this.CONSUME(DurationLiteral) },
1655
+ { ALT: () => this.CONSUME(NumberLiteral) }
1656
+ ]);
1657
+ });
1593
1658
  // Standard joins: (INNER | LEFT [OUTER] | RIGHT [OUTER] | FULL [OUTER] | CROSS)? JOIN + ON
1594
1659
  this.standardJoin = this.RULE("standardJoin", () => {
1595
1660
  this.OPTION(() => {
@@ -4996,6 +5061,7 @@ var QuestDBVisitor = class extends BaseVisitor {
4996
5061
  if (ctx.asofLtJoin) return this.visit(ctx.asofLtJoin);
4997
5062
  if (ctx.spliceJoin) return this.visit(ctx.spliceJoin);
4998
5063
  if (ctx.windowJoin) return this.visit(ctx.windowJoin);
5064
+ if (ctx.horizonJoin) return this.visit(ctx.horizonJoin);
4999
5065
  return this.visit(ctx.standardJoin);
5000
5066
  }
5001
5067
  asofLtJoin(ctx) {
@@ -5044,6 +5110,49 @@ var QuestDBVisitor = class extends BaseVisitor {
5044
5110
  }
5045
5111
  return result;
5046
5112
  }
5113
+ horizonJoin(ctx) {
5114
+ const tableRef = {
5115
+ type: "tableRef",
5116
+ table: this.visit(ctx.tableName)
5117
+ };
5118
+ if (ctx.Identifier) {
5119
+ tableRef.alias = ctx.Identifier[0].image;
5120
+ } else if (ctx.identifier && ctx.identifier.length > 1) {
5121
+ tableRef.alias = this.visit(ctx.identifier[0]).parts[0];
5122
+ }
5123
+ const result = {
5124
+ type: "join",
5125
+ joinType: "horizon",
5126
+ table: tableRef
5127
+ };
5128
+ if (ctx.expression) {
5129
+ result.on = this.visit(ctx.expression);
5130
+ }
5131
+ if (ctx.Range) {
5132
+ const offsets = ctx.horizonOffset;
5133
+ result.horizonRange = {
5134
+ from: this.visit(offsets[0]),
5135
+ to: this.visit(offsets[1]),
5136
+ step: this.visit(offsets[2])
5137
+ };
5138
+ } else if (ctx.List) {
5139
+ result.horizonList = ctx.horizonOffset.map(
5140
+ (o) => this.visit(o)
5141
+ );
5142
+ }
5143
+ if (ctx.identifier) {
5144
+ const lastId = ctx.identifier[ctx.identifier.length - 1];
5145
+ result.horizonAlias = this.visit(lastId).parts[0];
5146
+ }
5147
+ return result;
5148
+ }
5149
+ horizonOffset(ctx) {
5150
+ const sign = ctx.Minus ? "-" : "";
5151
+ if (ctx.DurationLiteral) {
5152
+ return sign + ctx.DurationLiteral[0].image;
5153
+ }
5154
+ return sign + ctx.NumberLiteral[0].image;
5155
+ }
5047
5156
  standardJoin(ctx) {
5048
5157
  const result = {
5049
5158
  type: "join",
@@ -7919,6 +8028,21 @@ function joinToSql(join) {
7919
8028
  join.prevailing === "include" ? "INCLUDE PREVAILING" : "EXCLUDE PREVAILING"
7920
8029
  );
7921
8030
  }
8031
+ if (join.horizonRange) {
8032
+ parts.push("RANGE FROM");
8033
+ parts.push(join.horizonRange.from);
8034
+ parts.push("TO");
8035
+ parts.push(join.horizonRange.to);
8036
+ parts.push("STEP");
8037
+ parts.push(join.horizonRange.step);
8038
+ }
8039
+ if (join.horizonList) {
8040
+ parts.push("LIST (" + join.horizonList.join(", ") + ")");
8041
+ }
8042
+ if (join.horizonAlias) {
8043
+ parts.push("AS");
8044
+ parts.push(escapeIdentifier(join.horizonAlias));
8045
+ }
7922
8046
  return parts.join(" ");
7923
8047
  }
7924
8048
  function windowJoinBoundToSql(bound) {
@@ -9792,12 +9916,16 @@ var functions = [
9792
9916
  "approx_percentile",
9793
9917
  "arg_max",
9794
9918
  "arg_min",
9919
+ "array_agg",
9795
9920
  "array_avg",
9921
+ "array_build",
9796
9922
  "array_count",
9797
9923
  "array_cum_sum",
9798
9924
  "array_max",
9799
9925
  "array_min",
9800
9926
  "array_position",
9927
+ "array_reverse",
9928
+ "array_sort",
9801
9929
  "array_stddev",
9802
9930
  "array_stddev_pop",
9803
9931
  "array_stddev_samp",
package/dist/index.js CHANGED
@@ -469,9 +469,9 @@ var IDENTIFIER_KEYWORD_NAMES = new globalThis.Set([
469
469
  "Capacity",
470
470
  "Cancel",
471
471
  "Prevailing",
472
+ "Range",
472
473
  "Writer",
473
474
  "Materialized",
474
- "Range",
475
475
  "Snapshot",
476
476
  "Unlock",
477
477
  "Refresh",
@@ -590,7 +590,6 @@ var IDENTIFIER_KEYWORD_NAMES = new globalThis.Set([
590
590
  "Every",
591
591
  "Prev",
592
592
  "Linear",
593
- "Horizon",
594
593
  "Step"
595
594
  ]);
596
595
  for (const name of IDENTIFIER_KEYWORD_NAMES) {
@@ -695,6 +694,7 @@ var Grant = getToken("Grant");
695
694
  var Group = getToken("Group");
696
695
  var Groups = getToken("Groups");
697
696
  var Header = getToken("Header");
697
+ var Horizon = getToken("Horizon");
698
698
  var Http = getToken("Http");
699
699
  var If = getToken("If");
700
700
  var Ignore = getToken("Ignore");
@@ -795,6 +795,7 @@ var Snapshot = getToken("Snapshot");
795
795
  var Splice = getToken("Splice");
796
796
  var Squash = getToken("Squash");
797
797
  var StandardConformingStrings = getToken("StandardConformingStrings");
798
+ var Step = getToken("Step");
798
799
  var Start = getToken("Start");
799
800
  var StatisticsEnabled = getToken("StatisticsEnabled");
800
801
  var Suspend = getToken("Suspend");
@@ -1473,6 +1474,7 @@ var QuestDBParser = class extends CstParser {
1473
1474
  { ALT: () => this.SUBRULE(this.asofLtJoin) },
1474
1475
  { ALT: () => this.SUBRULE(this.spliceJoin) },
1475
1476
  { ALT: () => this.SUBRULE(this.windowJoin) },
1477
+ { ALT: () => this.SUBRULE(this.horizonJoin) },
1476
1478
  { ALT: () => this.SUBRULE(this.standardJoin) }
1477
1479
  ]);
1478
1480
  });
@@ -1530,6 +1532,69 @@ var QuestDBParser = class extends CstParser {
1530
1532
  this.CONSUME1(Prevailing);
1531
1533
  });
1532
1534
  });
1535
+ // HORIZON JOIN: tableName alias [ON expr] (RANGE FROM/TO/STEP | LIST (...)) AS alias
1536
+ // Uses tableName + custom alias instead of tableRef to avoid ambiguity
1537
+ // between implicit keyword aliases and RANGE/LIST/ON keywords.
1538
+ this.horizonJoin = this.RULE("horizonJoin", () => {
1539
+ this.CONSUME(Horizon);
1540
+ this.CONSUME(Join);
1541
+ this.SUBRULE(this.tableName);
1542
+ this.OR1([
1543
+ {
1544
+ ALT: () => {
1545
+ this.CONSUME(As);
1546
+ this.SUBRULE(this.identifier);
1547
+ }
1548
+ },
1549
+ {
1550
+ // Implicit alias: only base Identifier, never keywords like RANGE/LIST
1551
+ ALT: () => this.CONSUME(Identifier)
1552
+ }
1553
+ ]);
1554
+ this.OPTION(() => {
1555
+ this.CONSUME(On);
1556
+ this.SUBRULE(this.expression);
1557
+ });
1558
+ this.OR2([
1559
+ {
1560
+ // RANGE FROM <offset> TO <offset> STEP <offset> AS <alias>
1561
+ ALT: () => {
1562
+ this.CONSUME(Range);
1563
+ this.CONSUME(From);
1564
+ this.SUBRULE(this.horizonOffset);
1565
+ this.CONSUME(To);
1566
+ this.SUBRULE1(this.horizonOffset);
1567
+ this.CONSUME(Step);
1568
+ this.SUBRULE2(this.horizonOffset);
1569
+ this.CONSUME1(As);
1570
+ this.SUBRULE1(this.identifier);
1571
+ }
1572
+ },
1573
+ {
1574
+ // LIST (<offset>, ...) AS <alias>
1575
+ ALT: () => {
1576
+ this.CONSUME(List);
1577
+ this.CONSUME(LParen);
1578
+ this.SUBRULE3(this.horizonOffset);
1579
+ this.MANY(() => {
1580
+ this.CONSUME(Comma);
1581
+ this.SUBRULE4(this.horizonOffset);
1582
+ });
1583
+ this.CONSUME(RParen);
1584
+ this.CONSUME2(As);
1585
+ this.SUBRULE2(this.identifier);
1586
+ }
1587
+ }
1588
+ ]);
1589
+ });
1590
+ // Horizon offset value: optional minus sign + DurationLiteral | NumberLiteral
1591
+ this.horizonOffset = this.RULE("horizonOffset", () => {
1592
+ this.OPTION(() => this.CONSUME(Minus));
1593
+ this.OR([
1594
+ { ALT: () => this.CONSUME(DurationLiteral) },
1595
+ { ALT: () => this.CONSUME(NumberLiteral) }
1596
+ ]);
1597
+ });
1533
1598
  // Standard joins: (INNER | LEFT [OUTER] | RIGHT [OUTER] | FULL [OUTER] | CROSS)? JOIN + ON
1534
1599
  this.standardJoin = this.RULE("standardJoin", () => {
1535
1600
  this.OPTION(() => {
@@ -4936,6 +5001,7 @@ var QuestDBVisitor = class extends BaseVisitor {
4936
5001
  if (ctx.asofLtJoin) return this.visit(ctx.asofLtJoin);
4937
5002
  if (ctx.spliceJoin) return this.visit(ctx.spliceJoin);
4938
5003
  if (ctx.windowJoin) return this.visit(ctx.windowJoin);
5004
+ if (ctx.horizonJoin) return this.visit(ctx.horizonJoin);
4939
5005
  return this.visit(ctx.standardJoin);
4940
5006
  }
4941
5007
  asofLtJoin(ctx) {
@@ -4984,6 +5050,49 @@ var QuestDBVisitor = class extends BaseVisitor {
4984
5050
  }
4985
5051
  return result;
4986
5052
  }
5053
+ horizonJoin(ctx) {
5054
+ const tableRef = {
5055
+ type: "tableRef",
5056
+ table: this.visit(ctx.tableName)
5057
+ };
5058
+ if (ctx.Identifier) {
5059
+ tableRef.alias = ctx.Identifier[0].image;
5060
+ } else if (ctx.identifier && ctx.identifier.length > 1) {
5061
+ tableRef.alias = this.visit(ctx.identifier[0]).parts[0];
5062
+ }
5063
+ const result = {
5064
+ type: "join",
5065
+ joinType: "horizon",
5066
+ table: tableRef
5067
+ };
5068
+ if (ctx.expression) {
5069
+ result.on = this.visit(ctx.expression);
5070
+ }
5071
+ if (ctx.Range) {
5072
+ const offsets = ctx.horizonOffset;
5073
+ result.horizonRange = {
5074
+ from: this.visit(offsets[0]),
5075
+ to: this.visit(offsets[1]),
5076
+ step: this.visit(offsets[2])
5077
+ };
5078
+ } else if (ctx.List) {
5079
+ result.horizonList = ctx.horizonOffset.map(
5080
+ (o) => this.visit(o)
5081
+ );
5082
+ }
5083
+ if (ctx.identifier) {
5084
+ const lastId = ctx.identifier[ctx.identifier.length - 1];
5085
+ result.horizonAlias = this.visit(lastId).parts[0];
5086
+ }
5087
+ return result;
5088
+ }
5089
+ horizonOffset(ctx) {
5090
+ const sign = ctx.Minus ? "-" : "";
5091
+ if (ctx.DurationLiteral) {
5092
+ return sign + ctx.DurationLiteral[0].image;
5093
+ }
5094
+ return sign + ctx.NumberLiteral[0].image;
5095
+ }
4987
5096
  standardJoin(ctx) {
4988
5097
  const result = {
4989
5098
  type: "join",
@@ -7859,6 +7968,21 @@ function joinToSql(join) {
7859
7968
  join.prevailing === "include" ? "INCLUDE PREVAILING" : "EXCLUDE PREVAILING"
7860
7969
  );
7861
7970
  }
7971
+ if (join.horizonRange) {
7972
+ parts.push("RANGE FROM");
7973
+ parts.push(join.horizonRange.from);
7974
+ parts.push("TO");
7975
+ parts.push(join.horizonRange.to);
7976
+ parts.push("STEP");
7977
+ parts.push(join.horizonRange.step);
7978
+ }
7979
+ if (join.horizonList) {
7980
+ parts.push("LIST (" + join.horizonList.join(", ") + ")");
7981
+ }
7982
+ if (join.horizonAlias) {
7983
+ parts.push("AS");
7984
+ parts.push(escapeIdentifier(join.horizonAlias));
7985
+ }
7862
7986
  return parts.join(" ");
7863
7987
  }
7864
7988
  function windowJoinBoundToSql(bound) {
@@ -9732,12 +9856,16 @@ var functions = [
9732
9856
  "approx_percentile",
9733
9857
  "arg_max",
9734
9858
  "arg_min",
9859
+ "array_agg",
9735
9860
  "array_avg",
9861
+ "array_build",
9736
9862
  "array_count",
9737
9863
  "array_cum_sum",
9738
9864
  "array_max",
9739
9865
  "array_min",
9740
9866
  "array_position",
9867
+ "array_reverse",
9868
+ "array_sort",
9741
9869
  "array_stddev",
9742
9870
  "array_stddev_pop",
9743
9871
  "array_stddev_samp",
@@ -603,7 +603,7 @@ export interface TableRef extends AstNode {
603
603
  }
604
604
  export interface JoinClause extends AstNode {
605
605
  type: "join";
606
- joinType?: "inner" | "left" | "right" | "full" | "cross" | "asof" | "lt" | "splice" | "window";
606
+ joinType?: "inner" | "left" | "right" | "full" | "cross" | "asof" | "lt" | "splice" | "window" | "horizon";
607
607
  outer?: boolean;
608
608
  table: TableRef;
609
609
  on?: Expression;
@@ -616,6 +616,16 @@ export interface JoinClause extends AstNode {
616
616
  };
617
617
  /** INCLUDE/EXCLUDE PREVAILING clause for WINDOW JOIN */
618
618
  prevailing?: "include" | "exclude";
619
+ /** RANGE FROM/TO/STEP for HORIZON JOIN */
620
+ horizonRange?: {
621
+ from: string;
622
+ to: string;
623
+ step: string;
624
+ };
625
+ /** LIST offsets for HORIZON JOIN */
626
+ horizonList?: string[];
627
+ /** Alias for the horizon pseudo-table */
628
+ horizonAlias?: string;
619
629
  }
620
630
  export interface WindowJoinBound extends AstNode {
621
631
  type: "windowJoinBound";
@@ -1,7 +1,7 @@
1
1
  import { Lexer, TokenType } from "chevrotain";
2
- import { IdentifierKeyword, Abort, Account, Accounts, Add, Alias, Align, All, Alter, And, Any, As, Asc, Asof, Assume, Attach, Atomic, Backup, Base, Batch, Between, Binary, Boolean, By, Bypass, Byte, Cache, Calendar, Cancel, Capacity, Cascade, Case, Cast, Char, Checkpoint, Column, Columns, Compile, Complete, CompressionCodec, CompressionLevel, CommitLag, Convert, Copy, Create, Cross, Cumulative, Current, Database, DataPageSize, Datestyle, Date, Day, Days, Decimal, Declare, Dedup, Default, DefaultTransactionReadOnly, Deferred, Delay, Delete, Delimiter, Desc, Detach, Details, Disable, Distinct, Double, Drop, Else, Enable, End, Error, Every, Except, Exclude, Exclusive, Exists, Exit, Explain, External, False, Fill, First, Float, Following, For, Foreign, Format, From, Full, Geohash, Grant, Group, Groups, Header, Hour, Hours, Http, If, Ignore, Ilike, Immediate, In, Include, Index, Inner, Insert, Incremental, Int, Integer, Intersect, Interval, Into, Ipv4, Is, Isolation, Jwk, Join, Keep, Key, Keys, Latest, Left, Length, Level, Like, Limit, Linear, List, Lock, Long, Long128, Long256, Lt, Manual, Maps, Materialized, MaxIdentifierLength, MaxUncommittedRows, Microsecond, Microseconds, Millennium, Millisecond, Milliseconds, Minute, Minutes, Month, Months, NaN, Nanosecond, Nanoseconds, No, Nocache, None, Not, Null, Nulls, O3MaxLag, Observation, Offset, On, Only, Option, Or, Order, Others, Outer, Over, Overridable, Owned, Param, Parameters, Parquet, ParquetVersion, PartitionBy, Partition, Partitions, Password, Period, Permissions, Pivot, Prepare, Preceding, Prev, Prevailing, Primary, Public, Query, Range, References, Refresh, Release, Reindex, Remove, Rename, Repair, Replace, Rest, Respect, Resume, Revoke, Right, Row, RowGroupSize, Rows, Sample, SearchPath, Second, Seconds, Select, ServerVersion, ServerVersionNum, Service, Set, Short, Show, Skip, SkipColumn, SkipRow, Snapshot, Splice, Squash, StandardConformingStrings, Start, StatisticsEnabled, String, Suspend, Symbol, System, Table, Tables, Then, Time, Timestamp, TimestampNs, To, Token, Tolerance, Transaction, TransactionIsolation, Transient, True, Truncate, Ttl, Txn, Type, Unbounded, Union, Unlock, Unpivot, Update, Upsert, User, Users, Uuid, Vacuum, Values, Varchar, Verification, View, Volume, Wal, Week, Weeks, When, Where, Window, With, Within, Writer, Year, Years, Zone, RawArrayEncoding, Uncompressed, Snappy, Gzip, Lz4, Zstd, Lz4Raw, Brotli, Lzo } from "./tokens";
2
+ import { IdentifierKeyword, Abort, Account, Accounts, Add, Alias, Align, All, Alter, And, Any, As, Asc, Asof, Assume, Attach, Atomic, Backup, Base, Batch, Between, Binary, Boolean, By, Bypass, Byte, Cache, Calendar, Cancel, Capacity, Cascade, Case, Cast, Char, Checkpoint, Column, Columns, Compile, Complete, CompressionCodec, CompressionLevel, CommitLag, Convert, Copy, Create, Cross, Cumulative, Current, Database, DataPageSize, Datestyle, Date, Day, Days, Decimal, Declare, Dedup, Default, DefaultTransactionReadOnly, Deferred, Delay, Delete, Delimiter, Desc, Detach, Details, Disable, Distinct, Double, Drop, Else, Enable, End, Error, Every, Except, Exclude, Exclusive, Exists, Exit, Explain, External, False, Fill, First, Float, Following, For, Foreign, Format, From, Full, Geohash, Grant, Group, Groups, Header, Horizon, Hour, Hours, Http, If, Ignore, Ilike, Immediate, In, Include, Index, Inner, Insert, Incremental, Int, Integer, Intersect, Interval, Into, Ipv4, Is, Isolation, Jwk, Join, Keep, Key, Keys, Latest, Left, Length, Level, Like, Limit, Linear, List, Lock, Long, Long128, Long256, Lt, Manual, Maps, Materialized, MaxIdentifierLength, MaxUncommittedRows, Microsecond, Microseconds, Millennium, Millisecond, Milliseconds, Minute, Minutes, Month, Months, NaN, Nanosecond, Nanoseconds, No, Nocache, None, Not, Null, Nulls, O3MaxLag, Observation, Offset, On, Only, Option, Or, Order, Others, Outer, Over, Overridable, Owned, Param, Parameters, Parquet, ParquetVersion, PartitionBy, Partition, Partitions, Password, Period, Permissions, Pivot, Prepare, Preceding, Prev, Prevailing, Primary, Public, Query, Range, References, Refresh, Release, Reindex, Remove, Rename, Repair, Replace, Rest, Respect, Resume, Revoke, Right, Row, RowGroupSize, Rows, Sample, SearchPath, Second, Seconds, Select, ServerVersion, ServerVersionNum, Service, Set, Short, Show, Skip, SkipColumn, SkipRow, Snapshot, Splice, Squash, StandardConformingStrings, Step, Start, StatisticsEnabled, String, Suspend, Symbol, System, Table, Tables, Then, Time, Timestamp, TimestampNs, To, Token, Tolerance, Transaction, TransactionIsolation, Transient, True, Truncate, Ttl, Txn, Type, Unbounded, Union, Unlock, Unpivot, Update, Upsert, User, Users, Uuid, Vacuum, Values, Varchar, Verification, View, Volume, Wal, Week, Weeks, When, Where, Window, With, Within, Writer, Year, Years, Zone, RawArrayEncoding, Uncompressed, Snappy, Gzip, Lz4, Zstd, Lz4Raw, Brotli, Lzo } from "./tokens";
3
3
  export { IdentifierKeyword };
4
- export { Abort, Account, Accounts, Add, Alias, Align, All, Alter, And, Any, As, Asc, Asof, Assume, Attach, Atomic, Backup, Base, Batch, Between, Binary, Boolean, By, Bypass, Byte, Cache, Calendar, Cancel, Capacity, Cascade, Case, Cast, Char, Checkpoint, Column, Columns, Compile, Complete, CompressionCodec, CompressionLevel, CommitLag, Convert, Copy, Create, Cross, Cumulative, Current, Database, DataPageSize, Datestyle, Date, Day, Days, Decimal, Declare, Dedup, Default, DefaultTransactionReadOnly, Deferred, Delay, Delete, Delimiter, Desc, Detach, Details, Disable, Distinct, Double, Drop, Else, Enable, End, Error, Every, Except, Exclude, Exclusive, Exists, Exit, Explain, External, False, Fill, First, Float, Following, For, Foreign, Format, From, Full, Geohash, Grant, Group, Groups, Header, Hour, Hours, Http, If, Ignore, Ilike, Immediate, In, Include, Index, Inner, Insert, Incremental, Int, Integer, Intersect, Interval, Into, Ipv4, Is, Isolation, Jwk, Join, Keep, Key, Keys, Latest, Left, Length, Level, Like, Limit, Linear, List, Lock, Long, Long128, Long256, Lt, Manual, Maps, Materialized, MaxIdentifierLength, MaxUncommittedRows, Microsecond, Microseconds, Millennium, Millisecond, Milliseconds, Minute, Minutes, Month, Months, NaN, Nanosecond, Nanoseconds, No, Nocache, None, Not, Null, Nulls, O3MaxLag, Observation, Offset, On, Only, Option, Or, Order, Others, Outer, Over, Overridable, Owned, Param, Parameters, Parquet, ParquetVersion, PartitionBy, Partition, Partitions, Password, Period, Permissions, Pivot, Prepare, Preceding, Prev, Prevailing, Primary, Public, Query, Range, References, Refresh, Release, Reindex, Remove, Rename, Repair, Replace, Rest, Respect, Resume, Revoke, Right, Row, RowGroupSize, Rows, Sample, SearchPath, Second, Seconds, Select, ServerVersion, ServerVersionNum, Service, Set, Short, Show, Skip, SkipColumn, SkipRow, Snapshot, Splice, Squash, StandardConformingStrings, Start, StatisticsEnabled, String, Suspend, Symbol, System, Table, Tables, Then, Time, Timestamp, TimestampNs, To, Token, Tolerance, Transaction, TransactionIsolation, Transient, True, Truncate, Ttl, Txn, Type, Unbounded, Union, Unlock, Unpivot, Update, Upsert, User, Users, Uuid, Vacuum, Values, Varchar, Verification, View, Volume, Wal, Week, Weeks, When, Where, Window, With, Within, Writer, Year, Years, Zone, RawArrayEncoding, Uncompressed, Snappy, Gzip, Lz4, Zstd, Lz4Raw, Brotli, Lzo, };
4
+ export { Abort, Account, Accounts, Add, Alias, Align, All, Alter, And, Any, As, Asc, Asof, Assume, Attach, Atomic, Backup, Base, Batch, Between, Binary, Boolean, By, Bypass, Byte, Cache, Calendar, Cancel, Capacity, Cascade, Case, Cast, Char, Checkpoint, Column, Columns, Compile, Complete, CompressionCodec, CompressionLevel, CommitLag, Convert, Copy, Create, Cross, Cumulative, Current, Database, DataPageSize, Datestyle, Date, Day, Days, Decimal, Declare, Dedup, Default, DefaultTransactionReadOnly, Deferred, Delay, Delete, Delimiter, Desc, Detach, Details, Disable, Distinct, Double, Drop, Else, Enable, End, Error, Every, Except, Exclude, Exclusive, Exists, Exit, Explain, External, False, Fill, First, Float, Following, For, Foreign, Format, From, Full, Geohash, Grant, Group, Groups, Header, Horizon, Hour, Hours, Http, If, Ignore, Ilike, Immediate, In, Include, Index, Inner, Insert, Incremental, Int, Integer, Intersect, Interval, Into, Ipv4, Is, Isolation, Jwk, Join, Keep, Key, Keys, Latest, Left, Length, Level, Like, Limit, Linear, List, Lock, Long, Long128, Long256, Lt, Manual, Maps, Materialized, MaxIdentifierLength, MaxUncommittedRows, Microsecond, Microseconds, Millennium, Millisecond, Milliseconds, Minute, Minutes, Month, Months, NaN, Nanosecond, Nanoseconds, No, Nocache, None, Not, Null, Nulls, O3MaxLag, Observation, Offset, On, Only, Option, Or, Order, Others, Outer, Over, Overridable, Owned, Param, Parameters, Parquet, ParquetVersion, PartitionBy, Partition, Partitions, Password, Period, Permissions, Pivot, Prepare, Preceding, Prev, Prevailing, Primary, Public, Query, Range, References, Refresh, Release, Reindex, Remove, Rename, Repair, Replace, Rest, Respect, Resume, Revoke, Right, Row, RowGroupSize, Rows, Sample, SearchPath, Second, Seconds, Select, ServerVersion, ServerVersionNum, Service, Set, Short, Show, Skip, SkipColumn, SkipRow, Snapshot, Splice, Squash, StandardConformingStrings, Step, Start, StatisticsEnabled, String, Suspend, Symbol, System, Table, Tables, Then, Time, Timestamp, TimestampNs, To, Token, Tolerance, Transaction, TransactionIsolation, Transient, True, Truncate, Ttl, Txn, Type, Unbounded, Union, Unlock, Unpivot, Update, Upsert, User, Users, Uuid, Vacuum, Values, Varchar, Verification, View, Volume, Wal, Week, Weeks, When, Where, Window, With, Within, Writer, Year, Years, Zone, RawArrayEncoding, Uncompressed, Snappy, Gzip, Lz4, Zstd, Lz4Raw, Brotli, Lzo, };
5
5
  export declare const Star: TokenType;
6
6
  export declare const Comma: TokenType;
7
7
  export declare const Semicolon: TokenType;
@@ -30,6 +30,8 @@ declare class QuestDBParser extends CstParser {
30
30
  private asofLtJoin;
31
31
  private spliceJoin;
32
32
  private windowJoin;
33
+ private horizonJoin;
34
+ private horizonOffset;
33
35
  private standardJoin;
34
36
  private windowJoinBound;
35
37
  private durationExpression;
@@ -100,6 +100,7 @@ export declare const Grant: TokenType;
100
100
  export declare const Group: TokenType;
101
101
  export declare const Groups: TokenType;
102
102
  export declare const Header: TokenType;
103
+ export declare const Horizon: TokenType;
103
104
  export declare const Http: TokenType;
104
105
  export declare const If: TokenType;
105
106
  export declare const Ignore: TokenType;
@@ -200,6 +201,7 @@ export declare const Snapshot: TokenType;
200
201
  export declare const Splice: TokenType;
201
202
  export declare const Squash: TokenType;
202
203
  export declare const StandardConformingStrings: TokenType;
204
+ export declare const Step: TokenType;
203
205
  export declare const Start: TokenType;
204
206
  export declare const StatisticsEnabled: TokenType;
205
207
  export declare const Suspend: TokenType;
@@ -1,5 +1,5 @@
1
1
  import * as AST from "./ast";
2
- import type { AddUserStatementCstChildren, AdditiveExpressionCstChildren, AlignToClauseCstChildren, AlterGroupStatementCstChildren, AlterMaterializedViewActionCstChildren, AlterMaterializedViewStatementCstChildren, AlterServiceAccountStatementCstChildren, AlterStatementCstChildren, AlterTableActionCstChildren, AlterTableStatementCstChildren, AlterUserActionCstChildren, AlterUserStatementCstChildren, AlterViewStatementCstChildren, AndExpressionCstChildren, ArrayBracketBodyCstChildren, ArrayElementCstChildren, ArrayLiteralCstChildren, ArraySubscriptCstChildren, AsofLtJoinCstChildren, AssumeServiceAccountStatementCstChildren, BackupStatementCstChildren, BatchClauseCstChildren, BitAndExpressionCstChildren, BitOrExpressionCstChildren, BitXorExpressionCstChildren, BooleanLiteralCstChildren, CancelQueryStatementCstChildren, CaseExpressionCstChildren, CastDefinitionCstChildren, CastExpressionCstChildren, CheckpointStatementCstChildren, ColumnDefinitionCstChildren, ColumnRefCstChildren, CompileViewStatementCstChildren, ConcatExpressionCstChildren, Ipv4ContainmentExpressionCstChildren, ConvertPartitionTargetCstChildren, CopyCancelCstChildren, CopyFromCstChildren, CopyOptionCstChildren, CopyOptionsCstChildren, CopyStatementCstChildren, CopyToCstChildren, CreateGroupStatementCstChildren, CreateMaterializedViewBodyCstChildren, CreateServiceAccountStatementCstChildren, CreateStatementCstChildren, CreateTableBodyCstChildren, CreateUserStatementCstChildren, CreateViewBodyCstChildren, CteDefinitionCstChildren, DataTypeCstChildren, DeclareAssignmentCstChildren, DeclareClauseCstChildren, DedupClauseCstChildren, DropGroupStatementCstChildren, DropMaterializedViewStatementCstChildren, DropServiceAccountStatementCstChildren, DropStatementCstChildren, DropTableStatementCstChildren, DropUserStatementCstChildren, DropViewStatementCstChildren, DurationExpressionCstChildren, EqualityExpressionCstChildren, ExitServiceAccountStatementCstChildren, ExplainStatementCstChildren, ExpressionCstChildren, FillClauseCstChildren, FillValueCstChildren, FromClauseCstChildren, FromToClauseCstChildren, FunctionCallCstChildren, FunctionNameCstChildren, GrantAssumeServiceAccountStatementCstChildren, GrantStatementCstChildren, GrantTableTargetCstChildren, GroupByClauseCstChildren, IdentifierCstChildren, IdentifierExpressionCstChildren, ImplicitSelectBodyCstChildren, ImplicitSelectStatementCstChildren, IndexDefinitionCstChildren, InsertStatementCstChildren, IntervalValueCstChildren, JoinClauseCstChildren, LatestOnClauseCstChildren, LimitClauseCstChildren, LiteralCstChildren, MaterializedViewPartitionCstChildren, MaterializedViewPeriodCstChildren, MaterializedViewRefreshCstChildren, MultiplicativeExpressionCstChildren, NotExpressionCstChildren, OrExpressionCstChildren, OrderByClauseCstChildren, OrderByItemCstChildren, OverClauseCstChildren, PartitionPeriodCstChildren, PermissionListCstChildren, PermissionTokenCstChildren, PivotAggregationCstChildren, PivotBodyCstChildren, PivotForClauseCstChildren, PivotInValueCstChildren, PivotStatementCstChildren, PrimaryExpressionCstChildren, QualifiedNameCstChildren, QualifiedStarCstChildren, ReindexTableStatementCstChildren, RefreshMaterializedViewStatementCstChildren, RelationalExpressionCstChildren, RemoveUserStatementCstChildren, RenameTableStatementCstChildren, ResumeWalStatementCstChildren, RevokeAssumeServiceAccountStatementCstChildren, RevokeStatementCstChildren, SampleByClauseCstChildren, SelectItemCstChildren, SelectListCstChildren, SelectStatementCstChildren, SetClauseCstChildren, SetExpressionCstChildren, SetOperationCstChildren, SetTypeStatementCstChildren, ShowStatementCstChildren, SimpleSelectCstChildren, SnapshotStatementCstChildren, SpliceJoinCstChildren, StandardJoinCstChildren, StatementCstChildren, StatementsCstChildren, StringOrIdentifierCstChildren, StringOrQualifiedNameCstChildren, TableFunctionCallCstChildren, TableFunctionNameCstChildren, TableNameCstChildren, TableNameOrStringCstChildren, TableParamCstChildren, TableParamNameCstChildren, TableRefCstChildren, TimeUnitCstChildren, TimeZoneValueCstChildren, TruncateTableStatementCstChildren, TypeCastExpressionCstChildren, UnaryExpressionCstChildren, UpdateStatementCstChildren, VacuumTableStatementCstChildren, ValuesClauseCstChildren, ValuesListCstChildren, WhereClauseCstChildren, WindowFrameBoundCstChildren, WindowFrameClauseCstChildren, WindowJoinBoundCstChildren, WindowJoinCstChildren, WindowPartitionByClauseCstChildren, WithClauseCstChildren, WithStatementCstChildren } from "./cst-types";
2
+ import type { AddUserStatementCstChildren, AdditiveExpressionCstChildren, AlignToClauseCstChildren, AlterGroupStatementCstChildren, AlterMaterializedViewActionCstChildren, AlterMaterializedViewStatementCstChildren, AlterServiceAccountStatementCstChildren, AlterStatementCstChildren, AlterTableActionCstChildren, AlterTableStatementCstChildren, AlterUserActionCstChildren, AlterUserStatementCstChildren, AlterViewStatementCstChildren, AndExpressionCstChildren, ArrayBracketBodyCstChildren, ArrayElementCstChildren, ArrayLiteralCstChildren, ArraySubscriptCstChildren, AsofLtJoinCstChildren, AssumeServiceAccountStatementCstChildren, BackupStatementCstChildren, BatchClauseCstChildren, BitAndExpressionCstChildren, BitOrExpressionCstChildren, BitXorExpressionCstChildren, BooleanLiteralCstChildren, CancelQueryStatementCstChildren, CaseExpressionCstChildren, CastDefinitionCstChildren, CastExpressionCstChildren, CheckpointStatementCstChildren, ColumnDefinitionCstChildren, ColumnRefCstChildren, CompileViewStatementCstChildren, ConcatExpressionCstChildren, Ipv4ContainmentExpressionCstChildren, ConvertPartitionTargetCstChildren, CopyCancelCstChildren, CopyFromCstChildren, CopyOptionCstChildren, CopyOptionsCstChildren, CopyStatementCstChildren, CopyToCstChildren, CreateGroupStatementCstChildren, CreateMaterializedViewBodyCstChildren, CreateServiceAccountStatementCstChildren, CreateStatementCstChildren, CreateTableBodyCstChildren, CreateUserStatementCstChildren, CreateViewBodyCstChildren, CteDefinitionCstChildren, DataTypeCstChildren, DeclareAssignmentCstChildren, DeclareClauseCstChildren, DedupClauseCstChildren, DropGroupStatementCstChildren, DropMaterializedViewStatementCstChildren, DropServiceAccountStatementCstChildren, DropStatementCstChildren, DropTableStatementCstChildren, DropUserStatementCstChildren, DropViewStatementCstChildren, DurationExpressionCstChildren, EqualityExpressionCstChildren, ExitServiceAccountStatementCstChildren, ExplainStatementCstChildren, ExpressionCstChildren, FillClauseCstChildren, FillValueCstChildren, FromClauseCstChildren, FromToClauseCstChildren, FunctionCallCstChildren, FunctionNameCstChildren, GrantAssumeServiceAccountStatementCstChildren, GrantStatementCstChildren, GrantTableTargetCstChildren, GroupByClauseCstChildren, IdentifierCstChildren, IdentifierExpressionCstChildren, ImplicitSelectBodyCstChildren, ImplicitSelectStatementCstChildren, IndexDefinitionCstChildren, InsertStatementCstChildren, IntervalValueCstChildren, JoinClauseCstChildren, LatestOnClauseCstChildren, LimitClauseCstChildren, LiteralCstChildren, MaterializedViewPartitionCstChildren, MaterializedViewPeriodCstChildren, MaterializedViewRefreshCstChildren, MultiplicativeExpressionCstChildren, NotExpressionCstChildren, OrExpressionCstChildren, OrderByClauseCstChildren, OrderByItemCstChildren, OverClauseCstChildren, PartitionPeriodCstChildren, PermissionListCstChildren, PermissionTokenCstChildren, PivotAggregationCstChildren, PivotBodyCstChildren, PivotForClauseCstChildren, PivotInValueCstChildren, PivotStatementCstChildren, PrimaryExpressionCstChildren, QualifiedNameCstChildren, QualifiedStarCstChildren, ReindexTableStatementCstChildren, RefreshMaterializedViewStatementCstChildren, RelationalExpressionCstChildren, RemoveUserStatementCstChildren, RenameTableStatementCstChildren, ResumeWalStatementCstChildren, RevokeAssumeServiceAccountStatementCstChildren, RevokeStatementCstChildren, SampleByClauseCstChildren, SelectItemCstChildren, SelectListCstChildren, SelectStatementCstChildren, SetClauseCstChildren, SetExpressionCstChildren, SetOperationCstChildren, SetTypeStatementCstChildren, ShowStatementCstChildren, SimpleSelectCstChildren, SnapshotStatementCstChildren, SpliceJoinCstChildren, HorizonJoinCstChildren, HorizonOffsetCstChildren, StandardJoinCstChildren, StatementCstChildren, StatementsCstChildren, StringOrIdentifierCstChildren, StringOrQualifiedNameCstChildren, TableFunctionCallCstChildren, TableFunctionNameCstChildren, TableNameCstChildren, TableNameOrStringCstChildren, TableParamCstChildren, TableParamNameCstChildren, TableRefCstChildren, TimeUnitCstChildren, TimeZoneValueCstChildren, TruncateTableStatementCstChildren, TypeCastExpressionCstChildren, UnaryExpressionCstChildren, UpdateStatementCstChildren, VacuumTableStatementCstChildren, ValuesClauseCstChildren, ValuesListCstChildren, WhereClauseCstChildren, WindowFrameBoundCstChildren, WindowFrameClauseCstChildren, WindowJoinBoundCstChildren, WindowJoinCstChildren, WindowPartitionByClauseCstChildren, WithClauseCstChildren, WithStatementCstChildren } from "./cst-types";
3
3
  declare const BaseVisitor: new (...args: any[]) => import("chevrotain").ICstVisitor<any, any>;
4
4
  declare class QuestDBVisitor extends BaseVisitor {
5
5
  constructor();
@@ -25,6 +25,8 @@ declare class QuestDBVisitor extends BaseVisitor {
25
25
  asofLtJoin(ctx: AsofLtJoinCstChildren): AST.JoinClause;
26
26
  spliceJoin(ctx: SpliceJoinCstChildren): AST.JoinClause;
27
27
  windowJoin(ctx: WindowJoinCstChildren): AST.JoinClause;
28
+ horizonJoin(ctx: HorizonJoinCstChildren): AST.JoinClause;
29
+ horizonOffset(ctx: HorizonOffsetCstChildren): string;
28
30
  standardJoin(ctx: StandardJoinCstChildren): AST.JoinClause;
29
31
  windowJoinBound(ctx: WindowJoinBoundCstChildren): AST.WindowJoinBound;
30
32
  durationExpression(ctx: DurationExpressionCstChildren): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@questdb/sql-parser",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "SQL parser for QuestDB syntax using Chevrotain",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",