Skip to content

Commit

Permalink
[analyser] Add tests to SqlAnalyzer abd checkMissingLimit()
Browse files Browse the repository at this point in the history
  • Loading branch information
romainr committed Feb 4, 2021
1 parent 9e829bd commit 44155e8
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
58 changes: 58 additions & 0 deletions desktop/core/src/desktop/js/catalog/optimizer/SqlAnalyser.test.ts
@@ -0,0 +1,58 @@
// 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 Connector from '../types/config';
import SqlAnalyzer from './SqlAnalyzer';

const connectorA: Connector = {
buttonName: '',
displayName: '',
id: 'connectorA',
page: '',
tooltip: '',
type: ''
};

describe('SqlAnalyzer.ts', () => {
describe('checkMissingLimit', () => {
it('Should detect a missing LIMIT', async () => {
const isMissingLimit = await new SqlAnalyzer(connectorA).checkMissingLimit(
'SELECT * FROM employee',
'hive'
);

expect(isMissingLimit).toBeTruthy();
});

it('Should avoid warning from a missing LIMIT in SELECT without a table', async () => {
const isMissingLimit = await new SqlAnalyzer(connectorA).checkMissingLimit(
'SELECT 1',
'hive'
);

expect(isMissingLimit).toBeFalsy();
});

it('Should not warning from a missing LIMIT in CREATE', async () => {
const isMissingLimit = await new SqlAnalyzer(connectorA).checkMissingLimit(
'CREATE TABLE a (a int)',
'hive'
);

expect(isMissingLimit).toBeFalsy();
});
});
});
Expand Up @@ -693,6 +693,7 @@ class AssistEditorContextPanel {

return false;
}

return true;
});
}
Expand Down

0 comments on commit 44155e8

Please sign in to comment.