aboutsummaryrefslogtreecommitdiffstats
path: root/bsfs/query/validator.py
diff options
context:
space:
mode:
Diffstat (limited to 'bsfs/query/validator.py')
-rw-r--r--bsfs/query/validator.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/bsfs/query/validator.py b/bsfs/query/validator.py
index ecea951..1b7f688 100644
--- a/bsfs/query/validator.py
+++ b/bsfs/query/validator.py
@@ -69,6 +69,8 @@ class Filter():
return self._not(type_, node)
if isinstance(node, ast.filter.Has):
return self._has(type_, node)
+ if isinstance(node, ast.filter.Distance):
+ return self._distance(type_, node)
if isinstance(node, (ast.filter.Any, ast.filter.All)):
return self._branch(type_, node)
if isinstance(node, (ast.filter.And, ast.filter.Or)):
@@ -177,6 +179,20 @@ class Filter():
# node.count is a numerical expression
self._parse_filter_expression(self.schema.literal(ns.bsfs.Number), node.count)
+ def _distance(self, type_: bsc.Vertex, node: ast.filter.Distance):
+ # type is a Literal
+ if not isinstance(type_, bsc.Feature):
+ raise errors.ConsistencyError(f'expected a Feature, found {type_}')
+ # type exists in the schema
+ if type_ not in self.schema.literals():
+ raise errors.ConsistencyError(f'literal {type_} is not in the schema')
+ # reference matches type_
+ if len(node.reference) != type_.dimension:
+ raise errors.ConsistencyError(f'reference has dimension {len(node.reference)}, expected {type_.dimension}')
+ # FIXME:
+ #if node.reference.dtype != type_.dtype:
+ # raise errors.ConsistencyError(f'')
+
## conditions