dt-sql-parser 4.5.0-beta.1 → 4.5.0-beta.2
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/dist/index.d.ts +3 -2
- package/dist/index.js +2 -2
- package/dist/lib/SQLParserBase.d.ts +1 -13
- package/dist/lib/SQLParserBase.js +5 -40
- package/dist/lib/flink/FlinkSqlParser.d.ts +179 -222
- package/dist/lib/flink/FlinkSqlParser.js +2949 -3300
- package/dist/lib/flink/FlinkSqlParserListener.d.ts +0 -33
- package/dist/lib/flink/FlinkSqlParserVisitor.d.ts +0 -21
- package/dist/lib/generic/GenericSqlLexer.d.ts +143 -0
- package/dist/lib/generic/GenericSqlLexer.js +603 -0
- package/dist/lib/generic/GenericSqlListener.d.ts +1089 -0
- package/dist/lib/generic/GenericSqlListener.js +11 -0
- package/dist/lib/generic/GenericSqlParser.d.ts +1272 -0
- package/dist/lib/generic/GenericSqlParser.js +7641 -0
- package/dist/lib/generic/GenericSqlVisitor.d.ts +684 -0
- package/dist/lib/generic/GenericSqlVisitor.js +12 -0
- package/dist/lib/hive/HiveSqlParser.d.ts +228 -274
- package/dist/lib/hive/HiveSqlParser.js +5912 -6304
- package/dist/lib/hive/HiveSqlParserListener.d.ts +0 -33
- package/dist/lib/hive/HiveSqlParserVisitor.d.ts +0 -21
- package/dist/lib/impala/ImpalaSqlParser.d.ts +103 -145
- package/dist/lib/impala/ImpalaSqlParser.js +3320 -3687
- package/dist/lib/impala/ImpalaSqlParserListener.d.ts +0 -33
- package/dist/lib/impala/ImpalaSqlParserVisitor.d.ts +0 -21
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.js +2 -0
- package/dist/lib/mysql/MySqlParser.d.ts +94 -161
- package/dist/lib/mysql/MySqlParser.js +9499 -9959
- package/dist/lib/mysql/MySqlParserListener.d.ts +5 -79
- package/dist/lib/mysql/MySqlParserVisitor.d.ts +3 -49
- package/dist/lib/postgresql/PostgreSqlParser.d.ts +71 -108
- package/dist/lib/postgresql/PostgreSqlParser.js +10388 -13330
- package/dist/lib/postgresql/PostgreSqlParserListener.d.ts +0 -48
- package/dist/lib/postgresql/PostgreSqlParserVisitor.d.ts +0 -30
- package/dist/lib/spark/SparkSqlParser.d.ts +145 -185
- package/dist/lib/spark/SparkSqlParser.js +5109 -5420
- package/dist/lib/spark/SparkSqlParserListener.d.ts +0 -33
- package/dist/lib/spark/SparkSqlParserVisitor.d.ts +0 -21
- package/dist/parser/common/basicSQL.d.ts +5 -5
- package/dist/parser/common/basicSQL.js +3 -3
- package/dist/parser/common/entityCollector.js +2 -14
- package/dist/parser/flink/index.js +2 -5
- package/dist/parser/generic/genericEntityCollector.d.ts +29 -0
- package/dist/parser/generic/genericEntityCollector.js +103 -0
- package/dist/parser/generic/genericErrorListener.d.ts +6 -0
- package/dist/parser/generic/genericErrorListener.js +56 -0
- package/dist/parser/generic/genericSemanticContextCollector.d.ts +9 -0
- package/dist/parser/generic/genericSemanticContextCollector.js +14 -0
- package/dist/parser/generic/genericSplitListener.d.ts +6 -0
- package/dist/parser/generic/genericSplitListener.js +6 -0
- package/dist/parser/generic/index.d.ts +33 -0
- package/dist/parser/generic/index.js +94 -0
- package/dist/parser/index.d.ts +1 -0
- package/dist/parser/index.js +1 -0
- package/dist/parser/mysql/index.js +1 -3
- package/dist/parser/mysql/mysqlEntityCollector.d.ts +1 -2
- package/dist/parser/mysql/mysqlEntityCollector.js +3 -13
- package/dist/parser/mysql/mysqlErrorListener.js +0 -2
- package/dist/parser/postgresql/postgreEntityCollector.d.ts +1 -3
- package/dist/parser/postgresql/postgreEntityCollector.js +0 -13
- package/dist/parser/spark/index.js +1 -3
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColumnCreateTableContext, CreateDefinitionContext, CreateFunctionContext, TableSourceItemContext, AtomTableItemContext, SubqueryTableItemContext,
|
|
1
|
+
import { ColumnCreateTableContext, CreateDefinitionContext, CreateFunctionContext, SelectElementContext, TableSourceItemContext, AtomTableItemContext, SubqueryTableItemContext, } from '../../lib/mysql/MySqlParser';
|
|
2
2
|
import { AttrName, ColumnDeclareType, EntityCollector, StmtContextType, TableDeclareType, } from '../common/entityCollector';
|
|
3
3
|
import { EntityContextType } from '../common/types';
|
|
4
4
|
export class MySqlEntityCollector extends EntityCollector {
|
|
@@ -79,30 +79,20 @@ export class MySqlEntityCollector extends EntityCollector {
|
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
exitSelectLiteralColumnName(ctx) {
|
|
82
|
-
// Handle empty column case (e.g., "select from")
|
|
83
|
-
// When emptyColumn matches, the context has no actual tokens
|
|
84
|
-
if (!ctx.start || !ctx.stop || ctx.start.start > ctx.stop.stop) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
82
|
this.pushEntity(ctx, EntityContextType.COLUMN, [
|
|
88
83
|
{
|
|
89
84
|
attrName: AttrName.alias,
|
|
90
|
-
endContextList: [
|
|
85
|
+
endContextList: [SelectElementContext.name],
|
|
91
86
|
},
|
|
92
87
|
], {
|
|
93
88
|
declareType: ColumnDeclareType.LITERAL,
|
|
94
89
|
});
|
|
95
90
|
}
|
|
96
|
-
exitSelectElement_dot_empty(ctx) {
|
|
97
|
-
this.pushEntity(ctx, EntityContextType.COLUMN, [], {
|
|
98
|
-
declareType: ColumnDeclareType.LITERAL,
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
91
|
exitSelectExpressionElement(ctx) {
|
|
102
92
|
this.pushEntity(ctx, EntityContextType.COLUMN, [
|
|
103
93
|
{
|
|
104
94
|
attrName: AttrName.alias,
|
|
105
|
-
endContextList: [
|
|
95
|
+
endContextList: [SelectElementContext.name],
|
|
106
96
|
},
|
|
107
97
|
], {
|
|
108
98
|
declareType: ColumnDeclareType.EXPRESSION,
|
|
@@ -14,7 +14,6 @@ export class MysqlErrorListener extends ParseErrorListener {
|
|
|
14
14
|
[MySqlParser.RULE_functionName, 'function'],
|
|
15
15
|
[MySqlParser.RULE_functionNameCreate, 'function'],
|
|
16
16
|
[MySqlParser.RULE_columnName, 'column'],
|
|
17
|
-
[MySqlParser.RULE_columnNamePath, 'column'],
|
|
18
17
|
[MySqlParser.RULE_columnNameCreate, 'column'],
|
|
19
18
|
]);
|
|
20
19
|
}
|
|
@@ -49,7 +48,6 @@ export class MysqlErrorListener extends ParseErrorListener {
|
|
|
49
48
|
case MySqlParser.RULE_tableName:
|
|
50
49
|
case MySqlParser.RULE_functionName:
|
|
51
50
|
case MySqlParser.RULE_viewName:
|
|
52
|
-
case MySqlParser.RULE_columnNamePath:
|
|
53
51
|
case MySqlParser.RULE_columnName: {
|
|
54
52
|
if (!result.includes(`{existing}${name}`)) {
|
|
55
53
|
result.push(`{existing}${name}`);
|
|
@@ -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,
|
|
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 {
|
|
@@ -16,8 +16,6 @@ export declare class PostgreSqlEntityCollector extends EntityCollector implement
|
|
|
16
16
|
exitColumnNameCreate(ctx: ColumnNameCreateContext): void;
|
|
17
17
|
exitTargetList(ctx: TargetListContext): void;
|
|
18
18
|
exitTableAllColumns(ctx: TableAllColumnsContext): void;
|
|
19
|
-
exitTarget_empty(ctx: Target_emptyContext): void;
|
|
20
|
-
exitTarget_dot_empty(ctx: Target_dot_emptyContext): void;
|
|
21
19
|
exitSelectExpressionColumnName(ctx: SelectExpressionColumnNameContext): void;
|
|
22
20
|
exitSelectLiteralColumnName(ctx: SelectLiteralColumnNameContext): void;
|
|
23
21
|
exitProcedureName(ctx: ProcedureNameContext): void;
|
|
@@ -81,7 +81,6 @@ export class PostgreSqlEntityCollector extends EntityCollector {
|
|
|
81
81
|
]);
|
|
82
82
|
}
|
|
83
83
|
exitTargetList(ctx) {
|
|
84
|
-
// Only create QUERY_RESULT for targetList that is direct child of simpleSelect
|
|
85
84
|
if (!isChildContextOf(ctx, PostgreSqlParser.RULE_simpleSelect))
|
|
86
85
|
return;
|
|
87
86
|
this.pushEntity(ctx, EntityContextType.QUERY_RESULT);
|
|
@@ -93,18 +92,6 @@ export class PostgreSqlEntityCollector extends EntityCollector {
|
|
|
93
92
|
declareType: ColumnDeclareType.ALL,
|
|
94
93
|
});
|
|
95
94
|
}
|
|
96
|
-
exitTarget_empty(ctx) {
|
|
97
|
-
// Don't create entity for empty column here
|
|
98
|
-
// The targetList will create QUERY_RESULT entity
|
|
99
|
-
// Empty targetEl means the QUERY_RESULT has no columns
|
|
100
|
-
}
|
|
101
|
-
exitTarget_dot_empty(ctx) {
|
|
102
|
-
// Create COLUMN entity for incomplete column reference (e.g., "tb.|")
|
|
103
|
-
// This allows completion to suggest columns from table "tb"
|
|
104
|
-
this.pushEntity(ctx, EntityContextType.COLUMN, [], {
|
|
105
|
-
declareType: ColumnDeclareType.LITERAL,
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
95
|
exitSelectExpressionColumnName(ctx) {
|
|
109
96
|
this.pushEntity(ctx, EntityContextType.COLUMN, [
|
|
110
97
|
{
|
|
@@ -30,7 +30,6 @@ export class SparkSQL extends BasicSQL {
|
|
|
30
30
|
SparkSqlParser.RULE_functionNameCreate,
|
|
31
31
|
SparkSqlParser.RULE_columnName,
|
|
32
32
|
SparkSqlParser.RULE_columnNamePath,
|
|
33
|
-
SparkSqlParser.RULE_columnNamePathAllowEmpty,
|
|
34
33
|
SparkSqlParser.RULE_columnNameCreate,
|
|
35
34
|
...this.excludeKeywordRules,
|
|
36
35
|
]);
|
|
@@ -102,8 +101,7 @@ export class SparkSQL extends BasicSQL {
|
|
|
102
101
|
syntaxContextType = EntityContextType.COLUMN_CREATE;
|
|
103
102
|
break;
|
|
104
103
|
}
|
|
105
|
-
case SparkSqlParser.RULE_columnNamePath:
|
|
106
|
-
case SparkSqlParser.RULE_columnNamePathAllowEmpty: {
|
|
104
|
+
case SparkSqlParser.RULE_columnNamePath: {
|
|
107
105
|
if (candidateRule.ruleList.includes(SparkSqlParser.RULE_whenClause) ||
|
|
108
106
|
candidateRule.ruleList.includes(SparkSqlParser.RULE_whereClause) ||
|
|
109
107
|
candidateRule.ruleList.includes(SparkSqlParser.RULE_joinRelation) ||
|