Skip to content

Commit d285b2b

Browse files
committed
Remove special handling of LATERAL keyword
That's for now too much of an edge case functionality. Plus there were no tests to veryfy what we wanted to achieve.
1 parent f8ea375 commit d285b2b

File tree

6 files changed

+8
-28
lines changed

6 files changed

+8
-28
lines changed

src/core/token.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ export const isToken = {
5454
BY: testToken({ value: 'BY', type: TokenType.RESERVED_KEYWORD }),
5555
END: testToken({ value: 'END', type: TokenType.BLOCK_END }),
5656
FROM: testToken({ value: 'FROM', type: TokenType.RESERVED_COMMAND }),
57-
LATERAL: testToken({ value: 'LATERAL', type: TokenType.RESERVED_DEPENDENT_CLAUSE }),
5857
LIMIT: testToken({ value: 'LIMIT', type: TokenType.RESERVED_COMMAND }),
5958
SELECT: testToken({ value: 'SELECT', type: TokenType.RESERVED_COMMAND }),
6059
SET: testToken({ value: 'SET', type: TokenType.RESERVED_COMMAND }),

src/languages/mysql.formatter.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,7 @@ const reservedKeywords = [
683683
'KEY_BLOCK_SIZE',
684684
'LANGUAGE',
685685
'LAST',
686+
'LATERAL',
686687
'LEADING',
687688
'LEAVE',
688689
'LEAVES',
@@ -1311,7 +1312,7 @@ const reservedBinaryCommands = [
13111312
* keywords that follow a previous Statement, must be attached to subsequent data
13121313
* can be fully inline or on newline with optional indent
13131314
*/
1314-
const reservedDependentClauses = ['WHEN', 'THEN', 'ELSE', 'ELSEIF', 'LATERAL'];
1315+
const reservedDependentClauses = ['WHEN', 'THEN', 'ELSE', 'ELSEIF'];
13151316

13161317
// https://dev.mysql.com/doc/refman/8.0/en/
13171318
export default class MySqlFormatter extends Formatter {
@@ -1350,12 +1351,6 @@ export default class MySqlFormatter extends Formatter {
13501351
}
13511352

13521353
tokenOverride(token: Token) {
1353-
// [LATERAL] ( ...
1354-
if (isToken.LATERAL(token) && this.tokenLookAhead().type === TokenType.BLOCK_START) {
1355-
// This is a subquery, treat it like a join
1356-
return { type: TokenType.RESERVED_LOGICAL_OPERATOR, value: token.value };
1357-
}
1358-
13591354
// [SET] ( ...
13601355
if (isToken.SET(token) && this.tokenLookAhead().value === '(') {
13611356
// This is SET datatype, not SET statement

src/languages/plsql.formatter.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -501,12 +501,6 @@ export default class PlSqlFormatter extends Formatter {
501501
return { type: TokenType.RESERVED_KEYWORD, value: token.value };
502502
}
503503

504-
// [LATERAL] ( ...
505-
if (isToken.LATERAL(token) && this.tokenLookAhead().type === TokenType.BLOCK_START) {
506-
// This is a subquery, treat it like a join
507-
return { type: TokenType.RESERVED_LOGICAL_OPERATOR, value: token.value };
508-
}
509-
510504
return token;
511505
}
512506
}

src/languages/postgresql.formatter.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Formatter from '../core/Formatter';
22
import Tokenizer from '../core/Tokenizer';
3-
import { isToken, Token, TokenType } from '../core/token'; // convert to partial type import in TS 4.5
43
import type { StringPatternType } from '../core/regexFactory';
54
import { dedupe } from '../utils';
65

@@ -1023,6 +1022,7 @@ const reservedKeywords = [
10231022
'LANGUAGE',
10241023
'LARGE',
10251024
'LAST',
1025+
'LATERAL',
10261026
'LEADING',
10271027
'LEAKPROOF',
10281028
'LEVEL',
@@ -1616,7 +1616,7 @@ const reservedBinaryCommands = [
16161616
* keywords that follow a previous Statement, must be attached to subsequent data
16171617
* can be fully inline or on newline with optional indent
16181618
*/
1619-
const reservedDependentClauses = ['WHEN', 'THEN', 'ELSE', 'LATERAL'];
1619+
const reservedDependentClauses = ['WHEN', 'THEN', 'ELSE'];
16201620

16211621
const binaryOperators = [
16221622
'<<',
@@ -1699,14 +1699,4 @@ export default class PostgreSqlFormatter extends Formatter {
16991699
operators: PostgreSqlFormatter.operators,
17001700
});
17011701
}
1702-
1703-
tokenOverride(token: Token) {
1704-
// [LATERAL] ( ...
1705-
if (isToken.LATERAL(token) && this.tokenLookAhead().type === TokenType.BLOCK_START) {
1706-
// This is a subquery, treat it like a join
1707-
return { type: TokenType.RESERVED_LOGICAL_OPERATOR, value: token.value };
1708-
}
1709-
1710-
return token;
1711-
}
17121702
}

src/languages/sparksql.formatter.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ const reservedCommands = [
709709
// other
710710
'FROM',
711711
'INSERT',
712+
'LATERAL VIEW',
712713
'UPDATE',
713714
'WINDOW', // verify
714715
];
@@ -772,7 +773,7 @@ const reservedBinaryCommands = [
772773
* keywords that follow a previous Statement, must be attached to subsequent data
773774
* can be fully inline or on newline with optional indent
774775
*/
775-
const reservedDependentClauses = ['WHEN', 'THEN', 'ELSE', 'LATERAL VIEW'];
776+
const reservedDependentClauses = ['WHEN', 'THEN', 'ELSE'];
776777

777778
// http://spark.apache.org/docs/latest/sql-programming-guide.html
778779
export default class SparkSqlFormatter extends Formatter {

src/languages/tsql.formatter.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,7 @@ const reservedKeywords = {
836836
'LANGUAGE',
837837
'LARGE',
838838
'LAST',
839+
'LATERAL',
839840
'LEADING',
840841
'LESS',
841842
'LEVEL',
@@ -1225,7 +1226,7 @@ const reservedBinaryCommands = [
12251226
* keywords that follow a previous Statement, must be attached to subsequent data
12261227
* can be fully inline or on newline with optional indent
12271228
*/
1228-
const reservedDependentClauses = ['WHEN', 'THEN', 'ELSE', 'LATERAL'];
1229+
const reservedDependentClauses = ['WHEN', 'THEN', 'ELSE'];
12291230

12301231
// https://docs.microsoft.com/en-us/sql/t-sql/language-reference?view=sql-server-ver15
12311232
export default class TSqlFormatter extends Formatter {

0 commit comments

Comments
 (0)