dt-sql-parser 4.4.2 → 4.5.0-beta.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.
- package/README.md +140 -3
- package/dist/lib/SQLParserBase.d.ts +13 -1
- package/dist/lib/SQLParserBase.js +40 -5
- package/dist/lib/flink/FlinkSqlLexer.d.ts +397 -399
- package/dist/lib/flink/FlinkSqlLexer.js +2489 -2504
- package/dist/lib/flink/FlinkSqlParser.d.ts +726 -728
- package/dist/lib/flink/FlinkSqlParser.js +4727 -5330
- package/dist/lib/flink/FlinkSqlParserListener.d.ts +132 -90
- package/dist/lib/flink/FlinkSqlParserVisitor.d.ts +84 -57
- package/dist/lib/hive/HiveSqlParser.d.ts +338 -239
- package/dist/lib/hive/HiveSqlParser.js +6466 -5794
- package/dist/lib/hive/HiveSqlParserListener.d.ts +88 -0
- package/dist/lib/hive/HiveSqlParserVisitor.d.ts +56 -0
- package/dist/lib/impala/ImpalaSqlParser.d.ts +236 -125
- package/dist/lib/impala/ImpalaSqlParser.js +4257 -3483
- package/dist/lib/impala/ImpalaSqlParserListener.d.ts +109 -14
- package/dist/lib/impala/ImpalaSqlParserVisitor.d.ts +69 -8
- package/dist/lib/mysql/MySqlParser.d.ts +403 -306
- package/dist/lib/mysql/MySqlParser.js +10694 -10030
- package/dist/lib/mysql/MySqlParserListener.d.ts +121 -18
- package/dist/lib/mysql/MySqlParserVisitor.d.ts +75 -10
- package/dist/lib/postgresql/PostgreSqlParser.d.ts +256 -173
- package/dist/lib/postgresql/PostgreSqlParser.js +14934 -11710
- package/dist/lib/postgresql/PostgreSqlParserListener.d.ts +97 -5
- package/dist/lib/postgresql/PostgreSqlParserVisitor.d.ts +61 -3
- package/dist/lib/spark/SparkSqlParser.d.ts +314 -149
- package/dist/lib/spark/SparkSqlParser.js +6185 -5227
- package/dist/lib/spark/SparkSqlParserListener.d.ts +180 -5
- package/dist/lib/spark/SparkSqlParserVisitor.d.ts +113 -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.d.ts +5 -5
- package/dist/parser/common/basicSQL.js +4 -2
- package/dist/parser/common/entityCollector.d.ts +91 -4
- package/dist/parser/common/entityCollector.js +227 -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/flink/index.js +5 -2
- 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/index.js +3 -1
- package/dist/parser/mysql/mysqlEntityCollector.d.ts +10 -1
- package/dist/parser/mysql/mysqlEntityCollector.js +65 -12
- package/dist/parser/mysql/mysqlErrorListener.js +2 -0
- package/dist/parser/postgresql/postgreEntityCollector.d.ts +12 -1
- package/dist/parser/postgresql/postgreEntityCollector.js +99 -22
- package/dist/parser/spark/index.js +3 -1
- package/dist/parser/spark/sparkEntityCollector.d.ts +13 -1
- package/dist/parser/spark/sparkEntityCollector.js +88 -12
- 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 { 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);
|
|
@@ -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);
|