Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
describe('time menu', () => {
const parser = sqlParserFactory(['COUNT']);
it('matches snapshot when menu is opened for column not inside group by', () => {
const timeMenu = (
{}}
/>
);
const { container } = render(timeMenu);
expect(container).toMatchSnapshot();
});
it('matches snapshot when menu is opened for column inside group by', () => {
const timeMenu = (
it('matches snapshot', () => {
const parser = sqlParserFactory(SQL_FUNCTIONS.map(sqlFunction => sqlFunction.name));
const parsedQuery = parser(`SELECT
"language",
COUNT(*) AS "Count", COUNT(DISTINCT "language") AS "dist_language", COUNT(*) FILTER (WHERE "language"= 'xxx') AS "language_filtered_count"
FROM "github"
WHERE "__time" >= CURRENT_TIMESTAMP - INTERVAL '1' DAY AND "language" != 'TypeScript'
GROUP BY 1
HAVING "Count" != 37392
ORDER BY "Count" DESC`);
const queryOutput = (
describe('number menu', () => {
const parser = sqlParserFactory(['COUNT']);
it('matches snapshot when menu is opened for column not inside group by', () => {
const numberMenu = (
{}}
/>
);
const { container } = render(numberMenu);
expect(container).toMatchSnapshot();
});
it('matches snapshot when menu is opened for column inside group by', () => {
const numberMenu = (
describe('string menu', () => {
const parser = sqlParserFactory(['COUNT']);
it('matches snapshot when menu is opened for column not inside group by', () => {
const stringMenu = (
{}}
/>
);
const { container } = render(stringMenu);
expect(container).toMatchSnapshot();
});
it('matches snapshot when menu is opened for column inside group by', () => {
const stringMenu = (
describe('column tree', () => {
const parser = sqlParserFactory(['COUNT']);
it('matches snapshot', () => {
const columnTree = (
{
return parser(`SELECT channel, count(*) as cnt FROM wikipedia GROUP BY 1`);
}}
defaultSchema="druid"
defaultTable="wikipedia"
columnMetadataLoading={false}
columnMetadata={
[
{
TABLE_SCHEMA: 'druid',
TABLE_NAME: 'wikipedia',
COLUMN_NAME: '__time',
function dateToTimestamp(date: Date): Timestamp {
return timestampFactory(
date
.toISOString()
.split('.')[0]
.split('T')
.join(' '),
);
}
onClick={() => {
onQueryChange(
parsedQuery.addFunctionToGroupBy(
'TIME_FLOOR',
[' '],
[stringFactory(columnName, `"`), stringFactory('PT1H', `'`)],
aliasFactory(`${columnName}_time_floor`),
),
true,
);
}}
/>
'COUNT',
aliasFactory(`${columnName}_filtered_count`),
false,
new FilterClause({
keyword: 'FILTER',
spacing: [' '],
ex: new WhereClause({
keyword: 'WHERE',
spacing: [' '],
filter: new ComparisonExpression({
parens: [],
ex: stringFactory(columnName, '"'),
rhs: new ComparisonExpressionRhs({
parens: [],
op: '=',
rhs: stringFactory('xxx', `'`),
spacing: [' ', ' '],
}),
}),
}),
}),
),
);
}}
/>
onClick={() => {
onQueryChange(
parsedQuery.addFunctionToGroupBy(
'TIME_FLOOR',
[' '],
[stringFactory(columnName, `"`), stringFactory('P1D', `'`)],
aliasFactory(`${columnName}_time_floor`),
),
true,
);
}}
/>
onClick={() => {
onQueryChange(
parsedQuery.addFunctionToGroupBy(
'TIME_FLOOR',
[' '],
[stringFactory(columnName, `"`), stringFactory('P7D', `'`)],
aliasFactory(`${columnName}_time_floor`),
),
true,
);
}}
/>