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 { 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();
|
||||
// Alter statements
|
||||
test('Test simple alter table Statement', () => {
|
||||
const sql = `
|
||||
ALTER TABLE Orders RENAME TO NewOrders;
|
||||
ALTER TABLE sample_table SET ('key1'='value2');
|
||||
`;
|
||||
const result = parser.validate(sql);
|
||||
expect(result.length).toBe(0);
|
||||
features.table.forEach((sql) => {
|
||||
it(sql, () => {
|
||||
expect(parser.validate(sql).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', () => {
|
||||
const sql = `ALTER DATABASE tempDB SET ("key1"="value1");`;
|
||||
const result = parser.validate(sql);
|
||||
expect(result.length).toBe(0);
|
||||
features.view.forEach((sql) => {
|
||||
it(sql, () => {
|
||||
expect(parser.validate(sql).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