Przeglądaj źródła

HUE-9077 [ksql] Adding show and list .jison

Romain 6 lat temu
rodzic
commit
04ab447238

+ 0 - 109
desktop/core/src/desktop/js/parse/jison/sql/ksql/sql_alter.jison

@@ -1,109 +0,0 @@
-// Licensed to Cloudera, Inc. under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  Cloudera, Inc. licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-DataDefinition
- : AlterStatement
- ;
-
-DataDefinition_EDIT
- : AlterStatement_EDIT
- ;
-
-AlterStatement
- : AlterTable
- | AlterView
- ;
-
-AlterStatement_EDIT
- : AlterTable_EDIT
- | AlterView_EDIT
- | 'ALTER' 'CURSOR'
-   {
-     parser.suggestKeywords(['TABLE', 'VIEW']);
-   }
- ;
-
-AlterTable
- : AlterTableLeftSide PartitionSpec
- ;
-
-AlterTable_EDIT
- : AlterTableLeftSide_EDIT
- | AlterTableLeftSide_EDIT PartitionSpec
- | AlterTableLeftSide 'CURSOR'
- | AlterTableLeftSide PartitionSpec 'CURSOR'
- ;
-
-AlterTableLeftSide
- : 'ALTER' 'TABLE' SchemaQualifiedTableIdentifier
-   {
-     parser.addTablePrimary($3);
-   }
- ;
-
-AlterTableLeftSide_EDIT
- : 'ALTER' 'TABLE' SchemaQualifiedTableIdentifier_EDIT
-   {
-     if (parser.yy.result.suggestTables) {
-       parser.yy.result.suggestTables.onlyTables = true;
-     }
-   }
- | 'ALTER' 'TABLE' 'CURSOR'
-   {
-     parser.suggestTables({ onlyTables: true });
-     parser.suggestDatabases({ appendDot: true });
-   }
- ;
-
-AlterView
- : AlterViewLeftSide 'AS' QuerySpecification
- ;
-
-AlterView_EDIT
- : AlterViewLeftSide_EDIT
- | AlterViewLeftSide 'CURSOR'
-   {
-     parser.suggestKeywords(['AS']);
-   }
- | AlterViewLeftSide 'SET' 'CURSOR'
- | AlterViewLeftSide 'AS' 'CURSOR'
-   {
-     parser.suggestKeywords(['SELECT']);
-   }
- | AlterViewLeftSide 'AS' QuerySpecification_EDIT
- ;
-
-
-AlterViewLeftSide
- : 'ALTER' 'VIEW' SchemaQualifiedTableIdentifier
-   {
-     parser.addTablePrimary($3);
-   }
- ;
-
-AlterViewLeftSide_EDIT
- : 'ALTER' 'VIEW' SchemaQualifiedTableIdentifier_EDIT
-   {
-     if (parser.yy.result.suggestTables) {
-       parser.yy.result.suggestTables.onlyViews = true;
-     }
-   }
- | 'ALTER' 'VIEW' 'CURSOR'
-   {
-     parser.suggestTables({ onlyViews: true });
-     parser.suggestDatabases({ appendDot: true });
-   }
- ;

+ 10 - 12
desktop/core/src/desktop/js/parse/jison/sql/ksql/sql_use.jison → desktop/core/src/desktop/js/parse/jison/sql/ksql/sql_list.jison

@@ -15,25 +15,23 @@
 // limitations under the License.
 
 DataDefinition
- : UseStatement
+ : 'LIST' ListStatement
  ;
 
 DataDefinition_EDIT
- : UseStatement_EDIT
+ : ListStatement_EDIT
  ;
 
-UseStatement
- : 'USE' RegularIdentifier
-   {
-     if (! parser.yy.cursorFound) {
-       parser.yy.result.useDatabase = $2;
-     }
-   }
+ListStatement
+ : 'TABLES'
+ | 'STREAMS'
+ | 'TOPICS'
  ;
 
-UseStatement_EDIT
- : 'USE' 'CURSOR'
+
+ListStatement_EDIT
+ : 'LIST' 'CURSOR'
    {
-     parser.suggestDatabases();
+     parser.suggestKeywords(['TABLES', 'STREAMS', 'TOPICS']);
    }
  ;

+ 39 - 0
desktop/core/src/desktop/js/parse/jison/sql/ksql/sql_show.jison

@@ -0,0 +1,39 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+DataDefinition
+ : 'SHOW' ShowStatement
+ ;
+
+DataDefinition_EDIT
+ : ShowStatement_EDIT
+ ;
+
+ShowStatement
+ : 'TABLES'
+ | 'STREAMS'
+ | 'TOPICS'
+ | 'QUERIES'
+ | 'PROPERTIES'
+ ;
+
+
+ShowStatement_EDIT
+ : 'SHOW' 'CURSOR'
+   {
+     parser.suggestKeywords(['TABLES', 'STREAMS', 'TOPICS', 'QUERIES', 'PROPERTIES']);
+   }
+ ;

+ 0 - 122
desktop/core/src/desktop/js/parse/jison/sql/ksql/sql_update.jison

@@ -1,122 +0,0 @@
-// Licensed to Cloudera, Inc. under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  Cloudera, Inc. licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-DataManipulation
- : UpdateStatement
- ;
-
-DataManipulation_EDIT
- : UpdateStatement_EDIT
- ;
-
-UpdateStatement
- : 'UPDATE' TargetTable 'SET' SetClauseList OptionalFromJoinedTable OptionalWhereClause
- ;
-
-UpdateStatement_EDIT
- : 'UPDATE' TargetTable_EDIT 'SET' SetClauseList OptionalFromJoinedTable OptionalWhereClause
- | 'UPDATE' TargetTable 'SET' SetClauseList_EDIT OptionalFromJoinedTable OptionalWhereClause
- | 'UPDATE' TargetTable 'SET' SetClauseList FromJoinedTable_EDIT OptionalWhereClause
- | 'UPDATE' TargetTable 'SET' SetClauseList OptionalFromJoinedTable WhereClause_EDIT
- | 'UPDATE' TargetTable 'SET' SetClauseList OptionalFromJoinedTable OptionalWhereClause 'CURSOR'
-   {
-     parser.suggestKeywords([ 'WHERE' ]);
-   }
- | 'UPDATE' TargetTable 'CURSOR'
-   {
-     parser.suggestKeywords([ 'SET' ]);
-   }
- | 'UPDATE' TargetTable_EDIT
- | 'UPDATE' TargetTable
- | 'UPDATE' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-   }
- ;
-
-TargetTable
- : TableName
- ;
-
-TargetTable_EDIT
- : TableName_EDIT
- ;
-
-TableName
- : LocalOrSchemaQualifiedName
-   {
-     parser.addTablePrimary($1);
-   }
- ;
-
-TableName_EDIT
- : LocalOrSchemaQualifiedName_EDIT
- ;
-
-SetClauseList
- : SetClause
- | SetClauseList ',' SetClause
- ;
-
-SetClauseList_EDIT
- : SetClause_EDIT
- | SetClauseList ',' SetClause_EDIT
- | SetClause_EDIT ',' SetClauseList
- | SetClauseList ',' SetClause_EDIT ',' SetClauseList
- ;
-
-SetClause
- : SetTarget '=' UpdateSource
- ;
-
-SetClause_EDIT
- : SetTarget '=' UpdateSource_EDIT
- | SetTarget 'CURSOR'
-   {
-     parser.suggestKeywords([ '=' ]);
-   }
- | 'CURSOR'
-   {
-     parser.suggestColumns();
-   }
- ;
-
-SetTarget
- : ColumnReference
- ;
-
-UpdateSource
- : ValueExpression
- ;
-
-UpdateSource_EDIT
- : ValueExpression_EDIT
- ;
-
-OptionalFromJoinedTable
- :
- | 'FROM' TableReference  -> $2
- ;
-
-FromJoinedTable_EDIT
- : 'FROM' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-   }
- | 'FROM' TableReference_EDIT
- ;

+ 0 - 155
desktop/core/src/desktop/js/parse/sql/ksql/test/ksqlAutocompleteParser.Alter.test.js

@@ -1,155 +0,0 @@
-// Licensed to Cloudera, Inc. under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  Cloudera, Inc. licenses this file
-// to you under the Apache License, Version 2.0 (the
-// 'License'); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an 'AS IS' BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-import ksqlAutocompleteParser from '../ksqlAutocompleteParser';
-
-describe('ksqlAutocompleteParser.js ALTER statements', () => {
-  beforeAll(() => {
-    ksqlAutocompleteParser.yy.parseError = function(msg) {
-      throw Error(msg);
-    };
-  });
-
-  const assertAutoComplete = testDefinition => {
-    const debug = false;
-
-    expect(
-      ksqlAutocompleteParser.parseSql(
-        testDefinition.beforeCursor,
-        testDefinition.afterCursor,
-        debug
-      )
-    ).toEqualDefinition(testDefinition);
-  };
-
-  describe('ALTER TABLE', () => {
-    it('should suggest keywords for "ALTER |"', () => {
-      assertAutoComplete({
-        beforeCursor: 'ALTER ',
-        afterCursor: '',
-        containsKeywords: ['TABLE'],
-        expectedResult: {
-          lowerCase: false
-        }
-      });
-    });
-
-    it('should suggest tables for "ALTER TABLE |"', () => {
-      assertAutoComplete({
-        beforeCursor: 'ALTER TABLE ',
-        afterCursor: '',
-        expectedResult: {
-          lowerCase: false,
-          suggestTables: { onlyTables: true },
-          suggestDatabases: { appendDot: true }
-        }
-      });
-    });
-
-    it('should suggest tables for "ALTER TABLE foo.|"', () => {
-      assertAutoComplete({
-        beforeCursor: 'ALTER TABLE foo.',
-        afterCursor: '',
-        expectedResult: {
-          lowerCase: false,
-          suggestTables: { identifierChain: [{ name: 'foo' }], onlyTables: true }
-        }
-      });
-    });
-  });
-
-  describe('ALTER VIEW', () => {
-    it('should handle "ALTER VIEW baa.boo AS SELECT * FROM bla;|"', () => {
-      assertAutoComplete({
-        beforeCursor: 'ALTER VIEW baa.boo AS SELECT * FROM bla;',
-        afterCursor: '',
-        noErrors: true,
-        containsKeywords: ['SELECT'],
-        expectedResult: {
-          lowerCase: false
-        }
-      });
-    });
-
-    it('should suggest keywords for "ALTER |"', () => {
-      assertAutoComplete({
-        beforeCursor: 'ALTER ',
-        afterCursor: '',
-        containsKeywords: ['VIEW'],
-        expectedResult: {
-          lowerCase: false
-        }
-      });
-    });
-
-    it('should suggest views for "ALTER VIEW |"', () => {
-      assertAutoComplete({
-        beforeCursor: 'ALTER VIEW ',
-        afterCursor: '',
-        expectedResult: {
-          lowerCase: false,
-          suggestTables: { onlyViews: true },
-          suggestDatabases: { appendDot: true }
-        }
-      });
-    });
-
-    it('should suggest views for "ALTER VIEW boo.|"', () => {
-      assertAutoComplete({
-        beforeCursor: 'ALTER VIEW boo.',
-        afterCursor: '',
-        expectedResult: {
-          lowerCase: false,
-          suggestTables: { identifierChain: [{ name: 'boo' }], onlyViews: true }
-        }
-      });
-    });
-
-    it('should suggest keywords for "ALTER VIEW boo |"', () => {
-      assertAutoComplete({
-        beforeCursor: 'ALTER VIEW boo ',
-        afterCursor: '',
-        containsKeywords: ['AS'],
-        expectedResult: {
-          lowerCase: false
-        }
-      });
-    });
-
-    it('should suggest keywords for "ALTER VIEW baa.boo AS |"', () => {
-      assertAutoComplete({
-        beforeCursor: 'ALTER VIEW baa.boo AS ',
-        afterCursor: '',
-        expectedResult: {
-          lowerCase: false,
-          suggestKeywords: ['SELECT']
-        }
-      });
-    });
-
-    it('should suggest databases for "ALTER VIEW baa.boo AS SELECT * FROM |"', () => {
-      assertAutoComplete({
-        beforeCursor: 'ALTER VIEW baa.boo AS SELECT * FROM ',
-        afterCursor: '',
-        expectedResult: {
-          lowerCase: false,
-          suggestTables: {},
-          suggestDatabases: { appendDot: true }
-        }
-      });
-    });
-  });
-});

+ 0 - 382
desktop/core/src/desktop/js/parse/sql/ksql/test/ksqlAutocompleteParser.Update.test.js

@@ -1,382 +0,0 @@
-// Licensed to Cloudera, Inc. under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  Cloudera, Inc. licenses this file
-// to you under the Apache License, Version 2.0 (the
-// 'License'); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an 'AS IS' BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-import ksqlAutocompleteParser from '../ksqlAutocompleteParser';
-
-describe('ksqlAutocompleteParser.js UPDATE statements', () => {
-  beforeAll(() => {
-    ksqlAutocompleteParser.yy.parseError = function(msg) {
-      throw Error(msg);
-    };
-  });
-
-  const assertAutoComplete = testDefinition => {
-    const debug = false;
-
-    expect(
-      ksqlAutocompleteParser.parseSql(
-        testDefinition.beforeCursor,
-        testDefinition.afterCursor,
-        debug
-      )
-    ).toEqualDefinition(testDefinition);
-  };
-
-  it('should suggest keywords for "|"', () => {
-    assertAutoComplete({
-      beforeCursor: '',
-      afterCursor: '',
-      containsKeywords: ['UPDATE'],
-      expectedResult: {
-        lowerCase: false
-      }
-    });
-  });
-
-  it('should suggest keywords for "UPDATE bar  |"', () => {
-    assertAutoComplete({
-      beforeCursor: 'UPDATE bar  ',
-      afterCursor: '',
-      expectedResult: {
-        lowerCase: false,
-        suggestKeywords: ['SET'],
-        locations: [
-          {
-            type: 'statement',
-            location: { first_line: 1, last_line: 1, first_column: 1, last_column: 12 }
-          },
-          {
-            type: 'table',
-            location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11 },
-            identifierChain: [{ name: 'bar' }]
-          }
-        ]
-      }
-    });
-  });
-
-  it('should suggest keywords for "UPDATE bar SET id=1, foo=2 |"', () => {
-    assertAutoComplete({
-      beforeCursor: 'UPDATE bar SET id=1, foo=2 ',
-      afterCursor: '',
-      containsKeywords: ['WHERE'],
-      expectedResult: {
-        lowerCase: false,
-        locations: [
-          {
-            type: 'statement',
-            location: { first_line: 1, last_line: 1, first_column: 1, last_column: 27 }
-          },
-          {
-            type: 'table',
-            location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11 },
-            identifierChain: [{ name: 'bar' }]
-          },
-          {
-            type: 'column',
-            location: { first_line: 1, last_line: 1, first_column: 16, last_column: 18 },
-            identifierChain: [{ name: 'id' }],
-            tables: [{ identifierChain: [{ name: 'bar' }] }],
-            qualified: false
-          },
-          {
-            type: 'column',
-            location: { first_line: 1, last_line: 1, first_column: 22, last_column: 25 },
-            identifierChain: [{ name: 'foo' }],
-            tables: [{ identifierChain: [{ name: 'bar' }] }],
-            qualified: false
-          }
-        ]
-      }
-    });
-  });
-
-  it('should suggest keywords for "UPDATE bar SET id |"', () => {
-    assertAutoComplete({
-      beforeCursor: 'UPDATE bar SET id ',
-      afterCursor: '',
-      expectedResult: {
-        lowerCase: false,
-        suggestKeywords: ['='],
-        locations: [
-          {
-            type: 'statement',
-            location: { first_line: 1, last_line: 1, first_column: 1, last_column: 18 }
-          },
-          {
-            type: 'table',
-            location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11 },
-            identifierChain: [{ name: 'bar' }]
-          },
-          {
-            type: 'column',
-            location: { first_line: 1, last_line: 1, first_column: 16, last_column: 18 },
-            identifierChain: [{ name: 'id' }],
-            tables: [{ identifierChain: [{ name: 'bar' }] }],
-            qualified: false
-          }
-        ]
-      }
-    });
-  });
-
-  it('should suggest tables for "UPDATE |"', () => {
-    assertAutoComplete({
-      beforeCursor: 'UPDATE ',
-      afterCursor: '',
-      expectedResult: {
-        lowerCase: false,
-        suggestTables: {},
-        suggestDatabases: {
-          appendDot: true
-        }
-      }
-    });
-  });
-
-  it('should suggest tables for "UPDATE bla|"', () => {
-    assertAutoComplete({
-      beforeCursor: 'UPDATE bla',
-      afterCursor: '',
-      expectedResult: {
-        lowerCase: false,
-        suggestTables: {},
-        suggestDatabases: {
-          appendDot: true
-        }
-      }
-    });
-  });
-
-  it('should suggest tables for "UPDATE bar.|"', () => {
-    assertAutoComplete({
-      beforeCursor: 'UPDATE bar.',
-      afterCursor: '',
-      expectedResult: {
-        lowerCase: false,
-        suggestTables: { identifierChain: [{ name: 'bar' }] }
-      }
-    });
-  });
-
-  it('should suggest tables for "UPDATE bar.foo|"', () => {
-    assertAutoComplete({
-      beforeCursor: 'UPDATE bar.foo',
-      afterCursor: '',
-      expectedResult: {
-        lowerCase: false,
-        suggestTables: { identifierChain: [{ name: 'bar' }] }
-      }
-    });
-  });
-
-  it('should suggest columns for "UPDATE bar.foo SET |"', () => {
-    assertAutoComplete({
-      beforeCursor: 'UPDATE bar.foo SET ',
-      afterCursor: '',
-      expectedResult: {
-        lowerCase: false,
-        suggestColumns: { tables: [{ identifierChain: [{ name: 'bar' }, { name: 'foo' }] }] },
-        locations: [
-          {
-            type: 'statement',
-            location: { first_line: 1, last_line: 1, first_column: 1, last_column: 19 }
-          },
-          {
-            type: 'database',
-            location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11 },
-            identifierChain: [{ name: 'bar' }]
-          },
-          {
-            type: 'table',
-            location: { first_line: 1, last_line: 1, first_column: 12, last_column: 15 },
-            identifierChain: [{ name: 'bar' }, { name: 'foo' }]
-          }
-        ]
-      }
-    });
-  });
-
-  it('should suggest columns for "UPDATE bar.foo SET id = 1, bla = \'foo\', |"', () => {
-    assertAutoComplete({
-      beforeCursor: "UPDATE bar.foo SET id = 1, bla = 'foo', ",
-      afterCursor: '',
-      expectedResult: {
-        lowerCase: false,
-        suggestColumns: { tables: [{ identifierChain: [{ name: 'bar' }, { name: 'foo' }] }] },
-        locations: [
-          {
-            type: 'statement',
-            location: { first_line: 1, last_line: 1, first_column: 1, last_column: 40 }
-          },
-          {
-            type: 'database',
-            location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11 },
-            identifierChain: [{ name: 'bar' }]
-          },
-          {
-            type: 'table',
-            location: { first_line: 1, last_line: 1, first_column: 12, last_column: 15 },
-            identifierChain: [{ name: 'bar' }, { name: 'foo' }]
-          },
-          {
-            type: 'column',
-            location: { first_line: 1, last_line: 1, first_column: 20, last_column: 22 },
-            identifierChain: [{ name: 'id' }],
-            tables: [{ identifierChain: [{ name: 'bar' }, { name: 'foo' }] }],
-            qualified: false
-          },
-          {
-            type: 'column',
-            location: { first_line: 1, last_line: 1, first_column: 28, last_column: 31 },
-            identifierChain: [{ name: 'bla' }],
-            tables: [{ identifierChain: [{ name: 'bar' }, { name: 'foo' }] }],
-            qualified: false
-          }
-        ]
-      }
-    });
-  });
-
-  it('should suggest columns for "UPDATE bar.foo SET bla = \'foo\' WHERE |"', () => {
-    assertAutoComplete({
-      beforeCursor: "UPDATE bar.foo SET bla = 'foo' WHERE ",
-      afterCursor: '',
-      expectedResult: {
-        lowerCase: false,
-        suggestFunctions: {},
-        suggestColumns: { tables: [{ identifierChain: [{ name: 'bar' }, { name: 'foo' }] }] },
-        suggestFilters: { tables: [{ identifierChain: [{ name: 'bar' }, { name: 'foo' }] }] },
-        suggestKeywords: ['EXISTS', 'NOT EXISTS'],
-        locations: [
-          {
-            type: 'statement',
-            location: { first_line: 1, last_line: 1, first_column: 1, last_column: 37 }
-          },
-          {
-            type: 'database',
-            location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11 },
-            identifierChain: [{ name: 'bar' }]
-          },
-          {
-            type: 'table',
-            location: { first_line: 1, last_line: 1, first_column: 12, last_column: 15 },
-            identifierChain: [{ name: 'bar' }, { name: 'foo' }]
-          },
-          {
-            type: 'column',
-            location: { first_line: 1, last_line: 1, first_column: 20, last_column: 23 },
-            identifierChain: [{ name: 'bla' }],
-            tables: [{ identifierChain: [{ name: 'bar' }, { name: 'foo' }] }],
-            qualified: false
-          }
-        ]
-      }
-    });
-  });
-
-  it('should suggest values for "UPDATE bar.foo SET bla = \'foo\' WHERE id = |"', () => {
-    assertAutoComplete({
-      beforeCursor: "UPDATE bar.foo SET bla = 'foo' WHERE id = ",
-      afterCursor: '',
-      containsKeywords: ['CASE'],
-      expectedResult: {
-        locations: [
-          {
-            type: 'statement',
-            location: { first_line: 1, last_line: 1, first_column: 1, last_column: 42 }
-          },
-          {
-            type: 'database',
-            location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11 },
-            identifierChain: [{ name: 'bar' }]
-          },
-          {
-            type: 'table',
-            location: { first_line: 1, last_line: 1, first_column: 12, last_column: 15 },
-            identifierChain: [{ name: 'bar' }, { name: 'foo' }]
-          },
-          {
-            type: 'column',
-            location: { first_line: 1, last_line: 1, first_column: 20, last_column: 23 },
-            identifierChain: [{ name: 'bla' }],
-            tables: [{ identifierChain: [{ name: 'bar' }, { name: 'foo' }] }],
-            qualified: false
-          },
-          {
-            type: 'column',
-            location: { first_line: 1, last_line: 1, first_column: 38, last_column: 40 },
-            identifierChain: [{ name: 'id' }],
-            tables: [{ identifierChain: [{ name: 'bar' }, { name: 'foo' }] }],
-            qualified: false
-          }
-        ],
-        suggestFunctions: { types: ['COLREF'] },
-        suggestValues: {},
-        colRef: { identifierChain: [{ name: 'bar' }, { name: 'foo' }, { name: 'id' }] },
-        suggestColumns: {
-          types: ['COLREF'],
-          tables: [{ identifierChain: [{ name: 'bar' }, { name: 'foo' }] }]
-        },
-        lowerCase: false
-      }
-    });
-  });
-
-  it('should suggest columns for "UPDATE bar.foo SET bla = \'foo\' WHERE id = 1 AND |"', () => {
-    assertAutoComplete({
-      beforeCursor: "UPDATE bar.foo SET bla = 'foo' WHERE id = 1 AND ",
-      afterCursor: '',
-      containsKeywords: ['CASE'],
-      expectedResult: {
-        lowerCase: false,
-        suggestFunctions: {},
-        suggestColumns: { tables: [{ identifierChain: [{ name: 'bar' }, { name: 'foo' }] }] },
-        suggestFilters: { tables: [{ identifierChain: [{ name: 'bar' }, { name: 'foo' }] }] },
-        locations: [
-          {
-            type: 'statement',
-            location: { first_line: 1, last_line: 1, first_column: 1, last_column: 48 }
-          },
-          {
-            type: 'database',
-            location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11 },
-            identifierChain: [{ name: 'bar' }]
-          },
-          {
-            type: 'table',
-            location: { first_line: 1, last_line: 1, first_column: 12, last_column: 15 },
-            identifierChain: [{ name: 'bar' }, { name: 'foo' }]
-          },
-          {
-            type: 'column',
-            location: { first_line: 1, last_line: 1, first_column: 20, last_column: 23 },
-            identifierChain: [{ name: 'bla' }],
-            tables: [{ identifierChain: [{ name: 'bar' }, { name: 'foo' }] }],
-            qualified: false
-          },
-          {
-            type: 'column',
-            location: { first_line: 1, last_line: 1, first_column: 38, last_column: 40 },
-            identifierChain: [{ name: 'id' }],
-            tables: [{ identifierChain: [{ name: 'bar' }, { name: 'foo' }] }],
-            qualified: false
-          }
-        ]
-      }
-    });
-  });
-});

+ 0 - 144
desktop/core/src/desktop/js/parse/sql/ksql/test/ksqlAutocompleteParser.Use.test.js

@@ -1,144 +0,0 @@
-// Licensed to Cloudera, Inc. under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  Cloudera, Inc. licenses this file
-// to you under the Apache License, Version 2.0 (the
-// 'License'); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an 'AS IS' BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-import ksqlAutocompleteParser from '../ksqlAutocompleteParser';
-
-describe('ksqlAutocompleteParser.js USE statements', () => {
-  beforeAll(() => {
-    ksqlAutocompleteParser.yy.parseError = function(msg) {
-      throw Error(msg);
-    };
-  });
-
-  const assertAutoComplete = testDefinition => {
-    const debug = false;
-
-    expect(
-      ksqlAutocompleteParser.parseSql(
-        testDefinition.beforeCursor,
-        testDefinition.afterCursor,
-        debug
-      )
-    ).toEqualDefinition(testDefinition);
-  };
-
-  it('should suggest keywords for "|"', () => {
-    assertAutoComplete({
-      beforeCursor: '',
-      afterCursor: '',
-      containsKeywords: ['USE'],
-      expectedResult: {
-        lowerCase: false
-      }
-    });
-  });
-
-  it('should suggest databases for "USE |"', () => {
-    assertAutoComplete({
-      serverResponses: {},
-      beforeCursor: 'USE ',
-      afterCursor: '',
-      expectedResult: {
-        lowerCase: false,
-        suggestDatabases: {}
-      }
-    });
-  });
-
-  it('should suggest databases for "USE bla|"', () => {
-    assertAutoComplete({
-      serverResponses: {},
-      beforeCursor: 'USE bla',
-      afterCursor: '',
-      expectedResult: {
-        lowerCase: false,
-        suggestDatabases: {}
-      }
-    });
-  });
-
-  it('should use a use statement for "use database_two; \\nselect |"', () => {
-    assertAutoComplete({
-      beforeCursor: 'use database_two; \nSELECT ',
-      afterCursor: '',
-      containsKeywords: ['*', 'ALL', 'DISTINCT'],
-      expectedResult: {
-        useDatabase: 'database_two',
-        lowerCase: true,
-        suggestAggregateFunctions: { tables: [] },
-        suggestAnalyticFunctions: true,
-        suggestFunctions: {},
-        suggestTables: {
-          prependQuestionMark: true,
-          prependFrom: true
-        },
-        suggestDatabases: {
-          prependQuestionMark: true,
-          prependFrom: true,
-          appendDot: true
-        }
-      }
-    });
-  });
-
-  it('should use the last use statement for "USE other_db; USE closest_db; \\n\\tSELECT |"', () => {
-    assertAutoComplete({
-      beforeCursor: 'USE other_db; USE closest_db; \n\tSELECT ',
-      afterCursor: '',
-      containsKeywords: ['*', 'ALL', 'DISTINCT'],
-      expectedResult: {
-        useDatabase: 'closest_db',
-        lowerCase: false,
-        suggestAggregateFunctions: { tables: [] },
-        suggestAnalyticFunctions: true,
-        suggestFunctions: {},
-        suggestTables: {
-          prependQuestionMark: true,
-          prependFrom: true
-        },
-        suggestDatabases: {
-          prependQuestionMark: true,
-          prependFrom: true,
-          appendDot: true
-        }
-      }
-    });
-  });
-
-  it('should use the use statement for "USE other_db; USE closest_db; \\n\\tSELECT |; USE some_other_db;"', () => {
-    assertAutoComplete({
-      beforeCursor: 'USE other_db; USE closest_db; \n\tSELECT ',
-      afterCursor: '; USE some_other_db;',
-      containsKeywords: ['*', 'ALL', 'DISTINCT'],
-      expectedResult: {
-        useDatabase: 'closest_db',
-        lowerCase: false,
-        suggestAggregateFunctions: { tables: [] },
-        suggestAnalyticFunctions: true,
-        suggestFunctions: {},
-        suggestTables: {
-          prependQuestionMark: true,
-          prependFrom: true
-        },
-        suggestDatabases: {
-          prependQuestionMark: true,
-          prependFrom: true,
-          appendDot: true
-        }
-      }
-    });
-  });
-});