roboto.query.conditions#

Module Contents#

class roboto.query.conditions.Comparator#

Bases: roboto.compat.StrEnum

The comparator to use when comparing a field to a value.

BeginsWith = 'BEGINS_WITH'#
Contains = 'CONTAINS'#
Equals = 'EQUALS'#
Exists = 'EXISTS'#
GreaterThan = 'GREATER_THAN'#
GreaterThanOrEqual = 'GREATER_THAN_OR_EQUAL'#
IsNotNull = 'IS_NOT_NULL'#
IsNull = 'IS_NULL'#
LessThan = 'LESS_THAN'#
LessThanOrEqual = 'LESS_THAN_OR_EQUAL'#
Like = 'LIKE'#
NotContains = 'NOT_CONTAINS'#
NotEquals = 'NOT_EQUALS'#
NotExists = 'NOT_EXISTS'#
NotLike = 'NOT_LIKE'#
static from_string(value)#
Parameters:

value (str)

Return type:

Comparator

to_compact_string()#
class roboto.query.conditions.Condition(/, **data)#

Bases: pydantic.BaseModel

A filter for any arbitrary attribute for a Roboto resource.

Parameters:

data (Any)

comparator: Comparator#
classmethod equals_cond(field, value)#
Parameters:
  • field (str)

  • value (ConditionValue)

Return type:

Condition

field: Annotated[str, Field]#
matches(target)#
Parameters:

target (dict)

Return type:

bool

target_unspecified()#

Is the target resource of this query condition unspecified?

Return type:

bool

targets_dataset()#

Does this query condition target a dataset?

Return type:

bool

targets_file()#

Does this query condition target a file?

Return type:

bool

targets_message_path()#

Does this query condition target a message path?

Return type:

bool

targets_topic()#

Does this query condition target a topic?

Return type:

bool

value: ConditionValue = None#
class roboto.query.conditions.ConditionGroup(/, **data)#

Bases: pydantic.BaseModel

A group of conditions that are combined together.

Parameters:

data (Any)

static and_group(*conditions)#
Parameters:

conditions (ConditionType)

Return type:

ConditionGroup

conditions: collections.abc.Sequence[ConditionType]#
matches(target)#
Parameters:

target (dict | Callable[[ConditionType], bool])

operator: ConditionOperator#
static or_group(*conditions)#
Parameters:

conditions (ConditionType)

Return type:

ConditionGroup

validate_conditions(v)#
Parameters:

v (collections.abc.Sequence[ConditionType])

class roboto.query.conditions.ConditionOperator#

Bases: roboto.compat.StrEnum

The operator to use when combining multiple conditions.

And = 'AND'#
Not = 'NOT'#
Or = 'OR'#
static from_string(value)#
Parameters:

value (str)

Return type:

ConditionOperator

roboto.query.conditions.ConditionType#
roboto.query.conditions.ConditionValue#
class roboto.query.conditions.Field(path)#

Bases: str

A string-like field path that parses resource qualifiers and extracts the target path.

Field extends str to provide automatic parsing of qualified field paths like “dataset.metadata.owner” or “topic.name” into their constituent parts. It identifies the target resource type (dataset, file, topic, or message_path) and extracts the actual field path within that resource.

The class supports both qualified paths (e.g., “dataset.org_id”) and unqualified paths (e.g., “org_id”). For qualified paths, it strips the resource prefix and stores both the original fully qualified path and the extracted target information.

Examples

>>> field = Field("dataset.metadata.foo")
>>> field.target.resource
'dataset'
>>> field.target.path
'metadata.foo'
>>> field = Field("org_id")
>>> field.target.resource is None
True
>>> field.target.path
'org_id'
Parameters:

path (str)

property target: FieldTarget#
Return type:

FieldTarget

classmethod wrap(field)#
Parameters:

field (Union[str, Field])

Return type:

Field

class roboto.query.conditions.FieldTarget#

Bases: NamedTuple

An immutable field path with an optional resource type hint for query interpretation.

FieldTarget pairs a field path with an optional resource qualifier to help the query system resolve which resource type the field belongs to (dataset, file, topic, or message_path). When the resource is omitted, the query context infers it.

Examples

>>> target = FieldTarget("org_id", "dataset")
>>> target.path
'org_id'
>>> target.resource
'dataset'
>>> target = FieldTarget("metadata.min", None)
>>> target.resource is None
True
path: str#

Field path within the target resource, using dot notation for nested fields.

resource: Literal['dataset', 'file', 'topic', 'message_path'] | None#

Optional resource type hint to disambiguate field path interpretation.