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.
- package/README.md +140 -3
- package/dist/lib/flink/FlinkSqlParser.d.ts +221 -114
- package/dist/lib/flink/FlinkSqlParser.js +3608 -2907
- package/dist/lib/flink/FlinkSqlParserListener.d.ts +99 -0
- package/dist/lib/flink/FlinkSqlParserVisitor.d.ts +63 -0
- package/dist/lib/hive/HiveSqlParser.d.ts +169 -116
- package/dist/lib/hive/HiveSqlParser.js +5708 -5428
- package/dist/lib/hive/HiveSqlParserListener.d.ts +55 -0
- package/dist/lib/hive/HiveSqlParserVisitor.d.ts +35 -0
- package/dist/lib/impala/ImpalaSqlParser.d.ts +150 -81
- package/dist/lib/impala/ImpalaSqlParser.js +3730 -3323
- package/dist/lib/impala/ImpalaSqlParserListener.d.ts +76 -14
- package/dist/lib/impala/ImpalaSqlParserVisitor.d.ts +48 -8
- package/dist/lib/mysql/MySqlParser.d.ts +346 -316
- package/dist/lib/mysql/MySqlParser.js +10224 -10020
- package/dist/lib/mysql/MySqlParserListener.d.ts +55 -26
- package/dist/lib/mysql/MySqlParserVisitor.d.ts +33 -14
- package/dist/lib/postgresql/PostgreSqlParser.d.ts +215 -169
- package/dist/lib/postgresql/PostgreSqlParser.js +10333 -10051
- package/dist/lib/postgresql/PostgreSqlParserListener.d.ts +51 -7
- package/dist/lib/postgresql/PostgreSqlParserVisitor.d.ts +32 -4
- package/dist/lib/spark/SparkSqlParser.d.ts +215 -90
- package/dist/lib/spark/SparkSqlParser.js +5143 -4496
- package/dist/lib/spark/SparkSqlParserListener.d.ts +147 -5
- package/dist/lib/spark/SparkSqlParserVisitor.d.ts +92 -3
- package/dist/lib/trino/TrinoSqlListener.d.ts +90 -37
- package/dist/lib/trino/TrinoSqlParser.d.ts +219 -165
- package/dist/lib/trino/TrinoSqlParser.js +4942 -4615
- package/dist/lib/trino/TrinoSqlVisitor.d.ts +55 -21
- package/dist/parser/common/basicSQL.js +2 -0
- package/dist/parser/common/entityCollector.d.ts +91 -4
- package/dist/parser/common/entityCollector.js +215 -11
- package/dist/parser/common/textAndWord.d.ts +9 -1
- package/dist/parser/common/textAndWord.js +2 -0
- package/dist/parser/common/types.d.ts +2 -0
- package/dist/parser/common/types.js +2 -0
- package/dist/parser/flink/flinkEntityCollector.d.ts +10 -2
- package/dist/parser/flink/flinkEntityCollector.js +76 -14
- package/dist/parser/hive/hiveEntityCollector.d.ts +13 -1
- package/dist/parser/hive/hiveEntityCollector.js +85 -12
- package/dist/parser/impala/impalaEntityCollector.d.ts +7 -1
- package/dist/parser/impala/impalaEntityCollector.js +63 -12
- package/dist/parser/impala/index.js +2 -1
- package/dist/parser/mysql/mysqlEntityCollector.d.ts +9 -1
- package/dist/parser/mysql/mysqlEntityCollector.js +55 -12
- package/dist/parser/postgresql/postgreEntityCollector.d.ts +10 -1
- package/dist/parser/postgresql/postgreEntityCollector.js +86 -22
- package/dist/parser/spark/sparkEntityCollector.d.ts +13 -1
- package/dist/parser/spark/sparkEntityCollector.js +88 -12
- package/dist/parser/trino/index.js +2 -1
- package/dist/parser/trino/trinoEntityCollector.d.ts +7 -1
- package/dist/parser/trino/trinoEntityCollector.js +53 -12
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Column_defContext, TableRefContext, } from '../../lib/postgresql/PostgreSqlParser';
|
|
2
|
-
import { AttrName, EntityCollector, StmtContextType } from '../common/entityCollector';
|
|
1
|
+
import { Column_defContext, ExpressionTableContext, PostgreSqlParser, TableRefContext, Target_labelContext, } from '../../lib/postgresql/PostgreSqlParser';
|
|
2
|
+
import { AttrName, ColumnDeclareType, EntityCollector, isChildContextOf, StmtContextType, TableDeclareType, } from '../common/entityCollector';
|
|
3
3
|
import { EntityContextType } from '../common/types';
|
|
4
4
|
export class PostgreSqlEntityCollector extends EntityCollector {
|
|
5
5
|
/** ====== Entity Begin */
|
|
@@ -10,31 +10,57 @@ export class PostgreSqlEntityCollector extends EntityCollector {
|
|
|
10
10
|
this.pushEntity(ctx, EntityContextType.DATABASE_CREATE);
|
|
11
11
|
}
|
|
12
12
|
exitTableName(ctx) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
this.pushEntity(ctx, EntityContextType.TABLE, [
|
|
14
|
+
{
|
|
15
|
+
attrName: AttrName.alias,
|
|
16
|
+
endContextList: [TableRefContext.name],
|
|
17
|
+
},
|
|
18
|
+
], {
|
|
19
|
+
declareType: TableDeclareType.LITERAL,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
exitXmlTable(ctx) {
|
|
23
|
+
this.pushEntity(ctx, EntityContextType.TABLE, [
|
|
24
|
+
{
|
|
25
|
+
attrName: AttrName.alias,
|
|
26
|
+
endContextList: [ExpressionTableContext.name],
|
|
27
|
+
},
|
|
28
|
+
], {
|
|
29
|
+
declareType: TableDeclareType.EXPRESSION,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
exitFuncTable(ctx) {
|
|
33
|
+
this.pushEntity(ctx, EntityContextType.TABLE, [
|
|
34
|
+
{
|
|
35
|
+
attrName: AttrName.alias,
|
|
36
|
+
endContextList: [ExpressionTableContext.name],
|
|
37
|
+
},
|
|
38
|
+
], {
|
|
39
|
+
declareType: TableDeclareType.EXPRESSION,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
exitSelectWithParens(ctx) {
|
|
43
|
+
if (!isChildContextOf(ctx, PostgreSqlParser.RULE_expressionTable))
|
|
44
|
+
return;
|
|
45
|
+
this.pushEntity(ctx, EntityContextType.TABLE, [
|
|
46
|
+
{
|
|
47
|
+
attrName: AttrName.alias,
|
|
48
|
+
endContextList: [ExpressionTableContext.name],
|
|
49
|
+
},
|
|
50
|
+
], {
|
|
51
|
+
declareType: TableDeclareType.EXPRESSION,
|
|
52
|
+
});
|
|
23
53
|
}
|
|
24
54
|
exitTableNameCreate(ctx) {
|
|
25
55
|
this.pushEntity(ctx, EntityContextType.TABLE_CREATE);
|
|
26
56
|
}
|
|
27
57
|
exitViewName(ctx) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
endContextList: [TableRefContext.name],
|
|
35
|
-
},
|
|
36
|
-
]
|
|
37
|
-
: undefined);
|
|
58
|
+
this.pushEntity(ctx, EntityContextType.VIEW, [
|
|
59
|
+
{
|
|
60
|
+
attrName: AttrName.alias,
|
|
61
|
+
endContextList: [TableRefContext.name],
|
|
62
|
+
},
|
|
63
|
+
]);
|
|
38
64
|
}
|
|
39
65
|
exitViewNameCreate(ctx) {
|
|
40
66
|
this.pushEntity(ctx, EntityContextType.VIEW_CREATE);
|
|
@@ -54,6 +80,38 @@ export class PostgreSqlEntityCollector extends EntityCollector {
|
|
|
54
80
|
},
|
|
55
81
|
]);
|
|
56
82
|
}
|
|
83
|
+
exitTargetList(ctx) {
|
|
84
|
+
if (!isChildContextOf(ctx, PostgreSqlParser.RULE_simpleSelect))
|
|
85
|
+
return;
|
|
86
|
+
this.pushEntity(ctx, EntityContextType.QUERY_RESULT);
|
|
87
|
+
}
|
|
88
|
+
exitTableAllColumns(ctx) {
|
|
89
|
+
if (!isChildContextOf(ctx, PostgreSqlParser.RULE_targetList))
|
|
90
|
+
return;
|
|
91
|
+
this.pushEntity(ctx, EntityContextType.COLUMN, [], {
|
|
92
|
+
declareType: ColumnDeclareType.ALL,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
exitSelectExpressionColumnName(ctx) {
|
|
96
|
+
this.pushEntity(ctx, EntityContextType.COLUMN, [
|
|
97
|
+
{
|
|
98
|
+
attrName: AttrName.alias,
|
|
99
|
+
endContextList: [Target_labelContext.name],
|
|
100
|
+
},
|
|
101
|
+
], {
|
|
102
|
+
declareType: ColumnDeclareType.EXPRESSION,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
exitSelectLiteralColumnName(ctx) {
|
|
106
|
+
this.pushEntity(ctx, EntityContextType.COLUMN, [
|
|
107
|
+
{
|
|
108
|
+
attrName: AttrName.alias,
|
|
109
|
+
endContextList: [Target_labelContext.name],
|
|
110
|
+
},
|
|
111
|
+
], {
|
|
112
|
+
declareType: ColumnDeclareType.LITERAL,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
57
115
|
exitProcedureName(ctx) {
|
|
58
116
|
this.pushEntity(ctx, EntityContextType.PROCEDURE);
|
|
59
117
|
}
|
|
@@ -115,6 +173,12 @@ export class PostgreSqlEntityCollector extends EntityCollector {
|
|
|
115
173
|
exitSelectStatement(ctx) {
|
|
116
174
|
this.popStmt();
|
|
117
175
|
}
|
|
176
|
+
enterSelectNoParens(ctx) {
|
|
177
|
+
this.pushStmt(ctx, StmtContextType.SELECT_STMT);
|
|
178
|
+
}
|
|
179
|
+
exitSelectNoParens(ctx) {
|
|
180
|
+
this.popStmt();
|
|
181
|
+
}
|
|
118
182
|
enterInsertStatement(ctx) {
|
|
119
183
|
this.pushStmt(ctx, StmtContextType.INSERT_STMT);
|
|
120
184
|
}
|
|
@@ -1,16 +1,28 @@
|
|
|
1
|
-
import { ColumnNameCreateContext, CreateFunctionContext, CreateNamespaceContext, CreateTableContext, CreateTableLikeContext, CreateTempViewUsingContext, CreateViewContext, FunctionNameCreateContext, InsertFromQueryContext, MultipleInsertContext, NamespaceNameContext, NamespaceNameCreateContext, QueryStatementContext, ReplaceTableContext, SingleStatementContext, TableNameContext, TableNameCreateContext, ViewNameContext, ViewNameCreateContext } from '../../lib/spark/SparkSqlParser';
|
|
1
|
+
import { AtomSubQueryTableSourceContext, ColumnNameCreateContext, CreateFunctionContext, CreateNamespaceContext, CreateTableContext, CreateTableLikeContext, CreateTempViewUsingContext, CreateViewContext, FunctionNameCreateContext, FunctionTableSourceContext, InlineTableSourceContext, InsertFromQueryContext, MultipleInsertContext, NamespaceNameContext, NamespaceNameCreateContext, QueryStatementContext, ReplaceTableContext, SelectExpressionColumnNameContext, SelectListContext, SelectLiteralColumnNameContext, SingleStatementContext, TableAllColumnsContext, TableNameContext, TableNameCreateContext, ViewNameContext, ViewNameCreateContext } from '../../lib/spark/SparkSqlParser';
|
|
2
2
|
import type { SparkSqlParserListener } from '../../lib/spark/SparkSqlParserListener';
|
|
3
3
|
import { EntityCollector } from '../common/entityCollector';
|
|
4
4
|
export declare class SparkEntityCollector extends EntityCollector implements SparkSqlParserListener {
|
|
5
5
|
/** ====== Entity Begin */
|
|
6
6
|
exitNamespaceName(ctx: NamespaceNameContext): void;
|
|
7
7
|
exitNamespaceNameCreate(ctx: NamespaceNameCreateContext): void;
|
|
8
|
+
/** Table Entity Rules */
|
|
8
9
|
exitTableName(ctx: TableNameContext): void;
|
|
10
|
+
/** Inline Table Entity Rules */
|
|
11
|
+
exitInlineTableSource(ctx: InlineTableSourceContext): void;
|
|
12
|
+
/** Function Table Entity Rules */
|
|
13
|
+
exitFunctionTableSource(ctx: FunctionTableSourceContext): void;
|
|
14
|
+
/** SubQuery Table Entity Rules */
|
|
15
|
+
exitAtomSubQueryTableSource(ctx: AtomSubQueryTableSourceContext): void;
|
|
9
16
|
exitTableNameCreate(ctx: TableNameCreateContext): void;
|
|
10
17
|
exitViewName(ctx: ViewNameContext): void;
|
|
18
|
+
exitSelectList(ctx: SelectListContext): void;
|
|
11
19
|
exitViewNameCreate(ctx: ViewNameCreateContext): void;
|
|
12
20
|
exitFunctionNameCreate(ctx: FunctionNameCreateContext): void;
|
|
21
|
+
/** Column Entity Rules */
|
|
13
22
|
exitColumnNameCreate(ctx: ColumnNameCreateContext): void;
|
|
23
|
+
exitSelectLiteralColumnName(ctx: SelectLiteralColumnNameContext): void;
|
|
24
|
+
exitSelectExpressionColumnName(ctx: SelectExpressionColumnNameContext): void;
|
|
25
|
+
exitTableAllColumns(ctx: TableAllColumnsContext): void;
|
|
14
26
|
/** ===== Statement begin */
|
|
15
27
|
enterSingleStatement(ctx: SingleStatementContext): void;
|
|
16
28
|
exitSingleStatement(ctx: SingleStatementContext): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CreateNamespaceContext, CreateOrReplaceTableColTypeContext, CreateTableContext, CreateViewContext, IdentifierCommentContext, RelationPrimaryContext, } from '../../lib/spark/SparkSqlParser';
|
|
2
|
-
import { AttrName, EntityCollector, StmtContextType } from '../common/entityCollector';
|
|
1
|
+
import { CreateNamespaceContext, CreateOrReplaceTableColTypeContext, CreateTableContext, CreateViewContext, FunctionTableSourceContext, IdentifierCommentContext, InlineTableSourceContext, NamedExpressionContext, RelationContext, RelationPrimaryContext, SparkSqlParser, SubQueryTableSourceContext, TableSourceContext, } from '../../lib/spark/SparkSqlParser';
|
|
2
|
+
import { AttrName, ColumnDeclareType, EntityCollector, isChildContextOf, StmtContextType, TableDeclareType, } from '../common/entityCollector';
|
|
3
3
|
import { EntityContextType } from '../common/types';
|
|
4
4
|
export class SparkEntityCollector extends EntityCollector {
|
|
5
5
|
/** ====== Entity Begin */
|
|
@@ -14,17 +14,53 @@ export class SparkEntityCollector extends EntityCollector {
|
|
|
14
14
|
},
|
|
15
15
|
]);
|
|
16
16
|
}
|
|
17
|
+
/** Table Entity Rules */
|
|
17
18
|
exitTableName(ctx) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
this.pushEntity(ctx, EntityContextType.TABLE, [
|
|
20
|
+
{
|
|
21
|
+
attrName: AttrName.alias,
|
|
22
|
+
endContextList: [
|
|
23
|
+
RelationPrimaryContext.name,
|
|
24
|
+
RelationContext.name,
|
|
25
|
+
TableSourceContext.name,
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
], {
|
|
29
|
+
declareType: TableDeclareType.LITERAL,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/** Inline Table Entity Rules */
|
|
33
|
+
exitInlineTableSource(ctx) {
|
|
34
|
+
this.pushEntity(ctx, EntityContextType.TABLE, [
|
|
35
|
+
{
|
|
36
|
+
attrName: AttrName.alias,
|
|
37
|
+
endContextList: [InlineTableSourceContext.name],
|
|
38
|
+
},
|
|
39
|
+
], {
|
|
40
|
+
declareType: TableDeclareType.EXPRESSION,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/** Function Table Entity Rules */
|
|
44
|
+
exitFunctionTableSource(ctx) {
|
|
45
|
+
this.pushEntity(ctx, EntityContextType.TABLE, [
|
|
46
|
+
{
|
|
47
|
+
attrName: AttrName.alias,
|
|
48
|
+
endContextList: [FunctionTableSourceContext.name],
|
|
49
|
+
},
|
|
50
|
+
], {
|
|
51
|
+
declareType: TableDeclareType.EXPRESSION,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/** SubQuery Table Entity Rules */
|
|
55
|
+
exitAtomSubQueryTableSource(ctx) {
|
|
56
|
+
this.pushEntity(ctx, EntityContextType.TABLE, [
|
|
57
|
+
{
|
|
58
|
+
attrName: AttrName.alias,
|
|
59
|
+
endContextList: [SubQueryTableSourceContext.name],
|
|
60
|
+
},
|
|
61
|
+
], {
|
|
62
|
+
declareType: TableDeclareType.EXPRESSION,
|
|
63
|
+
});
|
|
28
64
|
}
|
|
29
65
|
exitTableNameCreate(ctx) {
|
|
30
66
|
this.pushEntity(ctx, EntityContextType.TABLE_CREATE, [
|
|
@@ -37,6 +73,9 @@ export class SparkEntityCollector extends EntityCollector {
|
|
|
37
73
|
exitViewName(ctx) {
|
|
38
74
|
this.pushEntity(ctx, EntityContextType.VIEW);
|
|
39
75
|
}
|
|
76
|
+
exitSelectList(ctx) {
|
|
77
|
+
this.pushEntity(ctx, EntityContextType.QUERY_RESULT);
|
|
78
|
+
}
|
|
40
79
|
exitViewNameCreate(ctx) {
|
|
41
80
|
this.pushEntity(ctx, EntityContextType.VIEW_CREATE, [
|
|
42
81
|
{
|
|
@@ -48,6 +87,7 @@ export class SparkEntityCollector extends EntityCollector {
|
|
|
48
87
|
exitFunctionNameCreate(ctx) {
|
|
49
88
|
this.pushEntity(ctx, EntityContextType.FUNCTION_CREATE);
|
|
50
89
|
}
|
|
90
|
+
/** Column Entity Rules */
|
|
51
91
|
exitColumnNameCreate(ctx) {
|
|
52
92
|
this.pushEntity(ctx, EntityContextType.COLUMN_CREATE, [
|
|
53
93
|
{
|
|
@@ -63,6 +103,42 @@ export class SparkEntityCollector extends EntityCollector {
|
|
|
63
103
|
},
|
|
64
104
|
]);
|
|
65
105
|
}
|
|
106
|
+
exitSelectLiteralColumnName(ctx) {
|
|
107
|
+
if (!isChildContextOf(ctx, SparkSqlParser.RULE_namedExpression))
|
|
108
|
+
return;
|
|
109
|
+
this.pushEntity(ctx, EntityContextType.COLUMN, [
|
|
110
|
+
{
|
|
111
|
+
attrName: AttrName.alias,
|
|
112
|
+
endContextList: [NamedExpressionContext.name],
|
|
113
|
+
},
|
|
114
|
+
], {
|
|
115
|
+
declareType: ColumnDeclareType.LITERAL,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
exitSelectExpressionColumnName(ctx) {
|
|
119
|
+
if (!isChildContextOf(ctx, SparkSqlParser.RULE_namedExpression))
|
|
120
|
+
return;
|
|
121
|
+
this.pushEntity(ctx, EntityContextType.COLUMN, [
|
|
122
|
+
{
|
|
123
|
+
attrName: AttrName.alias,
|
|
124
|
+
endContextList: [NamedExpressionContext.name],
|
|
125
|
+
},
|
|
126
|
+
], {
|
|
127
|
+
declareType: ColumnDeclareType.EXPRESSION,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
exitTableAllColumns(ctx) {
|
|
131
|
+
if (!isChildContextOf(ctx, SparkSqlParser.RULE_namedExpression))
|
|
132
|
+
return;
|
|
133
|
+
this.pushEntity(ctx, EntityContextType.COLUMN, [
|
|
134
|
+
{
|
|
135
|
+
attrName: AttrName.alias,
|
|
136
|
+
endContextList: [NamedExpressionContext.name],
|
|
137
|
+
},
|
|
138
|
+
], {
|
|
139
|
+
declareType: ColumnDeclareType.ALL,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
66
142
|
/** ===== Statement begin */
|
|
67
143
|
enterSingleStatement(ctx) {
|
|
68
144
|
this.pushStmt(ctx, StmtContextType.COMMON_STMT);
|
|
@@ -108,7 +108,8 @@ export class TrinoSQL extends BasicSQL {
|
|
|
108
108
|
break;
|
|
109
109
|
}
|
|
110
110
|
case TrinoSqlParser.RULE_columnName: {
|
|
111
|
-
if (candidateRule.ruleList.includes(TrinoSqlParser.
|
|
111
|
+
if (candidateRule.ruleList.includes(TrinoSqlParser.RULE_selectItem) ||
|
|
112
|
+
candidateRule.ruleList.includes(TrinoSqlParser.RULE_groupBy) ||
|
|
112
113
|
candidateRule.ruleList.includes(TrinoSqlParser.RULE_sortItem) ||
|
|
113
114
|
candidateRule.ruleList.includes(TrinoSqlParser.RULE_whereClause) ||
|
|
114
115
|
candidateRule.ruleList.includes(TrinoSqlParser.RULE_havingClause) ||
|
|
@@ -1,5 +1,5 @@
|
|
|
1
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';
|
|
2
|
+
import { CatalogNameCreateContext, CatalogRefContext, ColumnNameCreateContext, CreateMaterializedViewContext, CreateSchemaContext, CreateTableAsSelectContext, CreateTableContext, CreateViewContext, ExpressionSourceTableContext, InsertIntoContext, QueryStatementContext, SchemaNameCreateContext, SchemaRefContext, SelectAllWithoutTableContext, SelectExpressionColumnNameContext, SelectListContext, SelectLiteralColumnNameContext, SingleStatementContext, TableAllColumnsContext, 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 */
|
|
@@ -8,10 +8,16 @@ export declare class TrinoEntityCollector extends EntityCollector implements Tri
|
|
|
8
8
|
exitSchemaRef(ctx: SchemaRefContext): void;
|
|
9
9
|
exitSchemaNameCreate(ctx: SchemaNameCreateContext): void;
|
|
10
10
|
exitTableRef(ctx: TableRefContext): void;
|
|
11
|
+
exitExpressionSourceTable(ctx: ExpressionSourceTableContext): void;
|
|
11
12
|
exitTableNameCreate(ctx: TableNameCreateContext): void;
|
|
12
13
|
exitViewRef(ctx: ViewRefContext): void;
|
|
13
14
|
exitViewNameCreate(ctx: ViewNameCreateContext): void;
|
|
15
|
+
exitSelectList(ctx: SelectListContext): void;
|
|
14
16
|
exitColumnNameCreate(ctx: ColumnNameCreateContext): void;
|
|
17
|
+
exitSelectLiteralColumnName(ctx: SelectLiteralColumnNameContext): void;
|
|
18
|
+
exitSelectExpressionColumnName(ctx: SelectExpressionColumnNameContext): void;
|
|
19
|
+
exitTableAllColumns(ctx: TableAllColumnsContext): void;
|
|
20
|
+
exitSelectAllWithoutTable(ctx: SelectAllWithoutTableContext): void;
|
|
15
21
|
/** ===== Statement begin */
|
|
16
22
|
enterSingleStatement(ctx: SingleStatementContext): void;
|
|
17
23
|
exitSingleStatement(ctx: SingleStatementContext): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AliasedRelationContext, ColumnDefinitionContext, CreateMaterializedViewContext, CreateTableAsSelectContext, CreateTableContext, CreateViewContext, } from '../../lib/trino/TrinoSqlParser';
|
|
2
|
-
import { AttrName, EntityCollector, StmtContextType } from '../common/entityCollector';
|
|
1
|
+
import { AliasedRelationContext, ColumnDefinitionContext, CreateMaterializedViewContext, CreateTableAsSelectContext, CreateTableContext, CreateViewContext, SelectItemContext, } from '../../lib/trino/TrinoSqlParser';
|
|
2
|
+
import { AttrName, ColumnDeclareType, EntityCollector, StmtContextType, TableDeclareType, } from '../common/entityCollector';
|
|
3
3
|
import { EntityContextType } from '../common/types';
|
|
4
4
|
export class TrinoEntityCollector extends EntityCollector {
|
|
5
5
|
/** ====== Entity Begin */
|
|
@@ -16,16 +16,24 @@ export class TrinoEntityCollector extends EntityCollector {
|
|
|
16
16
|
this.pushEntity(ctx, EntityContextType.DATABASE_CREATE);
|
|
17
17
|
}
|
|
18
18
|
exitTableRef(ctx) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
this.pushEntity(ctx, EntityContextType.TABLE, [
|
|
20
|
+
{
|
|
21
|
+
attrName: AttrName.alias,
|
|
22
|
+
endContextList: [AliasedRelationContext.name],
|
|
23
|
+
},
|
|
24
|
+
], {
|
|
25
|
+
declareType: TableDeclareType.LITERAL,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
exitExpressionSourceTable(ctx) {
|
|
29
|
+
this.pushEntity(ctx, EntityContextType.TABLE, [
|
|
30
|
+
{
|
|
31
|
+
attrName: AttrName.alias,
|
|
32
|
+
endContextList: [AliasedRelationContext.name],
|
|
33
|
+
},
|
|
34
|
+
], {
|
|
35
|
+
declareType: TableDeclareType.EXPRESSION,
|
|
36
|
+
});
|
|
29
37
|
}
|
|
30
38
|
exitTableNameCreate(ctx) {
|
|
31
39
|
this.pushEntity(ctx, EntityContextType.TABLE_CREATE, [
|
|
@@ -46,6 +54,9 @@ export class TrinoEntityCollector extends EntityCollector {
|
|
|
46
54
|
},
|
|
47
55
|
]);
|
|
48
56
|
}
|
|
57
|
+
exitSelectList(ctx) {
|
|
58
|
+
this.pushEntity(ctx, EntityContextType.QUERY_RESULT);
|
|
59
|
+
}
|
|
49
60
|
exitColumnNameCreate(ctx) {
|
|
50
61
|
this.pushEntity(ctx, EntityContextType.COLUMN_CREATE, [
|
|
51
62
|
{
|
|
@@ -58,6 +69,36 @@ export class TrinoEntityCollector extends EntityCollector {
|
|
|
58
69
|
},
|
|
59
70
|
]);
|
|
60
71
|
}
|
|
72
|
+
exitSelectLiteralColumnName(ctx) {
|
|
73
|
+
this.pushEntity(ctx, EntityContextType.COLUMN, [
|
|
74
|
+
{
|
|
75
|
+
attrName: AttrName.alias,
|
|
76
|
+
endContextList: [SelectItemContext.name],
|
|
77
|
+
},
|
|
78
|
+
], {
|
|
79
|
+
declareType: ColumnDeclareType.LITERAL,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
exitSelectExpressionColumnName(ctx) {
|
|
83
|
+
this.pushEntity(ctx, EntityContextType.COLUMN, [
|
|
84
|
+
{
|
|
85
|
+
attrName: AttrName.alias,
|
|
86
|
+
endContextList: [SelectItemContext.name],
|
|
87
|
+
},
|
|
88
|
+
], {
|
|
89
|
+
declareType: ColumnDeclareType.EXPRESSION,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
exitTableAllColumns(ctx) {
|
|
93
|
+
this.pushEntity(ctx, EntityContextType.COLUMN, [], {
|
|
94
|
+
declareType: ColumnDeclareType.ALL,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
exitSelectAllWithoutTable(ctx) {
|
|
98
|
+
this.pushEntity(ctx, EntityContextType.COLUMN, [], {
|
|
99
|
+
declareType: ColumnDeclareType.ALL,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
61
102
|
/** ===== Statement begin */
|
|
62
103
|
enterSingleStatement(ctx) {
|
|
63
104
|
this.pushStmt(ctx, StmtContextType.COMMON_STMT);
|