Skip to content

Commit

Permalink
Move convertDateTime, refactor query_utils (#1064)
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Fitzgibbons <[email protected]>
  • Loading branch information
pjfitzgibbons authored Oct 4, 2023
1 parent 8982b40 commit c4ed77c
Show file tree
Hide file tree
Showing 8 changed files with 392 additions and 234 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 c4ed77c

Please sign in to comment.