2023-05-04 10:13:05 +08:00
|
|
|
import FlinkSQL from "../../../../src/parser/flinksql";
|
2023-02-27 19:03:32 +08:00
|
|
|
|
|
|
|
describe('FlinkSQL Create Table Syntax Tests', () => {
|
|
|
|
const parser = new FlinkSQL();
|
|
|
|
// Create statements
|
|
|
|
test('Test Create Catalog Statement', () => {
|
|
|
|
const sql = `
|
|
|
|
CREATE CATALOG c1
|
|
|
|
WITH (
|
|
|
|
'key1'='value1',
|
|
|
|
'key2'='value2'
|
|
|
|
)
|
|
|
|
`;
|
|
|
|
const result = parser.validate(sql);
|
|
|
|
expect(result.length).toBe(0);
|
|
|
|
});
|
|
|
|
test('Test simple Create Database Statement', () => {
|
|
|
|
const sql = `
|
|
|
|
CREATE DATABASE IF NOT EXISTS dataApi
|
|
|
|
WITH (
|
|
|
|
"owner" = "admin"
|
|
|
|
);
|
|
|
|
`;
|
|
|
|
const result = parser.validate(sql);
|
|
|
|
expect(result.length).toBe(0);
|
|
|
|
});
|
|
|
|
test('Test simple Create View Statement', () => {
|
|
|
|
const sql = `
|
|
|
|
CREATE TEMPORARY VIEW IF NOT EXISTS tempView
|
|
|
|
AS SELECT product, amount FROM Orders;
|
|
|
|
`;
|
|
|
|
const result = parser.validate(sql);
|
|
|
|
expect(result.length).toBe(0);
|
|
|
|
});
|
|
|
|
test('Test simple Create Function Statement', () => {
|
|
|
|
const sql = `
|
|
|
|
CREATE FUNCTION IF NOT EXISTS tempFunction AS 'SimpleUdf';
|
|
|
|
CREATE TEMPORARY FUNCTION function1 AS 'org.apache.fink.function.function1' LANGUAGE JAVA USING JAR 'file:///path/to/test.jar', JAR 'hdfs:///path/to/test2.jar';
|
|
|
|
`;
|
|
|
|
const result = parser.validate(sql);
|
|
|
|
expect(result.length).toBe(0);
|
|
|
|
});
|
|
|
|
});
|