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

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 (33) hide show
  1. package/dist/lib/SQLParserBase.d.ts +9 -0
  2. package/dist/lib/SQLParserBase.js +15 -0
  3. package/dist/lib/hive/HiveSqlParser.d.ts +54 -30
  4. package/dist/lib/hive/HiveSqlParser.js +5633 -5467
  5. package/dist/lib/hive/HiveSqlParserListener.d.ts +22 -0
  6. package/dist/lib/hive/HiveSqlParserVisitor.d.ts +14 -0
  7. package/dist/lib/mysql/MySqlParser.d.ts +31 -8
  8. package/dist/lib/mysql/MySqlParser.js +5786 -5659
  9. package/dist/lib/mysql/MySqlParserListener.d.ts +33 -5
  10. package/dist/lib/mysql/MySqlParserVisitor.d.ts +20 -3
  11. package/dist/lib/postgresql/PostgreSqlParser.d.ts +19 -2
  12. package/dist/lib/postgresql/PostgreSqlParser.js +1857 -1756
  13. package/dist/lib/postgresql/PostgreSqlParserListener.d.ts +20 -5
  14. package/dist/lib/postgresql/PostgreSqlParserVisitor.d.ts +12 -3
  15. package/dist/lib/trino/TrinoSqlListener.d.ts +33 -0
  16. package/dist/lib/trino/TrinoSqlParser.d.ts +155 -114
  17. package/dist/lib/trino/TrinoSqlParser.js +4747 -4494
  18. package/dist/lib/trino/TrinoSqlVisitor.d.ts +21 -0
  19. package/dist/parser/common/basicSQL.d.ts +3 -0
  20. package/dist/parser/common/basicSQL.js +47 -1
  21. package/dist/parser/flink/index.js +1 -1
  22. package/dist/parser/generic/index.js +1 -1
  23. package/dist/parser/hive/index.js +1 -1
  24. package/dist/parser/impala/index.js +1 -1
  25. package/dist/parser/mysql/index.js +15 -1
  26. package/dist/parser/mysql/mysqlEntityCollector.d.ts +2 -1
  27. package/dist/parser/mysql/mysqlEntityCollector.js +5 -0
  28. package/dist/parser/postgresql/index.js +3 -2
  29. package/dist/parser/postgresql/postgreEntityCollector.d.ts +2 -1
  30. package/dist/parser/postgresql/postgreEntityCollector.js +5 -0
  31. package/dist/parser/spark/index.js +1 -1
  32. package/dist/parser/trino/index.js +4 -2
  33. package/package.json +1 -1
@@ -138,6 +138,8 @@ import { RelationDefaultContext } from "./TrinoSqlParser.js";
138
138
  import { JoinRelationContext } from "./TrinoSqlParser.js";
139
139
  import { JoinTypeContext } from "./TrinoSqlParser.js";
140
140
  import { JoinCriteriaContext } from "./TrinoSqlParser.js";
141
+ import { JoinColumnEqualityContext } from "./TrinoSqlParser.js";
142
+ import { JoinColumnReferenceContext } from "./TrinoSqlParser.js";
141
143
  import { SampledRelationContext } from "./TrinoSqlParser.js";
142
144
  import { SampleTypeContext } from "./TrinoSqlParser.js";
143
145
  import { TrimsSpecificationContext } from "./TrinoSqlParser.js";
@@ -356,6 +358,7 @@ import { CatalogNameCreateContext } from "./TrinoSqlParser.js";
356
358
  import { FunctionNameContext } from "./TrinoSqlParser.js";
357
359
  import { FunctionNameCreateContext } from "./TrinoSqlParser.js";
358
360
  import { ColumnRefContext } from "./TrinoSqlParser.js";
361
+ import { EmptyColumnContext } from "./TrinoSqlParser.js";
359
362
  import { ColumnNameContext } from "./TrinoSqlParser.js";
360
363
  import { ColumnNameCreateContext } from "./TrinoSqlParser.js";
361
364
  import { QualifiedNameContext } from "./TrinoSqlParser.js";
@@ -1320,6 +1323,18 @@ export declare class TrinoSqlVisitor<Result> extends AbstractParseTreeVisitor<Re
1320
1323
  * @return the visitor result
1321
1324
  */
1322
1325
  visitJoinCriteria?: (ctx: JoinCriteriaContext) => Result;
1326
+ /**
1327
+ * Visit a parse tree produced by `TrinoSqlParser.joinColumnEquality`.
1328
+ * @param ctx the parse tree
1329
+ * @return the visitor result
1330
+ */
1331
+ visitJoinColumnEquality?: (ctx: JoinColumnEqualityContext) => Result;
1332
+ /**
1333
+ * Visit a parse tree produced by `TrinoSqlParser.joinColumnReference`.
1334
+ * @param ctx the parse tree
1335
+ * @return the visitor result
1336
+ */
1337
+ visitJoinColumnReference?: (ctx: JoinColumnReferenceContext) => Result;
1323
1338
  /**
1324
1339
  * Visit a parse tree produced by `TrinoSqlParser.sampledRelation`.
1325
1340
  * @param ctx the parse tree
@@ -2769,6 +2784,12 @@ export declare class TrinoSqlVisitor<Result> extends AbstractParseTreeVisitor<Re
2769
2784
  * @return the visitor result
2770
2785
  */
2771
2786
  visitColumnRef?: (ctx: ColumnRefContext) => Result;
2787
+ /**
2788
+ * Visit a parse tree produced by `TrinoSqlParser.emptyColumn`.
2789
+ * @param ctx the parse tree
2790
+ * @return the visitor result
2791
+ */
2792
+ visitEmptyColumn?: (ctx: EmptyColumnContext) => Result;
2772
2793
  /**
2773
2794
  * Visit a parse tree produced by `TrinoSqlParser.columnName`.
2774
2795
  * @param ctx the parse tree
@@ -45,6 +45,7 @@ export declare abstract class BasicSQL<L extends Lexer = Lexer, PRC extends Pars
45
45
  * @param caretTokenIndex tokenIndex of caretPosition
46
46
  */
47
47
  protected abstract processCandidates(candidates: CandidatesCollection, allTokens: Token[], caretTokenIndex: number): Suggestions<Token>;
48
+ protected getCandidateTokenRanges(candidates: CandidatesCollection, candidateStartTokenIndex: number, allTokens: Token[], caretTokenIndex: number): Token[];
48
49
  /**
49
50
  * Get a new splitListener instance.
50
51
  */
@@ -169,6 +170,8 @@ export declare abstract class BasicSQL<L extends Lexer = Lexer, PRC extends Pars
169
170
  } | null;
170
171
  /**
171
172
  * Get the minimum statement tree for collecting completion candidates
173
+ * Each supported grammar exposes one top-level statement per direct program child
174
+ * Keep the lookup shallow to avoid selecting nested statements or subqueries
172
175
  */
173
176
  private getSuggestionParseTree;
174
177
  /**
@@ -1,5 +1,5 @@
1
1
  import { CodeCompletionCore } from 'antlr4-c3';
2
- import { CharStreams, CommonTokenStream, ParserRuleContext, ParseTreeWalker, PredictionMode, } from 'antlr4ng';
2
+ import { CharStreams, CommonTokenStream, ParserRuleContext, ParseTreeWalker, PredictionMode, Token, } from 'antlr4ng';
3
3
  import { ErrorStrategy } from './errorStrategy';
4
4
  import { findCaretTokenIndex } from './findCaretTokenIndex';
5
5
  import { ctxToText, tokenToWord } from './textAndWord';
@@ -17,6 +17,49 @@ export class BasicSQL {
17
17
  };
18
18
  this.locale = 'en_US';
19
19
  }
20
+ getCandidateTokenRanges(candidates, candidateStartTokenIndex, allTokens, caretTokenIndex) {
21
+ var _a;
22
+ // antlr4-c3 may return both entity and alias candidates; use the nearest candidate's start index as boundary
23
+ const endTokenIndex = Array.from(candidates.rules.values()).reduce((nearestStartTokenIndex, candidateRule) => {
24
+ if (candidateRule.startTokenIndex <= candidateStartTokenIndex) {
25
+ return nearestStartTokenIndex;
26
+ }
27
+ return Math.min(nearestStartTokenIndex, candidateRule.startTokenIndex);
28
+ }, caretTokenIndex + 1);
29
+ const previousVisibleToken = allTokens
30
+ .slice(candidateStartTokenIndex, endTokenIndex)
31
+ .reverse()
32
+ .find((token) => token.channel === Token.DEFAULT_CHANNEL);
33
+ const visibleTokenIndexes = allTokens
34
+ .slice(endTokenIndex, caretTokenIndex + 1)
35
+ .reduce((indexes, token, offset) => {
36
+ if (token.channel === Token.DEFAULT_CHANNEL) {
37
+ indexes.push(endTokenIndex + offset);
38
+ }
39
+ return indexes;
40
+ }, []);
41
+ const firstVisibleToken = allTokens[visibleTokenIndexes[0]];
42
+ let rangeEndTokenIndex = endTokenIndex;
43
+ // candidate boundary may fall inside a multi-level qualified name; extend along the identifier and dot chain
44
+ if ((previousVisibleToken === null || previousVisibleToken === void 0 ? void 0 : previousVisibleToken.text) === '.' || (firstVisibleToken === null || firstVisibleToken === void 0 ? void 0 : firstVisibleToken.text) === '.') {
45
+ let visibleTokenOffset = 0;
46
+ if ((previousVisibleToken === null || previousVisibleToken === void 0 ? void 0 : previousVisibleToken.text) === '.' && firstVisibleToken) {
47
+ rangeEndTokenIndex = visibleTokenIndexes[visibleTokenOffset] + 1;
48
+ visibleTokenOffset += 1;
49
+ }
50
+ while (((_a = allTokens[visibleTokenIndexes[visibleTokenOffset]]) === null || _a === void 0 ? void 0 : _a.text) === '.') {
51
+ rangeEndTokenIndex = visibleTokenIndexes[visibleTokenOffset] + 1;
52
+ visibleTokenOffset += 1;
53
+ if (visibleTokenOffset < visibleTokenIndexes.length) {
54
+ rangeEndTokenIndex = visibleTokenIndexes[visibleTokenOffset] + 1;
55
+ visibleTokenOffset += 1;
56
+ }
57
+ }
58
+ }
59
+ return allTokens
60
+ .slice(candidateStartTokenIndex, rangeEndTokenIndex)
61
+ .filter((token) => token.channel === Token.DEFAULT_CHANNEL);
62
+ }
20
63
  /**
21
64
  * Create an antlr4 lexer from input.
22
65
  * @param input string
@@ -387,6 +430,8 @@ export class BasicSQL {
387
430
  }
388
431
  /**
389
432
  * Get the minimum statement tree for collecting completion candidates
433
+ * Each supported grammar exposes one top-level statement per direct program child
434
+ * Keep the lookup shallow to avoid selecting nested statements or subqueries
390
435
  */
391
436
  getSuggestionParseTree(parseTree, caretTokenIndex) {
392
437
  var _a, _b, _c;
@@ -421,6 +466,7 @@ export class BasicSQL {
421
466
  const suggestionParseTree = this.getSuggestionParseTree(parseTree, caretTokenIndex);
422
467
  if (suggestionParseTree === parseTree)
423
468
  return candidates;
469
+ // Keep the program candidates for outer rule paths and use statement candidates for isolation
424
470
  const statementCore = new CodeCompletionCore(parser);
425
471
  statementCore.preferredRules = this.preferredRules;
426
472
  const statementCandidates = statementCore.collectCandidates(caretTokenIndex, suggestionParseTree);
@@ -67,7 +67,7 @@ export class FlinkSQL extends BasicSQL {
67
67
  const keywords = [];
68
68
  for (let candidate of candidates.rules) {
69
69
  const [ruleType, candidateRule] = candidate;
70
- const tokenRanges = allTokens.slice(candidateRule.startTokenIndex, caretTokenIndex + 1);
70
+ const tokenRanges = this.getCandidateTokenRanges(candidates, candidateRule.startTokenIndex, allTokens, caretTokenIndex);
71
71
  let syntaxContextType = void 0;
72
72
  switch (ruleType) {
73
73
  case FlinkSqlParser.RULE_catalogPath: {
@@ -53,7 +53,7 @@ export class GenericSQL extends BasicSQL {
53
53
  const keywords = [];
54
54
  for (const candidate of candidates.rules) {
55
55
  const [ruleType, candidateRule] = candidate;
56
- const tokenRanges = allTokens.slice(candidateRule.startTokenIndex, caretTokenIndex + 1);
56
+ const tokenRanges = this.getCandidateTokenRanges(candidates, candidateRule.startTokenIndex, allTokens, caretTokenIndex);
57
57
  let syntaxContextType = void 0;
58
58
  switch (ruleType) {
59
59
  case GenericSqlParser.RULE_tableName: {
@@ -55,7 +55,7 @@ export class HiveSQL extends BasicSQL {
55
55
  const keywords = [];
56
56
  for (let candidate of candidates.rules) {
57
57
  const [ruleType, candidateRule] = candidate;
58
- const tokenRanges = allTokens.slice(candidateRule.startTokenIndex, caretTokenIndex + 1);
58
+ const tokenRanges = this.getCandidateTokenRanges(candidates, candidateRule.startTokenIndex, allTokens, caretTokenIndex);
59
59
  let syntaxContextType = void 0;
60
60
  switch (ruleType) {
61
61
  case HiveSqlParser.RULE_dbSchemaName: {
@@ -54,7 +54,7 @@ export class ImpalaSQL extends BasicSQL {
54
54
  const keywords = [];
55
55
  for (let candidate of candidates.rules) {
56
56
  const [ruleType, candidateRule] = candidate;
57
- const tokenRanges = allTokens.slice(candidateRule.startTokenIndex, caretTokenIndex + 1);
57
+ const tokenRanges = this.getCandidateTokenRanges(candidates, candidateRule.startTokenIndex, allTokens, caretTokenIndex);
58
58
  let syntaxContextType = void 0;
59
59
  switch (ruleType) {
60
60
  case ImpalaSqlParser.RULE_functionNameCreate: {
@@ -8,6 +8,13 @@ import { MysqlErrorListener } from './mysqlErrorListener';
8
8
  import { MysqlSplitListener } from './mysqlSplitListener';
9
9
  import { MySqlSemanticContextCollector } from '../mysql/mysqlSemanticContextCollector';
10
10
  export { MySqlEntityCollector, MysqlSplitListener };
11
+ const ALLOW_EMPTY_COLUMN_PARENT_RULES = new Set([
12
+ MySqlParser.RULE_joinSpec,
13
+ MySqlParser.RULE_fromClause,
14
+ MySqlParser.RULE_orderByExpression,
15
+ MySqlParser.RULE_groupByItem,
16
+ MySqlParser.RULE_havingClause,
17
+ ]);
11
18
  export class MySQL extends BasicSQL {
12
19
  constructor() {
13
20
  super(...arguments);
@@ -26,6 +33,7 @@ export class MySQL extends BasicSQL {
26
33
  MySqlParser.RULE_functionNameCreate,
27
34
  MySqlParser.RULE_columnName,
28
35
  MySqlParser.RULE_columnNamePath,
36
+ MySqlParser.RULE_columnNamePathAllowEmpty,
29
37
  MySqlParser.RULE_columnNameCreate,
30
38
  ...this.excludeKeywordRules,
31
39
  ]);
@@ -54,7 +62,7 @@ export class MySQL extends BasicSQL {
54
62
  const keywords = [];
55
63
  for (const candidate of candidates.rules) {
56
64
  const [ruleType, candidateRule] = candidate;
57
- const tokenRanges = allTokens.slice(candidateRule.startTokenIndex, caretTokenIndex + 1);
65
+ const tokenRanges = this.getCandidateTokenRanges(candidates, candidateRule.startTokenIndex, allTokens, caretTokenIndex);
58
66
  let syntaxContextType = void 0;
59
67
  switch (ruleType) {
60
68
  case MySqlParser.RULE_databaseName: {
@@ -94,6 +102,12 @@ export class MySQL extends BasicSQL {
94
102
  syntaxContextType = EntityContextType.COLUMN;
95
103
  break;
96
104
  }
105
+ case MySqlParser.RULE_columnNamePathAllowEmpty: {
106
+ if (candidateRule.ruleList.some((rule) => ALLOW_EMPTY_COLUMN_PARENT_RULES.has(rule))) {
107
+ syntaxContextType = EntityContextType.COLUMN;
108
+ }
109
+ break;
110
+ }
97
111
  case MySqlParser.RULE_columnNameCreate: {
98
112
  syntaxContextType = EntityContextType.COLUMN_CREATE;
99
113
  break;
@@ -1,4 +1,4 @@
1
- import { ColumnCreateTableContext, ColumnNameCreateContext, CopyCreateTableContext, CreateDatabaseContext, CreateFunctionContext, CreateFunctionLoadableContext, CreateViewContext, DatabaseNameContext, DatabaseNameCreateContext, FunctionNameCreateContext, InsertStatementContext, QueryCreateTableContext, SelectElementsContext, SelectExpressionElementContext, SelectLiteralColumnNameContext, SelectStatementContext, SingleStatementContext, TableNameContext, TableNameCreateContext, ViewNameContext, ViewNameCreateContext, TableAllColumnsContext, AtomSubQueryTableSourceContext, PureAllColumnsContext, SelectElement_dot_emptyContext } from '../../lib/mysql/MySqlParser';
1
+ import { ColumnCreateTableContext, ColumnNameCreateContext, CopyCreateTableContext, CreateDatabaseContext, CreateFunctionContext, CreateFunctionLoadableContext, CreateViewContext, DatabaseNameContext, DatabaseNameCreateContext, FunctionNameCreateContext, InsertStatementContext, QueryCreateTableContext, SelectElementsContext, SelectExpressionElementContext, SelectLiteralColumnNameContext, SelectStatementContext, SingleStatementContext, TableNameContext, TableNameCreateContext, ViewNameContext, ViewNameCreateContext, TableAllColumnsContext, AtomSubQueryTableSourceContext, PureAllColumnsContext, SelectElement_dot_emptyContext, ColumnNamePath_dot_emptyContext } from '../../lib/mysql/MySqlParser';
2
2
  import type { MySqlParserListener } from '../../lib/mysql/MySqlParserListener';
3
3
  import { EntityCollector } from '../common/entityCollector';
4
4
  export declare class MySqlEntityCollector extends EntityCollector implements MySqlParserListener {
@@ -19,6 +19,7 @@ export declare class MySqlEntityCollector extends EntityCollector implements MyS
19
19
  exitPureAllColumns(ctx: PureAllColumnsContext): void;
20
20
  exitSelectLiteralColumnName(ctx: SelectLiteralColumnNameContext): void;
21
21
  exitSelectElement_dot_empty(ctx: SelectElement_dot_emptyContext): void;
22
+ exitColumnNamePath_dot_empty(ctx: ColumnNamePath_dot_emptyContext): void;
22
23
  exitSelectExpressionElement(ctx: SelectExpressionElementContext): void;
23
24
  /** ===== Statement begin */
24
25
  enterSingleStatement(ctx: SingleStatementContext): void;
@@ -98,6 +98,11 @@ export class MySqlEntityCollector extends EntityCollector {
98
98
  declareType: ColumnDeclareType.LITERAL,
99
99
  });
100
100
  }
101
+ exitColumnNamePath_dot_empty(ctx) {
102
+ this.pushEntity(ctx, EntityContextType.COLUMN, [], {
103
+ declareType: ColumnDeclareType.LITERAL,
104
+ });
105
+ }
101
106
  exitSelectExpressionElement(ctx) {
102
107
  this.pushEntity(ctx, EntityContextType.COLUMN, [
103
108
  {
@@ -64,7 +64,7 @@ export class PostgreSQL extends BasicSQL {
64
64
  const keywords = [];
65
65
  for (let candidate of candidates.rules) {
66
66
  const [ruleType, candidateRule] = candidate;
67
- const tokenRanges = allTokens.slice(candidateRule.startTokenIndex, caretTokenIndex + 1);
67
+ const tokenRanges = this.getCandidateTokenRanges(candidates, candidateRule.startTokenIndex, allTokens, caretTokenIndex);
68
68
  let syntaxContextType = void 0;
69
69
  switch (ruleType) {
70
70
  case PostgreSqlParser.RULE_tableNameCreate: {
@@ -130,7 +130,8 @@ export class PostgreSQL extends BasicSQL {
130
130
  candidateRule.ruleList.includes(PostgreSqlParser.RULE_whereClause) ||
131
131
  candidateRule.ruleList.includes(PostgreSqlParser.RULE_havingClause) ||
132
132
  candidateRule.ruleList.includes(PostgreSqlParser.RULE_windowClause) ||
133
- candidateRule.ruleList.includes(PostgreSqlParser.RULE_triggerWhen)) {
133
+ candidateRule.ruleList.includes(PostgreSqlParser.RULE_triggerWhen) ||
134
+ candidateRule.ruleList.includes(PostgreSqlParser.RULE_joinQual)) {
134
135
  syntaxContextType = EntityContextType.COLUMN;
135
136
  }
136
137
  break;
@@ -1,4 +1,4 @@
1
- import { type AlterTableStmtContext, type ColumnCreateTableContext, type ColumnNameCreateContext, type CreateDatabaseContext, type CreateForeignTableContext, type CreateFunctionStmtContext, type CreateMaterializedViewContext, type CreatePartitionForeignTableContext, type CreateViewContext, type DatabaseNameContext, type DatabaseNameCreateContext, FuncTableContext, type FunctionNameCreateContext, type InsertStatementContext, type ProcedureNameContext, type ProcedureNameCreateContext, type QueryCreateTableContext, SelectExpressionColumnNameContext, SelectLiteralColumnNameContext, SelectNoParensContext, type SelectStatementContext, SelectWithParensContext, type SingleStmtContext, TableAllColumnsContext, type TableNameContext, type TableNameCreateContext, Target_dot_emptyContext, Target_emptyContext, TargetListContext, type ViewNameContext, type ViewNameCreateContext, XmlTableContext } from '../../lib/postgresql/PostgreSqlParser';
1
+ import { type AlterTableStmtContext, type ColumnCreateTableContext, type ColumnNameCreateContext, type CreateDatabaseContext, type CreateForeignTableContext, type CreateFunctionStmtContext, type CreateMaterializedViewContext, type CreatePartitionForeignTableContext, type CreateViewContext, type DatabaseNameContext, type DatabaseNameCreateContext, FuncTableContext, type FunctionNameCreateContext, type InsertStatementContext, type ProcedureNameContext, type ProcedureNameCreateContext, type QueryCreateTableContext, SelectExpressionColumnNameContext, SelectLiteralColumnNameContext, SelectNoParensContext, type SelectStatementContext, SelectWithParensContext, type SingleStmtContext, TableAllColumnsContext, type TableNameContext, type TableNameCreateContext, Target_dot_emptyContext, Target_emptyContext, ColumnNamePath_dot_emptyContext, TargetListContext, type ViewNameContext, type ViewNameCreateContext, XmlTableContext } from '../../lib/postgresql/PostgreSqlParser';
2
2
  import type { PostgreSqlParserListener } from '../../lib/postgresql/PostgreSqlParserListener';
3
3
  import { EntityCollector } from '../common/entityCollector';
4
4
  export declare class PostgreSqlEntityCollector extends EntityCollector implements PostgreSqlParserListener {
@@ -18,6 +18,7 @@ export declare class PostgreSqlEntityCollector extends EntityCollector implement
18
18
  exitTableAllColumns(ctx: TableAllColumnsContext): void;
19
19
  exitTarget_empty(ctx: Target_emptyContext): void;
20
20
  exitTarget_dot_empty(ctx: Target_dot_emptyContext): void;
21
+ exitColumnNamePath_dot_empty(ctx: ColumnNamePath_dot_emptyContext): void;
21
22
  exitSelectExpressionColumnName(ctx: SelectExpressionColumnNameContext): void;
22
23
  exitSelectLiteralColumnName(ctx: SelectLiteralColumnNameContext): void;
23
24
  exitProcedureName(ctx: ProcedureNameContext): void;
@@ -105,6 +105,11 @@ export class PostgreSqlEntityCollector extends EntityCollector {
105
105
  declareType: ColumnDeclareType.LITERAL,
106
106
  });
107
107
  }
108
+ exitColumnNamePath_dot_empty(ctx) {
109
+ this.pushEntity(ctx, EntityContextType.COLUMN, [], {
110
+ declareType: ColumnDeclareType.LITERAL,
111
+ });
112
+ }
108
113
  exitSelectExpressionColumnName(ctx) {
109
114
  this.pushEntity(ctx, EntityContextType.COLUMN, [
110
115
  {
@@ -59,7 +59,7 @@ export class SparkSQL extends BasicSQL {
59
59
  const keywords = [];
60
60
  for (const candidate of candidates.rules) {
61
61
  const [ruleType, candidateRule] = candidate;
62
- const tokenRanges = allTokens.slice(candidateRule.startTokenIndex, caretTokenIndex + 1);
62
+ const tokenRanges = this.getCandidateTokenRanges(candidates, candidateRule.startTokenIndex, allTokens, caretTokenIndex);
63
63
  let syntaxContextType = void 0;
64
64
  switch (ruleType) {
65
65
  case SparkSqlParser.RULE_namespaceName: {
@@ -56,7 +56,7 @@ export class TrinoSQL extends BasicSQL {
56
56
  const keywords = [];
57
57
  for (let candidate of candidates.rules) {
58
58
  const [ruleType, candidateRule] = candidate;
59
- const tokenRanges = allTokens.slice(candidateRule.startTokenIndex, caretTokenIndex + 1);
59
+ const tokenRanges = this.getCandidateTokenRanges(candidates, candidateRule.startTokenIndex, allTokens, caretTokenIndex);
60
60
  let syntaxContextType = void 0;
61
61
  switch (ruleType) {
62
62
  case TrinoSqlParser.RULE_catalogRef: {
@@ -115,9 +115,11 @@ export class TrinoSQL extends BasicSQL {
115
115
  candidateRule.ruleList.includes(TrinoSqlParser.RULE_havingClause) ||
116
116
  candidateRule.ruleList.includes(TrinoSqlParser.RULE_partitionBy) ||
117
117
  candidateRule.ruleList.includes(TrinoSqlParser.RULE_whenClause) ||
118
- candidateRule.ruleList.includes(TrinoSqlParser.RULE_relation)) {
118
+ candidateRule.ruleList.includes(TrinoSqlParser.RULE_relation) ||
119
+ candidateRule.ruleList.includes(TrinoSqlParser.RULE_joinCriteria)) {
119
120
  syntaxContextType = EntityContextType.COLUMN;
120
121
  }
122
+ break;
121
123
  }
122
124
  default:
123
125
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dt-sql-parser",
3
- "version": "4.5.1-beta.3",
3
+ "version": "4.5.1",
4
4
  "authors": "DTStack Corporation",
5
5
  "description": "SQL Parsers for BigData, built with antlr4",
6
6
  "keywords": [