2023-12-19 19:22:27 +08:00
|
|
|
import { FlinkSQL } from '../../../filters';
|
2023-10-13 11:16:36 +08:00
|
|
|
import { readSQL } from '../../../helper';
|
2023-05-17 10:30:25 +08:00
|
|
|
|
|
|
|
const parser = new FlinkSQL();
|
|
|
|
|
|
|
|
const features = {
|
2023-10-13 11:16:36 +08:00
|
|
|
base: readSQL(__dirname, 'select.sql'),
|
|
|
|
withClause: readSQL(__dirname, 'selectWithClause.sql'),
|
|
|
|
distinct: readSQL(__dirname, 'selectDistinct.sql'),
|
|
|
|
windowTVF: readSQL(__dirname, 'selectWindowTVF.sql'),
|
|
|
|
aggregation: readSQL(__dirname, 'selectAggregation.sql'),
|
|
|
|
join: readSQL(__dirname, 'selectJoin.sql'),
|
|
|
|
setOperation: readSQL(__dirname, 'selectSetOperations.sql'),
|
|
|
|
pattern: readSQL(__dirname, 'selectPatternRecognition.sql'),
|
|
|
|
where: readSQL(__dirname, 'selectWhere.sql'),
|
2023-05-17 10:30:25 +08:00
|
|
|
};
|
|
|
|
|
2023-10-13 11:16:36 +08:00
|
|
|
describe('FlinkSQL Query Statement Tests', () => {
|
|
|
|
describe('Base Select', () => {
|
2023-05-17 10:30:25 +08:00
|
|
|
features.base.forEach((sql) => {
|
|
|
|
it(sql, () => {
|
|
|
|
expect(parser.validate(sql).length).toBe(0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2023-10-13 11:16:36 +08:00
|
|
|
describe('With Clause Select', () => {
|
2023-05-17 10:30:25 +08:00
|
|
|
features.withClause.forEach((sql) => {
|
|
|
|
it(sql, () => {
|
|
|
|
expect(parser.validate(sql).length).toBe(0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2023-10-13 11:16:36 +08:00
|
|
|
describe('Select DISTINCT', () => {
|
2023-05-17 10:30:25 +08:00
|
|
|
features.distinct.forEach((sql) => {
|
|
|
|
it(sql, () => {
|
|
|
|
expect(parser.validate(sql).length).toBe(0);
|
|
|
|
});
|
2023-10-13 11:16:36 +08:00
|
|
|
});
|
|
|
|
});
|
2023-05-17 10:30:25 +08:00
|
|
|
|
2023-10-13 11:16:36 +08:00
|
|
|
describe('Select Window TVF', () => {
|
2023-05-17 10:30:25 +08:00
|
|
|
features.windowTVF.forEach((sql) => {
|
|
|
|
it(sql, () => {
|
|
|
|
expect(parser.validate(sql).length).toBe(0);
|
|
|
|
});
|
2023-10-13 11:16:36 +08:00
|
|
|
});
|
|
|
|
});
|
2023-05-17 10:30:25 +08:00
|
|
|
|
2023-10-13 11:16:36 +08:00
|
|
|
describe('Select Aggregation', () => {
|
2023-05-17 10:30:25 +08:00
|
|
|
features.aggregation.forEach((sql) => {
|
|
|
|
it(sql, () => {
|
|
|
|
expect(parser.validate(sql).length).toBe(0);
|
|
|
|
});
|
2023-10-13 11:16:36 +08:00
|
|
|
});
|
|
|
|
});
|
2023-05-17 10:30:25 +08:00
|
|
|
|
2023-10-13 11:16:36 +08:00
|
|
|
describe('Select Join', () => {
|
2023-05-17 10:30:25 +08:00
|
|
|
features.join.forEach((sql) => {
|
|
|
|
it(sql, () => {
|
|
|
|
expect(parser.validate(sql).length).toBe(0);
|
|
|
|
});
|
2023-10-13 11:16:36 +08:00
|
|
|
});
|
|
|
|
});
|
2023-05-17 10:30:25 +08:00
|
|
|
|
2023-10-13 11:16:36 +08:00
|
|
|
describe('Select Set Operations', () => {
|
2023-05-17 10:30:25 +08:00
|
|
|
features.setOperation.forEach((sql) => {
|
|
|
|
it(sql, () => {
|
|
|
|
expect(parser.validate(sql).length).toBe(0);
|
|
|
|
});
|
2023-10-13 11:16:36 +08:00
|
|
|
});
|
|
|
|
});
|
2023-05-17 10:30:25 +08:00
|
|
|
|
2023-10-13 11:16:36 +08:00
|
|
|
describe('Select Pattern Recognition', () => {
|
2023-05-17 10:30:25 +08:00
|
|
|
features.pattern.forEach((sql) => {
|
|
|
|
it(sql, () => {
|
|
|
|
expect(parser.validate(sql).length).toBe(0);
|
|
|
|
});
|
2023-10-13 11:16:36 +08:00
|
|
|
});
|
|
|
|
});
|
2023-05-24 15:03:08 +08:00
|
|
|
|
2023-10-13 11:16:36 +08:00
|
|
|
describe('Select Where', () => {
|
2023-05-24 15:03:08 +08:00
|
|
|
features.where.forEach((sql) => {
|
|
|
|
it(sql, () => {
|
2023-10-13 11:16:36 +08:00
|
|
|
expect(parser.validate(sql).length).toBe(0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2023-05-17 10:30:25 +08:00
|
|
|
});
|