TQL Syntax

How to properly format TQL queries

Query syntax for the Tensor Query Language (TQL)

CONTAINS and ==

-- Exact match, which generally requires that the sample
-- has 1 value, i.e. no lists or multi-dimensional arrays
select * where tensor_name == 'text_value'   # If value is text
select * where tensor_name == numeric_value  # If values is numeric

select * where contains(tensor_name, 'text_value')

SHAPE

select * where shape(tensor_name)[dimension_index] > numeric_value 
select * where shape(tensor_name)[1] > numeric_value # Second array dimension > value

LIMIT

AND, OR, NOT

UNION and INTERSECT

ORDER BY

ANY, ALL, and ALL_STRICT

IN and BETWEEN

LOGICAL_AND and LOGICAL_OR

REFERENCING SAMPLES IN EXISTING TENORS

SAMPLE BY

  • weight_choice resolves the weight that is used when multiple expressions evaluate to True for a given sample. Options are max_weight, sum_weight. For example, if weight_choice is max_weight, then the maximum weight will be chosen for that sample.

  • replace determines whether samples should be drawn with replacement. It defaults to True.

  • limit specifies the number of samples that should be returned. If unspecified, the sampler will return the number of samples corresponding to the length of the dataset

Deep Lake supports several vector operations for embedding search. Typically, vector operations are called by returning data ordered by the score based on the vector search method.

VIRTUAL TENSORS

Virtual tensors are the result of a computation and are not tensors in the Deep Lake dataset. However, they can be treated as tensors in the API.

GROUP BY AND UNGROUP BY

Group by creates a sequence of data based on the common properties that are being grouped (i.e. frames into videos). Ungroup by splits sequences into their individual elements (i.e. videos into images).

EXPAND BY

Expand by includes samples before and after a query condition is satisfied.

Last updated

Was this helpful?