lava-oushudb-dt-sql-parser/test/parser/trinosql/syntax/showStatement.test.ts
mumiao 9c82a5d248
feat: support trino(presto) sql language (#105)
* feat(trino): intergrate prestoGrammar to dt-sql-parser

* feat(trino): add trinoSQl test framework

* feat(trino): intergrate test files for trinoSQL

* test(trino): support alterStatement test

* test(trino): support alter table set authorization statement

* feat(trino): complete trinosql alter unit tests

* test(trino): complete dropStatement unit cases for trinosql

* test(trino): complete create statement unit cases for trinoSQL

* test(trino): complete insertStatement unit cases for trinoSQl

* test(trino): dropStatement test files changed to short line split

* test(trino): complete selectStatement unit cases and grammar check

* test(trino): complete commentStatement unit case for trinoSQL

* test(trino): complete analyze commit and call clause unit case

* test(trino): complete delete deny and describe statement unit case

* test(trino): complete explain execute and grant statement unit case

* feat(trino): improve GRANT Role grammar

* test(trino): complete show statement unit case

* test(trino): complete truncateTable startTransaction update and values  statement unit case

* test(trino): improve update statement test cases

* test(trino): complete revoke revoke roles  and rollback statement unit case

* test(trino): add set statement test case

* feat: generator new trino parser and lexer file

* feat(trino): improve alter statement grammar

* test(trino): complete alter statement unit cases

* feat(trino): support case-insensitive lexers

* fix(trino): rm unless gen files

* test(trino): complete merge and reset session statement unit cases

* test(trino): complete merge anduse statement unit cases

* test(trino): complete prepare and refresh materialized view statement unit cases

* test(trino): improve statement unit cases

* test(trino): complete match recognize statement unit cases

* test(trino): complete window with row pattern recognition statement unit cases
2023-05-24 15:07:02 +08:00

79 lines
2.4 KiB
TypeScript

import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
const features = {
tables: readSQL(__dirname, 'show_tables.sql'),
catalogs: readSQL(__dirname, 'show_catalogs.sql'),
columns: readSQL(__dirname, 'show_columns.sql'),
functions: readSQL(__dirname, 'show_functions.sql'),
grants: readSQL(__dirname, 'show_grants.sql'),
roleGrants: readSQL(__dirname, 'show_role_grants.sql'),
roles: readSQL(__dirname, 'show_roles.sql'),
schemas: readSQL(__dirname, 'show_schemas.sql'),
session: readSQL(__dirname, 'show_session.sql'),
statsForQuery: readSQL(__dirname, 'show_stats_for_query.sql'),
stats: readSQL(__dirname, 'show_stats.sql'),
create: readSQL(__dirname, 'show_create.sql'),
};
describe('TrinoSQL Show Statements Syntax Tests', () => {
const parser = new TrinoSQL();
// show statements
features.tables.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
features.catalogs.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
features.columns.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
features.functions.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
features.grants.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
features.roleGrants.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
features.roles.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
features.schemas.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
features.session.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
features.statsForQuery.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
features.stats.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
});