File tree Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -330,6 +330,9 @@ export default class Statement {
330
330
if ( sqlObj ) {
331
331
doAdd ( sqlObj ) ;
332
332
i += sqlObj . tokens . length ;
333
+ if ( sqlObj . isUDTF || sqlObj . fromLateral ) {
334
+ i += 3 ; //For the brackets
335
+ }
333
336
}
334
337
}
335
338
}
@@ -520,6 +523,7 @@ export default class Statement {
520
523
if ( sqlObj ) {
521
524
sqlObj . isUDTF = true ;
522
525
const blockTokens = this . getBlockAt ( sqlObj . tokens [ 0 ] . range . end ) ;
526
+
523
527
sqlObj . tokens = blockTokens ;
524
528
nextIndex = i + 2 + blockTokens . length ;
525
529
nextToken = this . tokens [ nextIndex ] ;
@@ -529,12 +533,11 @@ export default class Statement {
529
533
nextToken = undefined ;
530
534
}
531
535
} else if ( isLateral ) {
532
- console . log ( `HI` ) ;
533
536
const blockTokens = this . getBlockAt ( nextToken . range . end + 1 ) ;
534
- console . log ( blockTokens ) ;
535
537
const newStatement = new Statement ( blockTokens , { start : nextToken . range . start , end : blockTokens [ blockTokens . length - 1 ] . range . end } ) ;
536
538
[ sqlObj ] = newStatement . getObjectReferences ( ) ;
537
-
539
+
540
+ sqlObj . fromLateral = true ;
538
541
nextIndex = i + 2 + blockTokens . length ;
539
542
nextToken = this . tokens [ nextIndex ] ;
540
543
Original file line number Diff line number Diff line change @@ -996,6 +996,24 @@ describe(`Object references`, () => {
996
996
] . join ( `\n` ) ;
997
997
998
998
const document = new Document ( lines ) ;
999
+
1000
+ expect ( document . statements . length ) . toBe ( 1 ) ;
1001
+
1002
+ const statement = document . statements [ 0 ] ;
1003
+
1004
+ expect ( statement . type ) . toBe ( StatementType . Select ) ;
1005
+
1006
+ const refs = statement . getObjectReferences ( ) ;
1007
+
1008
+ console . log ( refs ) ;
1009
+ expect ( refs . length ) . toBe ( 2 ) ;
1010
+ expect ( refs [ 0 ] . object . name ) . toBe ( `OBJECT_STATISTICS` ) ;
1011
+ expect ( refs [ 0 ] . object . schema ) . toBe ( `QSYS2` ) ;
1012
+ expect ( refs [ 0 ] . alias ) . toBe ( `a` ) ;
1013
+
1014
+ expect ( refs [ 1 ] . object . name ) . toBe ( `OBJECT_STATISTICS` ) ;
1015
+ expect ( refs [ 1 ] . object . schema ) . toBe ( `QSYS2` ) ;
1016
+ expect ( refs [ 1 ] . alias ) . toBe ( `b` ) ;
999
1017
} )
1000
1018
} ) ;
1001
1019
Original file line number Diff line number Diff line change @@ -84,6 +84,7 @@ export interface ObjectRef {
84
84
alias ?: string ;
85
85
86
86
isUDTF ?: boolean ;
87
+ fromLateral ?: boolean ;
87
88
88
89
/** only used within create statements */
89
90
createType ?: string ;
You can’t perform that action at this time.
0 commit comments