Skip to content

Commit 186adfc

Browse files
committed
fix(cubejs-schema-compiler): support unary operators in DAP filters
1 parent 2fffada commit 186adfc

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

packages/cubejs-schema-compiler/src/compiler/CubeValidator.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,18 +627,28 @@ const PolicyFilterSchema = Joi.object().keys({
627627
'notStartsWith',
628628
'endsWith',
629629
'notEndsWith',
630+
'in',
631+
'notIn',
630632
'gt',
631633
'gte',
632634
'lt',
633635
'lte',
636+
'set',
637+
'notSet',
634638
'inDateRange',
635639
'notInDateRange',
640+
'onTheDate',
636641
'beforeDate',
637642
'beforeOrOnDate',
638643
'afterDate',
639644
'afterOrOnDate',
645+
'measureFilter',
640646
).required(),
641-
values: Joi.func().required(),
647+
values: Joi.when('operator', {
648+
is: Joi.valid('set', 'notSet'),
649+
then: Joi.func().optional(),
650+
otherwise: Joi.func().required()
651+
})
642652
});
643653

644654
const PolicyFilterConditionSchema = Joi.object().keys({

packages/cubejs-server-core/src/core/CompilerApi.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ export class CompilerApi {
252252
if (filter.memberReference) {
253253
const evaluatedValues = cubeEvaluator.evaluateContextFunction(
254254
cube,
255-
filter.values,
255+
filter.values || (() => undefined),
256256
context
257257
);
258258
result.member = filter.memberReference;

packages/cubejs-testing/birdbox-fixtures/rbac-python/model/cubes/users.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ cubes:
4747
operator: notEquals
4848
values:
4949
- 'San Francisco'
50+
# This is to validate that unary filters are interpreted correctly
51+
- member: "city"
52+
operator: set
5053
- member: "{CUBE}.city"
5154
operator: equals
5255
values:

0 commit comments

Comments
 (0)