dt-sql-parser 4.0.1 → 4.1.0-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 (88) hide show
  1. package/README.md +6 -1
  2. package/dist/lib/flink/FlinkSqlLexer.js +1 -2
  3. package/dist/lib/flink/FlinkSqlParser.d.ts +175 -174
  4. package/dist/lib/flink/FlinkSqlParser.js +2315 -2388
  5. package/dist/lib/flink/FlinkSqlParserListener.d.ts +5 -16
  6. package/dist/lib/flink/FlinkSqlParserVisitor.d.ts +3 -10
  7. package/dist/lib/hive/HiveSqlLexer.js +1 -2
  8. package/dist/lib/hive/HiveSqlParser.d.ts +3 -1
  9. package/dist/lib/hive/HiveSqlParser.js +8 -9
  10. package/dist/lib/impala/ImpalaSqlLexer.js +1 -2
  11. package/dist/lib/impala/ImpalaSqlParser.d.ts +123 -107
  12. package/dist/lib/impala/ImpalaSqlParser.js +3223 -3155
  13. package/dist/lib/impala/ImpalaSqlParserListener.d.ts +22 -0
  14. package/dist/lib/impala/ImpalaSqlParserVisitor.d.ts +14 -0
  15. package/dist/lib/mysql/MySqlLexer.js +1 -2
  16. package/dist/lib/mysql/MySqlParser.d.ts +469 -422
  17. package/dist/lib/mysql/MySqlParser.js +11463 -10512
  18. package/dist/lib/mysql/MySqlParserListener.d.ts +42 -20
  19. package/dist/lib/mysql/MySqlParserVisitor.d.ts +26 -12
  20. package/dist/lib/postgresql/PostgreSqlLexer.js +1 -2
  21. package/dist/lib/postgresql/PostgreSqlParser.d.ts +2025 -6265
  22. package/dist/lib/postgresql/PostgreSqlParser.js +60092 -88368
  23. package/dist/lib/postgresql/PostgreSqlParserListener.d.ts +1688 -6083
  24. package/dist/lib/postgresql/PostgreSqlParserVisitor.d.ts +712 -3511
  25. package/dist/lib/spark/SparkSqlLexer.js +1 -2
  26. package/dist/lib/spark/SparkSqlParser.d.ts +16 -13
  27. package/dist/lib/spark/SparkSqlParser.js +50 -51
  28. package/dist/lib/spark/SparkSqlParserListener.d.ts +10 -10
  29. package/dist/lib/spark/SparkSqlParserVisitor.d.ts +6 -6
  30. package/dist/lib/trino/TrinoSqlLexer.d.ts +323 -260
  31. package/dist/lib/trino/TrinoSqlLexer.js +1610 -1264
  32. package/dist/lib/trino/TrinoSqlListener.d.ts +1311 -200
  33. package/dist/lib/trino/TrinoSqlParser.d.ts +1908 -562
  34. package/dist/lib/trino/TrinoSqlParser.js +22629 -13412
  35. package/dist/lib/trino/TrinoSqlVisitor.d.ts +761 -69
  36. package/dist/locale/locale.d.ts +41 -0
  37. package/dist/locale/locale.js +43 -0
  38. package/dist/parser/common/basicSQL.d.ts +7 -2
  39. package/dist/parser/common/basicSQL.js +5 -15
  40. package/dist/parser/common/entityCollector.d.ts +60 -12
  41. package/dist/parser/common/entityCollector.js +141 -17
  42. package/dist/parser/common/parseErrorListener.d.ts +6 -3
  43. package/dist/parser/common/parseErrorListener.js +83 -2
  44. package/dist/parser/common/textAndWord.d.ts +6 -9
  45. package/dist/parser/common/textAndWord.js +9 -20
  46. package/dist/parser/common/transform.d.ts +8 -0
  47. package/dist/parser/common/transform.js +11 -0
  48. package/dist/parser/common/types.d.ts +1 -0
  49. package/dist/parser/flink/flinkEntityCollector.js +40 -6
  50. package/dist/parser/flink/flinkErrorListener.d.ts +9 -0
  51. package/dist/parser/flink/flinkErrorListener.js +67 -0
  52. package/dist/parser/flink/index.d.ts +3 -0
  53. package/dist/parser/flink/index.js +13 -9
  54. package/dist/parser/hive/hiveEntityCollector.js +40 -6
  55. package/dist/parser/hive/hiveErrorListener.d.ts +9 -0
  56. package/dist/parser/hive/hiveErrorListener.js +65 -0
  57. package/dist/parser/hive/index.d.ts +3 -0
  58. package/dist/parser/hive/index.js +13 -9
  59. package/dist/parser/impala/ImpalaErrorListener.d.ts +9 -0
  60. package/dist/parser/impala/ImpalaErrorListener.js +63 -0
  61. package/dist/parser/impala/impalaEntityCollector.js +51 -6
  62. package/dist/parser/impala/index.d.ts +3 -0
  63. package/dist/parser/impala/index.js +4 -0
  64. package/dist/parser/mysql/index.d.ts +3 -0
  65. package/dist/parser/mysql/index.js +4 -0
  66. package/dist/parser/mysql/mysqlEntityCollector.d.ts +3 -1
  67. package/dist/parser/mysql/mysqlEntityCollector.js +40 -5
  68. package/dist/parser/mysql/mysqlErrorListener.d.ts +9 -0
  69. package/dist/parser/mysql/mysqlErrorListener.js +63 -0
  70. package/dist/parser/postgresql/index.d.ts +3 -0
  71. package/dist/parser/postgresql/index.js +17 -13
  72. package/dist/parser/postgresql/postgreEntityCollector.d.ts +5 -1
  73. package/dist/parser/postgresql/postgreEntityCollector.js +44 -4
  74. package/dist/parser/postgresql/postgreErrorListener.d.ts +9 -0
  75. package/dist/parser/postgresql/postgreErrorListener.js +71 -0
  76. package/dist/parser/spark/index.d.ts +3 -0
  77. package/dist/parser/spark/index.js +4 -0
  78. package/dist/parser/spark/sparkEntityCollector.d.ts +1 -1
  79. package/dist/parser/spark/sparkEntityCollector.js +43 -6
  80. package/dist/parser/spark/sparkErrorListener.d.ts +9 -0
  81. package/dist/parser/spark/sparkErrorListener.js +63 -0
  82. package/dist/parser/trino/index.d.ts +3 -0
  83. package/dist/parser/trino/index.js +23 -10
  84. package/dist/parser/trino/trinoEntityCollector.d.ts +6 -4
  85. package/dist/parser/trino/trinoEntityCollector.js +44 -9
  86. package/dist/parser/trino/trinoErrorListener.d.ts +9 -0
  87. package/dist/parser/trino/trinoErrorListener.js +65 -0
  88. package/package.json +40 -12
@@ -0,0 +1,63 @@
1
+ import { CodeCompletionCore } from 'antlr4-c3';
2
+ import { ParseErrorListener } from '../common/parseErrorListener';
3
+ import { SparkSqlParser } from '../../lib/spark/SparkSqlParser';
4
+ export class SparkErrorListener extends ParseErrorListener {
5
+ constructor(errorListener, preferredRules, locale) {
6
+ super(errorListener, locale);
7
+ this.objectNames = new Map([
8
+ [SparkSqlParser.RULE_namespaceName, 'namespace'],
9
+ [SparkSqlParser.RULE_namespaceNameCreate, 'namespace'],
10
+ [SparkSqlParser.RULE_tableName, 'table'],
11
+ [SparkSqlParser.RULE_tableNameCreate, 'table'],
12
+ [SparkSqlParser.RULE_viewName, 'view'],
13
+ [SparkSqlParser.RULE_viewNameCreate, 'view'],
14
+ [SparkSqlParser.RULE_functionName, 'function'],
15
+ [SparkSqlParser.RULE_functionNameCreate, 'function'],
16
+ [SparkSqlParser.RULE_columnName, 'column'],
17
+ [SparkSqlParser.RULE_columnNameCreate, 'column'],
18
+ ]);
19
+ this.preferredRules = preferredRules;
20
+ }
21
+ getExpectedText(parser, token) {
22
+ var _a;
23
+ let expectedText = '';
24
+ let currentContext = (_a = parser.context) !== null && _a !== void 0 ? _a : undefined;
25
+ while (currentContext === null || currentContext === void 0 ? void 0 : currentContext.parent) {
26
+ currentContext = currentContext.parent;
27
+ }
28
+ const core = new CodeCompletionCore(parser);
29
+ core.preferredRules = this.preferredRules;
30
+ const candidates = core.collectCandidates(token.tokenIndex, currentContext);
31
+ if (candidates.rules.size) {
32
+ const result = [];
33
+ // get expectedText as collect rules first
34
+ for (const candidate of candidates.rules) {
35
+ const [ruleType] = candidate;
36
+ const name = this.objectNames.get(ruleType);
37
+ switch (ruleType) {
38
+ case SparkSqlParser.RULE_namespaceName:
39
+ case SparkSqlParser.RULE_tableName:
40
+ case SparkSqlParser.RULE_viewName:
41
+ case SparkSqlParser.RULE_functionName:
42
+ case SparkSqlParser.RULE_columnName: {
43
+ result.push(`{existing}${name}`);
44
+ break;
45
+ }
46
+ case SparkSqlParser.RULE_namespaceNameCreate:
47
+ case SparkSqlParser.RULE_tableNameCreate:
48
+ case SparkSqlParser.RULE_functionNameCreate:
49
+ case SparkSqlParser.RULE_viewNameCreate:
50
+ case SparkSqlParser.RULE_columnNameCreate: {
51
+ result.push(`{new}${name}`);
52
+ break;
53
+ }
54
+ }
55
+ }
56
+ expectedText = result.join('{or}');
57
+ }
58
+ if (candidates.tokens.size) {
59
+ expectedText += expectedText ? '{orKeyword}' : '{keyword}';
60
+ }
61
+ return expectedText;
62
+ }
63
+ }
@@ -6,11 +6,14 @@ import { BasicSQL } from '../common/basicSQL';
6
6
  import { Suggestions } from '../common/types';
7
7
  import { TrinoSqlSplitListener } from './trinoSplitListener';
8
8
  import { TrinoEntityCollector } from './trinoEntityCollector';
9
+ import { ErrorListener } from '../common/parseErrorListener';
10
+ import { TrinoErrorListener } from './trinoErrorListener';
9
11
  export { TrinoSqlSplitListener, TrinoEntityCollector };
10
12
  export declare class TrinoSQL extends BasicSQL<TrinoSqlLexer, ProgramContext, TrinoSqlParser> {
11
13
  protected createLexerFromCharStream(charStreams: CharStream): TrinoSqlLexer;
12
14
  protected createParserFromTokenStream(tokenStream: CommonTokenStream): TrinoSqlParser;
13
15
  protected get splitListener(): TrinoSqlSplitListener;
16
+ protected createErrorListener(_errorListener: ErrorListener): TrinoErrorListener;
14
17
  protected createEntityCollector(input: string, caretTokenIndex?: number): TrinoEntityCollector;
15
18
  protected preferredRules: Set<number>;
16
19
  protected processCandidates(candidates: CandidatesCollection, allTokens: Token[], caretTokenIndex: number, tokenIndexOffset: number): Suggestions<Token>;
@@ -4,21 +4,23 @@ import { BasicSQL } from '../common/basicSQL';
4
4
  import { EntityContextType } from '../common/types';
5
5
  import { TrinoSqlSplitListener } from './trinoSplitListener';
6
6
  import { TrinoEntityCollector } from './trinoEntityCollector';
7
+ import { TrinoErrorListener } from './trinoErrorListener';
7
8
  export { TrinoSqlSplitListener, TrinoEntityCollector };
8
9
  export class TrinoSQL extends BasicSQL {
9
10
  constructor() {
10
11
  super(...arguments);
11
12
  this.preferredRules = new Set([
12
- TrinoSqlParser.RULE_catalogName,
13
+ TrinoSqlParser.RULE_catalogRef,
13
14
  TrinoSqlParser.RULE_catalogNameCreate,
14
- TrinoSqlParser.RULE_schemaName,
15
+ TrinoSqlParser.RULE_schemaRef,
15
16
  TrinoSqlParser.RULE_schemaNameCreate,
16
- TrinoSqlParser.RULE_tableName,
17
+ TrinoSqlParser.RULE_tableRef,
17
18
  TrinoSqlParser.RULE_tableNameCreate,
18
- TrinoSqlParser.RULE_viewName,
19
+ TrinoSqlParser.RULE_viewRef,
19
20
  TrinoSqlParser.RULE_viewNameCreate,
20
21
  TrinoSqlParser.RULE_functionName,
21
- TrinoSqlParser.RULE_columnName,
22
+ TrinoSqlParser.RULE_functionNameCreate,
23
+ TrinoSqlParser.RULE_columnRef,
22
24
  TrinoSqlParser.RULE_columnNameCreate,
23
25
  ]);
24
26
  }
@@ -31,6 +33,9 @@ export class TrinoSQL extends BasicSQL {
31
33
  get splitListener() {
32
34
  return new TrinoSqlSplitListener();
33
35
  }
36
+ createErrorListener(_errorListener) {
37
+ return new TrinoErrorListener(_errorListener, this.preferredRules, this.locale);
38
+ }
34
39
  createEntityCollector(input, caretTokenIndex) {
35
40
  return new TrinoEntityCollector(input, caretTokenIndex);
36
41
  }
@@ -43,11 +48,15 @@ export class TrinoSQL extends BasicSQL {
43
48
  const tokenRanges = allTokens.slice(startTokenIndex, caretTokenIndex + tokenIndexOffset + 1);
44
49
  let syntaxContextType = void 0;
45
50
  switch (ruleType) {
46
- case TrinoSqlParser.RULE_catalogName: {
51
+ case TrinoSqlParser.RULE_catalogRef: {
47
52
  syntaxContextType = EntityContextType.CATALOG;
48
53
  break;
49
54
  }
50
- case TrinoSqlParser.RULE_schemaName: {
55
+ case TrinoSqlParser.RULE_catalogNameCreate: {
56
+ syntaxContextType = EntityContextType.CATALOG_CREATE;
57
+ break;
58
+ }
59
+ case TrinoSqlParser.RULE_schemaRef: {
51
60
  syntaxContextType = EntityContextType.DATABASE;
52
61
  break;
53
62
  }
@@ -55,7 +64,7 @@ export class TrinoSQL extends BasicSQL {
55
64
  syntaxContextType = EntityContextType.DATABASE_CREATE;
56
65
  break;
57
66
  }
58
- case TrinoSqlParser.RULE_tableName: {
67
+ case TrinoSqlParser.RULE_tableRef: {
59
68
  syntaxContextType = EntityContextType.TABLE;
60
69
  break;
61
70
  }
@@ -63,7 +72,7 @@ export class TrinoSQL extends BasicSQL {
63
72
  syntaxContextType = EntityContextType.TABLE_CREATE;
64
73
  break;
65
74
  }
66
- case TrinoSqlParser.RULE_viewName: {
75
+ case TrinoSqlParser.RULE_viewRef: {
67
76
  syntaxContextType = EntityContextType.VIEW;
68
77
  break;
69
78
  }
@@ -75,11 +84,15 @@ export class TrinoSQL extends BasicSQL {
75
84
  syntaxContextType = EntityContextType.FUNCTION;
76
85
  break;
77
86
  }
87
+ case TrinoSqlParser.RULE_functionNameCreate: {
88
+ syntaxContextType = EntityContextType.FUNCTION_CREATE;
89
+ break;
90
+ }
78
91
  case TrinoSqlParser.RULE_columnNameCreate: {
79
92
  syntaxContextType = EntityContextType.COLUMN_CREATE;
80
93
  break;
81
94
  }
82
- case TrinoSqlParser.RULE_columnName: {
95
+ case TrinoSqlParser.RULE_columnRef: {
83
96
  syntaxContextType = EntityContextType.COLUMN;
84
97
  break;
85
98
  }
@@ -1,13 +1,15 @@
1
- import type { ColumnNameCreateContext, CreateMaterializedViewContext, CreateSchemaContext, CreateTableAsSelectContext, CreateTableContext, CreateViewContext, InsertIntoContext, QueryStatementContext, SchemaNameContext, SchemaNameCreateContext, SingleStatementContext, TableNameContext, TableNameCreateContext, ViewNameContext, ViewNameCreateContext } from '../../lib/trino/TrinoSqlParser';
2
1
  import type { TrinoSqlListener } from '../../lib/trino/TrinoSqlListener';
2
+ import { CatalogNameCreateContext, CatalogRefContext, ColumnNameCreateContext, CreateMaterializedViewContext, CreateSchemaContext, CreateTableAsSelectContext, CreateTableContext, CreateViewContext, InsertIntoContext, QueryStatementContext, SchemaNameCreateContext, SchemaRefContext, SingleStatementContext, TableNameCreateContext, TableRefContext, ViewNameCreateContext, ViewRefContext } from '../../lib/trino/TrinoSqlParser';
3
3
  import { EntityCollector } from '../common/entityCollector';
4
4
  export declare class TrinoEntityCollector extends EntityCollector implements TrinoSqlListener {
5
5
  /** ====== Entity Begin */
6
- exitSchemaName(ctx: SchemaNameContext): void;
6
+ exitCatalogRef(ctx: CatalogRefContext): void;
7
+ exitCatalogNameCreate(ctx: CatalogNameCreateContext): void;
8
+ exitSchemaRef(ctx: SchemaRefContext): void;
7
9
  exitSchemaNameCreate(ctx: SchemaNameCreateContext): void;
8
- exitTableName(ctx: TableNameContext): void;
10
+ exitTableRef(ctx: TableRefContext): void;
9
11
  exitTableNameCreate(ctx: TableNameCreateContext): void;
10
- exitViewName(ctx: ViewNameContext): void;
12
+ exitViewRef(ctx: ViewRefContext): void;
11
13
  exitViewNameCreate(ctx: ViewNameCreateContext): void;
12
14
  exitColumnNameCreate(ctx: ColumnNameCreateContext): void;
13
15
  /** ===== Statement begin */
@@ -1,27 +1,62 @@
1
+ import { AliasedRelationContext, ColumnDefinitionContext, CreateMaterializedViewContext, CreateTableAsSelectContext, CreateTableContext, CreateViewContext, } from '../../lib/trino/TrinoSqlParser';
2
+ import { AttrName, EntityCollector, StmtContextType } from '../common/entityCollector';
1
3
  import { EntityContextType } from '../common/types';
2
- import { StmtContextType, EntityCollector } from '../common/entityCollector';
3
4
  export class TrinoEntityCollector extends EntityCollector {
4
5
  /** ====== Entity Begin */
5
- exitSchemaName(ctx) {
6
+ exitCatalogRef(ctx) {
7
+ this.pushEntity(ctx, EntityContextType.CATALOG);
8
+ }
9
+ exitCatalogNameCreate(ctx) {
10
+ this.pushEntity(ctx, EntityContextType.CATALOG_CREATE);
11
+ }
12
+ exitSchemaRef(ctx) {
6
13
  this.pushEntity(ctx, EntityContextType.DATABASE);
7
14
  }
8
15
  exitSchemaNameCreate(ctx) {
9
16
  this.pushEntity(ctx, EntityContextType.DATABASE_CREATE);
10
17
  }
11
- exitTableName(ctx) {
12
- this.pushEntity(ctx, EntityContextType.TABLE);
18
+ exitTableRef(ctx) {
19
+ var _a;
20
+ const needCollectAttr = ((_a = this.getRootStmt()) === null || _a === void 0 ? void 0 : _a.stmtContextType) === StmtContextType.SELECT_STMT;
21
+ this.pushEntity(ctx, EntityContextType.TABLE, needCollectAttr
22
+ ? [
23
+ {
24
+ attrName: AttrName.alias,
25
+ endContextList: [AliasedRelationContext.name],
26
+ },
27
+ ]
28
+ : undefined);
13
29
  }
14
30
  exitTableNameCreate(ctx) {
15
- this.pushEntity(ctx, EntityContextType.TABLE_CREATE);
16
- }
17
- exitViewName(ctx) {
31
+ this.pushEntity(ctx, EntityContextType.TABLE_CREATE, [
32
+ {
33
+ attrName: AttrName.comment,
34
+ endContextList: [CreateTableContext.name, CreateTableAsSelectContext.name],
35
+ },
36
+ ]);
37
+ }
38
+ exitViewRef(ctx) {
18
39
  this.pushEntity(ctx, EntityContextType.VIEW);
19
40
  }
20
41
  exitViewNameCreate(ctx) {
21
- this.pushEntity(ctx, EntityContextType.VIEW_CREATE);
42
+ this.pushEntity(ctx, EntityContextType.VIEW_CREATE, [
43
+ {
44
+ attrName: AttrName.comment,
45
+ endContextList: [CreateMaterializedViewContext.name, CreateViewContext.name],
46
+ },
47
+ ]);
22
48
  }
23
49
  exitColumnNameCreate(ctx) {
24
- this.pushEntity(ctx, EntityContextType.COLUMN_CREATE);
50
+ this.pushEntity(ctx, EntityContextType.COLUMN_CREATE, [
51
+ {
52
+ attrName: AttrName.colType,
53
+ endContextList: [ColumnDefinitionContext.name],
54
+ },
55
+ {
56
+ attrName: AttrName.comment,
57
+ endContextList: [ColumnDefinitionContext.name],
58
+ },
59
+ ]);
25
60
  }
26
61
  /** ===== Statement begin */
27
62
  enterSingleStatement(ctx) {
@@ -0,0 +1,9 @@
1
+ import { Parser, Token } from 'antlr4ng';
2
+ import { ErrorListener, ParseErrorListener } from '../common/parseErrorListener';
3
+ import { LOCALE_TYPE } from '../common/types';
4
+ export declare class TrinoErrorListener extends ParseErrorListener {
5
+ private preferredRules;
6
+ private objectNames;
7
+ constructor(errorListener: ErrorListener, preferredRules: Set<number>, locale: LOCALE_TYPE);
8
+ getExpectedText(parser: Parser, token: Token): string;
9
+ }
@@ -0,0 +1,65 @@
1
+ import { CodeCompletionCore } from 'antlr4-c3';
2
+ import { TrinoSqlParser } from '../../lib/trino/TrinoSqlParser';
3
+ import { ParseErrorListener } from '../common/parseErrorListener';
4
+ export class TrinoErrorListener extends ParseErrorListener {
5
+ constructor(errorListener, preferredRules, locale) {
6
+ super(errorListener, locale);
7
+ this.objectNames = new Map([
8
+ [TrinoSqlParser.RULE_catalogRef, 'catalog'],
9
+ [TrinoSqlParser.RULE_catalogNameCreate, 'catalog'],
10
+ [TrinoSqlParser.RULE_tableRef, 'table'],
11
+ [TrinoSqlParser.RULE_tableNameCreate, 'table'],
12
+ [TrinoSqlParser.RULE_viewRef, 'view'],
13
+ [TrinoSqlParser.RULE_viewNameCreate, 'view'],
14
+ [TrinoSqlParser.RULE_schemaRef, 'schema'],
15
+ [TrinoSqlParser.RULE_schemaNameCreate, 'schema'],
16
+ [TrinoSqlParser.RULE_functionName, 'function'],
17
+ [TrinoSqlParser.RULE_columnRef, 'column'],
18
+ [TrinoSqlParser.RULE_columnNameCreate, 'column'],
19
+ ]);
20
+ this.preferredRules = preferredRules;
21
+ }
22
+ getExpectedText(parser, token) {
23
+ var _a;
24
+ let expectedText = '';
25
+ let currentContext = (_a = parser.context) !== null && _a !== void 0 ? _a : undefined;
26
+ while (currentContext === null || currentContext === void 0 ? void 0 : currentContext.parent) {
27
+ currentContext = currentContext.parent;
28
+ }
29
+ const core = new CodeCompletionCore(parser);
30
+ core.preferredRules = this.preferredRules;
31
+ const candidates = core.collectCandidates(token.tokenIndex, currentContext);
32
+ if (candidates.rules.size) {
33
+ const result = [];
34
+ // get expectedText as collect rules first
35
+ for (const candidate of candidates.rules) {
36
+ const [ruleType] = candidate;
37
+ const name = this.objectNames.get(ruleType);
38
+ switch (ruleType) {
39
+ case TrinoSqlParser.RULE_catalogRef:
40
+ case TrinoSqlParser.RULE_schemaRef:
41
+ case TrinoSqlParser.RULE_tableRef:
42
+ case TrinoSqlParser.RULE_viewRef:
43
+ case TrinoSqlParser.RULE_functionName:
44
+ case TrinoSqlParser.RULE_columnRef: {
45
+ result.push(`{existing}${name}`);
46
+ break;
47
+ }
48
+ case TrinoSqlParser.RULE_catalogNameCreate:
49
+ case TrinoSqlParser.RULE_tableNameCreate:
50
+ case TrinoSqlParser.RULE_schemaNameCreate:
51
+ case TrinoSqlParser.RULE_viewNameCreate:
52
+ case TrinoSqlParser.RULE_tableNameCreate: {
53
+ result.push(`{new}${name}`);
54
+ break;
55
+ }
56
+ }
57
+ }
58
+ expectedText = result.join('{or}');
59
+ }
60
+ if (candidates.tokens.size) {
61
+ expectedText += expectedText ? '{orKeyword}' : '{keyword}';
62
+ }
63
+ return expectedText;
64
+ }
65
+ }
package/package.json CHANGED
@@ -1,16 +1,20 @@
1
1
  {
2
2
  "name": "dt-sql-parser",
3
- "version": "4.0.1",
3
+ "version": "4.1.0-beta.0",
4
4
  "authors": "DTStack Corporation",
5
5
  "description": "SQL Parsers for BigData, built with antlr4",
6
6
  "keywords": [
7
+ "antlr4",
7
8
  "sql",
8
9
  "parser",
9
- "monaco-editor",
10
+ "code-completion",
10
11
  "hive",
11
12
  "spark",
12
13
  "flink",
13
- "bigdata"
14
+ "mysql",
15
+ "postgresql",
16
+ "trino",
17
+ "impala"
14
18
  ],
15
19
  "main": "dist/index.js",
16
20
  "module": "dist/index.js",
@@ -26,12 +30,17 @@
26
30
  "check-types": "tsc -p ./tsconfig.json && tsc -p ./test/tsconfig.json",
27
31
  "test": "NODE_OPTIONS=--max_old_space_size=4096 && jest",
28
32
  "release": "node ./scripts/release.js",
29
- "lint": "prettier --check '**/*.ts' --config ./.prettierrc",
30
- "lint-fix": "prettier --write '**/*.ts' --config ./.prettierrc",
33
+ "prettier-check": "prettier --check .",
34
+ "format": "prettier --write .",
31
35
  "format-g4": "antlr-format -c ./antlr.format.json -v ./src/grammar/**/*.g4",
32
- "cleanComment": "node ./scripts/cleanCommentCli.js"
36
+ "cleanComment": "node ./scripts/cleanCommentCli.js",
37
+ "benchmark": "node --no-warnings ./scripts/benchmark.js"
33
38
  },
34
39
  "license": "MIT",
40
+ "dependencies": {
41
+ "antlr4-c3": "3.3.7",
42
+ "antlr4ng": "2.0.11"
43
+ },
35
44
  "devDependencies": {
36
45
  "@commitlint/cli": "^17.7.2",
37
46
  "@commitlint/config-conventional": "^17.7.0",
@@ -44,24 +53,43 @@
44
53
  "antlr4ng-cli": "^1.0.7",
45
54
  "chalk": "4.1.2",
46
55
  "commitizen": "^4.3.0",
56
+ "console-table-printer": "^2.12.0",
57
+ "envinfo": "^7.11.1",
47
58
  "glob": "^10.3.10",
48
59
  "husky": "^8.0.3",
49
60
  "inquirer": "^8.2.2",
50
61
  "jest": "^29.5.0",
51
62
  "lint-staged": "12.5.0",
52
63
  "prettier": "^3.0.3",
64
+ "semver": "^7.6.2",
53
65
  "standard-version": "^9.5.0",
66
+ "tsx": "^4.7.1",
54
67
  "typescript": "^5.0.4",
55
68
  "yargs-parser": "^21.1.1"
56
69
  },
57
- "git repository": "https://github.com/DTStack/dt-sql-parser",
58
- "repository": "https://github.com/DTStack/dt-sql-parser",
70
+ "repository": {
71
+ "type": "git",
72
+ "url": "https://github.com/DTStack/dt-sql-parser.git"
73
+ },
59
74
  "publishConfig": {
60
75
  "registry": "https://registry.npmjs.org/"
61
76
  },
62
- "dependencies": {
63
- "antlr4-c3": "3.3.7",
64
- "antlr4ng": "2.0.11"
77
+ "sideEffects": false,
78
+ "engines": {
79
+ "node": ">=18"
80
+ },
81
+ "packageManager": "pnpm@9.7.0",
82
+ "config": {
83
+ "commitizen": {
84
+ "path": "./node_modules/@commitlint/cz-commitlint"
85
+ }
65
86
  },
66
- "sideEffects": false
87
+ "lint-staged": {
88
+ "*": [
89
+ "prettier --write --ignore-unknown"
90
+ ],
91
+ "*.g4": [
92
+ "antlr-format -c ./antlr.format.json -v"
93
+ ]
94
+ }
67
95
  }