dt-sql-parser 4.4.0-beta.0 → 4.5.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 (53) hide show
  1. package/README.md +140 -3
  2. package/dist/lib/flink/FlinkSqlParser.d.ts +221 -114
  3. package/dist/lib/flink/FlinkSqlParser.js +3608 -2907
  4. package/dist/lib/flink/FlinkSqlParserListener.d.ts +99 -0
  5. package/dist/lib/flink/FlinkSqlParserVisitor.d.ts +63 -0
  6. package/dist/lib/hive/HiveSqlParser.d.ts +169 -116
  7. package/dist/lib/hive/HiveSqlParser.js +5708 -5428
  8. package/dist/lib/hive/HiveSqlParserListener.d.ts +55 -0
  9. package/dist/lib/hive/HiveSqlParserVisitor.d.ts +35 -0
  10. package/dist/lib/impala/ImpalaSqlParser.d.ts +150 -81
  11. package/dist/lib/impala/ImpalaSqlParser.js +3730 -3323
  12. package/dist/lib/impala/ImpalaSqlParserListener.d.ts +76 -14
  13. package/dist/lib/impala/ImpalaSqlParserVisitor.d.ts +48 -8
  14. package/dist/lib/mysql/MySqlParser.d.ts +346 -316
  15. package/dist/lib/mysql/MySqlParser.js +10224 -10020
  16. package/dist/lib/mysql/MySqlParserListener.d.ts +55 -26
  17. package/dist/lib/mysql/MySqlParserVisitor.d.ts +33 -14
  18. package/dist/lib/postgresql/PostgreSqlParser.d.ts +215 -169
  19. package/dist/lib/postgresql/PostgreSqlParser.js +10333 -10051
  20. package/dist/lib/postgresql/PostgreSqlParserListener.d.ts +51 -7
  21. package/dist/lib/postgresql/PostgreSqlParserVisitor.d.ts +32 -4
  22. package/dist/lib/spark/SparkSqlParser.d.ts +215 -90
  23. package/dist/lib/spark/SparkSqlParser.js +5143 -4496
  24. package/dist/lib/spark/SparkSqlParserListener.d.ts +147 -5
  25. package/dist/lib/spark/SparkSqlParserVisitor.d.ts +92 -3
  26. package/dist/lib/trino/TrinoSqlListener.d.ts +90 -37
  27. package/dist/lib/trino/TrinoSqlParser.d.ts +219 -165
  28. package/dist/lib/trino/TrinoSqlParser.js +4942 -4615
  29. package/dist/lib/trino/TrinoSqlVisitor.d.ts +55 -21
  30. package/dist/parser/common/basicSQL.js +2 -0
  31. package/dist/parser/common/entityCollector.d.ts +91 -4
  32. package/dist/parser/common/entityCollector.js +215 -11
  33. package/dist/parser/common/textAndWord.d.ts +9 -1
  34. package/dist/parser/common/textAndWord.js +2 -0
  35. package/dist/parser/common/types.d.ts +2 -0
  36. package/dist/parser/common/types.js +2 -0
  37. package/dist/parser/flink/flinkEntityCollector.d.ts +10 -2
  38. package/dist/parser/flink/flinkEntityCollector.js +76 -14
  39. package/dist/parser/hive/hiveEntityCollector.d.ts +13 -1
  40. package/dist/parser/hive/hiveEntityCollector.js +85 -12
  41. package/dist/parser/impala/impalaEntityCollector.d.ts +7 -1
  42. package/dist/parser/impala/impalaEntityCollector.js +63 -12
  43. package/dist/parser/impala/index.js +2 -1
  44. package/dist/parser/mysql/mysqlEntityCollector.d.ts +9 -1
  45. package/dist/parser/mysql/mysqlEntityCollector.js +55 -12
  46. package/dist/parser/postgresql/postgreEntityCollector.d.ts +10 -1
  47. package/dist/parser/postgresql/postgreEntityCollector.js +86 -22
  48. package/dist/parser/spark/sparkEntityCollector.d.ts +13 -1
  49. package/dist/parser/spark/sparkEntityCollector.js +88 -12
  50. package/dist/parser/trino/index.js +2 -1
  51. package/dist/parser/trino/trinoEntityCollector.d.ts +7 -1
  52. package/dist/parser/trino/trinoEntityCollector.js +53 -12
  53. package/package.json +1 -1
@@ -34,6 +34,8 @@ export function ctxToText(ctx, input) {
34
34
  endIndex,
35
35
  startColumn: ctx.start.column + 1,
36
36
  endColumn: ctx.stop.column + 1 + ((_b = (_a = ctx.stop.text) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0),
37
+ startTokenIndex: ctx.start.tokenIndex,
38
+ endTokenIndex: ctx.stop.tokenIndex,
37
39
  };
38
40
  }
39
41
  /**
@@ -42,6 +42,8 @@ export declare enum EntityContextType {
42
42
  COLUMN = "column",
43
43
  /** column name that will be created */
44
44
  COLUMN_CREATE = "columnCreate",
45
+ /** query result */
46
+ QUERY_RESULT = "queryResult",
45
47
  /** table property key when creating table*/
46
48
  TABLE_PROPERTY_KEY = "tablePropertyKey",
47
49
  /** table property value when creating table*/
@@ -31,6 +31,8 @@ export var EntityContextType;
31
31
  EntityContextType["COLUMN"] = "column";
32
32
  /** column name that will be created */
33
33
  EntityContextType["COLUMN_CREATE"] = "columnCreate";
34
+ /** query result */
35
+ EntityContextType["QUERY_RESULT"] = "queryResult";
34
36
  /** table property key when creating table*/
35
37
  EntityContextType["TABLE_PROPERTY_KEY"] = "tablePropertyKey";
36
38
  /** table property value when creating table*/
@@ -1,4 +1,4 @@
1
- import { CatalogPathContext, CatalogPathCreateContext, ColumnNameCreateContext, CreateCatalogContext, CreateDatabaseContext, CreateFunctionContext, CreateTableContext, CreateViewContext, DatabasePathContext, DatabasePathCreateContext, FunctionNameCreateContext, InsertStatementContext, QueryStatementContext, SqlStatementContext, TablePathContext, TablePathCreateContext, ViewPathContext, ViewPathCreateContext } from '../../lib/flink/FlinkSqlParser';
1
+ import { AtomExpressionTableContext, AtomFunctionTableContext, CatalogPathContext, CatalogPathCreateContext, ColumnNameCreateContext, CreateCatalogContext, CreateDatabaseContext, CreateFunctionContext, CreateTableContext, CreateViewContext, DatabasePathContext, DatabasePathCreateContext, FunctionNameCreateContext, InsertStatementContext, QueryStatementContext, SelectExpressionColumnNameContext, SelectListContext, SelectLiteralColumnNameContext, SelectWindowItemColumnNameContext, SqlStatementContext, TableAllColumnsContext, TablePathContext, TablePathCreateContext, ViewPathContext, ViewPathCreateContext } from '../../lib/flink/FlinkSqlParser';
2
2
  import { FlinkSqlParserListener } from '../../lib/flink/FlinkSqlParserListener';
3
3
  import { EntityCollector } from '../common/entityCollector';
4
4
  export declare class FlinkEntityCollector extends EntityCollector implements FlinkSqlParserListener {
@@ -8,11 +8,19 @@ export declare class FlinkEntityCollector extends EntityCollector implements Fli
8
8
  exitDatabasePathCreate(ctx: DatabasePathCreateContext): void;
9
9
  exitDatabasePath(ctx: DatabasePathContext): void;
10
10
  exitTablePath(ctx: TablePathContext): void;
11
+ exitAtomFunctionTable(ctx: AtomFunctionTableContext): void;
12
+ exitAtomExpressionTable(ctx: AtomExpressionTableContext): void;
11
13
  exitTablePathCreate(ctx: TablePathCreateContext): void;
12
14
  exitViewPath(ctx: ViewPathContext): void;
13
15
  exitViewPathCreate(ctx: ViewPathCreateContext): void;
14
- exitColumnNameCreate(ctx: ColumnNameCreateContext): void;
15
16
  exitFunctionNameCreate(ctx: FunctionNameCreateContext): void;
17
+ exitSelectList(ctx: SelectListContext): void;
18
+ /** Column entity rules */
19
+ exitColumnNameCreate(ctx: ColumnNameCreateContext): void;
20
+ exitSelectLiteralColumnName(ctx: SelectLiteralColumnNameContext): void;
21
+ exitSelectExpressionColumnName(ctx: SelectExpressionColumnNameContext): void;
22
+ exitSelectWindowItemColumnName(ctx: SelectWindowItemColumnNameContext): void;
23
+ exitTableAllColumns(ctx: TableAllColumnsContext): void;
16
24
  /** ===== Statement begin */
17
25
  enterSqlStatement(ctx: SqlStatementContext): void;
18
26
  exitSqlStatement(ctx: SqlStatementContext): void;
@@ -1,5 +1,5 @@
1
- import { CreateDatabaseContext, CreateTableContext, CreateViewContext, PhysicalColumnDefinitionContext, TableReferenceContext, } from '../../lib/flink/FlinkSqlParser';
2
- import { AttrName, EntityCollector, StmtContextType } from '../common/entityCollector';
1
+ import { ColumnProjectItemContext, CreateDatabaseContext, CreateTableContext, CreateViewContext, OverWindowItemContext, PhysicalColumnDefinitionContext, TableReferenceContext, } from '../../lib/flink/FlinkSqlParser';
2
+ import { AttrName, ColumnDeclareType, EntityCollector, StmtContextType, TableDeclareType, } from '../common/entityCollector';
3
3
  import { EntityContextType } from '../common/types';
4
4
  export class FlinkEntityCollector extends EntityCollector {
5
5
  /** ====== Entity Begin */
@@ -21,16 +21,34 @@ export class FlinkEntityCollector extends EntityCollector {
21
21
  this.pushEntity(ctx, EntityContextType.DATABASE);
22
22
  }
23
23
  exitTablePath(ctx) {
24
- var _a;
25
- const needCollectAttr = ((_a = this.getRootStmt()) === null || _a === void 0 ? void 0 : _a.stmtContextType) === StmtContextType.SELECT_STMT;
26
- this.pushEntity(ctx, EntityContextType.TABLE, needCollectAttr
27
- ? [
28
- {
29
- attrName: AttrName.alias,
30
- endContextList: [TableReferenceContext.name],
31
- },
32
- ]
33
- : undefined);
24
+ this.pushEntity(ctx, EntityContextType.TABLE, [
25
+ {
26
+ attrName: AttrName.alias,
27
+ endContextList: [TableReferenceContext.name],
28
+ },
29
+ ], {
30
+ declareType: TableDeclareType.LITERAL,
31
+ });
32
+ }
33
+ exitAtomFunctionTable(ctx) {
34
+ this.pushEntity(ctx, EntityContextType.TABLE, [
35
+ {
36
+ attrName: AttrName.alias,
37
+ endContextList: [TableReferenceContext.name],
38
+ },
39
+ ], {
40
+ declareType: TableDeclareType.EXPRESSION,
41
+ });
42
+ }
43
+ exitAtomExpressionTable(ctx) {
44
+ this.pushEntity(ctx, EntityContextType.TABLE, [
45
+ {
46
+ attrName: AttrName.alias,
47
+ endContextList: [TableReferenceContext.name],
48
+ },
49
+ ], {
50
+ declareType: TableDeclareType.EXPRESSION,
51
+ });
34
52
  }
35
53
  exitTablePathCreate(ctx) {
36
54
  this.pushEntity(ctx, EntityContextType.TABLE_CREATE, [
@@ -51,6 +69,13 @@ export class FlinkEntityCollector extends EntityCollector {
51
69
  },
52
70
  ]);
53
71
  }
72
+ exitFunctionNameCreate(ctx) {
73
+ this.pushEntity(ctx, EntityContextType.FUNCTION_CREATE);
74
+ }
75
+ exitSelectList(ctx) {
76
+ this.pushEntity(ctx, EntityContextType.QUERY_RESULT);
77
+ }
78
+ /** Column entity rules */
54
79
  exitColumnNameCreate(ctx) {
55
80
  this.pushEntity(ctx, EntityContextType.COLUMN_CREATE, [
56
81
  {
@@ -63,8 +88,45 @@ export class FlinkEntityCollector extends EntityCollector {
63
88
  },
64
89
  ]);
65
90
  }
66
- exitFunctionNameCreate(ctx) {
67
- this.pushEntity(ctx, EntityContextType.FUNCTION_CREATE);
91
+ exitSelectLiteralColumnName(ctx) {
92
+ this.pushEntity(ctx, EntityContextType.COLUMN, [
93
+ {
94
+ attrName: AttrName.alias,
95
+ endContextList: [ColumnProjectItemContext.name],
96
+ },
97
+ ], {
98
+ declareType: ColumnDeclareType.LITERAL,
99
+ });
100
+ }
101
+ exitSelectExpressionColumnName(ctx) {
102
+ this.pushEntity(ctx, EntityContextType.COLUMN, [
103
+ {
104
+ attrName: AttrName.alias,
105
+ endContextList: [ColumnProjectItemContext.name],
106
+ },
107
+ ], {
108
+ declareType: ColumnDeclareType.EXPRESSION,
109
+ });
110
+ }
111
+ exitSelectWindowItemColumnName(ctx) {
112
+ this.pushEntity(ctx, EntityContextType.COLUMN, [
113
+ {
114
+ attrName: AttrName.alias,
115
+ endContextList: [ColumnProjectItemContext.name, OverWindowItemContext.name],
116
+ },
117
+ ], {
118
+ declareType: ColumnDeclareType.EXPRESSION,
119
+ });
120
+ }
121
+ exitTableAllColumns(ctx) {
122
+ this.pushEntity(ctx, EntityContextType.COLUMN, [
123
+ {
124
+ attrName: AttrName.alias,
125
+ endContextList: [ColumnProjectItemContext.name],
126
+ },
127
+ ], {
128
+ declareType: ColumnDeclareType.ALL,
129
+ });
68
130
  }
69
131
  /** ===== Statement begin */
70
132
  enterSqlStatement(ctx) {
@@ -1,12 +1,24 @@
1
1
  import { HiveSqlParserListener } from '../../lib';
2
- import { ColumnNameCreateContext, CreateDatabaseStatementContext, CreateFunctionStatementContext, CreateMaterializedViewStatementContext, CreateTableStatementContext, CreateViewStatementContext, DbSchemaNameContext, DbSchemaNameCreateContext, FromInsertStmtContext, FromSelectStmtContext, FunctionNameCreateContext, InsertStmtContext, SelectStatementContext, StatementContext, TableNameContext, TableNameCreateContext, ViewNameContext, ViewNameCreateContext } from '../../lib/hive/HiveSqlParser';
2
+ import { AtomPartitionedTableFunctionContext, AtomValuesClauseContext, ColumnNameCreateContext, CreateDatabaseStatementContext, CreateFunctionStatementContext, CreateMaterializedViewStatementContext, CreateTableStatementContext, CreateViewStatementContext, DbSchemaNameContext, DbSchemaNameCreateContext, FromInsertStmtContext, FromSelectStmtContext, FunctionNameCreateContext, InsertStmtContext, QueryStatementExpressionContext, SelectExpressionColumnNameContext, SelectListContext, SelectLiteralColumnNameContext, SelectStatementContext, StatementContext, TableAllColumnsContext, TableNameContext, TableNameCreateContext, ViewNameContext, ViewNameCreateContext } from '../../lib/hive/HiveSqlParser';
3
3
  import { EntityCollector } from '../common/entityCollector';
4
4
  export declare class HiveEntityCollector extends EntityCollector implements HiveSqlParserListener {
5
5
  /** ====== Entity Begin */
6
6
  exitTableNameCreate(ctx: TableNameCreateContext): void;
7
+ /** Table Entity Rules */
7
8
  exitTableName(ctx: TableNameContext): void;
9
+ /** Virtual Table Entity Rules */
10
+ exitAtomValuesClause(ctx: AtomValuesClauseContext): void;
11
+ /** SubQuery Table Entity Rules */
12
+ exitQueryStatementExpression(ctx: QueryStatementExpressionContext): void;
13
+ /** Partitioned Table Entity Rules */
14
+ exitAtomPartitionedTableFunction(ctx: AtomPartitionedTableFunctionContext): void;
15
+ /** Column Entity Rules */
8
16
  exitColumnNameCreate(ctx: ColumnNameCreateContext): void;
17
+ exitSelectLiteralColumnName(ctx: SelectLiteralColumnNameContext): void;
18
+ exitSelectExpressionColumnName(ctx: SelectExpressionColumnNameContext): void;
19
+ exitTableAllColumns(ctx: TableAllColumnsContext): void;
9
20
  exitViewNameCreate(ctx: ViewNameCreateContext): void;
21
+ exitSelectList(ctx: SelectListContext): void;
10
22
  exitViewName(ctx: ViewNameContext): void;
11
23
  exitDbSchemaNameCreate(ctx: DbSchemaNameCreateContext): void;
12
24
  exitDbSchemaName(ctx: DbSchemaNameContext): void;
@@ -1,5 +1,5 @@
1
- import { ColumnNameCommentContext, ColumnNameTypeConstraintContext, CreateDatabaseStatementContext, CreateTableStatementContext, CreateViewStatementContext, TableSourceContext, UniqueJoinSourceContext, } from '../../lib/hive/HiveSqlParser';
2
- import { AttrName, EntityCollector, StmtContextType } from '../common/entityCollector';
1
+ import { ColumnNameCommentContext, ColumnNameTypeConstraintContext, CreateDatabaseStatementContext, CreateTableStatementContext, CreateViewStatementContext, HiveSqlParser, PartitionedTableFunctionContext, SelectItemContext, SubQuerySourceContext, TableSourceContext, UniqueJoinSourceContext, VirtualTableSourceContext, } from '../../lib/hive/HiveSqlParser';
2
+ import { AttrName, ColumnDeclareType, EntityCollector, isChildContextOf, StmtContextType, TableDeclareType, } from '../common/entityCollector';
3
3
  import { EntityContextType } from '../common/types';
4
4
  export class HiveEntityCollector extends EntityCollector {
5
5
  /** ====== Entity Begin */
@@ -11,18 +11,57 @@ export class HiveEntityCollector extends EntityCollector {
11
11
  },
12
12
  ]);
13
13
  }
14
+ /** Table Entity Rules */
14
15
  exitTableName(ctx) {
15
- var _a;
16
- const needCollectAttr = ((_a = this.getRootStmt()) === null || _a === void 0 ? void 0 : _a.stmtContextType) === StmtContextType.SELECT_STMT;
17
- this.pushEntity(ctx, EntityContextType.TABLE, needCollectAttr
18
- ? [
19
- {
20
- attrName: AttrName.alias,
21
- endContextList: [TableSourceContext.name, UniqueJoinSourceContext.name],
22
- },
23
- ]
24
- : undefined);
16
+ this.pushEntity(ctx, EntityContextType.TABLE, [
17
+ {
18
+ attrName: AttrName.alias,
19
+ endContextList: [TableSourceContext.name, UniqueJoinSourceContext.name],
20
+ },
21
+ ], {
22
+ declareType: TableDeclareType.LITERAL,
23
+ });
24
+ }
25
+ /** Virtual Table Entity Rules */
26
+ exitAtomValuesClause(ctx) {
27
+ if (!isChildContextOf(ctx, HiveSqlParser.RULE_fromClause))
28
+ return;
29
+ this.pushEntity(ctx, EntityContextType.TABLE, [
30
+ {
31
+ attrName: AttrName.alias,
32
+ endContextList: [VirtualTableSourceContext.name],
33
+ },
34
+ ], {
35
+ declareType: TableDeclareType.EXPRESSION,
36
+ });
37
+ }
38
+ /** SubQuery Table Entity Rules */
39
+ exitQueryStatementExpression(ctx) {
40
+ if (!isChildContextOf(ctx, HiveSqlParser.RULE_fromClause))
41
+ return;
42
+ this.pushEntity(ctx, EntityContextType.TABLE, [
43
+ {
44
+ attrName: AttrName.alias,
45
+ endContextList: [SubQuerySourceContext.name],
46
+ },
47
+ ], {
48
+ declareType: TableDeclareType.EXPRESSION,
49
+ });
50
+ }
51
+ /** Partitioned Table Entity Rules */
52
+ exitAtomPartitionedTableFunction(ctx) {
53
+ if (!isChildContextOf(ctx, HiveSqlParser.RULE_fromClause))
54
+ return;
55
+ this.pushEntity(ctx, EntityContextType.TABLE, [
56
+ {
57
+ attrName: AttrName.alias,
58
+ endContextList: [PartitionedTableFunctionContext.name],
59
+ },
60
+ ], {
61
+ declareType: TableDeclareType.EXPRESSION,
62
+ });
25
63
  }
64
+ /** Column Entity Rules */
26
65
  exitColumnNameCreate(ctx) {
27
66
  this.pushEntity(ctx, EntityContextType.COLUMN_CREATE, [
28
67
  {
@@ -35,6 +74,37 @@ export class HiveEntityCollector extends EntityCollector {
35
74
  },
36
75
  ]);
37
76
  }
77
+ exitSelectLiteralColumnName(ctx) {
78
+ if (!isChildContextOf(ctx, HiveSqlParser.RULE_selectItem))
79
+ return;
80
+ this.pushEntity(ctx, EntityContextType.COLUMN, [
81
+ {
82
+ attrName: AttrName.alias,
83
+ endContextList: [SelectItemContext.name],
84
+ },
85
+ ], {
86
+ declareType: ColumnDeclareType.LITERAL,
87
+ });
88
+ }
89
+ exitSelectExpressionColumnName(ctx) {
90
+ if (!isChildContextOf(ctx, HiveSqlParser.RULE_selectItem))
91
+ return;
92
+ this.pushEntity(ctx, EntityContextType.COLUMN, [
93
+ {
94
+ attrName: AttrName.alias,
95
+ endContextList: [SelectItemContext.name],
96
+ },
97
+ ], {
98
+ declareType: ColumnDeclareType.EXPRESSION,
99
+ });
100
+ }
101
+ exitTableAllColumns(ctx) {
102
+ if (!isChildContextOf(ctx, HiveSqlParser.RULE_selectItem))
103
+ return;
104
+ this.pushEntity(ctx, EntityContextType.COLUMN, [], {
105
+ declareType: ColumnDeclareType.ALL,
106
+ });
107
+ }
38
108
  exitViewNameCreate(ctx) {
39
109
  this.pushEntity(ctx, EntityContextType.VIEW_CREATE, [
40
110
  {
@@ -43,6 +113,9 @@ export class HiveEntityCollector extends EntityCollector {
43
113
  },
44
114
  ]);
45
115
  }
116
+ exitSelectList(ctx) {
117
+ this.pushEntity(ctx, EntityContextType.QUERY_RESULT);
118
+ }
46
119
  exitViewName(ctx) {
47
120
  this.pushEntity(ctx, EntityContextType.VIEW);
48
121
  }
@@ -1,16 +1,22 @@
1
1
  import { ImpalaSqlParserListener } from '../../lib';
2
- import { ColumnNamePathCreateContext, CreateAggregateFunctionContext, CreateFunctionContext, CreateKuduTableAsSelectContext, CreateSchemaContext, CreateTableLikeContext, CreateTableSelectContext, CreateViewContext, DatabaseNameCreateContext, DatabaseNamePathContext, FunctionNameCreateContext, InsertStatementContext, QueryStatementContext, SingleStatementContext, TableNameCreateContext, TableNamePathContext, ViewNameCreateContext, ViewNamePathContext } from '../../lib/impala/ImpalaSqlParser';
2
+ import { AtomSubQueryTableSourceContext, ColumnNamePathCreateContext, CreateAggregateFunctionContext, CreateFunctionContext, CreateKuduTableAsSelectContext, CreateSchemaContext, CreateTableLikeContext, CreateTableSelectContext, CreateViewContext, DatabaseNameCreateContext, DatabaseNamePathContext, FunctionNameCreateContext, InsertStatementContext, QueryStatementContext, SelectExpressionColumnNameContext, SelectListContext, SelectLiteralColumnNameContext, SingleStatementContext, TableAllColumnsContext, TableNameCreateContext, TableNamePathContext, UnnestContext, ViewNameCreateContext, ViewNamePathContext } from '../../lib/impala/ImpalaSqlParser';
3
3
  import { EntityCollector } from '../common/entityCollector';
4
4
  export declare class ImpalaEntityCollector extends EntityCollector implements ImpalaSqlParserListener {
5
5
  /** ===== Entity begin */
6
6
  exitTableNameCreate(ctx: TableNameCreateContext): void;
7
7
  exitTableNamePath(ctx: TableNamePathContext): void;
8
+ exitAtomSubQueryTableSource(ctx: AtomSubQueryTableSourceContext): void;
9
+ exitUnnest(ctx: UnnestContext): void;
8
10
  exitColumnNamePathCreate(ctx: ColumnNamePathCreateContext): void;
9
11
  exitViewNameCreate(ctx: ViewNameCreateContext): void;
10
12
  exitViewNamePath(ctx: ViewNamePathContext): void;
11
13
  exitDatabaseNamePath(ctx: DatabaseNamePathContext): void;
12
14
  exitDatabaseNameCreate(ctx: DatabaseNameCreateContext): void;
13
15
  exitFunctionNameCreate(ctx: FunctionNameCreateContext): void;
16
+ exitSelectList(ctx: SelectListContext): void;
17
+ exitSelectLiteralColumnName(ctx: SelectLiteralColumnNameContext): void;
18
+ exitSelectExpressionColumnName(ctx: SelectExpressionColumnNameContext): void;
19
+ exitTableAllColumns(ctx: TableAllColumnsContext): void;
14
20
  /** ===== Statement begin */
15
21
  enterSingleStatement(ctx: SingleStatementContext): void;
16
22
  exitSingleStatement(ctx: SingleStatementContext): void;
@@ -1,5 +1,5 @@
1
- import { ColumnDefinitionContext, CreateKuduTableAsSelectContext, CreateSchemaContext, CreateTableSelectContext, CreateViewContext, KuduTableElementContext, SampledRelationContext, ViewColumnItemContext, } from '../../lib/impala/ImpalaSqlParser';
2
- import { AttrName, EntityCollector, StmtContextType } from '../common/entityCollector';
1
+ import { AliasedRelationContext, ColumnDefinitionContext, CreateKuduTableAsSelectContext, CreateSchemaContext, CreateTableSelectContext, CreateViewContext, KuduTableElementContext, SelectItemContext, ViewColumnItemContext, } from '../../lib/impala/ImpalaSqlParser';
2
+ import { AttrName, ColumnDeclareType, EntityCollector, StmtContextType, TableDeclareType, } from '../common/entityCollector';
3
3
  import { EntityContextType } from '../common/types';
4
4
  export class ImpalaEntityCollector extends EntityCollector {
5
5
  /** ===== Entity begin */
@@ -15,16 +15,34 @@ export class ImpalaEntityCollector extends EntityCollector {
15
15
  ]);
16
16
  }
17
17
  exitTableNamePath(ctx) {
18
- var _a;
19
- const needCollectAttr = ((_a = this.getRootStmt()) === null || _a === void 0 ? void 0 : _a.stmtContextType) === StmtContextType.SELECT_STMT;
20
- this.pushEntity(ctx, EntityContextType.TABLE, needCollectAttr
21
- ? [
22
- {
23
- attrName: AttrName.alias,
24
- endContextList: [SampledRelationContext.name],
25
- },
26
- ]
27
- : undefined);
18
+ this.pushEntity(ctx, EntityContextType.TABLE, [
19
+ {
20
+ attrName: AttrName.alias,
21
+ endContextList: [AliasedRelationContext.name],
22
+ },
23
+ ], {
24
+ declareType: TableDeclareType.LITERAL,
25
+ });
26
+ }
27
+ exitAtomSubQueryTableSource(ctx) {
28
+ this.pushEntity(ctx, EntityContextType.TABLE, [
29
+ {
30
+ attrName: AttrName.alias,
31
+ endContextList: [AliasedRelationContext.name],
32
+ },
33
+ ], {
34
+ declareType: TableDeclareType.EXPRESSION,
35
+ });
36
+ }
37
+ exitUnnest(ctx) {
38
+ this.pushEntity(ctx, EntityContextType.TABLE, [
39
+ {
40
+ attrName: AttrName.alias,
41
+ endContextList: [AliasedRelationContext.name],
42
+ },
43
+ ], {
44
+ declareType: TableDeclareType.EXPRESSION,
45
+ });
28
46
  }
29
47
  exitColumnNamePathCreate(ctx) {
30
48
  this.pushEntity(ctx, EntityContextType.COLUMN_CREATE, [
@@ -71,6 +89,39 @@ export class ImpalaEntityCollector extends EntityCollector {
71
89
  exitFunctionNameCreate(ctx) {
72
90
  this.pushEntity(ctx, EntityContextType.FUNCTION_CREATE);
73
91
  }
92
+ exitSelectList(ctx) {
93
+ this.pushEntity(ctx, EntityContextType.QUERY_RESULT);
94
+ }
95
+ exitSelectLiteralColumnName(ctx) {
96
+ this.pushEntity(ctx, EntityContextType.COLUMN, [
97
+ {
98
+ attrName: AttrName.alias,
99
+ endContextList: [SelectItemContext.name],
100
+ },
101
+ ], {
102
+ declareType: ColumnDeclareType.LITERAL,
103
+ });
104
+ }
105
+ exitSelectExpressionColumnName(ctx) {
106
+ this.pushEntity(ctx, EntityContextType.COLUMN, [
107
+ {
108
+ attrName: AttrName.alias,
109
+ endContextList: [SelectItemContext.name],
110
+ },
111
+ ], {
112
+ declareType: ColumnDeclareType.EXPRESSION,
113
+ });
114
+ }
115
+ exitTableAllColumns(ctx) {
116
+ this.pushEntity(ctx, EntityContextType.COLUMN, [
117
+ {
118
+ attrName: AttrName.alias,
119
+ endContextList: [SelectItemContext.name],
120
+ },
121
+ ], {
122
+ declareType: ColumnDeclareType.ALL,
123
+ });
124
+ }
74
125
  /** ===== Statement begin */
75
126
  enterSingleStatement(ctx) {
76
127
  this.pushStmt(ctx, StmtContextType.COMMON_STMT);
@@ -102,7 +102,8 @@ export class ImpalaSQL extends BasicSQL {
102
102
  candidateRule.ruleList.includes(ImpalaSqlParser.RULE_whereClause) ||
103
103
  candidateRule.ruleList.includes(ImpalaSqlParser.RULE_whenClause) ||
104
104
  candidateRule.ruleList.includes(ImpalaSqlParser.RULE_partitionByClause) ||
105
- candidateRule.ruleList.includes(ImpalaSqlParser.RULE_relation)) {
105
+ candidateRule.ruleList.includes(ImpalaSqlParser.RULE_relation) ||
106
+ candidateRule.ruleList.includes(ImpalaSqlParser.RULE_functionCallExpression)) {
106
107
  syntaxContextType = EntityContextType.COLUMN;
107
108
  }
108
109
  }
@@ -1,16 +1,24 @@
1
- import { ColumnCreateTableContext, ColumnNameCreateContext, CopyCreateTableContext, CreateDatabaseContext, CreateFunctionContext, CreateFunctionLoadableContext, CreateViewContext, DatabaseNameContext, DatabaseNameCreateContext, FunctionNameCreateContext, InsertStatementContext, QueryCreateTableContext, SelectStatementContext, SingleStatementContext, TableNameContext, TableNameCreateContext, ViewNameContext, ViewNameCreateContext } from '../../lib/mysql/MySqlParser';
1
+ import { ColumnCreateTableContext, ColumnNameCreateContext, CopyCreateTableContext, CreateDatabaseContext, CreateFunctionContext, CreateFunctionLoadableContext, CreateViewContext, DatabaseNameContext, DatabaseNameCreateContext, FunctionNameCreateContext, InsertStatementContext, QueryCreateTableContext, SelectExpressionElementContext, SelectStatementContext, SingleStatementContext, TableNameContext, TableNameCreateContext, ViewNameContext, ViewNameCreateContext, TableAllColumnsContext, SelectLiteralColumnNameContext, AtomSubQueryTableSourceContext, SelectElementsContext, PureAllColumnsContext } 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 {
5
5
  /** ====== Entity Begin */
6
6
  exitDatabaseName(ctx: DatabaseNameContext): void;
7
7
  exitDatabaseNameCreate(ctx: DatabaseNameCreateContext): void;
8
+ /** Table Entity Rules */
8
9
  exitTableName(ctx: TableNameContext): void;
10
+ /** SubQuery Table Entity Rules */
11
+ exitAtomSubQueryTableSource(ctx: AtomSubQueryTableSourceContext): void;
9
12
  exitTableNameCreate(ctx: TableNameCreateContext): void;
10
13
  exitViewName(ctx: ViewNameContext): void;
11
14
  exitViewNameCreate(ctx: ViewNameCreateContext): void;
12
15
  exitFunctionNameCreate(ctx: FunctionNameCreateContext): void;
16
+ exitSelectElements(ctx: SelectElementsContext): void;
13
17
  exitColumnNameCreate(ctx: ColumnNameCreateContext): void;
18
+ exitTableAllColumns(ctx: TableAllColumnsContext): void;
19
+ exitPureAllColumns(ctx: PureAllColumnsContext): void;
20
+ exitSelectLiteralColumnName(ctx: SelectLiteralColumnNameContext): void;
21
+ exitSelectExpressionElement(ctx: SelectExpressionElementContext): void;
14
22
  /** ===== Statement begin */
15
23
  enterSingleStatement(ctx: SingleStatementContext): void;
16
24
  exitSingleStatement(ctx: SingleStatementContext): void;
@@ -1,5 +1,5 @@
1
- import { ColumnCreateTableContext, CreateDefinitionContext, CreateFunctionContext, TableSourceContext, } from '../../lib/mysql/MySqlParser';
2
- import { AttrName, EntityCollector, StmtContextType } from '../common/entityCollector';
1
+ import { ColumnCreateTableContext, CreateDefinitionContext, CreateFunctionContext, SelectElementContext, TableSourceItemContext, AtomTableItemContext, SubqueryTableItemContext, } from '../../lib/mysql/MySqlParser';
2
+ import { AttrName, ColumnDeclareType, EntityCollector, StmtContextType, TableDeclareType, } from '../common/entityCollector';
3
3
  import { EntityContextType } from '../common/types';
4
4
  export class MySqlEntityCollector extends EntityCollector {
5
5
  /** ====== Entity Begin */
@@ -9,17 +9,27 @@ export class MySqlEntityCollector extends EntityCollector {
9
9
  exitDatabaseNameCreate(ctx) {
10
10
  this.pushEntity(ctx, EntityContextType.DATABASE_CREATE);
11
11
  }
12
+ /** Table Entity Rules */
12
13
  exitTableName(ctx) {
13
- var _a;
14
- const needCollectAttr = ((_a = this.getRootStmt()) === null || _a === void 0 ? void 0 : _a.stmtContextType) === StmtContextType.SELECT_STMT;
15
- this.pushEntity(ctx, EntityContextType.TABLE, needCollectAttr
16
- ? [
17
- {
18
- attrName: AttrName.alias,
19
- endContextList: [TableSourceContext.name],
20
- },
21
- ]
22
- : undefined);
14
+ this.pushEntity(ctx, EntityContextType.TABLE, [
15
+ {
16
+ attrName: AttrName.alias,
17
+ endContextList: [TableSourceItemContext.name, AtomTableItemContext.name],
18
+ },
19
+ ], {
20
+ declareType: TableDeclareType.LITERAL,
21
+ });
22
+ }
23
+ /** SubQuery Table Entity Rules */
24
+ exitAtomSubQueryTableSource(ctx) {
25
+ this.pushEntity(ctx, EntityContextType.TABLE, [
26
+ {
27
+ attrName: AttrName.alias,
28
+ endContextList: [TableSourceItemContext.name, SubqueryTableItemContext.name],
29
+ },
30
+ ], {
31
+ declareType: TableDeclareType.EXPRESSION,
32
+ });
23
33
  }
24
34
  exitTableNameCreate(ctx) {
25
35
  this.pushEntity(ctx, EntityContextType.TABLE_CREATE, [
@@ -43,6 +53,9 @@ export class MySqlEntityCollector extends EntityCollector {
43
53
  },
44
54
  ]);
45
55
  }
56
+ exitSelectElements(ctx) {
57
+ this.pushEntity(ctx, EntityContextType.QUERY_RESULT);
58
+ }
46
59
  exitColumnNameCreate(ctx) {
47
60
  this.pushEntity(ctx, EntityContextType.COLUMN_CREATE, [
48
61
  {
@@ -55,6 +68,36 @@ export class MySqlEntityCollector extends EntityCollector {
55
68
  },
56
69
  ]);
57
70
  }
71
+ exitTableAllColumns(ctx) {
72
+ this.pushEntity(ctx, EntityContextType.COLUMN, [], {
73
+ declareType: ColumnDeclareType.ALL,
74
+ });
75
+ }
76
+ exitPureAllColumns(ctx) {
77
+ this.pushEntity(ctx, EntityContextType.COLUMN, [], {
78
+ declareType: ColumnDeclareType.ALL,
79
+ });
80
+ }
81
+ exitSelectLiteralColumnName(ctx) {
82
+ this.pushEntity(ctx, EntityContextType.COLUMN, [
83
+ {
84
+ attrName: AttrName.alias,
85
+ endContextList: [SelectElementContext.name],
86
+ },
87
+ ], {
88
+ declareType: ColumnDeclareType.LITERAL,
89
+ });
90
+ }
91
+ exitSelectExpressionElement(ctx) {
92
+ this.pushEntity(ctx, EntityContextType.COLUMN, [
93
+ {
94
+ attrName: AttrName.alias,
95
+ endContextList: [SelectElementContext.name],
96
+ },
97
+ ], {
98
+ declareType: ColumnDeclareType.EXPRESSION,
99
+ });
100
+ }
58
101
  /** ===== Statement begin */
59
102
  enterSingleStatement(ctx) {
60
103
  this.pushStmt(ctx, StmtContextType.COMMON_STMT);
@@ -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, type FunctionNameCreateContext, type InsertStatementContext, type ProcedureNameContext, type ProcedureNameCreateContext, type QueryCreateTableContext, type SelectStatementContext, type SingleStmtContext, type TableNameContext, type TableNameCreateContext, type ViewNameContext, type ViewNameCreateContext } 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, type FunctionNameCreateContext, type InsertStatementContext, type ProcedureNameContext, type ProcedureNameCreateContext, type QueryCreateTableContext, SelectExpressionColumnNameContext, SelectLiteralColumnNameContext, type SelectStatementContext, type SingleStmtContext, TableAllColumnsContext, type TableNameContext, type TableNameCreateContext, type ViewNameContext, type ViewNameCreateContext, TargetListContext, SelectNoParensContext, XmlTableContext, FuncTableContext, SelectWithParensContext } 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 {
@@ -6,11 +6,18 @@ export declare class PostgreSqlEntityCollector extends EntityCollector implement
6
6
  exitDatabaseName(ctx: DatabaseNameContext): void;
7
7
  exitDatabaseNameCreate(ctx: DatabaseNameCreateContext): void;
8
8
  exitTableName(ctx: TableNameContext): void;
9
+ exitXmlTable(ctx: XmlTableContext): void;
10
+ exitFuncTable(ctx: FuncTableContext): void;
11
+ exitSelectWithParens(ctx: SelectWithParensContext): void;
9
12
  exitTableNameCreate(ctx: TableNameCreateContext): void;
10
13
  exitViewName(ctx: ViewNameContext): void;
11
14
  exitViewNameCreate(ctx: ViewNameCreateContext): void;
12
15
  exitFunctionNameCreate(ctx: FunctionNameCreateContext): void;
13
16
  exitColumnNameCreate(ctx: ColumnNameCreateContext): void;
17
+ exitTargetList(ctx: TargetListContext): void;
18
+ exitTableAllColumns(ctx: TableAllColumnsContext): void;
19
+ exitSelectExpressionColumnName(ctx: SelectExpressionColumnNameContext): void;
20
+ exitSelectLiteralColumnName(ctx: SelectLiteralColumnNameContext): void;
14
21
  exitProcedureName(ctx: ProcedureNameContext): void;
15
22
  exitProcedureNameCreate(ctx: ProcedureNameCreateContext): void;
16
23
  /** ===== Statement begin */
@@ -32,6 +39,8 @@ export declare class PostgreSqlEntityCollector extends EntityCollector implement
32
39
  exitCreateMaterializedView(ctx: CreateMaterializedViewContext): void;
33
40
  enterSelectStatement(ctx: SelectStatementContext): void;
34
41
  exitSelectStatement(ctx: SelectStatementContext): void;
42
+ enterSelectNoParens(ctx: SelectNoParensContext): void;
43
+ exitSelectNoParens(ctx: SelectNoParensContext): void;
35
44
  enterInsertStatement(ctx: InsertStatementContext): void;
36
45
  exitInsertStatement(ctx: InsertStatementContext): void;
37
46
  enterCreateFunctionStmt(ctx: CreateFunctionStmtContext): void;