lava-oushudb-dt-sql-parser/test/parser/trino/syntax/selectStatement.test.ts
Hayden bb0fad1dbe
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
2024-03-27 10:33:25 +08:00

83 lines
2.8 KiB
TypeScript

import { TrinoSQL } from 'src/parser/trino';
import { readSQL } from 'test/helper';
const features = {
select: readSQL(__dirname, 'select.sql'),
selectWithClause: readSQL(__dirname, 'select_with_clause.sql'),
selectWithSetOperations: readSQL(__dirname, 'select_with_set_operations.sql'),
selectWithSubQueries: readSQL(__dirname, 'select_with_sub_queries.sql'),
selectWithTableSample: readSQL(__dirname, 'select_with_table_sample.sql'),
selectWithRowType: readSQL(__dirname, 'select_with_row_type.sql'),
selectWithOffset: readSQL(__dirname, 'select_with_offset.sql'),
selectWithJoin: readSQL(__dirname, 'select_with_join.sql'),
selectWithFetch: readSQL(__dirname, 'select_with_fetch.sql'),
selectWithUNNEST: readSQL(__dirname, 'select_with_ unnest.sql'),
selectWithExists: readSQL(__dirname, 'select_with_exists.sql'),
selectWithUnion: readSQL(__dirname, 'select_with_union.sql'),
};
describe('TrinoSQL Select Statements Syntax Tests', () => {
const trino = new TrinoSQL();
features.select.forEach((sql) => {
it(sql, () => {
expect(trino.validate(sql).length).toBe(0);
});
});
features.selectWithClause.forEach((sql) => {
it(sql, () => {
expect(trino.validate(sql).length).toBe(0);
});
});
features.selectWithSetOperations.forEach((sql) => {
it(sql, () => {
expect(trino.validate(sql).length).toBe(0);
});
});
features.selectWithSubQueries.forEach((sql) => {
it(sql, () => {
expect(trino.validate(sql).length).toBe(0);
});
});
features.selectWithTableSample.forEach((sql) => {
it(sql, () => {
expect(trino.validate(sql).length).toBe(0);
});
});
features.selectWithRowType.forEach((sql) => {
it(sql, () => {
expect(trino.validate(sql).length).toBe(0);
});
});
features.selectWithOffset.forEach((sql) => {
it(sql, () => {
expect(trino.validate(sql).length).toBe(0);
});
});
features.selectWithJoin.forEach((sql) => {
it(sql, () => {
expect(trino.validate(sql).length).toBe(0);
});
});
features.selectWithFetch.forEach((sql) => {
it(sql, () => {
expect(trino.validate(sql).length).toBe(0);
});
});
features.selectWithUNNEST.forEach((sql) => {
it(sql, () => {
expect(trino.validate(sql).length).toBe(0);
});
});
features.selectWithExists.forEach((sql) => {
it(sql, () => {
expect(trino.validate(sql).length).toBe(0);
});
});
features.selectWithUnion.forEach((sql) => {
it(sql, () => {
expect(trino.validate(sql).length).toBe(0);
});
});
});