test: update tests of alter statemnts
This commit is contained in:
parent
34590a5e9b
commit
65a754e533
@ -1,38 +1,36 @@
|
|||||||
import FlinkSQL from "../../../../src/parser/flinksql";
|
import FlinkSQL from "../../../../src/parser/flinksql";
|
||||||
|
import { readSQL } from "../../../helper";
|
||||||
|
|
||||||
describe('FlinkSQL Create Table Syntax Tests', () => {
|
const features = {
|
||||||
|
table: readSQL(__dirname, 'alterTable.sql'),
|
||||||
|
view: readSQL(__dirname, 'alterView.sql'),
|
||||||
|
function: readSQL(__dirname, 'alterFunction.sql'),
|
||||||
|
database: readSQL(__dirname, 'alterDatabase.sql'),
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('FlinkSQL Alter Statements Syntax Tests', () => {
|
||||||
const parser = new FlinkSQL();
|
const parser = new FlinkSQL();
|
||||||
// Alter statements
|
// Alter statements
|
||||||
test('Test simple alter table Statement', () => {
|
features.table.forEach((sql) => {
|
||||||
const sql = `
|
it(sql, () => {
|
||||||
ALTER TABLE Orders RENAME TO NewOrders;
|
expect(parser.validate(sql).length).toBe(0);
|
||||||
ALTER TABLE sample_table SET ('key1'='value2');
|
|
||||||
`;
|
|
||||||
const result = parser.validate(sql);
|
|
||||||
expect(result.length).toBe(0);
|
|
||||||
});
|
});
|
||||||
test('Test simple alter view Statement', () => {
|
|
||||||
const sql = `
|
|
||||||
ALTER VIEW v1 RENAME TO v2;
|
|
||||||
ALTER VIEW v1 AS SELECT c1, c2 FROM tbl;
|
|
||||||
`;
|
|
||||||
const result = parser.validate(sql);
|
|
||||||
expect(result.length).toBe(0);
|
|
||||||
});
|
});
|
||||||
test('Test simple alter database Statement', () => {
|
features.view.forEach((sql) => {
|
||||||
const sql = `ALTER DATABASE tempDB SET ("key1"="value1");`;
|
it(sql, () => {
|
||||||
const result = parser.validate(sql);
|
expect(parser.validate(sql).length).toBe(0);
|
||||||
expect(result.length).toBe(0);
|
});
|
||||||
|
});
|
||||||
|
features.database.forEach((sql) => {
|
||||||
|
it(sql, () => {
|
||||||
|
expect(parser.validate(sql).length).toBe(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
features.function.forEach((sql) => {
|
||||||
|
it(sql, () => {
|
||||||
|
expect(parser.validate(sql).length).toBe(0);
|
||||||
});
|
});
|
||||||
test('Test simple alter function Statement', () => {
|
|
||||||
const sql = `
|
|
||||||
ALTER FUNCTION tempFunction AS 'SimpleUdf';
|
|
||||||
ALTER TEMPORARY FUNCTION IF EXISTS tempFunction AS 'SimpleUdf';
|
|
||||||
ALTER TEMPORARY SYSTEM FUNCTION IF EXISTS tempFunction AS 'SimpleUdf';
|
|
||||||
ALTER FUNCTION myudf AS 'com.example.MyUdf' LANGUAGE PYTHON;
|
|
||||||
`;
|
|
||||||
const result = parser.validate(sql);
|
|
||||||
expect(result.length).toBe(0);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
1
test/parser/flinksql/syntax/fixtures/alterDatabase.sql
Normal file
1
test/parser/flinksql/syntax/fixtures/alterDatabase.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
ALTER DATABASE tempDB SET ("key1"="value1");
|
7
test/parser/flinksql/syntax/fixtures/alterFunction.sql
Normal file
7
test/parser/flinksql/syntax/fixtures/alterFunction.sql
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
ALTER FUNCTION tempFunction AS 'SimpleUdf';
|
||||||
|
|
||||||
|
ALTER TEMPORARY FUNCTION IF EXISTS tempFunction AS 'SimpleUdf';
|
||||||
|
|
||||||
|
ALTER TEMPORARY SYSTEM FUNCTION IF EXISTS tempFunction AS 'SimpleUdf';
|
||||||
|
|
||||||
|
ALTER FUNCTION myudf AS 'com.example.MyUdf' LANGUAGE PYTHON;
|
7
test/parser/flinksql/syntax/fixtures/alterTable.sql
Normal file
7
test/parser/flinksql/syntax/fixtures/alterTable.sql
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
ALTER TABLE
|
||||||
|
Orders RENAME TO NewOrders;
|
||||||
|
|
||||||
|
ALTER TABLE
|
||||||
|
sample_table
|
||||||
|
SET
|
||||||
|
('key1' = 'value2');
|
8
test/parser/flinksql/syntax/fixtures/alterView.sql
Normal file
8
test/parser/flinksql/syntax/fixtures/alterView.sql
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
ALTER VIEW v1 RENAME TO v2;
|
||||||
|
|
||||||
|
ALTER VIEW v1 AS
|
||||||
|
SELECT
|
||||||
|
c1,
|
||||||
|
c2
|
||||||
|
FROM
|
||||||
|
tbl;
|
Loading…
Reference in New Issue
Block a user