Skip to content

Commit

Permalink
Move convertDateTime, refactor query_utils (opensearch-project#1064)
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Fitzgibbons <peter.fitzgibbons@gmail.com>
  • Loading branch information
pjfitzgibbons authored and derek-ho committed Oct 4, 2023
1 parent 9d96fa2 commit 7f2f568
Show file tree
Hide file tree
Showing 8 changed files with 392 additions and 227 deletions.
161 changes: 0 additions & 161 deletions public/components/common/query_utils.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import { parsePromQLIntoKeywords } from '../';

describe('Query Utils', () => {
describe('parsePromQLIntoKeywords', () => {
test('should parse plain catalog.metric into keywords', () => {
const query = 'catalog.metric';
const keywords = parsePromQLIntoKeywords(query);
expect(keywords).toEqual({
aggregation: 'avg',
attributesGroupBy: '',
connection: 'catalog',
metric: 'metric',
});
});

test('should parse simple ppl query_range into keywords', () => {
console.log('should parse simple ppl query_range into keywords');
const query = "source = test_catalog.query_range('metric')";
const keywords = parsePromQLIntoKeywords(query);
expect(keywords).toEqual({
aggregation: 'avg',
attributesGroupBy: '',
connection: 'test_catalog',
metric: 'metric',
});
});

test('should parse promql into keywords', () => {
console.log('should parse promql into keywords');
const query = "source = test_catalog.query_range('count by(one,two) (metric)')";
const keywords = parsePromQLIntoKeywords(query);
expect(keywords).toEqual({
aggregation: 'count',
attributesGroupBy: 'one,two',
connection: 'test_catalog',
metric: 'metric',
});
});
});
});
Loading

0 comments on commit 7f2f568

Please sign in to comment.