refactor: standard naming (#278)
* refactor: rename flinksql to flink * refactor: rename pgsql to postgresql * refactor: rename trinosql to trino * refactor: replace all default exports with named export * refactor: rename basicParser to basicSQL * refactor: rename basic-parser-types to types * refactor: replace arrow func with plain func
This commit is contained in:
@ -1,11 +1,9 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { ImpalaSqlSplitListener } from 'src/parser/impala';
|
||||
import { EntityContextType } from 'src/parser/common/basic-parser-types';
|
||||
import { EntityContextType } from 'src/parser/common/types';
|
||||
import { StmtContextType } from 'src/parser/common/entityCollector';
|
||||
import ImpalaSQL from 'src/parser/impala';
|
||||
import { ImpalaSQL, ImpalaEntityCollector, ImpalaSqlSplitListener } from 'src/parser/impala';
|
||||
import { ImpalaSqlParserListener } from 'src/lib/impala/ImpalaSqlParserListener';
|
||||
import ImpalaEntityCollector from 'src/parser/impala/impalaEntityCollector';
|
||||
import { ParseTreeListener } from 'antlr4ng';
|
||||
|
||||
const commonSql = fs.readFileSync(path.join(__dirname, 'fixtures', 'common.sql'), 'utf-8');
|
||||
|
@ -1,4 +1,4 @@
|
||||
import ImpalaSQL, { ImpalaSqlSplitListener } from 'src/parser/impala';
|
||||
import { ImpalaSQL, ImpalaSqlSplitListener } from 'src/parser/impala';
|
||||
import { ImpalaSqlParserListener } from 'src/lib/impala/ImpalaSqlParserListener';
|
||||
|
||||
const validSQL1 = `INSERT INTO country_page_view
|
||||
|
@ -1,10 +1,10 @@
|
||||
import ImpalaSQL from 'src/parser/impala';
|
||||
import { ImpalaSQL } from 'src/parser/impala';
|
||||
|
||||
describe('ImpalaSQL Lexer tests', () => {
|
||||
const parser = new ImpalaSQL();
|
||||
const impala = new ImpalaSQL();
|
||||
|
||||
const sql = 'SELECT * FROM table1';
|
||||
const tokens = parser.getAllTokens(sql);
|
||||
const tokens = impala.getAllTokens(sql);
|
||||
|
||||
test('token counts', () => {
|
||||
expect(tokens.length).toBe(7);
|
||||
|
@ -1,13 +1,13 @@
|
||||
import ImpalaSQL from 'src/parser/impala';
|
||||
import { ImpalaSQL } from 'src/parser/impala';
|
||||
import { ImpalaSqlParserListener } from 'src/lib/impala/ImpalaSqlParserListener';
|
||||
import { ParseTreeListener } from 'antlr4ng';
|
||||
|
||||
describe('impala SQL Listener Tests', () => {
|
||||
const expectTableName = 'user1';
|
||||
const sql = `select id,name,sex from ${expectTableName};`;
|
||||
const parser = new ImpalaSQL();
|
||||
const impala = new ImpalaSQL();
|
||||
|
||||
const parseTree = parser.parse(sql);
|
||||
const parseTree = impala.parse(sql);
|
||||
|
||||
test('Listener enterTableNamePath', async () => {
|
||||
let result = '';
|
||||
@ -23,7 +23,7 @@ describe('impala SQL Listener Tests', () => {
|
||||
}
|
||||
const listenTableName = new MyListener();
|
||||
|
||||
await parser.listen(listenTableName as ParseTreeListener, parseTree);
|
||||
await impala.listen(listenTableName as ParseTreeListener, parseTree);
|
||||
expect(result).toBe(expectTableName);
|
||||
});
|
||||
|
||||
@ -41,7 +41,7 @@ describe('impala SQL Listener Tests', () => {
|
||||
FROM unsorted_census_data;`,
|
||||
];
|
||||
const sql = singleStatementArr.join('\n');
|
||||
const sqlSlices = parser.splitSQLByStatement(sql);
|
||||
const sqlSlices = impala.splitSQLByStatement(sql);
|
||||
|
||||
expect(sqlSlices).not.toBeNull();
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import ImpalaSQL from 'src/parser/impala';
|
||||
import { CaretPosition, EntityContextType } from 'src/parser/common/basic-parser-types';
|
||||
import { ImpalaSQL } from 'src/parser/impala';
|
||||
import { CaretPosition, EntityContextType } from 'src/parser/common/types';
|
||||
|
||||
const syntaxSql = fs.readFileSync(
|
||||
path.join(__dirname, 'fixtures', 'multipleStatement.sql'),
|
||||
@ -9,14 +9,14 @@ const syntaxSql = fs.readFileSync(
|
||||
);
|
||||
|
||||
describe('ImpalaSQL Multiple Statements Syntax Suggestion', () => {
|
||||
const parser = new ImpalaSQL();
|
||||
const impala = new ImpalaSQL();
|
||||
|
||||
test('Select from table ', () => {
|
||||
const pos: CaretPosition = {
|
||||
lineNumber: 1,
|
||||
column: 15,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
|
||||
const syntaxes = impala.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
|
||||
const suggestion = syntaxes?.find(
|
||||
(syn) => syn.syntaxContextType === EntityContextType.TABLE
|
||||
);
|
||||
@ -30,7 +30,7 @@ describe('ImpalaSQL Multiple Statements Syntax Suggestion', () => {
|
||||
lineNumber: 9,
|
||||
column: 17,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
|
||||
const syntaxes = impala.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
|
||||
const suggestion = syntaxes?.find(
|
||||
(syn) => syn.syntaxContextType === EntityContextType.TABLE_CREATE
|
||||
);
|
||||
@ -44,7 +44,7 @@ describe('ImpalaSQL Multiple Statements Syntax Suggestion', () => {
|
||||
lineNumber: 15,
|
||||
column: 13,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
|
||||
const syntaxes = impala.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
|
||||
const suggestion = syntaxes?.find(
|
||||
(syn) => syn.syntaxContextType === EntityContextType.TABLE
|
||||
);
|
||||
@ -58,7 +58,7 @@ describe('ImpalaSQL Multiple Statements Syntax Suggestion', () => {
|
||||
lineNumber: 21,
|
||||
column: 39,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
|
||||
const syntaxes = impala.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
|
||||
const suggestion = syntaxes?.find(
|
||||
(syn) => syn.syntaxContextType === EntityContextType.TABLE
|
||||
);
|
||||
|
@ -1,7 +1,7 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import ImpalaSQL from 'src/parser/impala';
|
||||
import { CaretPosition, EntityContextType } from 'src/parser/common/basic-parser-types';
|
||||
import { ImpalaSQL } from 'src/parser/impala';
|
||||
import { CaretPosition, EntityContextType } from 'src/parser/common/types';
|
||||
import { commentOtherLine } from 'test/helper';
|
||||
|
||||
const syntaxSql = fs.readFileSync(
|
||||
|
@ -1,7 +1,7 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import ImpalaSQL from 'src/parser/impala';
|
||||
import { CaretPosition, EntityContextType } from 'src/parser/common/basic-parser-types';
|
||||
import { ImpalaSQL } from 'src/parser/impala';
|
||||
import { CaretPosition, EntityContextType } from 'src/parser/common/types';
|
||||
import { commentOtherLine } from 'test/helper';
|
||||
|
||||
const syntaxSql = fs.readFileSync(
|
||||
@ -10,14 +10,14 @@ const syntaxSql = fs.readFileSync(
|
||||
);
|
||||
|
||||
describe('Impala SQL Syntax Suggestion', () => {
|
||||
const parser = new ImpalaSQL();
|
||||
const impala = new ImpalaSQL();
|
||||
|
||||
test('Select table', () => {
|
||||
const pos: CaretPosition = {
|
||||
lineNumber: 1,
|
||||
column: 20,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = impala.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -34,7 +34,7 @@ describe('Impala SQL Syntax Suggestion', () => {
|
||||
lineNumber: 3,
|
||||
column: 27,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = impala.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -51,7 +51,7 @@ describe('Impala SQL Syntax Suggestion', () => {
|
||||
lineNumber: 5,
|
||||
column: 19,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = impala.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -68,7 +68,7 @@ describe('Impala SQL Syntax Suggestion', () => {
|
||||
lineNumber: 7,
|
||||
column: 21,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = impala.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -85,7 +85,7 @@ describe('Impala SQL Syntax Suggestion', () => {
|
||||
lineNumber: 7,
|
||||
column: 39,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = impala.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -102,7 +102,7 @@ describe('Impala SQL Syntax Suggestion', () => {
|
||||
lineNumber: 9,
|
||||
column: 19,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = impala.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -119,7 +119,7 @@ describe('Impala SQL Syntax Suggestion', () => {
|
||||
lineNumber: 11,
|
||||
column: 12,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = impala.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -136,7 +136,7 @@ describe('Impala SQL Syntax Suggestion', () => {
|
||||
lineNumber: 13,
|
||||
column: 20,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = impala.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -153,7 +153,7 @@ describe('Impala SQL Syntax Suggestion', () => {
|
||||
lineNumber: 15,
|
||||
column: 20,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = impala.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -170,7 +170,7 @@ describe('Impala SQL Syntax Suggestion', () => {
|
||||
lineNumber: 17,
|
||||
column: 22,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = impala.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -187,7 +187,7 @@ describe('Impala SQL Syntax Suggestion', () => {
|
||||
lineNumber: 19,
|
||||
column: 21,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = impala.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -204,7 +204,7 @@ describe('Impala SQL Syntax Suggestion', () => {
|
||||
lineNumber: 21,
|
||||
column: 15,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = impala.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -221,7 +221,7 @@ describe('Impala SQL Syntax Suggestion', () => {
|
||||
lineNumber: 23,
|
||||
column: 20,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = impala.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -238,7 +238,7 @@ describe('Impala SQL Syntax Suggestion', () => {
|
||||
lineNumber: 25,
|
||||
column: 20,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = impala.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -255,7 +255,7 @@ describe('Impala SQL Syntax Suggestion', () => {
|
||||
lineNumber: 27,
|
||||
column: 25,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = impala.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -272,7 +272,7 @@ describe('Impala SQL Syntax Suggestion', () => {
|
||||
lineNumber: 29,
|
||||
column: 19,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = impala.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -289,7 +289,7 @@ describe('Impala SQL Syntax Suggestion', () => {
|
||||
lineNumber: 31,
|
||||
column: 22,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = impala.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -306,7 +306,7 @@ describe('Impala SQL Syntax Suggestion', () => {
|
||||
lineNumber: 33,
|
||||
column: 22,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = impala.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -323,7 +323,7 @@ describe('Impala SQL Syntax Suggestion', () => {
|
||||
lineNumber: 35,
|
||||
column: 20,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = impala.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -340,7 +340,7 @@ describe('Impala SQL Syntax Suggestion', () => {
|
||||
lineNumber: 37,
|
||||
column: 22,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = impala.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -357,7 +357,7 @@ describe('Impala SQL Syntax Suggestion', () => {
|
||||
lineNumber: 39,
|
||||
column: 22,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = impala.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -374,7 +374,7 @@ describe('Impala SQL Syntax Suggestion', () => {
|
||||
lineNumber: 41,
|
||||
column: 36,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = impala.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -391,7 +391,7 @@ describe('Impala SQL Syntax Suggestion', () => {
|
||||
lineNumber: 43,
|
||||
column: 36,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = impala.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -408,7 +408,7 @@ describe('Impala SQL Syntax Suggestion', () => {
|
||||
lineNumber: 45,
|
||||
column: 45,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = impala.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -425,7 +425,7 @@ describe('Impala SQL Syntax Suggestion', () => {
|
||||
lineNumber: 47,
|
||||
column: 49,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = impala.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
|
@ -1,20 +1,20 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import ImpalaSQL from 'src/parser/impala';
|
||||
import { CaretPosition } from 'src/parser/common/basic-parser-types';
|
||||
import { ImpalaSQL } from 'src/parser/impala';
|
||||
import { CaretPosition } from 'src/parser/common/types';
|
||||
import { commentOtherLine } from 'test/helper';
|
||||
|
||||
const tokenSql = fs.readFileSync(path.join(__dirname, 'fixtures', 'tokenSuggestion.sql'), 'utf-8');
|
||||
|
||||
describe('Impala SQL Token Suggestion', () => {
|
||||
const parser = new ImpalaSQL();
|
||||
const impala = new ImpalaSQL();
|
||||
|
||||
test('After ALTER', () => {
|
||||
const pos: CaretPosition = {
|
||||
lineNumber: 1,
|
||||
column: 7,
|
||||
};
|
||||
const suggestion = parser.getSuggestionAtCaretPosition(
|
||||
const suggestion = impala.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(tokenSql, pos.lineNumber),
|
||||
pos
|
||||
)?.keywords;
|
||||
@ -27,7 +27,7 @@ describe('Impala SQL Token Suggestion', () => {
|
||||
lineNumber: 3,
|
||||
column: 8,
|
||||
};
|
||||
const suggestion = parser.getSuggestionAtCaretPosition(
|
||||
const suggestion = impala.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(tokenSql, pos.lineNumber),
|
||||
pos
|
||||
)?.keywords;
|
||||
@ -49,7 +49,7 @@ describe('Impala SQL Token Suggestion', () => {
|
||||
lineNumber: 5,
|
||||
column: 6,
|
||||
};
|
||||
const suggestion = parser.getSuggestionAtCaretPosition(
|
||||
const suggestion = impala.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(tokenSql, pos.lineNumber),
|
||||
pos
|
||||
)?.keywords;
|
||||
@ -72,7 +72,7 @@ describe('Impala SQL Token Suggestion', () => {
|
||||
lineNumber: 7,
|
||||
column: 8,
|
||||
};
|
||||
const suggestion = parser.getSuggestionAtCaretPosition(
|
||||
const suggestion = impala.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(tokenSql, pos.lineNumber),
|
||||
pos
|
||||
)?.keywords;
|
||||
@ -85,7 +85,7 @@ describe('Impala SQL Token Suggestion', () => {
|
||||
lineNumber: 9,
|
||||
column: 6,
|
||||
};
|
||||
const suggestion = parser.getSuggestionAtCaretPosition(
|
||||
const suggestion = impala.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(tokenSql, pos.lineNumber),
|
||||
pos
|
||||
)?.keywords;
|
||||
|
@ -1,7 +1,7 @@
|
||||
import ImpalaSQL from 'src/parser/impala';
|
||||
import { ImpalaSQL } from 'src/parser/impala';
|
||||
import { readSQL } from 'test/helper';
|
||||
|
||||
const parser = new ImpalaSQL();
|
||||
const impala = new ImpalaSQL();
|
||||
|
||||
const features = {
|
||||
tables: readSQL(__dirname, 'alter_table.sql'),
|
||||
@ -13,21 +13,21 @@ describe('ImpalaSQL Alter Syntax Tests', () => {
|
||||
describe('ALTER TABLE', () => {
|
||||
features.tables.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('ALTER DATABASE', () => {
|
||||
features.dbs.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('ALTER VIEW', () => {
|
||||
features.views.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
import ImpalaSQL from 'src/parser/impala';
|
||||
import { ImpalaSQL } from 'src/parser/impala';
|
||||
import { readSQL } from 'test/helper';
|
||||
|
||||
const parser = new ImpalaSQL();
|
||||
const impala = new ImpalaSQL();
|
||||
|
||||
const features = {
|
||||
dbs: readSQL(__dirname, 'create_db.sql'),
|
||||
@ -15,35 +15,35 @@ describe('ImpalaSQL Create Syntax Tests', () => {
|
||||
describe('CREATE DB', () => {
|
||||
features.dbs.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('CREATE FUNCTION', () => {
|
||||
features.functions.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('CREATE ROLE', () => {
|
||||
features.roles.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('CREATE TABLE', () => {
|
||||
features.tables.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('CREATE VIEW', () => {
|
||||
features.views.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
import ImpalaSQL from 'src/parser/impala';
|
||||
import { ImpalaSQL } from 'src/parser/impala';
|
||||
import { readSQL } from 'test/helper';
|
||||
|
||||
const parser = new ImpalaSQL();
|
||||
const impala = new ImpalaSQL();
|
||||
|
||||
const features = {
|
||||
deletes: readSQL(__dirname, 'delete.sql'),
|
||||
@ -11,7 +11,7 @@ describe('ImpalaSQL Delete Syntax Tests', () => {
|
||||
describe('DELETE', () => {
|
||||
features.deletes.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
import ImpalaSQL from 'src/parser/impala';
|
||||
import { ImpalaSQL } from 'src/parser/impala';
|
||||
import { readSQL } from 'test/helper';
|
||||
|
||||
const parser = new ImpalaSQL();
|
||||
const impala = new ImpalaSQL();
|
||||
|
||||
const features = {
|
||||
dbs: readSQL(__dirname, 'drop_db.sql'),
|
||||
@ -16,42 +16,42 @@ describe('ImpalaSQL Drop Syntax Tests', () => {
|
||||
describe('DROP DATABASE', () => {
|
||||
features.dbs.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('DROP FUNCTION', () => {
|
||||
features.functions.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('DROP ROLE', () => {
|
||||
features.roles.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('DROP STATS', () => {
|
||||
features.stats.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('DROP TABLE', () => {
|
||||
features.tables.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('DROP VIEW', () => {
|
||||
features.views.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
import ImpalaSQL from 'src/parser/impala';
|
||||
import { ImpalaSQL } from 'src/parser/impala';
|
||||
import { readSQL } from 'test/helper';
|
||||
|
||||
const parser = new ImpalaSQL();
|
||||
const impala = new ImpalaSQL();
|
||||
|
||||
const features = {
|
||||
insert: readSQL(__dirname, 'insert.sql'),
|
||||
@ -11,7 +11,7 @@ describe('ImpalaSQL Insert Syntax Tests', () => {
|
||||
describe('INSERT', () => {
|
||||
features.insert.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
import ImpalaSQL from 'src/parser/impala';
|
||||
import { ImpalaSQL } from 'src/parser/impala';
|
||||
import { readSQL } from 'test/helper';
|
||||
|
||||
const parser = new ImpalaSQL();
|
||||
const impala = new ImpalaSQL();
|
||||
|
||||
const features = {
|
||||
computeStats: readSQL(__dirname, 'compute_stats.sql'),
|
||||
@ -23,91 +23,91 @@ describe('ImpalaSQL Other Syntax Tests', () => {
|
||||
describe('COMPUTE STATS', () => {
|
||||
features.computeStats.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('COMMENT STATEMENT', () => {
|
||||
features.comments.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('GRANT STATEMENT', () => {
|
||||
features.grants.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('REVOKE STATEMENT', () => {
|
||||
features.revokes.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('LOAD DATA STATEMENT', () => {
|
||||
features.loadData.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('DESCRIBE STATEMENT', () => {
|
||||
features.describes.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('EXPLAIN STATEMENT', () => {
|
||||
features.explains.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('INVALIDATE METADATA STATEMENT', () => {
|
||||
features.invalidates.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('SET STATEMENT', () => {
|
||||
features.set.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('SHUTDOWN STATEMENT', () => {
|
||||
features.shutdown.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('TRUNCATE TABLE STATEMENT', () => {
|
||||
features.truncate.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('USE STATEMENT', () => {
|
||||
features.use.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('VALUES STATEMENT', () => {
|
||||
features.values.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
import ImpalaSQL from 'src/parser/impala';
|
||||
import { ImpalaSQL } from 'src/parser/impala';
|
||||
import { readSQL } from 'test/helper';
|
||||
|
||||
const parser = new ImpalaSQL();
|
||||
const impala = new ImpalaSQL();
|
||||
|
||||
const features = {
|
||||
refresh: readSQL(__dirname, 'refresh.sql'),
|
||||
@ -13,21 +13,21 @@ describe('ImpalaSQL Refresh Syntax Tests', () => {
|
||||
describe('REFRESH', () => {
|
||||
features.refresh.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('REFRESH AUTHORIZATION', () => {
|
||||
features.authorization.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('REFRESH FUNCTION', () => {
|
||||
features.function.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
import ImpalaSQL from 'src/parser/impala';
|
||||
import { ImpalaSQL } from 'src/parser/impala';
|
||||
import { readSQL } from 'test/helper';
|
||||
|
||||
const parser = new ImpalaSQL();
|
||||
const impala = new ImpalaSQL();
|
||||
|
||||
const features = {
|
||||
select: readSQL(__dirname, 'select.sql'),
|
||||
@ -11,7 +11,7 @@ describe('ImpalaSQL Select Syntax Tests', () => {
|
||||
describe('SELECT', () => {
|
||||
features.select.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
import ImpalaSQL from 'src/parser/impala';
|
||||
import { ImpalaSQL } from 'src/parser/impala';
|
||||
import { readSQL } from 'test/helper';
|
||||
|
||||
const parser = new ImpalaSQL();
|
||||
const impala = new ImpalaSQL();
|
||||
|
||||
const features = {
|
||||
shows: readSQL(__dirname, 'show.sql'),
|
||||
@ -11,7 +11,7 @@ describe('ImpalaSQL Show Syntax Tests', () => {
|
||||
describe('SHOW', () => {
|
||||
features.shows.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
import ImpalaSQL from 'src/parser/impala';
|
||||
import { ImpalaSQL } from 'src/parser/impala';
|
||||
import { readSQL } from 'test/helper';
|
||||
|
||||
const parser = new ImpalaSQL();
|
||||
const impala = new ImpalaSQL();
|
||||
|
||||
const features = {
|
||||
update: readSQL(__dirname, 'update.sql'),
|
||||
@ -11,7 +11,7 @@ describe('ImpalaSQL Update Syntax Tests', () => {
|
||||
describe('UPDATE', () => {
|
||||
features.update.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
import ImpalaSQL from 'src/parser/impala';
|
||||
import { ImpalaSQL } from 'src/parser/impala';
|
||||
import { readSQL } from 'test/helper';
|
||||
|
||||
const parser = new ImpalaSQL();
|
||||
const impala = new ImpalaSQL();
|
||||
|
||||
const features = {
|
||||
update: readSQL(__dirname, 'upsert.sql'),
|
||||
@ -11,7 +11,7 @@ describe('ImpalaSQL Upsert Syntax Tests', () => {
|
||||
describe('UPSERT', () => {
|
||||
features.update.forEach((db) => {
|
||||
it(db, () => {
|
||||
expect(parser.validate(db).length).toBe(0);
|
||||
expect(impala.validate(db).length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,16 +1,16 @@
|
||||
import ImpalaSQL from 'src/parser/impala';
|
||||
import { ImpalaSQL } from 'src/parser/impala';
|
||||
|
||||
const randomText = `dhsdansdnkla ndjnsla ndnalks`;
|
||||
const unCompleteSQL = `CREATE TABLE`;
|
||||
|
||||
describe('Impala SQL validate invalid sql', () => {
|
||||
const parser = new ImpalaSQL();
|
||||
const impala = new ImpalaSQL();
|
||||
|
||||
test('validate random text', () => {
|
||||
expect(parser.validate(randomText).length).not.toBe(0);
|
||||
expect(impala.validate(randomText).length).not.toBe(0);
|
||||
});
|
||||
|
||||
test('validate unComplete sql', () => {
|
||||
expect(parser.validate(unCompleteSQL).length).not.toBe(0);
|
||||
expect(impala.validate(unCompleteSQL).length).not.toBe(0);
|
||||
});
|
||||
});
|
||||
|
@ -1,13 +1,13 @@
|
||||
import ImpalaSQL from 'src/parser/impala';
|
||||
import { ImpalaSQL } from 'src/parser/impala';
|
||||
import { AbstractParseTreeVisitor } from 'antlr4ng';
|
||||
import { ImpalaSqlParserVisitor } from 'src/lib/impala/ImpalaSqlParserVisitor';
|
||||
|
||||
describe('impala SQL Visitor Tests', () => {
|
||||
const expectTableName = 'user1';
|
||||
const sql = `select id,name,sex from ${expectTableName};`;
|
||||
const parser = new ImpalaSQL();
|
||||
const impala = new ImpalaSQL();
|
||||
|
||||
const parseTree = parser.parse(sql, (error) => {
|
||||
const parseTree = impala.parse(sql, (error) => {
|
||||
console.error('Parse error:', error);
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user