2023-06-09 11:22:53 +08:00
|
|
|
import fs from 'fs';
|
|
|
|
import path from 'path';
|
|
|
|
import { CaretPosition } from '../../../../src/parser/common/basic-parser-types';
|
|
|
|
import FlinkSQL from '../../../../src/parser/flinksql'
|
|
|
|
|
|
|
|
const tokenSql = fs.readFileSync(path.join(__dirname, 'fixtures', 'tokenSuggestion.sql'), 'utf-8');
|
|
|
|
|
2023-10-10 16:37:49 +08:00
|
|
|
describe('Flink SQL Token Suggestion', () => {
|
2023-06-09 11:22:53 +08:00
|
|
|
const parser = new FlinkSQL();
|
|
|
|
|
|
|
|
test('Use Statement ', () => {
|
|
|
|
const pos: CaretPosition = {
|
|
|
|
lineNumber: 3,
|
|
|
|
column: 5
|
|
|
|
}
|
|
|
|
const suggestion = parser.getSuggestionAtCaretPosition(tokenSql, pos)?.keywords;
|
|
|
|
|
|
|
|
expect(suggestion)
|
|
|
|
.toEqual([ 'MODULES', 'CATALOG' ])
|
|
|
|
})
|
|
|
|
|
|
|
|
test('Create Statement ', () => {
|
|
|
|
const pos: CaretPosition = {
|
|
|
|
lineNumber: 5,
|
|
|
|
column: 8
|
|
|
|
}
|
|
|
|
const suggestion = parser.getSuggestionAtCaretPosition(tokenSql, pos)?.keywords;
|
|
|
|
|
|
|
|
expect(suggestion)
|
|
|
|
.toEqual([ 'CATALOG', 'FUNCTION', 'TEMPORARY', 'VIEW', 'DATABASE', 'TABLE' ])
|
|
|
|
})
|
|
|
|
|
|
|
|
test('Show Statement ', () => {
|
|
|
|
const pos: CaretPosition = {
|
|
|
|
lineNumber: 7,
|
|
|
|
column: 6
|
|
|
|
}
|
|
|
|
const suggestion = parser.getSuggestionAtCaretPosition(tokenSql, pos)?.keywords;
|
|
|
|
|
|
|
|
expect(suggestion)
|
|
|
|
.toEqual([
|
|
|
|
'MODULES',
|
|
|
|
'FULL',
|
|
|
|
'FUNCTIONS',
|
|
|
|
'USER',
|
|
|
|
'CREATE',
|
|
|
|
'COLUMNS',
|
|
|
|
'TABLES',
|
|
|
|
'CURRENT',
|
|
|
|
'CATALOGS',
|
|
|
|
'DATABASES',
|
|
|
|
'JARS',
|
|
|
|
'VIEWS'
|
|
|
|
])
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|