2024-03-26 14:28:27 +08:00
|
|
|
import TrinoSQL from 'src/parser/trino';
|
2024-01-19 21:10:00 +08:00
|
|
|
import { readSQL } from 'test/helper';
|
2023-05-24 15:07:02 +08:00
|
|
|
|
|
|
|
const features = {
|
|
|
|
table: readSQL(__dirname, 'create_table.sql'),
|
|
|
|
view: readSQL(__dirname, 'create_view.sql'),
|
|
|
|
schema: readSQL(__dirname, 'create_schema.sql'),
|
|
|
|
role: readSQL(__dirname, 'create_role.sql'),
|
|
|
|
tableAsSelect: readSQL(__dirname, 'create_table_as_select.sql'),
|
|
|
|
materializedView: readSQL(__dirname, 'create_materialized_view.sql'),
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('TrinoSQL Create Statements Syntax Tests', () => {
|
|
|
|
const parser = new TrinoSQL();
|
2023-10-13 11:16:36 +08:00
|
|
|
features.table.forEach((sql) => {
|
2023-05-24 15:07:02 +08:00
|
|
|
it(sql, () => {
|
|
|
|
expect(parser.validate(sql).length).toBe(0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
features.view.forEach((sql) => {
|
|
|
|
it(sql, () => {
|
|
|
|
expect(parser.validate(sql).length).toBe(0);
|
|
|
|
});
|
2023-10-13 11:16:36 +08:00
|
|
|
});
|
2023-05-24 15:07:02 +08:00
|
|
|
features.schema.forEach((sql) => {
|
|
|
|
it(sql, () => {
|
|
|
|
expect(parser.validate(sql).length).toBe(0);
|
|
|
|
});
|
2023-10-13 11:16:36 +08:00
|
|
|
});
|
2023-05-24 15:07:02 +08:00
|
|
|
|
|
|
|
features.tableAsSelect.forEach((sql) => {
|
|
|
|
it(sql, () => {
|
|
|
|
expect(parser.validate(sql).length).toBe(0);
|
|
|
|
});
|
2023-10-13 11:16:36 +08:00
|
|
|
});
|
2023-05-24 15:07:02 +08:00
|
|
|
features.role.forEach((sql) => {
|
|
|
|
it(sql, () => {
|
|
|
|
expect(parser.validate(sql).length).toBe(0);
|
|
|
|
});
|
2023-10-13 11:16:36 +08:00
|
|
|
});
|
2023-05-24 15:07:02 +08:00
|
|
|
features.materializedView.forEach((sql) => {
|
|
|
|
it(sql, () => {
|
|
|
|
expect(parser.validate(sql).length).toBe(0);
|
|
|
|
});
|
2023-10-13 11:16:36 +08:00
|
|
|
});
|
2023-05-24 15:07:02 +08:00
|
|
|
});
|