hydra.pg.query module
A common model for pattern-matching queries over property graphs.
- class hydra.pg.query.AggregationQuery(*values)
Bases:
EnumAn 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:
objectAn 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:
EnumA 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:
objectA 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:
objectBinaryOperatorBoolean | 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:
objectA 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()
- with_key(key)
- with_value(value)
- class hydra.pg.query.ComparisonOperator(*values)
Bases:
EnumA 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:
objectA 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()
- properties: Sequence[PropertyPattern]
- with_direction(direction)
- with_label(label)
- with_properties(properties)
- with_vertex(vertex)
- class hydra.pg.query.Expression
Bases:
objectExpressionAssociative | 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.ExpressionVertex(value: T)
Bases:
Node[VertexPattern]
- class hydra.pg.query.LetQuery(bindings: Sequence[Binding], environment: Query)
Bases:
objectA 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')
- static builder()
- with_bindings(bindings)
- with_environment(environment)
- class hydra.pg.query.MatchQuery(optional: bool, pattern: Sequence[Projection], where: object)
Bases:
objectA 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]
- with_optional(optional)
- with_pattern(pattern)
- with_where(where)
- class hydra.pg.query.Projection(value: Expression, as_: object)
Bases:
objectA 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')
- static builder()
- value: Expression
- with_as_(as_)
- with_value(value)
- class hydra.pg.query.Projections(all: bool, explicit: Sequence[Projection])
Bases:
objectA 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:
objectA 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:
objectA 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:
objectPropertyValuePatternVariable | PropertyValuePatternValue
- TYPE_ = Name(value='hydra.pg.query.PropertyValuePattern')
- VALUE = Name(value='value')
- VARIABLE = Name(value='variable')
- class hydra.pg.query.PropertyValuePatternVariable(value: T)
Bases:
Node[hydra.pg.model.PropertyKey]
- class hydra.pg.query.Query
Bases:
objectQueryApplication | 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.QueryMatch(value: T)
Bases:
Node[MatchQuery]
- class hydra.pg.query.QuerySelect(value: T)
Bases:
Node[SelectQuery]
- class hydra.pg.query.SelectQuery(distinct: bool, projection: Projections)
Bases:
objectA 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:
objectA 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:
EnumA 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:
objectA 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]
- properties: Sequence[PropertyPattern]
- with_edges(edges)
- with_label(label)
- with_properties(properties)
- with_variable(variable)