Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: generic sql based on spark sql #324

Draft
wants to merge 8 commits into
base: next
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: spell check (#337)
Co-authored-by: liuyi <liuyi@dtstack.com>
2 people authored and HaydenOrz committed Oct 17, 2024
commit 0fd094dbbb1f91b808d6c74b197685e04246a9b2
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -61,7 +61,7 @@ All notable changes to this project will be documented in this file. See [standa

### Features

* add toMatchUnorderedArrary matcher and apply it ([#271](https://github.com/DTStack/dt-sql-parser/issues/271)) ([a05f099](https://github.com/DTStack/dt-sql-parser/commit/a05f099aa1ad555c408bc2018240fb4611ec09b8))
* add toMatchUnorderedArray matcher and apply it ([#271](https://github.com/DTStack/dt-sql-parser/issues/271)) ([a05f099](https://github.com/DTStack/dt-sql-parser/commit/a05f099aa1ad555c408bc2018240fb4611ec09b8))
* collect entity ([#265](https://github.com/DTStack/dt-sql-parser/issues/265)) ([a997211](https://github.com/DTStack/dt-sql-parser/commit/a99721162be0d463b513f53bb13ada6d10168548)), closes [#256](https://github.com/DTStack/dt-sql-parser/issues/256) [#263](https://github.com/DTStack/dt-sql-parser/issues/263) [#268](https://github.com/DTStack/dt-sql-parser/issues/268)
* migrate to antlr4ng ([#267](https://github.com/DTStack/dt-sql-parser/issues/267)) ([195878d](https://github.com/DTStack/dt-sql-parser/commit/195878da9bb1ff8011b5d60c02389fa66d2bc0b8))
* **spark:** support materialized view for spark sql ([#262](https://github.com/DTStack/dt-sql-parser/issues/262)) ([5ce89cb](https://github.com/DTStack/dt-sql-parser/commit/5ce89cb421de18330d56e23a4ab5b658b2130a0b))
6 changes: 3 additions & 3 deletions test/jest.d.ts
Original file line number Diff line number Diff line change
@@ -9,9 +9,9 @@ namespace jest {
* Every item must be primitive type, like string, number, etc.
*
* @example
* expect(['a', 'b']).toMatchUnorderedArrary(['b', 'a']) // pass
* expect(['b', 'a']).toMatchUnorderedArrary(['c', 'b', 'a']) // not pass, missing item 'c'
* expect(['a', 'b']).toMatchUnorderedArray(['b', 'a']) // pass
* expect(['b', 'a']).toMatchUnorderedArray(['c', 'b', 'a']) // not pass, missing item 'c'
*/
toMatchUnorderedArrary(expected: unknown[]): R;
toMatchUnorderedArray(expected: unknown[]): R;
}
}
2 changes: 1 addition & 1 deletion test/matchers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const toMatchUnorderedArrary: jest.CustomMatcher = function (
export const toMatchUnorderedArray: jest.CustomMatcher = function (
actual: Array<unknown>,
expected: Array<unknown>
) {
6 changes: 3 additions & 3 deletions test/parser/flink/suggestion/tokenSuggestion.test.ts
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ describe('Flink SQL Token Suggestion', () => {
pos
)?.keywords;

expect(suggestion).toMatchUnorderedArrary(['MODULES', 'CATALOG']);
expect(suggestion).toMatchUnorderedArray(['MODULES', 'CATALOG']);
});

test('Create Statement ', () => {
@@ -32,7 +32,7 @@ describe('Flink SQL Token Suggestion', () => {
pos
)?.keywords;

expect(suggestion).toMatchUnorderedArrary([
expect(suggestion).toMatchUnorderedArray([
'CATALOG',
'FUNCTION',
'TEMPORARY',
@@ -52,7 +52,7 @@ describe('Flink SQL Token Suggestion', () => {
pos
)?.keywords;

expect(suggestion).toMatchUnorderedArrary([
expect(suggestion).toMatchUnorderedArray([
'MODULES',
'FULL',
'FUNCTIONS',
20 changes: 10 additions & 10 deletions test/parser/hive/suggestion/tokenSuggestion.test.ts
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ describe('Hive SQL Token Suggestion', () => {
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toMatchUnorderedArrary([
expect(suggestion).toMatchUnorderedArray([
'APPLICATION',
'GROUP',
'USER',
@@ -45,7 +45,7 @@ describe('Hive SQL Token Suggestion', () => {
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toMatchUnorderedArrary([
expect(suggestion).toMatchUnorderedArray([
'CONNECTOR',
'APPLICATION',
'GROUP',
@@ -80,7 +80,7 @@ describe('Hive SQL Token Suggestion', () => {
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toMatchUnorderedArrary(['FROM']);
expect(suggestion).toMatchUnorderedArray(['FROM']);
});

test('After DESCRIBE', () => {
@@ -92,7 +92,7 @@ describe('Hive SQL Token Suggestion', () => {
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toMatchUnorderedArrary([
expect(suggestion).toMatchUnorderedArray([
'EXTENDED',
'FORMATTED',
'FUNCTION',
@@ -111,7 +111,7 @@ describe('Hive SQL Token Suggestion', () => {
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toMatchUnorderedArrary([
expect(suggestion).toMatchUnorderedArray([
'CONNECTOR',
'APPLICATION',
'GROUP',
@@ -141,7 +141,7 @@ describe('Hive SQL Token Suggestion', () => {
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toMatchUnorderedArrary(['TABLE']);
expect(suggestion).toMatchUnorderedArray(['TABLE']);
});

test('After IMPORT', () => {
@@ -153,7 +153,7 @@ describe('Hive SQL Token Suggestion', () => {
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toMatchUnorderedArrary(['FROM', 'TABLE', 'EXTERNAL']);
expect(suggestion).toMatchUnorderedArray(['FROM', 'TABLE', 'EXTERNAL']);
});

test('After INSERT', () => {
@@ -165,7 +165,7 @@ describe('Hive SQL Token Suggestion', () => {
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toMatchUnorderedArrary(['INTO', 'OVERWRITE']);
expect(suggestion).toMatchUnorderedArray(['INTO', 'OVERWRITE']);
});

test('After LOAD', () => {
@@ -177,7 +177,7 @@ describe('Hive SQL Token Suggestion', () => {
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toMatchUnorderedArrary(['DATA']);
expect(suggestion).toMatchUnorderedArray(['DATA']);
});

test('After SHOW', () => {
@@ -189,7 +189,7 @@ describe('Hive SQL Token Suggestion', () => {
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toMatchUnorderedArrary([
expect(suggestion).toMatchUnorderedArray([
'CURRENT',
'ROLES',
'PRINCIPALS',
10 changes: 5 additions & 5 deletions test/parser/impala/suggestion/tokenSuggestion.test.ts
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ describe('Impala SQL Token Suggestion', () => {
pos
)?.keywords;

expect(suggestion).toMatchUnorderedArrary(['TABLE', 'VIEW', 'DATABASE']);
expect(suggestion).toMatchUnorderedArray(['TABLE', 'VIEW', 'DATABASE']);
});

test('After CREATE', () => {
@@ -32,7 +32,7 @@ describe('Impala SQL Token Suggestion', () => {
pos
)?.keywords;

expect(suggestion).toMatchUnorderedArrary([
expect(suggestion).toMatchUnorderedArray([
'TABLE',
'EXTERNAL',
'VIEW',
@@ -54,7 +54,7 @@ describe('Impala SQL Token Suggestion', () => {
pos
)?.keywords;

expect(suggestion).toMatchUnorderedArrary([
expect(suggestion).toMatchUnorderedArray([
'DATABASE',
'SCHEMA',
'TABLE',
@@ -77,7 +77,7 @@ describe('Impala SQL Token Suggestion', () => {
pos
)?.keywords;

expect(suggestion).toMatchUnorderedArrary(['INTO', 'OVERWRITE']);
expect(suggestion).toMatchUnorderedArray(['INTO', 'OVERWRITE']);
});

test('After SHOW', () => {
@@ -90,7 +90,7 @@ describe('Impala SQL Token Suggestion', () => {
pos
)?.keywords;

expect(suggestion).toMatchUnorderedArrary([
expect(suggestion).toMatchUnorderedArray([
'DATABASES',
'SCHEMAS',
'TABLES',
16 changes: 8 additions & 8 deletions test/parser/mysql/suggestion/tokenSuggestion.test.ts
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ describe('MySQL Token Suggestion', () => {
pos
)?.keywords;

expect(suggestion).toMatchUnorderedArrary([
expect(suggestion).toMatchUnorderedArray([
'RESOURCE',
'USER',
'VIEW',
@@ -50,7 +50,7 @@ describe('MySQL Token Suggestion', () => {
pos
)?.keywords;

expect(suggestion).toMatchUnorderedArrary([
expect(suggestion).toMatchUnorderedArray([
'RESOURCE',
'USER',
'ROLE',
@@ -92,7 +92,7 @@ describe('MySQL Token Suggestion', () => {
pos
)?.keywords;

expect(suggestion).toMatchUnorderedArrary(['FROM', 'IGNORE', 'QUICK', 'LOW_PRIORITY']);
expect(suggestion).toMatchUnorderedArray(['FROM', 'IGNORE', 'QUICK', 'LOW_PRIORITY']);
});

test('After DESCRIBE', () => {
@@ -105,7 +105,7 @@ describe('MySQL Token Suggestion', () => {
pos
)?.keywords;

expect(suggestion).toMatchUnorderedArrary([
expect(suggestion).toMatchUnorderedArray([
'ANALYZE',
'SELECT',
'DELETE',
@@ -129,7 +129,7 @@ describe('MySQL Token Suggestion', () => {
pos
)?.keywords;

expect(suggestion).toMatchUnorderedArrary([
expect(suggestion).toMatchUnorderedArray([
'RESOURCE',
'USER',
'PREPARE',
@@ -162,7 +162,7 @@ describe('MySQL Token Suggestion', () => {
pos
)?.keywords;

expect(suggestion).toMatchUnorderedArrary([
expect(suggestion).toMatchUnorderedArray([
'INTO',
'IGNORE',
'DELAYED',
@@ -181,7 +181,7 @@ describe('MySQL Token Suggestion', () => {
pos
)?.keywords;

expect(suggestion).toMatchUnorderedArrary(['INDEX', 'XML', 'DATA']);
expect(suggestion).toMatchUnorderedArray(['INDEX', 'XML', 'DATA']);
});

test('After SHOW', () => {
@@ -194,7 +194,7 @@ describe('MySQL Token Suggestion', () => {
pos
)?.keywords;

expect(suggestion).toMatchUnorderedArrary([
expect(suggestion).toMatchUnorderedArray([
'REPLICAS',
'REPLICA',
'SLAVE',
10 changes: 5 additions & 5 deletions test/parser/postgresql/suggestion/tokenSuggestion.test.ts
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ describe('Postgres SQL Token Suggestion', () => {
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toMatchUnorderedArrary([
expect(suggestion).toMatchUnorderedArray([
'TYPE',
'TEXT',
'STATISTICS',
@@ -66,7 +66,7 @@ describe('Postgres SQL Token Suggestion', () => {
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toMatchUnorderedArrary([
expect(suggestion).toMatchUnorderedArray([
'RECURSIVE',
'VIEW',
'TEMPORARY',
@@ -126,7 +126,7 @@ describe('Postgres SQL Token Suggestion', () => {
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toMatchUnorderedArrary(['FROM']);
expect(suggestion).toMatchUnorderedArray(['FROM']);
});

test('After DROP', () => {
@@ -138,7 +138,7 @@ describe('Postgres SQL Token Suggestion', () => {
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toMatchUnorderedArrary([
expect(suggestion).toMatchUnorderedArray([
'OPERATOR',
'ROUTINE',
'PROCEDURE',
@@ -188,6 +188,6 @@ describe('Postgres SQL Token Suggestion', () => {
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toMatchUnorderedArrary(['INTO']);
expect(suggestion).toMatchUnorderedArray(['INTO']);
});
});
18 changes: 9 additions & 9 deletions test/parser/spark/suggestion/tokenSuggestion.test.ts
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ describe('Spark SQL Token Suggestion', () => {
pos
)?.keywords;

expect(suggestion).toMatchUnorderedArrary([
expect(suggestion).toMatchUnorderedArray([
'TABLE',
'INDEX',
'VIEW',
@@ -40,7 +40,7 @@ describe('Spark SQL Token Suggestion', () => {
pos
)?.keywords;

expect(suggestion).toMatchUnorderedArrary([
expect(suggestion).toMatchUnorderedArray([
'TEMPORARY',
'INDEX',
'ROLE',
@@ -67,7 +67,7 @@ describe('Spark SQL Token Suggestion', () => {
pos
)?.keywords;

expect(suggestion).toMatchUnorderedArrary(['FROM']);
expect(suggestion).toMatchUnorderedArray(['FROM']);
});

test('After DESCRIBE', () => {
@@ -80,7 +80,7 @@ describe('Spark SQL Token Suggestion', () => {
pos
)?.keywords;

expect(suggestion).toMatchUnorderedArrary([
expect(suggestion).toMatchUnorderedArray([
'WITH',
'SELECT',
'MAP',
@@ -106,7 +106,7 @@ describe('Spark SQL Token Suggestion', () => {
pos
)?.keywords;

expect(suggestion).toMatchUnorderedArrary([
expect(suggestion).toMatchUnorderedArray([
'TEMPORARY',
'INDEX',
'ROLE',
@@ -130,7 +130,7 @@ describe('Spark SQL Token Suggestion', () => {
pos
)?.keywords;

expect(suggestion).toMatchUnorderedArrary(['OVERWRITE', 'INTO']);
expect(suggestion).toMatchUnorderedArray(['OVERWRITE', 'INTO']);
});

test('After LOAD', () => {
@@ -143,7 +143,7 @@ describe('Spark SQL Token Suggestion', () => {
pos
)?.keywords;

expect(suggestion).toMatchUnorderedArrary(['DATA']);
expect(suggestion).toMatchUnorderedArray(['DATA']);
});

test('After SHOW', () => {
@@ -156,7 +156,7 @@ describe('Spark SQL Token Suggestion', () => {
pos
)?.keywords;

expect(suggestion).toMatchUnorderedArrary([
expect(suggestion).toMatchUnorderedArray([
'LOCKS',
'INDEXES',
'TRANSACTIONS',
@@ -195,6 +195,6 @@ describe('Spark SQL Token Suggestion', () => {
pos
)?.keywords;

expect(suggestion).toMatchUnorderedArrary(['TABLE']);
expect(suggestion).toMatchUnorderedArray(['TABLE']);
});
});
Loading