Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/cubejs-schema-compiler/src/adapter/Granularity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
timeSeriesFromCustomInterval,
TimeSeriesOptions
} from '@cubejs-backend/shared';
import { UserError } from '../compiler/UserError';
import { BaseQuery } from './BaseQuery';

export class Granularity {
Expand Down Expand Up @@ -44,7 +45,7 @@ export class Granularity {
);

if (!customGranularity) {
throw new Error(`Granularity "${timeDimension.granularity}" does not exist in dimension ${timeDimension.dimension}`);
throw new UserError(`Granularity "${timeDimension.granularity}" does not exist in dimension ${timeDimension.dimension}`);
}

this.granularityInterval = customGranularity.interval;
Expand Down
21 changes: 21 additions & 0 deletions packages/cubejs-schema-compiler/test/unit/base-query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,27 @@ describe('SQL Generation', () => {
}
});

it('throws UserError for unknown granularity', async () => {
await compilers.compiler.compile();

const buildQuery = () => new PostgresQuery(compilers, {
measures: ['orders.count'],
timeDimensions: [
{
dimension: 'orders.createdAt',
granularity: 'all',
dateRange: ['2020-01-01', '2021-12-31']
}
],
dimensions: [],
filters: [],
timezone: 'Europe/Kyiv'
});

expect(buildQuery).toThrow(UserError);
expect(buildQuery).toThrow('Granularity "all" does not exist in dimension orders.createdAt');
});

describe('via PostgresQuery', () => {
beforeAll(async () => {
await compilers.compiler.compile();
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -24662,9 +24662,9 @@ webpack@5.94.0:
webpack-sources "^3.2.3"

websocket-driver@>=0.5.1, websocket-driver@^0.7.4:
version "0.7.4"
resolved "https://registry.yarnpkg.com/websocket-driver/-/websocket-driver-0.7.4.tgz#89ad5295bbf64b480abcba31e4953aca706f5760"
integrity sha512-b17KeDIQVjvb0ssuSDF2cYXSg2iztliJ4B9WdsuB6J952qCPKmnVq4DyW5motImXHDC1cBT/1UezrJVsKw5zjg==
version "0.7.5"
resolved "https://registry.yarnpkg.com/websocket-driver/-/websocket-driver-0.7.5.tgz#569d22764ab21f2de20af0e74b411e8ae5a0fa46"
integrity sha512-ZL2+3c7kMBdIRCMz6l8jQMHyGVxj+UL+xVk74Ombiciboca8rHa15L86B19E5oh1pL9Ii/uj54gtsIrZGMo6zA==
dependencies:
http-parser-js ">=0.5.1"
safe-buffer ">=5.1.0"
Expand Down
Loading