瀏覽代碼

HUE-9115 [ksql] Simplify grammar and remove 40 test failures

jest ksqlAutocompleteParser --testPathIgnorePatterns=[]
Romain 5 年之前
父節點
當前提交
af1d17067a

文件差異過大導致無法顯示
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/ksql/ksqlAutocompleteParser.js


文件差異過大導致無法顯示
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/ksql/ksqlSyntaxParser.js


+ 0 - 7
desktop/core/src/desktop/js/parse/sql/ksql/sqlParseSupport.js

@@ -1471,8 +1471,6 @@ const initSqlParser = function(parser) {
             loc.identifier = 'CREATE TABLE';
           } else if (/CREATE\s+DATABASE/i.test(additionalText)) {
             loc.identifier = 'CREATE DATABASE';
-          } else if (/CREATE\s+ROLE/i.test(additionalText)) {
-            loc.identifier = 'CREATE ROLE';
           } else if (/CREATE\s+FUNCTION/i.test(additionalText)) {
             loc.identifier = 'CREATE FUNCTION';
           } else {
@@ -1486,8 +1484,6 @@ const initSqlParser = function(parser) {
             loc.identifier = 'DROP TABLE';
           } else if (/DROP\s+DATABASE/i.test(additionalText)) {
             loc.identifier = 'DROP DATABASE';
-          } else if (/DROP\s+ROLE/i.test(additionalText)) {
-            loc.identifier = 'DROP ROLE';
           } else if (/DROP\s+STATS/i.test(additionalText)) {
             loc.identifier = 'DROP STATS';
           } else if (/DROP\s+FUNCTION/i.test(additionalText)) {
@@ -1502,9 +1498,6 @@ const initSqlParser = function(parser) {
         case 'LOAD':
           loc.identifier = 'LOAD DATA';
           break;
-        case 'TRUNCATE':
-          loc.identifier = 'TRUNCATE TABLE';
-          break;
         default:
       }
     }

+ 1 - 15
desktop/core/src/desktop/js/parse/sql/ksql/test/ksqlAutocompleteParser.Create.test.js

@@ -50,7 +50,7 @@ describe('ksqlAutocompleteParser.js CREATE statements', () => {
     assertAutoComplete({
       beforeCursor: 'CREATE ',
       afterCursor: '',
-      containsKeywords: ['DATABASE', 'ROLE', 'SCHEMA', 'TABLE', 'VIEW'],
+      containsKeywords: ['DATABASE', 'SCHEMA', 'TABLE', 'VIEW'],
       expectedResult: {
         lowerCase: false
       }
@@ -103,20 +103,6 @@ describe('ksqlAutocompleteParser.js CREATE statements', () => {
     });
   });
 
-  describe('CREATE ROLE', () => {
-    it('should handle "CREATE ROLE boo; |"', () => {
-      assertAutoComplete({
-        beforeCursor: 'CREATE ROLE boo; ',
-        afterCursor: '',
-        noErrors: true,
-        containsKeywords: ['SELECT'],
-        expectedResult: {
-          lowerCase: false
-        }
-      });
-    });
-  });
-
   describe('CREATE TABLE', () => {
     it('should suggest keywords for "CREATE TABLE |"', () => {
       assertAutoComplete({

+ 1 - 53
desktop/core/src/desktop/js/parse/sql/ksql/test/ksqlAutocompleteParser.Drop.test.js

@@ -39,7 +39,7 @@ describe('ksqlAutocompleteParser.js DROP statements', () => {
     assertAutoComplete({
       beforeCursor: 'DROP ',
       afterCursor: '',
-      containsKeywords: ['DATABASE', 'ROLE', 'SCHEMA', 'TABLE', 'VIEW'],
+      containsKeywords: ['DATABASE', 'SCHEMA', 'TABLE', 'VIEW'],
       expectedResult: {
         lowerCase: false
       }
@@ -105,20 +105,6 @@ describe('ksqlAutocompleteParser.js DROP statements', () => {
     });
   });
 
-  describe('DROP ROLE', () => {
-    it('should handle "DROP ROLE boo;|"', () => {
-      assertAutoComplete({
-        beforeCursor: 'DROP ROLE boo;',
-        afterCursor: '',
-        noErrors: true,
-        containsKeywords: ['SELECT'],
-        expectedResult: {
-          lowerCase: false
-        }
-      });
-    });
-  });
-
   describe('DROP TABLE', () => {
     it('should handle "DROP TABLE db.tbl PURGE;"', () => {
       assertAutoComplete({
@@ -247,42 +233,4 @@ describe('ksqlAutocompleteParser.js DROP statements', () => {
       });
     });
   });
-
-  describe('TRUNCATE TABLE', () => {
-    it('should handle "TRUNCATE TABLE baa.boo;"', () => {
-      assertAutoComplete({
-        beforeCursor: 'TRUNCATE TABLE baa.boo;',
-        afterCursor: '',
-        containsKeywords: ['SELECT'],
-        noErrors: true,
-        expectedResult: {
-          lowerCase: false
-        }
-      });
-    });
-
-    it('should suggest keywords for "TRUNCATE |"', () => {
-      assertAutoComplete({
-        beforeCursor: 'truncate ',
-        afterCursor: '',
-        expectedResult: {
-          lowerCase: true,
-          suggestKeywords: ['TABLE']
-        }
-      });
-    });
-
-    it('should suggest tables for "TRUNCATE TABLE |"', () => {
-      assertAutoComplete({
-        beforeCursor: 'TRUNCATE TABLE ',
-        afterCursor: '',
-        expectedResult: {
-          lowerCase: false,
-          suggestTables: {},
-          suggestDatabases: { appendDot: true },
-          suggestKeywords: ['IF EXISTS']
-        }
-      });
-    });
-  });
 });

+ 2 - 2
desktop/core/src/desktop/js/parse/sql/ksql/test/ksqlAutocompleteParser.Error.test.js

@@ -116,7 +116,7 @@ describe('ksqlAutocompleteParser.js Error statements', () => {
     assertAutoComplete({
       beforeCursor: 'SELECT * FROM testTable ORDER BY bla bla bla boo ',
       afterCursor: '',
-      containsKeywords: ['LIMIT', 'UNION'],
+      containsKeywords: ['LIMIT'],
       expectedResult: {
         lowerCase: false
       }
@@ -127,7 +127,7 @@ describe('ksqlAutocompleteParser.js Error statements', () => {
     assertAutoComplete({
       beforeCursor: 'SELECT * FROM testTable ORDER BY bla bla bla boo ',
       afterCursor: '',
-      containsKeywords: ['LIMIT', 'UNION'],
+      containsKeywords: ['LIMIT'],
       expectedResult: {
         lowerCase: false
       }

+ 4 - 668
desktop/core/src/desktop/js/parse/sql/ksql/test/ksqlAutocompleteParser.Select.test.js

@@ -165,7 +165,6 @@ describe('ksqlAutocompleteParser.js SELECT statements', () => {
           'HAVING',
           'ORDER BY',
           'LIMIT',
-          'UNION',
           'FULL JOIN',
           'FULL OUTER JOIN',
           'INNER JOIN',
@@ -1290,391 +1289,6 @@ describe('ksqlAutocompleteParser.js SELECT statements', () => {
     });
   });
 
-  describe('Window and analytic functions', () => {
-    it('should handle "SELECT row_number() OVER (PARTITION BY a) FROM testTable;|"', () => {
-      assertAutoComplete({
-        beforeCursor: 'SELECT row_number() OVER (PARTITION BY a) FROM testTable;',
-        afterCursor: '',
-        noErrors: true,
-        containsKeywords: ['SELECT'],
-        expectedResult: {
-          lowerCase: false
-        }
-      });
-    });
-
-    it('should handle "SELECT COUNT(DISTINCT a) OVER (PARTITION by c) FROM testTable;|"', () => {
-      assertAutoComplete({
-        beforeCursor: 'SELECT COUNT(DISTINCT a) OVER (PARTITION by c) FROM testTable;',
-        afterCursor: '',
-        noErrors: true,
-        containsKeywords: ['SELECT'],
-        expectedResult: {
-          lowerCase: false
-        }
-      });
-    });
-
-    it('should suggest analytical functions for "SELECT |"', () => {
-      assertAutoComplete({
-        beforeCursor: 'SELECT ',
-        afterCursor: '',
-        containsKeywords: ['*'],
-        expectedResult: {
-          lowerCase: false,
-          suggestAggregateFunctions: { tables: [] },
-          suggestAnalyticFunctions: true,
-          suggestFunctions: {},
-          suggestTables: { prependQuestionMark: true, prependFrom: true },
-          suggestDatabases: { prependQuestionMark: true, prependFrom: true, appendDot: true }
-        }
-      });
-    });
-
-    it('should suggest keywords for "SELECT row_number() |"', () => {
-      assertAutoComplete({
-        beforeCursor: 'SELECT row_number() ',
-        afterCursor: '',
-        containsKeywords: ['OVER'],
-        expectedResult: {
-          lowerCase: false
-        }
-      });
-    });
-
-    it('should suggest keywords for "SELECT row_number() | FROM testTable"', () => {
-      assertAutoComplete({
-        beforeCursor: 'SELECT row_number() ',
-        afterCursor: ' FROM testTable',
-        containsKeywords: ['OVER'],
-        expectedResult: {
-          lowerCase: false
-        }
-      });
-    });
-
-    it('should suggest keywords for "SELECT row_number() |, b, c FROM testTable"', () => {
-      assertAutoComplete({
-        beforeCursor: 'SELECT row_number() ',
-        afterCursor: ', b, c FROM testTable',
-        containsKeywords: ['OVER'],
-        expectedResult: {
-          lowerCase: false
-        }
-      });
-    });
-
-    it('should suggest keywords for "SELECT count(DISTINCT a) |"', () => {
-      assertAutoComplete({
-        beforeCursor: 'SELECT count(DISTINCT a) ',
-        afterCursor: '',
-        containsKeywords: ['OVER'],
-        expectedResult: {
-          lowerCase: false,
-          suggestTables: { prependFrom: true },
-          suggestDatabases: { prependFrom: true, appendDot: true }
-        }
-      });
-    });
-
-    it('should suggest keywords for "SELECT count(DISTINCT a) | FROM testTable"', () => {
-      assertAutoComplete({
-        beforeCursor: 'SELECT count(DISTINCT a) ',
-        afterCursor: ' FROM testTable',
-        containsKeywords: ['OVER'],
-        expectedResult: {
-          lowerCase: false
-        }
-      });
-    });
-
-    it('should suggest keywords for "SELECT count(DISTINCT a) |, b, c FROM testTable"', () => {
-      assertAutoComplete({
-        beforeCursor: 'SELECT count(DISTINCT a) ',
-        afterCursor: ', b, c FROM testTable',
-        containsKeywords: ['OVER'],
-        expectedResult: {
-          lowerCase: false
-        }
-      });
-    });
-
-    it('should suggest keywords for "SELECT row_number() OVER (| FROM testTable"', () => {
-      assertAutoComplete({
-        beforeCursor: 'SELECT row_number() OVER ( ',
-        afterCursor: ' FROM testTable',
-        containsKeywords: ['PARTITION BY'],
-        expectedResult: {
-          lowerCase: false
-        }
-      });
-    });
-
-    it('should suggest keywords for "SELECT row_number() OVER (PARTITION | FROM testTable"', () => {
-      assertAutoComplete({
-        beforeCursor: 'SELECT row_number() OVER (PARTITION ',
-        afterCursor: ' FROM testTable',
-        containsKeywords: ['BY'],
-        expectedResult: {
-          lowerCase: false
-        }
-      });
-    });
-
-    it('should suggest keywords for "SELECT row_number() OVER (PARTITION BY a, b ORDER | FROM testTable"', () => {
-      assertAutoComplete({
-        beforeCursor: 'SELECT row_number() OVER (PARTITION BY a, b ORDER ',
-        afterCursor: ' FROM testTable',
-        containsKeywords: ['BY'],
-        expectedResult: {
-          lowerCase: false
-        }
-      });
-    });
-
-    it('should suggest columns for "SELECT row_number() OVER (ORDER BY | FROM testTable"', () => {
-      assertAutoComplete({
-        beforeCursor: 'SELECT row_number() OVER (ORDER BY ',
-        afterCursor: ' FROM testTable',
-        containsKeywords: ['CASE'],
-        expectedResult: {
-          lowerCase: false,
-          suggestAggregateFunctions: { tables: [] },
-          suggestFunctions: {},
-          suggestColumns: {
-            source: 'select',
-            tables: [{ identifierChain: [{ name: 'testTable' }] }]
-          }
-        }
-      });
-    });
-
-    it('should suggest columns for "SELECT row_number() OVER (ORDER BY |) FROM testTable"', () => {
-      assertAutoComplete({
-        beforeCursor: 'SELECT row_number() OVER (ORDER BY ',
-        afterCursor: ') FROM testTable',
-        containsKeywords: ['CASE'],
-        expectedResult: {
-          lowerCase: false,
-          suggestAggregateFunctions: { tables: [] },
-          suggestFunctions: {},
-          suggestColumns: {
-            source: 'select',
-            tables: [{ identifierChain: [{ name: 'testTable' }] }]
-          } // TODO: source: 'order by'
-        }
-      });
-    });
-
-    it('should suggest columns for "SELECT row_number() OVER (ORDER BY foo |) FROM testTable"', () => {
-      assertAutoComplete({
-        beforeCursor: 'SELECT row_number() OVER (ORDER BY a ',
-        afterCursor: ') FROM testTable',
-        containsKeywords: ['ASC', 'DESC'],
-        expectedResult: {
-          lowerCase: false
-        }
-      });
-    });
-
-    it('should suggest columns for "SELECT row_number() OVER (PARTITION BY | FROM testTable"', () => {
-      assertAutoComplete({
-        beforeCursor: 'SELECT row_number() OVER (PARTITION BY ',
-        afterCursor: ' FROM testTable',
-        containsKeywords: ['CASE'],
-        expectedResult: {
-          lowerCase: false,
-          suggestAggregateFunctions: { tables: [] },
-          suggestFunctions: {},
-          suggestColumns: {
-            source: 'select',
-            tables: [{ identifierChain: [{ name: 'testTable' }] }]
-          }
-        }
-      });
-    });
-
-    it('should suggest columns for "SELECT row_number() OVER (PARTITION BY a, | FROM testTable"', () => {
-      assertAutoComplete({
-        beforeCursor: 'SELECT row_number() OVER (PARTITION BY a, ',
-        afterCursor: ' FROM testTable',
-        containsKeywords: ['CASE'],
-        expectedResult: {
-          lowerCase: false,
-          suggestAggregateFunctions: { tables: [] },
-          suggestFunctions: {},
-          suggestColumns: {
-            source: 'select',
-            tables: [{ identifierChain: [{ name: 'testTable' }] }]
-          }
-        }
-      });
-    });
-
-    it('should suggest keywords for "SELECT row_number() OVER (PARTITION BY a ORDER BY b |"', () => {
-      assertAutoComplete({
-        beforeCursor: 'SELECT row_number() OVER (PARTITION BY a ORDER BY b ',
-        afterCursor: '',
-        containsKeywords: ['ASC', 'ROWS BETWEEN', 'RANGE BETWEEN'],
-        expectedResult: {
-          lowerCase: false
-        }
-      });
-    });
-
-    it('should suggest keywords for "SELECT row_number() OVER (PARTITION BY a ORDER BY b ROWS BETWEEN |"', () => {
-      assertAutoComplete({
-        beforeCursor: 'SELECT row_number() OVER (PARTITION BY a ORDER BY b ROWS BETWEEN ',
-        afterCursor: '',
-        expectedResult: {
-          lowerCase: false,
-          suggestKeywords: ['CURRENT ROW', 'UNBOUNDED PRECEDING']
-        }
-      });
-    });
-
-    it('should suggest keywords for "SELECT row_number() OVER (PARTITION BY a ORDER BY b ROWS BETWEEN 1 |"', () => {
-      assertAutoComplete({
-        beforeCursor: 'SELECT row_number() OVER (PARTITION BY a ORDER BY b ROWS BETWEEN 1 ',
-        afterCursor: '',
-        expectedResult: {
-          lowerCase: false,
-          suggestKeywords: ['PRECEDING']
-        }
-      });
-    });
-
-    it('should suggest keywords for "SELECT row_number() OVER (PARTITION BY a ORDER BY b ROWS BETWEEN UNBOUNDED |"', () => {
-      assertAutoComplete({
-        beforeCursor: 'SELECT row_number() OVER (PARTITION BY a ORDER BY b ROWS BETWEEN UNBOUNDED ',
-        afterCursor: '',
-        expectedResult: {
-          lowerCase: false,
-          suggestKeywords: ['PRECEDING']
-        }
-      });
-    });
-
-    it('should suggest keywords for "SELECT row_number() OVER (PARTITION BY a ORDER BY b ROWS BETWEEN CURRENT |"', () => {
-      assertAutoComplete({
-        beforeCursor: 'SELECT row_number() OVER (PARTITION BY a ORDER BY b ROWS BETWEEN CURRENT ',
-        afterCursor: '',
-        expectedResult: {
-          lowerCase: false,
-          suggestKeywords: ['ROW']
-        }
-      });
-    });
-
-    it('should suggest keywords for "SELECT row_number() OVER (PARTITION BY a ORDER BY b ROWS BETWEEN 1 PRECEDING |"', () => {
-      assertAutoComplete({
-        beforeCursor:
-          'SELECT row_number() OVER (PARTITION BY a ORDER BY b ROWS BETWEEN 1 PRECEDING ',
-        afterCursor: '',
-        expectedResult: {
-          lowerCase: false,
-          suggestKeywords: ['AND']
-        }
-      });
-    });
-
-    it('should suggest keywords for "SELECT row_number() OVER (PARTITION BY a ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING |"', () => {
-      assertAutoComplete({
-        beforeCursor:
-          'SELECT row_number() OVER (PARTITION BY a ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING ',
-        afterCursor: '',
-        expectedResult: {
-          lowerCase: false,
-          suggestKeywords: ['AND']
-        }
-      });
-    });
-
-    it('should suggest keywords for "SELECT row_number() OVER (PARTITION BY a ORDER BY b ROWS BETWEEN CURRENT ROW |"', () => {
-      assertAutoComplete({
-        beforeCursor:
-          'SELECT row_number() OVER (PARTITION BY a ORDER BY b ROWS BETWEEN CURRENT ROW ',
-        afterCursor: '',
-        expectedResult: {
-          lowerCase: false,
-          suggestKeywords: ['AND']
-        }
-      });
-    });
-
-    it('should suggest keywords for "SELECT row_number() OVER (PARTITION BY a ORDER BY b ROWS BETWEEN 1 PRECEDING AND |"', () => {
-      assertAutoComplete({
-        beforeCursor:
-          'SELECT row_number() OVER (PARTITION BY a ORDER BY b ROWS BETWEEN 1 PRECEDING AND ',
-        afterCursor: '',
-        expectedResult: {
-          lowerCase: false,
-          suggestKeywords: ['CURRENT ROW', 'UNBOUNDED FOLLOWING']
-        }
-      });
-    });
-
-    it('should suggest keywords for "SELECT row_number() OVER (PARTITION BY a ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND |"', () => {
-      assertAutoComplete({
-        beforeCursor:
-          'SELECT row_number() OVER (PARTITION BY a ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND ',
-        afterCursor: '',
-        expectedResult: {
-          lowerCase: false,
-          suggestKeywords: ['CURRENT ROW', 'UNBOUNDED FOLLOWING']
-        }
-      });
-    });
-
-    it('should suggest keywords for "SELECT row_number() OVER (PARTITION BY a ORDER BY b ROWS BETWEEN CURRENT ROW AND |"', () => {
-      assertAutoComplete({
-        beforeCursor:
-          'SELECT row_number() OVER (PARTITION BY a ORDER BY b ROWS BETWEEN CURRENT ROW AND ',
-        afterCursor: '',
-        expectedResult: {
-          lowerCase: false,
-          suggestKeywords: ['CURRENT ROW', 'UNBOUNDED FOLLOWING']
-        }
-      });
-    });
-
-    it('should suggest keywords for "SELECT row_number() OVER (PARTITION BY a ORDER BY b ROWS BETWEEN 1 PRECEDING AND CURRENT |"', () => {
-      assertAutoComplete({
-        beforeCursor:
-          'SELECT row_number() OVER (PARTITION BY a ORDER BY b ROWS BETWEEN 1 PRECEDING AND CURRENT ',
-        afterCursor: '',
-        expectedResult: {
-          lowerCase: false,
-          suggestKeywords: ['ROW']
-        }
-      });
-    });
-
-    it('should suggest keywords for "SELECT row_number() OVER (PARTITION BY a ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED |"', () => {
-      assertAutoComplete({
-        beforeCursor:
-          'SELECT row_number() OVER (PARTITION BY a ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED ',
-        afterCursor: '',
-        expectedResult: {
-          lowerCase: false,
-          suggestKeywords: ['FOLLOWING']
-        }
-      });
-    });
-
-    it('should suggest keywords for "SELECT row_number() OVER (PARTITION BY a ORDER BY b ROWS BETWEEN CURRENT ROW AND 1 |"', () => {
-      assertAutoComplete({
-        beforeCursor:
-          'SELECT row_number() OVER (PARTITION BY a ORDER BY b ROWS BETWEEN CURRENT ROW AND 1 ',
-        afterCursor: '',
-        expectedResult: {
-          lowerCase: false,
-          suggestKeywords: ['FOLLOWING']
-        }
-      });
-    });
-  });
-
   describe('Functions', () => {
     it('should suggest tables for "SELECT COUNT(*) |"', () => {
       assertAutoComplete({
@@ -3584,7 +3198,6 @@ describe('ksqlAutocompleteParser.js SELECT statements', () => {
             'HAVING',
             'ORDER BY',
             'LIMIT',
-            'UNION',
             '<',
             '<=',
             '<=>',
@@ -3622,7 +3235,6 @@ describe('ksqlAutocompleteParser.js SELECT statements', () => {
             'HAVING',
             'ORDER BY',
             'LIMIT',
-            'UNION',
             '<',
             '<=',
             '<=>',
@@ -4366,7 +3978,7 @@ describe('ksqlAutocompleteParser.js SELECT statements', () => {
         afterCursor: '',
         expectedResult: {
           lowerCase: false,
-          suggestKeywords: ['ASC', 'DESC', 'LIMIT', 'UNION']
+          suggestKeywords: ['ASC', 'DESC', 'LIMIT']
         }
       });
     });
@@ -4445,7 +4057,7 @@ describe('ksqlAutocompleteParser.js SELECT statements', () => {
         afterCursor: '',
         expectedResult: {
           lowerCase: false,
-          suggestKeywords: ['ASC', 'DESC', 'LIMIT', 'UNION']
+          suggestKeywords: ['ASC', 'DESC', 'LIMIT']
         }
       });
     });
@@ -4461,13 +4073,13 @@ describe('ksqlAutocompleteParser.js SELECT statements', () => {
       });
     });
 
-    it('should suggest keywords for "SELECT * FROM database_two.testTable ORDER BY foo LIMIT 10 |"', () => {
+    it('should not suggest keywords for "SELECT * FROM database_two.testTable ORDER BY foo LIMIT 10 |"', () => {
       assertAutoComplete({
         beforeCursor: 'SELECT * FROM database_two.testTable ORDER BY foo LIMIT 10 ',
         afterCursor: '',
         expectedResult: {
           lowerCase: false,
-          suggestKeywords: ['UNION']
+          suggestKeywords: undefined
         }
       });
     });
@@ -4635,282 +4247,6 @@ describe('ksqlAutocompleteParser.js SELECT statements', () => {
     });
   });
 
-  describe('UNION clause', () => {
-    // TODO: Fix locations
-    xit('should handle "SELECT * FROM (SELECT x FROM few_ints UNION ALL SELECT x FROM few_ints) AS t1 ORDER BY x;|', () => {
-      assertAutoComplete({
-        beforeCursor:
-          'SELECT * FROM (SELECT x FROM few_ints UNION ALL SELECT x FROM few_ints) AS t1 ORDER BY x;',
-        afterCursor: '',
-        noErrors: true,
-        containsKeywords: ['SELECT'],
-        expectedResult: {
-          lowerCase: false
-        }
-      });
-    });
-
-    it('should handle "SELECT key FROM (SELECT key FROM src ORDER BY key LIMIT 10)subq1 UNION SELECT key FROM (SELECT key FROM src1 ORDER BY key LIMIT 10)subq2;|', () => {
-      assertAutoComplete({
-        beforeCursor:
-          'SELECT key FROM (SELECT key FROM src ORDER BY key LIMIT 10)subq1 UNION SELECT key FROM (SELECT key FROM src1 ORDER BY key LIMIT 10)subq2;',
-        afterCursor: '',
-        noErrors: true,
-        containsKeywords: ['SELECT'],
-        expectedResult: {
-          lowerCase: false
-        }
-      });
-    });
-
-    it('should handle "SELECT * FROM t1 UNION DISTINCT SELECT * FROM t2;|', () => {
-      assertAutoComplete({
-        beforeCursor: 'SELECT * FROM t1 UNION DISTINCT SELECT * FROM t2;',
-        afterCursor: '',
-        noErrors: true,
-        containsKeywords: ['SELECT'],
-        expectedResult: {
-          lowerCase: false
-        }
-      });
-    });
-
-    it('should handle "SELECT * FROM t1 UNION SELECT * FROM t2;|', () => {
-      assertAutoComplete({
-        beforeCursor: 'SELECT * FROM t1 UNION SELECT * FROM t2;',
-        afterCursor: '',
-        noErrors: true,
-        containsKeywords: ['SELECT'],
-        expectedResult: {
-          lowerCase: false
-        }
-      });
-    });
-
-    it('should suggest keywords for "SELECT * FROM t1 UNION |', () => {
-      assertAutoComplete({
-        beforeCursor: 'SELECT * FROM t1 UNION ',
-        afterCursor: '',
-        noErrors: true,
-        expectedResult: {
-          lowerCase: false,
-          suggestKeywords: ['ALL', 'DISTINCT', 'SELECT']
-        }
-      });
-    });
-
-    it('should suggest tables for "SELECT * FROM t1 UNION ALL SELECT |', () => {
-      assertAutoComplete({
-        beforeCursor: 'SELECT * FROM t1 UNION ALL SELECT ',
-        afterCursor: '',
-        noErrors: true,
-        containsKeywords: ['*', 'ALL', 'DISTINCT'],
-        expectedResult: {
-          lowerCase: false,
-          suggestAggregateFunctions: { tables: [] },
-          suggestAnalyticFunctions: true,
-          suggestFunctions: {},
-          suggestTables: {
-            prependQuestionMark: true,
-            prependFrom: true
-          },
-          suggestDatabases: {
-            prependQuestionMark: true,
-            prependFrom: true,
-            appendDot: true
-          }
-        }
-      });
-    });
-  });
-
-  describe('WITH clause', () => {
-    it('should handle "WITH q1 AS ( SELECT key FROM src WHERE something) SELECT * FROM q1;|', () => {
-      assertAutoComplete({
-        beforeCursor: 'WITH q1 AS ( SELECT key FROM src WHERE something) SELECT * FROM q1;',
-        afterCursor: '',
-        noErrors: true,
-        containsKeywords: ['SELECT'],
-        expectedResult: {
-          lowerCase: false
-        }
-      });
-    });
-
-    it('should handle "WITH q1 AS (SELECT * FROM src WHERE something), q2 AS (SELECT * FROM src s2 WHERE something) SELECT * FROM q1 UNION ALL SELECT * FROM q2;|', () => {
-      assertAutoComplete({
-        beforeCursor:
-          'WITH q1 AS (SELECT * FROM src WHERE something), q2 AS (SELECT * FROM src s2 WHERE something) SELECT * FROM q1 UNION ALL SELECT * FROM q2;',
-        afterCursor: '',
-        noErrors: true,
-        containsKeywords: ['SELECT'],
-        expectedResult: {
-          lowerCase: false
-        }
-      });
-    });
-
-    it('should handle "WITH t1 AS (SELECT 1) (WITH t2 AS (SELECT 2) SELECT * FROM t2) UNION ALL SELECT * FROM t1;|', () => {
-      assertAutoComplete({
-        beforeCursor:
-          'WITH t1 AS (SELECT 1) (WITH t2 AS (SELECT 2) SELECT * FROM t2) UNION ALL SELECT * FROM t1;',
-        afterCursor: '',
-        noErrors: true,
-        containsKeywords: ['SELECT'],
-        expectedResult: {
-          lowerCase: false
-        }
-      });
-    });
-
-    it('should suggest keywords for "WITH t1 |', () => {
-      assertAutoComplete({
-        beforeCursor: 'WITH t1 ',
-        afterCursor: '',
-        expectedResult: {
-          lowerCase: false,
-          suggestKeywords: ['AS']
-        }
-      });
-    });
-
-    it('should suggest keywords for "WITH t1 AS (|', () => {
-      assertAutoComplete({
-        beforeCursor: 'WITH t1 AS (',
-        afterCursor: '',
-        expectedResult: {
-          lowerCase: false,
-          suggestKeywords: ['SELECT']
-        }
-      });
-    });
-
-    it('should suggest keywords for "WITH t1 AS (SELECT * FROM boo) |', () => {
-      assertAutoComplete({
-        beforeCursor: 'WITH t1 AS (SELECT * FROM boo) ',
-        afterCursor: '',
-        containsKeywords: ['SELECT'],
-        expectedResult: {
-          lowerCase: false
-        }
-      });
-    });
-
-    it('should suggest identifiers for "WITH t1 AS (SELECT * FROM FOO) SELECT |', () => {
-      assertAutoComplete({
-        beforeCursor: 'WITH t1 AS (SELECT * FROM FOO) SELECT ',
-        afterCursor: '',
-        noErrors: true,
-        containsKeywords: ['*', 'ALL', 'DISTINCT'],
-        expectedResult: {
-          lowerCase: false,
-          suggestAggregateFunctions: { tables: [] },
-          suggestAnalyticFunctions: true,
-          suggestFunctions: {},
-          suggestTables: { prependQuestionMark: true, prependFrom: true },
-          suggestDatabases: { prependQuestionMark: true, prependFrom: true, appendDot: true },
-          suggestCommonTableExpressions: [
-            { name: 't1', prependFrom: true, prependQuestionMark: true }
-          ],
-          commonTableExpressions: [
-            { alias: 't1', columns: [{ tables: [{ identifierChain: [{ name: 'FOO' }] }] }] }
-          ]
-        }
-      });
-    });
-
-    it('should suggest identifiers for "WITH t1 AS (SELECT * FROM FOO), t2 AS (SELECT |', () => {
-      assertAutoComplete({
-        beforeCursor: 'WITH t1 AS (SELECT * FROM FOO), t2 AS (SELECT ',
-        afterCursor: '',
-        containsKeywords: ['*', 'ALL', 'DISTINCT'],
-        expectedResult: {
-          suggestAggregateFunctions: { tables: [] },
-          suggestAnalyticFunctions: true,
-          suggestFunctions: {},
-          suggestTables: { prependQuestionMark: true, prependFrom: true },
-          suggestDatabases: { prependQuestionMark: true, prependFrom: true, appendDot: true },
-          lowerCase: false,
-          suggestCommonTableExpressions: [
-            { name: 't1', prependFrom: true, prependQuestionMark: true }
-          ],
-          commonTableExpressions: [
-            { alias: 't1', columns: [{ tables: [{ identifierChain: [{ name: 'FOO' }] }] }] }
-          ]
-        }
-      });
-    });
-
-    it('should suggest identifiers for "WITH t1 AS (SELECT * FROM FOO) SELECT * FROM |', () => {
-      assertAutoComplete({
-        beforeCursor: 'WITH t1 AS (SELECT * FROM FOO) SELECT * FROM ',
-        afterCursor: '',
-        noErrors: true,
-        expectedResult: {
-          lowerCase: false,
-          suggestTables: {},
-          suggestDatabases: { appendDot: true },
-          suggestCommonTableExpressions: [{ name: 't1' }],
-          commonTableExpressions: [
-            { alias: 't1', columns: [{ tables: [{ identifierChain: [{ name: 'FOO' }] }] }] }
-          ]
-        }
-      });
-    });
-
-    it('should suggest keywords for "with s as (select * from foo join bar) select * from |"', () => {
-      assertAutoComplete({
-        beforeCursor: 'with s as (select * from foo join bar) select * from ',
-        afterCursor: '',
-        expectedResult: {
-          lowerCase: true,
-          suggestTables: {},
-          suggestDatabases: { appendDot: true },
-          commonTableExpressions: [
-            {
-              columns: [
-                {
-                  tables: [
-                    { identifierChain: [{ name: 'foo' }] },
-                    { identifierChain: [{ name: 'bar' }] }
-                  ]
-                }
-              ],
-              alias: 's'
-            }
-          ],
-          suggestCommonTableExpressions: [{ name: 's' }]
-        }
-      });
-    });
-
-    it('should suggest keywords for "with s as (select * from foo join bar) select * from |;', () => {
-      assertAutoComplete({
-        beforeCursor: 'with s as (select * from foo join bar) select * from ',
-        afterCursor: ';',
-        expectedResult: {
-          lowerCase: true,
-          suggestTables: {},
-          suggestDatabases: { appendDot: true },
-          commonTableExpressions: [
-            {
-              columns: [
-                {
-                  tables: [
-                    { identifierChain: [{ name: 'foo' }] },
-                    { identifierChain: [{ name: 'bar' }] }
-                  ]
-                }
-              ],
-              alias: 's'
-            }
-          ],
-          suggestCommonTableExpressions: [{ name: 's' }]
-        }
-      });
-    });
-  });
-
   describe('Joins', () => {
     it('should suggest tables for "SELECT * FROM testTable1 JOIN |"', () => {
       assertAutoComplete({

+ 1 - 4
desktop/core/src/desktop/js/parse/sql/ksql/test/ksqlSyntaxParser.test.js

@@ -137,7 +137,6 @@ describe('ksqlSyntaxParser.js', () => {
       'CREATE',
       'USE',
       'DROP',
-      'TRUNCATE',
       'UPDATE',
       'WITH'
     ]);
@@ -155,9 +154,7 @@ describe('ksqlSyntaxParser.js', () => {
       'create',
       'use',
       'drop',
-      'truncate',
-      'update',
-      'with'
+      'update'
     ]);
   });
 

部分文件因文件數量過多而無法顯示