@@ -374,4 +374,89 @@ describe('Flink SQL Syntax Suggestion', () => {
374
374
expect ( suggestion ) . not . toBeUndefined ( ) ;
375
375
expect ( suggestion ?. wordRanges . map ( ( token ) => token . text ) ) . toEqual ( [ ] ) ;
376
376
} ) ;
377
+
378
+ test ( 'Select expression column' , ( ) => {
379
+ const pos : CaretPosition = {
380
+ lineNumber : 43 ,
381
+ column : 18 ,
382
+ } ;
383
+ const syntaxes = flink . getSuggestionAtCaretPosition (
384
+ commentOtherLine ( syntaxSql , pos . lineNumber ) ,
385
+ pos
386
+ ) ?. syntax ;
387
+ const suggestion = syntaxes ?. find (
388
+ ( syn ) => syn . syntaxContextType === EntityContextType . COLUMN
389
+ ) ;
390
+
391
+ expect ( suggestion ) . not . toBeUndefined ( ) ;
392
+ expect ( suggestion ?. wordRanges . map ( ( token ) => token . text ) ) . toEqual ( [ 'amount' ] ) ;
393
+ } ) ;
394
+
395
+ test ( 'Group by expression column' , ( ) => {
396
+ const pos : CaretPosition = {
397
+ lineNumber : 43 ,
398
+ column : 53 ,
399
+ } ;
400
+ const syntaxes = flink . getSuggestionAtCaretPosition (
401
+ commentOtherLine ( syntaxSql , pos . lineNumber ) ,
402
+ pos
403
+ ) ?. syntax ;
404
+ const suggestion = syntaxes ?. find (
405
+ ( syn ) => syn . syntaxContextType === EntityContextType . COLUMN
406
+ ) ;
407
+
408
+ expect ( suggestion ) . not . toBeUndefined ( ) ;
409
+ expect ( suggestion ?. wordRanges . map ( ( token ) => token . text ) ) . toEqual ( [ 'users' ] ) ;
410
+ } ) ;
411
+
412
+ test ( 'Having expression column' , ( ) => {
413
+ const pos : CaretPosition = {
414
+ lineNumber : 43 ,
415
+ column : 72 ,
416
+ } ;
417
+ const syntaxes = flink . getSuggestionAtCaretPosition (
418
+ commentOtherLine ( syntaxSql , pos . lineNumber ) ,
419
+ pos
420
+ ) ?. syntax ;
421
+ const suggestion = syntaxes ?. find (
422
+ ( syn ) => syn . syntaxContextType === EntityContextType . COLUMN
423
+ ) ;
424
+
425
+ expect ( suggestion ) . not . toBeUndefined ( ) ;
426
+ expect ( suggestion ?. wordRanges . map ( ( token ) => token . text ) ) . toEqual ( [ 'amount' ] ) ;
427
+ } ) ;
428
+
429
+ test ( 'Limit by expression column' , ( ) => {
430
+ const pos : CaretPosition = {
431
+ lineNumber : 45 ,
432
+ column : 62 ,
433
+ } ;
434
+ const syntaxes = flink . getSuggestionAtCaretPosition (
435
+ commentOtherLine ( syntaxSql , pos . lineNumber ) ,
436
+ pos
437
+ ) ?. syntax ;
438
+ const suggestion = syntaxes ?. find (
439
+ ( syn ) => syn . syntaxContextType === EntityContextType . COLUMN
440
+ ) ;
441
+
442
+ expect ( suggestion ) . not . toBeUndefined ( ) ;
443
+ expect ( suggestion ?. wordRanges . map ( ( token ) => token . text ) ) . toEqual ( [ 'order_id' ] ) ;
444
+ } ) ;
445
+
446
+ test ( 'When by expression column' , ( ) => {
447
+ const pos : CaretPosition = {
448
+ lineNumber : 47 ,
449
+ column : 25 ,
450
+ } ;
451
+ const syntaxes = flink . getSuggestionAtCaretPosition (
452
+ commentOtherLine ( syntaxSql , pos . lineNumber ) ,
453
+ pos
454
+ ) ?. syntax ;
455
+ const suggestion = syntaxes ?. find (
456
+ ( syn ) => syn . syntaxContextType === EntityContextType . COLUMN
457
+ ) ;
458
+
459
+ expect ( suggestion ) . not . toBeUndefined ( ) ;
460
+ expect ( suggestion ?. wordRanges . map ( ( token ) => token . text ) ) . toEqual ( [ 'age' ] ) ;
461
+ } ) ;
377
462
} ) ;
0 commit comments