hydra.pg.query module

A common model for pattern-matching queries over property graphs.

class hydra.pg.query.AggregationQuery(*values)

Bases: Enum

An aggregation query over a property graph.

COUNT = Name(value='count')
TYPE_ = Name(value='hydra.pg.query.AggregationQuery')
class hydra.pg.query.ApplicationQuery(value: T)

Bases: Node[Sequence[Query]]

A non-empty sequence of queries applied in order.

TYPE_ = Name(value='hydra.pg.query.ApplicationQuery')
class hydra.pg.query.AssociativeExpression(operator: BinaryOperator, operands: Sequence[Expression])

Bases: object

An associative expression: a binary operator applied to a non-empty list of operands.

class Builder(_operator: 'BinaryOperator' = None, _operands: 'Sequence[Expression]' = None)

Bases: object

build()
operands(operands)
operator(operator)
OPERANDS = Name(value='operands')
OPERATOR = Name(value='operator')
TYPE_ = Name(value='hydra.pg.query.AssociativeExpression')
static builder()
operands: Sequence[Expression]
operator: BinaryOperator
with_operands(operands)
with_operator(operator)
class hydra.pg.query.BinaryBooleanOperator(*values)

Bases: Enum

A binary boolean operator: and, or, or xor.

AND = Name(value='and')
OR = Name(value='or')
TYPE_ = Name(value='hydra.pg.query.BinaryBooleanOperator')
XOR = Name(value='xor')
class hydra.pg.query.BinaryExpression(left: Expression, operator: BinaryOperator, right: Expression)

Bases: object

A binary expression: a left operand, an operator, and a right operand.

class Builder(_left: 'Expression' = None, _operator: 'BinaryOperator' = None, _right: 'Expression' = None)

Bases: object

build()
left(left)
operator(operator)
right(right)
LEFT = Name(value='left')
OPERATOR = Name(value='operator')
RIGHT = Name(value='right')
TYPE_ = Name(value='hydra.pg.query.BinaryExpression')
static builder()
left: Expression
operator: BinaryOperator
right: Expression
with_left(left)
with_operator(operator)
with_right(right)
class hydra.pg.query.BinaryOperator

Bases: object

BinaryOperatorBoolean | BinaryOperatorComparison | BinaryOperatorPower

BOOLEAN = Name(value='boolean')
COMPARISON = Name(value='comparison')
POWER = Name(value='power')
TYPE_ = Name(value='hydra.pg.query.BinaryOperator')
class hydra.pg.query.BinaryOperatorBoolean(value: T)

Bases: Node[BinaryBooleanOperator]

class hydra.pg.query.BinaryOperatorComparison(value: T)

Bases: Node[ComparisonOperator]

class hydra.pg.query.BinaryOperatorPower

Bases: object

class hydra.pg.query.Binding(key: Variable, value: Query)

Bases: object

A variable bound to the result of a query.

class Builder(_key: 'Variable' = None, _value: 'Query' = None)

Bases: object

build()
key(key)
value(value)
KEY = Name(value='key')
TYPE_ = Name(value='hydra.pg.query.Binding')
VALUE = Name(value='value')
static builder()
key: Variable
value: Query
with_key(key)
with_value(value)
class hydra.pg.query.ComparisonOperator(*values)

Bases: Enum

A comparison operator: equal, not-equal, or an ordering relation.

EQ = Name(value='eq')
GT = Name(value='gt')
GTE = Name(value='gte')
LT = Name(value='lt')
LTE = Name(value='lte')
NEQ = Name(value='neq')
TYPE_ = Name(value='hydra.pg.query.ComparisonOperator')
class hydra.pg.query.EdgeProjectionPattern(direction: Direction, label: object, properties: Sequence[PropertyPattern], vertex: object)

Bases: object

A pattern matching an edge, its direction, optional label, properties, and adjacent vertex.

class Builder(_direction: 'hydra.pg.model.Direction' = None, _label: 'Optional[hydra.pg.model.EdgeLabel]' = None, _properties: 'Sequence[PropertyPattern]' = None, _vertex: 'Optional[VertexPattern]' = None)

Bases: object

build()
direction(direction)
label(label)
properties(properties)
vertex(vertex)
DIRECTION = Name(value='direction')
LABEL = Name(value='label')
PROPERTIES = Name(value='properties')
TYPE_ = Name(value='hydra.pg.query.EdgeProjectionPattern')
VERTEX = Name(value='vertex')
static builder()
direction: Direction
label: object
properties: Sequence[PropertyPattern]
vertex: object
with_direction(direction)
with_label(label)
with_properties(properties)
with_vertex(vertex)
class hydra.pg.query.Expression

Bases: object

ExpressionAssociative | ExpressionBinary | ExpressionProperty | ExpressionUnary | ExpressionVariable | ExpressionVertex

ASSOCIATIVE = Name(value='associative')
BINARY = Name(value='binary')
PROPERTY = Name(value='property')
TYPE_ = Name(value='hydra.pg.query.Expression')
UNARY = Name(value='unary')
VARIABLE = Name(value='variable')
VERTEX = Name(value='vertex')
class hydra.pg.query.ExpressionAssociative(value: T)

Bases: Node[AssociativeExpression]

class hydra.pg.query.ExpressionBinary(value: T)

Bases: Node[BinaryExpression]

class hydra.pg.query.ExpressionProperty(value: T)

Bases: Node[PropertyProjection]

class hydra.pg.query.ExpressionUnary(value: T)

Bases: Node[UnaryExpression]

class hydra.pg.query.ExpressionVariable(value: T)

Bases: Node[Variable]

class hydra.pg.query.ExpressionVertex(value: T)

Bases: Node[VertexPattern]

class hydra.pg.query.LetQuery(bindings: Sequence[Binding], environment: Query)

Bases: object

A let query: variable bindings evaluated in an environment query.

BINDINGS = Name(value='bindings')
class Builder(_bindings: 'Sequence[Binding]' = None, _environment: 'Query' = None)

Bases: object

bindings(bindings)
build()
environment(environment)
ENVIRONMENT = Name(value='environment')
TYPE_ = Name(value='hydra.pg.query.LetQuery')
bindings: Sequence[Binding]
static builder()
environment: Query
with_bindings(bindings)
with_environment(environment)
class hydra.pg.query.MatchQuery(optional: bool, pattern: Sequence[Projection], where: object)

Bases: object

A pattern-matching query, with optional matching semantics and a filter condition.

class Builder(_optional: 'bool' = None, _pattern: 'Sequence[Projection]' = None, _where: 'Optional[Expression]' = None)

Bases: object

build()
optional(optional)
pattern(pattern)
where(where)
OPTIONAL = Name(value='optional')
PATTERN = Name(value='pattern')
TYPE_ = Name(value='hydra.pg.query.MatchQuery')
WHERE = Name(value='where')
static builder()
optional: bool
pattern: Sequence[Projection]
where: object
with_optional(optional)
with_pattern(pattern)
with_where(where)
class hydra.pg.query.Projection(value: Expression, as_: object)

Bases: object

A projected expression, optionally bound to a variable.

AS = Name(value='as')
class Builder(_value: 'Expression' = None, _as_: 'Optional[Variable]' = None)

Bases: object

as_(as_)
build()
value(value)
TYPE_ = Name(value='hydra.pg.query.Projection')
VALUE = Name(value='value')
as_: object
static builder()
value: Expression
with_as_(as_)
with_value(value)
class hydra.pg.query.Projections(all: bool, explicit: Sequence[Projection])

Bases: object

A set of projections, optionally including all fields.

ALL = Name(value='all')
class Builder(_all: 'bool' = None, _explicit: 'Sequence[Projection]' = None)

Bases: object

all(all)
build()
explicit(explicit)
EXPLICIT = Name(value='explicit')
TYPE_ = Name(value='hydra.pg.query.Projections')
all: bool
static builder()
explicit: Sequence[Projection]
with_all(all)
with_explicit(explicit)
class hydra.pg.query.PropertyPattern(key: PropertyKey, value: PropertyValuePattern)

Bases: object

A pattern matching a property by key against a value pattern.

class Builder(_key: 'hydra.pg.model.PropertyKey' = None, _value: 'PropertyValuePattern' = None)

Bases: object

build()
key(key)
value(value)
KEY = Name(value='key')
TYPE_ = Name(value='hydra.pg.query.PropertyPattern')
VALUE = Name(value='value')
static builder()
key: PropertyKey
value: PropertyValuePattern
with_key(key)
with_value(value)
class hydra.pg.query.PropertyProjection(base: Expression, key: PropertyKey)

Bases: object

A projection of a property, by key, from a base expression.

BASE = Name(value='base')
class Builder(_base: 'Expression' = None, _key: 'hydra.pg.model.PropertyKey' = None)

Bases: object

base(base)
build()
key(key)
KEY = Name(value='key')
TYPE_ = Name(value='hydra.pg.query.PropertyProjection')
base: Expression
static builder()
key: PropertyKey
with_base(base)
with_key(key)
class hydra.pg.query.PropertyValue(value: T)

Bases: Node[str]

A property value.

TYPE_ = Name(value='hydra.pg.query.PropertyValue')
class hydra.pg.query.PropertyValuePattern

Bases: object

PropertyValuePatternVariable | PropertyValuePatternValue

TYPE_ = Name(value='hydra.pg.query.PropertyValuePattern')
VALUE = Name(value='value')
VARIABLE = Name(value='variable')
class hydra.pg.query.PropertyValuePatternValue(value: T)

Bases: Node[str]

class hydra.pg.query.PropertyValuePatternVariable(value: T)

Bases: Node[hydra.pg.model.PropertyKey]

class hydra.pg.query.Query

Bases: object

QueryApplication | QueryAggregate | QueryLetQuery | QueryMatch | QuerySelect | QueryValue

AGGREGATE = Name(value='aggregate')
APPLICATION = Name(value='application')
LET_QUERY = Name(value='LetQuery')
MATCH = Name(value='match')
SELECT = Name(value='select')
TYPE_ = Name(value='hydra.pg.query.Query')
VALUE = Name(value='value')
class hydra.pg.query.QueryAggregate(value: T)

Bases: Node[AggregationQuery]

class hydra.pg.query.QueryApplication(value: T)

Bases: Node[ApplicationQuery]

class hydra.pg.query.QueryLetQuery(value: T)

Bases: Node[LetQuery]

class hydra.pg.query.QueryMatch(value: T)

Bases: Node[MatchQuery]

class hydra.pg.query.QuerySelect(value: T)

Bases: Node[SelectQuery]

class hydra.pg.query.QueryValue(value: T)

Bases: Node[str]

class hydra.pg.query.SelectQuery(distinct: bool, projection: Projections)

Bases: object

A select query, with optional distinctness and a set of projections.

class Builder(_distinct: 'bool' = None, _projection: 'Projections' = None)

Bases: object

build()
distinct(distinct)
projection(projection)
DISTINCT = Name(value='distinct')
PROJECTION = Name(value='projection')
TYPE_ = Name(value='hydra.pg.query.SelectQuery')
static builder()
distinct: bool
projection: Projections
with_distinct(distinct)
with_projection(projection)
class hydra.pg.query.UnaryExpression(operator: UnaryOperator, operand: Expression)

Bases: object

A unary expression: an operator applied to a single operand.

class Builder(_operator: 'UnaryOperator' = None, _operand: 'Expression' = None)

Bases: object

build()
operand(operand)
operator(operator)
OPERAND = Name(value='operand')
OPERATOR = Name(value='operator')
TYPE_ = Name(value='hydra.pg.query.UnaryExpression')
static builder()
operand: Expression
operator: UnaryOperator
with_operand(operand)
with_operator(operator)
class hydra.pg.query.UnaryOperator(*values)

Bases: Enum

A unary operator: negation.

NEGATE = Name(value='negate')
TYPE_ = Name(value='hydra.pg.query.UnaryOperator')
class hydra.pg.query.Variable(value: T)

Bases: Node[str]

A query variable name.

TYPE_ = Name(value='hydra.pg.query.Variable')
class hydra.pg.query.VertexPattern(variable: object, label: object, properties: Sequence[PropertyPattern], edges: Sequence[EdgeProjectionPattern])

Bases: object

A pattern matching a vertex, its optional binding variable and label, properties, and adjacent edges.

class Builder(_variable: 'Optional[Variable]' = None, _label: 'Optional[hydra.pg.model.VertexLabel]' = None, _properties: 'Sequence[PropertyPattern]' = None, _edges: 'Sequence[EdgeProjectionPattern]' = None)

Bases: object

build()
edges(edges)
label(label)
properties(properties)
variable(variable)
EDGES = Name(value='edges')
LABEL = Name(value='label')
PROPERTIES = Name(value='properties')
TYPE_ = Name(value='hydra.pg.query.VertexPattern')
VARIABLE = Name(value='variable')
static builder()
edges: Sequence[EdgeProjectionPattern]
label: object
properties: Sequence[PropertyPattern]
variable: object
with_edges(edges)
with_label(label)
with_properties(properties)
with_variable(variable)