dt-sql-parser 4.5.1-beta.3 → 4.5.2-beta.0

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.
Files changed (51) hide show
  1. package/dist/lib/SQLParserBase.d.ts +9 -0
  2. package/dist/lib/SQLParserBase.js +15 -0
  3. package/dist/lib/generic/GenericSqlListener.d.ts +11 -0
  4. package/dist/lib/generic/GenericSqlParser.d.ts +61 -47
  5. package/dist/lib/generic/GenericSqlParser.js +1047 -949
  6. package/dist/lib/generic/GenericSqlVisitor.d.ts +7 -0
  7. package/dist/lib/hive/HiveSqlParser.d.ts +54 -30
  8. package/dist/lib/hive/HiveSqlParser.js +5633 -5467
  9. package/dist/lib/hive/HiveSqlParserListener.d.ts +22 -0
  10. package/dist/lib/hive/HiveSqlParserVisitor.d.ts +14 -0
  11. package/dist/lib/mysql/MySqlParser.d.ts +34 -9
  12. package/dist/lib/mysql/MySqlParser.js +5697 -5550
  13. package/dist/lib/mysql/MySqlParserListener.d.ts +33 -5
  14. package/dist/lib/mysql/MySqlParserVisitor.d.ts +20 -3
  15. package/dist/lib/postgresql/PostgreSqlParser.d.ts +200 -166
  16. package/dist/lib/postgresql/PostgreSqlParser.js +10389 -10136
  17. package/dist/lib/postgresql/PostgreSqlParserListener.d.ts +31 -5
  18. package/dist/lib/postgresql/PostgreSqlParserVisitor.d.ts +19 -3
  19. package/dist/lib/trino/TrinoSqlListener.d.ts +33 -0
  20. package/dist/lib/trino/TrinoSqlParser.d.ts +157 -115
  21. package/dist/lib/trino/TrinoSqlParser.js +4775 -4494
  22. package/dist/lib/trino/TrinoSqlVisitor.d.ts +21 -0
  23. package/dist/parser/common/basicSQL.d.ts +3 -0
  24. package/dist/parser/common/basicSQL.js +47 -1
  25. package/dist/parser/common/entityCollector.d.ts +37 -2
  26. package/dist/parser/common/entityCollector.js +303 -2
  27. package/dist/parser/flink/flinkEntityCollector.d.ts +2 -1
  28. package/dist/parser/flink/flinkEntityCollector.js +4 -0
  29. package/dist/parser/flink/index.js +1 -1
  30. package/dist/parser/generic/genericEntityCollector.d.ts +7 -2
  31. package/dist/parser/generic/genericEntityCollector.js +65 -15
  32. package/dist/parser/generic/index.js +13 -1
  33. package/dist/parser/hive/hiveEntityCollector.d.ts +2 -1
  34. package/dist/parser/hive/hiveEntityCollector.js +5 -0
  35. package/dist/parser/hive/index.js +1 -1
  36. package/dist/parser/impala/impalaEntityCollector.d.ts +2 -1
  37. package/dist/parser/impala/impalaEntityCollector.js +4 -0
  38. package/dist/parser/impala/index.js +1 -1
  39. package/dist/parser/mysql/index.js +15 -1
  40. package/dist/parser/mysql/mysqlEntityCollector.d.ts +3 -1
  41. package/dist/parser/mysql/mysqlEntityCollector.js +24 -0
  42. package/dist/parser/postgresql/index.js +3 -2
  43. package/dist/parser/postgresql/postgreEntityCollector.d.ts +3 -1
  44. package/dist/parser/postgresql/postgreEntityCollector.js +10 -0
  45. package/dist/parser/spark/index.js +1 -1
  46. package/dist/parser/spark/sparkEntityCollector.d.ts +2 -1
  47. package/dist/parser/spark/sparkEntityCollector.js +5 -0
  48. package/dist/parser/trino/index.js +4 -2
  49. package/dist/parser/trino/trinoEntityCollector.d.ts +2 -1
  50. package/dist/parser/trino/trinoEntityCollector.js +5 -0
  51. package/package.json +1 -1
@@ -17,4 +17,13 @@ export declare abstract class SQLParserBase<T = antlr.ParserRuleContext> extends
17
17
  * prediction in non-entity-collecting contexts.
18
18
  */
19
19
  shouldMatchEmpty(ruleName?: string): boolean;
20
+ /**
21
+ * Semantic predicate to check whether the previous token and the next token
22
+ * are adjacent (no whitespace in between).
23
+ *
24
+ * Used to support hyphens inside Hive SET config property names, e.g.
25
+ * `set tez.grouping.max-size = 1`, while still rejecting invalid spacing
26
+ * like `set hive.a - b = 1`.
27
+ */
28
+ isNextTokenAdjacent(): boolean;
20
29
  }
@@ -46,4 +46,19 @@ export class SQLParserBase extends antlr.Parser {
46
46
  // This allows ANTLR to report errors naturally
47
47
  return false;
48
48
  }
49
+ /**
50
+ * Semantic predicate to check whether the previous token and the next token
51
+ * are adjacent (no whitespace in between).
52
+ *
53
+ * Used to support hyphens inside Hive SET config property names, e.g.
54
+ * `set tez.grouping.max-size = 1`, while still rejecting invalid spacing
55
+ * like `set hive.a - b = 1`.
56
+ */
57
+ isNextTokenAdjacent() {
58
+ const previousToken = this.tokenStream.LT(-1);
59
+ const nextToken = this.tokenStream.LT(1);
60
+ return (previousToken !== null &&
61
+ nextToken !== null &&
62
+ previousToken.stop + 1 === nextToken.start);
63
+ }
49
64
  }
@@ -12,6 +12,7 @@ import { DropTableContext } from "./GenericSqlParser.js";
12
12
  import { QueryStatementContext } from "./GenericSqlParser.js";
13
13
  import { WithClauseContext } from "./GenericSqlParser.js";
14
14
  import { NamedQueryContext } from "./GenericSqlParser.js";
15
+ import { CteColumnListContext } from "./GenericSqlParser.js";
15
16
  import { QueryNoWithContext } from "./GenericSqlParser.js";
16
17
  import { QueryTermContext } from "./GenericSqlParser.js";
17
18
  import { QueryPrimaryContext } from "./GenericSqlParser.js";
@@ -238,6 +239,16 @@ export declare class GenericSqlListener implements ParseTreeListener {
238
239
  * @param ctx the parse tree
239
240
  */
240
241
  exitNamedQuery?: (ctx: NamedQueryContext) => void;
242
+ /**
243
+ * Enter a parse tree produced by `GenericSqlParser.cteColumnList`.
244
+ * @param ctx the parse tree
245
+ */
246
+ enterCteColumnList?: (ctx: CteColumnListContext) => void;
247
+ /**
248
+ * Exit a parse tree produced by `GenericSqlParser.cteColumnList`.
249
+ * @param ctx the parse tree
250
+ */
251
+ exitCteColumnList?: (ctx: CteColumnListContext) => void;
241
252
  /**
242
253
  * Enter a parse tree produced by `GenericSqlParser.queryNoWith`.
243
254
  * @param ctx the parse tree
@@ -133,53 +133,54 @@ export declare class GenericSqlParser extends SQLParserBase {
133
133
  static readonly RULE_queryStatement = 4;
134
134
  static readonly RULE_withClause = 5;
135
135
  static readonly RULE_namedQuery = 6;
136
- static readonly RULE_queryNoWith = 7;
137
- static readonly RULE_queryTerm = 8;
138
- static readonly RULE_queryPrimary = 9;
139
- static readonly RULE_querySpecification = 10;
140
- static readonly RULE_setQuantifier = 11;
141
- static readonly RULE_selectItem = 12;
142
- static readonly RULE_fromClause = 13;
143
- static readonly RULE_relation = 14;
144
- static readonly RULE_joinType = 15;
145
- static readonly RULE_aliasedRelation = 16;
146
- static readonly RULE_relationPrimary = 17;
147
- static readonly RULE_whereClause = 18;
148
- static readonly RULE_groupByClause = 19;
149
- static readonly RULE_havingClause = 20;
150
- static readonly RULE_orderByClause = 21;
151
- static readonly RULE_sortItem = 22;
152
- static readonly RULE_limitClause = 23;
153
- static readonly RULE_insertStatement = 24;
154
- static readonly RULE_columnList = 25;
155
- static readonly RULE_updateStatement = 26;
156
- static readonly RULE_updateAssignment = 27;
157
- static readonly RULE_deleteStatement = 28;
158
- static readonly RULE_createTableStatement = 29;
159
- static readonly RULE_tableElement = 30;
160
- static readonly RULE_columnDefinition = 31;
161
- static readonly RULE_tableConstraint = 32;
162
- static readonly RULE_alterTableStatement = 33;
163
- static readonly RULE_dropTableStatement = 34;
164
- static readonly RULE_expression = 35;
165
- static readonly RULE_booleanExpression = 36;
166
- static readonly RULE_predicatedExpression = 37;
167
- static readonly RULE_predicate = 38;
168
- static readonly RULE_comparisonOperator = 39;
169
- static readonly RULE_valueExpression = 40;
170
- static readonly RULE_primaryExpression = 41;
171
- static readonly RULE_whenClause = 42;
172
- static readonly RULE_subqueryExpression = 43;
173
- static readonly RULE_dataType = 44;
174
- static readonly RULE_properties = 45;
175
- static readonly RULE_property = 46;
176
- static readonly RULE_literal = 47;
177
- static readonly RULE_identifier = 48;
178
- static readonly RULE_qualifiedName = 49;
179
- static readonly RULE_columnRef = 50;
180
- static readonly RULE_tableName = 51;
181
- static readonly RULE_tableNameCreate = 52;
182
- static readonly RULE_nonReserved = 53;
136
+ static readonly RULE_cteColumnList = 7;
137
+ static readonly RULE_queryNoWith = 8;
138
+ static readonly RULE_queryTerm = 9;
139
+ static readonly RULE_queryPrimary = 10;
140
+ static readonly RULE_querySpecification = 11;
141
+ static readonly RULE_setQuantifier = 12;
142
+ static readonly RULE_selectItem = 13;
143
+ static readonly RULE_fromClause = 14;
144
+ static readonly RULE_relation = 15;
145
+ static readonly RULE_joinType = 16;
146
+ static readonly RULE_aliasedRelation = 17;
147
+ static readonly RULE_relationPrimary = 18;
148
+ static readonly RULE_whereClause = 19;
149
+ static readonly RULE_groupByClause = 20;
150
+ static readonly RULE_havingClause = 21;
151
+ static readonly RULE_orderByClause = 22;
152
+ static readonly RULE_sortItem = 23;
153
+ static readonly RULE_limitClause = 24;
154
+ static readonly RULE_insertStatement = 25;
155
+ static readonly RULE_columnList = 26;
156
+ static readonly RULE_updateStatement = 27;
157
+ static readonly RULE_updateAssignment = 28;
158
+ static readonly RULE_deleteStatement = 29;
159
+ static readonly RULE_createTableStatement = 30;
160
+ static readonly RULE_tableElement = 31;
161
+ static readonly RULE_columnDefinition = 32;
162
+ static readonly RULE_tableConstraint = 33;
163
+ static readonly RULE_alterTableStatement = 34;
164
+ static readonly RULE_dropTableStatement = 35;
165
+ static readonly RULE_expression = 36;
166
+ static readonly RULE_booleanExpression = 37;
167
+ static readonly RULE_predicatedExpression = 38;
168
+ static readonly RULE_predicate = 39;
169
+ static readonly RULE_comparisonOperator = 40;
170
+ static readonly RULE_valueExpression = 41;
171
+ static readonly RULE_primaryExpression = 42;
172
+ static readonly RULE_whenClause = 43;
173
+ static readonly RULE_subqueryExpression = 44;
174
+ static readonly RULE_dataType = 45;
175
+ static readonly RULE_properties = 46;
176
+ static readonly RULE_property = 47;
177
+ static readonly RULE_literal = 48;
178
+ static readonly RULE_identifier = 49;
179
+ static readonly RULE_qualifiedName = 50;
180
+ static readonly RULE_columnRef = 51;
181
+ static readonly RULE_tableName = 52;
182
+ static readonly RULE_tableNameCreate = 53;
183
+ static readonly RULE_nonReserved = 54;
183
184
  static readonly literalNames: (string | null)[];
184
185
  static readonly symbolicNames: (string | null)[];
185
186
  static readonly ruleNames: string[];
@@ -197,6 +198,7 @@ export declare class GenericSqlParser extends SQLParserBase {
197
198
  queryStatement(): QueryStatementContext;
198
199
  withClause(): WithClauseContext;
199
200
  namedQuery(): NamedQueryContext;
201
+ cteColumnList(): CteColumnListContext;
200
202
  queryNoWith(): QueryNoWithContext;
201
203
  queryTerm(): QueryTermContext;
202
204
  queryPrimary(): QueryPrimaryContext;
@@ -365,6 +367,16 @@ export declare class NamedQueryContext extends antlr.ParserRuleContext {
365
367
  KW_AS(): antlr.TerminalNode;
366
368
  queryStatement(): QueryStatementContext;
367
369
  identifier(): IdentifierContext;
370
+ cteColumnList(): CteColumnListContext | null;
371
+ get ruleIndex(): number;
372
+ enterRule(listener: GenericSqlListener): void;
373
+ exitRule(listener: GenericSqlListener): void;
374
+ accept<Result>(visitor: GenericSqlVisitor<Result>): Result | null;
375
+ }
376
+ export declare class CteColumnListContext extends antlr.ParserRuleContext {
377
+ constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
378
+ identifier(): IdentifierContext[];
379
+ identifier(i: number): IdentifierContext | null;
368
380
  get ruleIndex(): number;
369
381
  enterRule(listener: GenericSqlListener): void;
370
382
  exitRule(listener: GenericSqlListener): void;
@@ -431,6 +443,7 @@ export declare class SetQuantifierContext extends antlr.ParserRuleContext {
431
443
  accept<Result>(visitor: GenericSqlVisitor<Result>): Result | null;
432
444
  }
433
445
  export declare class SelectItemContext extends antlr.ParserRuleContext {
446
+ _alias?: IdentifierContext;
434
447
  constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
435
448
  expression(): ExpressionContext | null;
436
449
  identifier(): IdentifierContext | null;
@@ -493,6 +506,7 @@ export declare class JoinTypeContext extends antlr.ParserRuleContext {
493
506
  accept<Result>(visitor: GenericSqlVisitor<Result>): Result | null;
494
507
  }
495
508
  export declare class AliasedRelationContext extends antlr.ParserRuleContext {
509
+ _alias?: IdentifierContext;
496
510
  constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
497
511
  relationPrimary(): RelationPrimaryContext;
498
512
  identifier(): IdentifierContext | null;