muspan.query.

validate_query#

validate_query(domain, query, bypass_checks=False)#

Validate and convert a tuple-like query into a muspan.query object.

Tuple-like queries have the form (‘label_name’, label_value), and are interpreted as the query ‘label_name’ == label_value. This is equivalent to calling query(domain, (‘label’, ‘label_name’), ‘is’, label_value).

Parameters:
domainobject

A muspan domain object.

querytuple or muspan.query object

The query to be validated and converted. It can be a tuple of the form (‘label_name’, label_value) or an instance of muspan.query.query or muspan.query.query_container.

bypass_checksbool

If True, standard checks on whether this query can be interpreted are bypassed. May generate unexpected crashes if objects that can’t be interpreted as a query are passed in, but generates a substantial speed increase for large datasets when we’re confident the query is formatted correctly. Defaults to False.

Returns:
muspan.query.query

A new muspan.query.query object created from the tuple-like query.

Raises:
ValueError

If the query is not a tuple-like query.

ValueError

If the query is not correctly formatted as a muspan tuple query.

ValueError

If the label_name in the tuple is not a string.

ValueError

If the label_value in the tuple is not a string, int, or float.