Skip to content

Commit c51a2d8

Browse files
committed
fix(syntaxSuggestion): resolve conflicts and move tests
1 parent 65a8760 commit c51a2d8

File tree

4 files changed

+31
-59
lines changed

4 files changed

+31
-59
lines changed

test/parser/flink/suggestion/fixtures/syntaxSuggestion.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ CREATE TABLE yourTable (ts TIMESTAMP(3), WATERMARK FOR );
4040

4141
CREATE TABLE newTable ( );
4242

43+
CREATE TABLE tmp_table (col INT) WITH ('connector'='kafka');
44+
4345
SELECT SUM(amount) FROM Orders GROUP BY length(users) HAVING SUM(amount) > 50;
4446

4547
SELECT * FROM Orders ORDER BY orderTime LIMIT length(order_id);

test/parser/flink/suggestion/fixtures/tokenSuggestion.sql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,3 @@ CREATE TABLE IF NOT EXISTS
1313
CREATE TABLE tb (id
1414

1515
);
16-
17-
CREATE TABLE tmp_table (col INT) WITH ('connector'='kafka');

test/parser/flink/suggestion/syntaxSuggestion.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,4 +469,32 @@ describe('Flink SQL Syntax Suggestion', () => {
469469
expect(suggestion).not.toBeUndefined();
470470
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['age']);
471471
});
472+
473+
test('Create Statement table properties', () => {
474+
const scenarios = [
475+
{
476+
caretPosition: {
477+
lineNumber: 9,
478+
column: 45,
479+
},
480+
entityContextType: EntityContextType.TABLE_PROPERTY_KEY,
481+
},
482+
{
483+
caretPosition: {
484+
lineNumber: 9,
485+
column: 55,
486+
},
487+
entityContextType: EntityContextType.TABLE_PROPERTY_VALUE,
488+
},
489+
];
490+
491+
scenarios.forEach((scenario) => {
492+
const suggestion = flink.getSuggestionAtCaretPosition(
493+
commentOtherLine(syntaxSql, scenario.caretPosition.lineNumber),
494+
scenario.caretPosition
495+
)?.syntax;
496+
497+
expect(suggestion[0].syntaxContextType).toBe(scenario.entityContextType);
498+
});
499+
});
472500
});

test/parser/flink/suggestion/tokenSuggestion.test.ts

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from 'fs';
22
import path from 'path';
33
import { FlinkSQL } from 'src/parser/flink';
4-
import { CaretPosition, EntityContextType } from 'src/parser/common/types';
4+
import { CaretPosition } from 'src/parser/common/types';
55
import { commentOtherLine } from 'test/helper';
66

77
const tokenSql = fs.readFileSync(path.join(__dirname, 'fixtures', 'tokenSuggestion.sql'), 'utf-8');
@@ -94,62 +94,6 @@ describe('Flink SQL Token Suggestion', () => {
9494
expect(suggestion).toContain('NOT EXISTS');
9595
});
9696

97-
test('Create Statement table properties', () => {
98-
const scenarios = [
99-
{
100-
caretPosition: {
101-
lineNumber: 9,
102-
column: 45,
103-
},
104-
entityContextType: EntityContextType.TABLE_PROPERTY_KEY,
105-
},
106-
{
107-
caretPosition: {
108-
lineNumber: 9,
109-
column: 55,
110-
},
111-
entityContextType: EntityContextType.TABLE_PROPERTY_VALUE,
112-
},
113-
];
114-
115-
scenarios.forEach((scenario) => {
116-
const suggestion = flink.getSuggestionAtCaretPosition(
117-
commentOtherLine(tokenSql, scenario.caretPosition.lineNumber),
118-
scenario.caretPosition
119-
)?.syntax;
120-
121-
expect(suggestion[0].syntaxContextType).toBe(scenario.entityContextType);
122-
});
123-
});
124-
125-
test('Create Statement table properties', () => {
126-
const scenarios = [
127-
{
128-
caretPosition: {
129-
lineNumber: 9,
130-
column: 45,
131-
},
132-
entityContextType: EntityContextType.TABLE_PROPERTY_KEY,
133-
},
134-
{
135-
caretPosition: {
136-
lineNumber: 9,
137-
column: 55,
138-
},
139-
entityContextType: EntityContextType.TABLE_PROPERTY_VALUE,
140-
},
141-
];
142-
143-
scenarios.forEach((scenario) => {
144-
const suggestion = flink.getSuggestionAtCaretPosition(
145-
commentOtherLine(tokenSql, scenario.caretPosition.lineNumber),
146-
scenario.caretPosition
147-
)?.syntax;
148-
149-
expect(suggestion[0].syntaxContextType).toBe(scenario.entityContextType);
150-
});
151-
});
152-
15397
test('Suggestion in new line', () => {
15498
const pos: CaretPosition = {
15599
lineNumber: 13,

0 commit comments

Comments
 (0)