Documentation
¶
Index ¶
- Variables
- func ConjoinExpressions(kindMapper *contextAwareKindMapper, expressions []pgsql.Expression) (pgsql.Expression, error)
- func ExtractSyntaxNodeReferences(root pgsql.SyntaxNode) (*pgsql.IdentifierSet, error)
- func FromCypher(ctx context.Context, regularQuery *cypher.RegularQuery, ...) (format.Formatted, error)
- func GetAggregatedFunctionParameterSymbols(call pgsql.FunctionCall) (*pgsql.SymbolTable, error)
- func GetTypeHint(expression pgsql.Expression) (pgsql.DataType, bool)
- func InferExpressionType(expression pgsql.Expression) (pgsql.DataType, error)
- func MeasureSelectivity(scope *Scope, owningIdentifierBound bool, expression pgsql.Expression) (int, error)
- func RewriteFrameBindings(scope *Scope, expression pgsql.Expression) error
- func SymbolsFor(node pgsql.SyntaxNode) (*pgsql.SymbolTable, error)
- func Translated(translation Result) (string, error)
- func TypeCastExpression(expression pgsql.Expression, dataType pgsql.DataType) (pgsql.Expression, error)
- type BindingResult
- type BoundIdentifier
- type BoundProjections
- type Builder
- type Constraint
- type ConstraintTracker
- func (s *ConstraintTracker) Constrain(kindMapper *contextAwareKindMapper, dependencies *pgsql.IdentifierSet, ...) error
- func (s *ConstraintTracker) ConsumeAll(kindMapper *contextAwareKindMapper) (*Constraint, error)
- func (s *ConstraintTracker) ConsumeSet(kindMapper *contextAwareKindMapper, visible *pgsql.IdentifierSet) (*Constraint, error)
- func (s *ConstraintTracker) HasConstraints(scope *pgsql.IdentifierSet) (bool, error)
- type Delete
- type Expansion
- type ExpansionBuilder
- func (s *ExpansionBuilder) Build(expansionIdentifier pgsql.Identifier) pgsql.Query
- func (s *ExpansionBuilder) BuildAllShortestPathsRoot() (pgsql.Query, error)
- func (s *ExpansionBuilder) BuildBiDirectionalAllShortestPathsRoot() (pgsql.Query, error)
- func (s *ExpansionBuilder) BuildShortestPathsRoot() (pgsql.Query, error)
- type ExpansionOptions
- type ExpressionTreeTranslator
- func (s *ExpressionTreeTranslator) AddTranslationConstraint(requiredIdentifiers *pgsql.IdentifierSet, expression pgsql.Expression) error
- func (s *ExpressionTreeTranslator) AddUserConstraint(requiredIdentifiers *pgsql.IdentifierSet, expression pgsql.Expression) error
- func (s *ExpressionTreeTranslator) CompleteBinaryExpression(scope *Scope, operator pgsql.Operator) error
- func (s *ExpressionTreeTranslator) ConstrainConjoinedOperandPair() error
- func (s *ExpressionTreeTranslator) ConstrainDisjointOperandPair() error
- func (s *ExpressionTreeTranslator) ConsumeAllConstraints() (*Constraint, error)
- func (s *ExpressionTreeTranslator) ConsumeConstraintsFromVisibleSet(visible *pgsql.IdentifierSet) (*Constraint, error)
- func (s *ExpressionTreeTranslator) PeekOperand() pgsql.Expression
- func (s *ExpressionTreeTranslator) PopBinaryExpression(operator pgsql.Operator) (*pgsql.BinaryExpression, error)
- func (s *ExpressionTreeTranslator) PopOperand() (pgsql.Expression, error)
- func (s *ExpressionTreeTranslator) PopParenthetical() (*pgsql.Parenthetical, error)
- func (s *ExpressionTreeTranslator) PopRemainingExpressionsAsUserConstraints() error
- func (s *ExpressionTreeTranslator) PushOperand(expression pgsql.Expression)
- func (s *ExpressionTreeTranslator) PushParenthetical()
- func (s *ExpressionTreeTranslator) VisitOperator(operator pgsql.Operator)
- type Frame
- type FrameBindingRewriter
- type IdentifierGenerator
- type LabelAssignment
- type Mutations
- func (s *Mutations) AddDeletion(scope *Scope, targetIdentifier pgsql.Identifier, frame *Frame) (*Delete, error)
- func (s *Mutations) AddKindAssignment(scope *Scope, targetIdentifier pgsql.Identifier, kinds graph.Kinds) error
- func (s *Mutations) AddKindRemoval(scope *Scope, targetIdentifier pgsql.Identifier, kinds graph.Kinds) error
- func (s *Mutations) AddPropertyAssignment(scope *Scope, propertyLookup PropertyLookup, operator pgsql.Operator, ...) error
- func (s *Mutations) AddPropertyRemoval(scope *Scope, propertyLookup PropertyLookup) error
- type NodeSelect
- type Pattern
- type PatternConstraints
- type PatternPart
- type Projection
- type Projections
- type PropertyAssignment
- type PropertyLookup
- type Query
- type QueryPart
- func (s *QueryPart) AddFromClause(clause pgsql.FromClause)
- func (s *QueryPart) AddPatternPredicateFuture(predicateFuture *pgsql.Future[*Pattern])
- func (s *QueryPart) AddProperty(key string, expression pgsql.Expression)
- func (s *QueryPart) ConsumeCurrentPattern() *Pattern
- func (s *QueryPart) ConsumeFromClauses() []pgsql.FromClause
- func (s *QueryPart) ConsumeProperties() map[string]pgsql.Expression
- func (s *QueryPart) CurrentOrderBy() *pgsql.OrderBy
- func (s *QueryPart) CurrentProjection() *Projection
- func (s *QueryPart) HasDeletions() bool
- func (s *QueryPart) HasMutations() bool
- func (s *QueryPart) HasProjections() bool
- func (s *QueryPart) HasProperties() bool
- func (s *QueryPart) PrepareMutations()
- func (s *QueryPart) PrepareProjection()
- func (s *QueryPart) PrepareProjections(distinct bool)
- func (s *QueryPart) RestoreStashedPattern()
- func (s *QueryPart) StashCurrentPattern()
- type Removal
- type Result
- type Scope
- func (s *Scope) Alias(alias pgsql.Identifier, binding *BoundIdentifier)
- func (s *Scope) AliasedLookup(identifier pgsql.Identifier) (*BoundIdentifier, bool)
- func (s *Scope) CurrentFrame() *Frame
- func (s *Scope) CurrentFrameBinding() *BoundIdentifier
- func (s *Scope) Declare(identifier pgsql.Identifier)
- func (s *Scope) Define(identifier pgsql.Identifier, dataType pgsql.DataType) *BoundIdentifier
- func (s *Scope) DefineNew(dataType pgsql.DataType) (*BoundIdentifier, error)
- func (s *Scope) FrameAt(depth int) *Frame
- func (s *Scope) IsMaterialized(identifier pgsql.Identifier) bool
- func (s *Scope) Lookup(identifier pgsql.Identifier) (*BoundIdentifier, bool)
- func (s *Scope) LookupBindings(identifiers ...pgsql.Identifier) ([]*BoundIdentifier, error)
- func (s *Scope) LookupString(identifierString string) (*BoundIdentifier, bool)
- func (s *Scope) PopFrame() error
- func (s *Scope) PreviousFrame() *Frame
- func (s *Scope) PruneDefinitions(protectedIdentifiers *pgsql.IdentifierSet) error
- func (s *Scope) PushFrame() (*Frame, error)
- func (s *Scope) ReferenceFrame() *Frame
- func (s *Scope) Snapshot() *Scope
- func (s *Scope) UnwindToFrame(frame *Frame) error
- func (s *Scope) Visible() *pgsql.IdentifierSet
- type Translator
- type TraversalStep
- type Update
Constants ¶
This section is empty.
Variables ¶
var (
ErrUnsupportedExpansionDirection = errors.New("unsupported expansion direction")
)
Functions ¶
func ConjoinExpressions ¶
func ConjoinExpressions(kindMapper *contextAwareKindMapper, expressions []pgsql.Expression) (pgsql.Expression, error)
func ExtractSyntaxNodeReferences ¶
func ExtractSyntaxNodeReferences(root pgsql.SyntaxNode) (*pgsql.IdentifierSet, error)
func FromCypher ¶
func FromCypher(ctx context.Context, regularQuery *cypher.RegularQuery, kindMapper pgsql.KindMapper, stripLiterals bool) (format.Formatted, error)
func GetAggregatedFunctionParameterSymbols ¶
func GetAggregatedFunctionParameterSymbols(call pgsql.FunctionCall) (*pgsql.SymbolTable, error)
func GetTypeHint ¶
func GetTypeHint(expression pgsql.Expression) (pgsql.DataType, bool)
func InferExpressionType ¶
func InferExpressionType(expression pgsql.Expression) (pgsql.DataType, error)
func MeasureSelectivity ¶
func MeasureSelectivity(scope *Scope, owningIdentifierBound bool, expression pgsql.Expression) (int, error)
MeasureSelectivity attempts to measure how selective (i.e. how narrow) the query expression passed in is. This is a simple heuristic that is best-effort for attempting to find which side of a traversal step ()-[]->() is more selective.
The boolean parameter owningIdentifierBound is intended to represent if the identifier the expression constraints is part of a materialized set of nodes where the entity IDs of each are known at time of query. In this case the bound component is considered to be highly-selective.
Many numbers are magic values selected based on implementor's perception of selectivity of certain operators.
func RewriteFrameBindings ¶
func RewriteFrameBindings(scope *Scope, expression pgsql.Expression) error
func SymbolsFor ¶
func SymbolsFor(node pgsql.SyntaxNode) (*pgsql.SymbolTable, error)
func Translated ¶
func TypeCastExpression ¶
func TypeCastExpression(expression pgsql.Expression, dataType pgsql.DataType) (pgsql.Expression, error)
Types ¶
type BindingResult ¶
type BindingResult struct {
Binding *BoundIdentifier
AlreadyBound bool
}
type BoundIdentifier ¶
type BoundIdentifier struct {
Identifier pgsql.Identifier
Alias models.Optional[pgsql.Identifier]
Parameter *pgsql.Parameter
LastProjection *Frame
Dependencies []*BoundIdentifier
DataType pgsql.DataType
}
BoundIdentifier is a declared query identifier bound to the current scope frame.
Bound identifiers have two states:
- Defined - the translation code is aware of this identifier and its type
- Visible - the identifier has been projected into the query's scope and can be referenced
Bound identifiers may also be aliased if the source query contains an alias for the identifier. In the openCypher query `match (n) return n as e` the projection for `n` is aliased as `e`. The translations will eagerly bind anonymous identifiers for traversal steps and rebind existing identifiers and their aliases to prevent naming collisions.
func (*BoundIdentifier) Aliased ¶
func (s *BoundIdentifier) Aliased() pgsql.Identifier
func (*BoundIdentifier) Copy ¶
func (s *BoundIdentifier) Copy() *BoundIdentifier
func (*BoundIdentifier) Dematerialize ¶
func (s *BoundIdentifier) Dematerialize()
func (*BoundIdentifier) DependOn ¶
func (s *BoundIdentifier) DependOn(other *BoundIdentifier)
func (*BoundIdentifier) MaterializedBy ¶
func (s *BoundIdentifier) MaterializedBy(frame *Frame)
type BoundProjections ¶
type BoundProjections struct {
Items pgsql.Projection
Bindings []*BoundIdentifier
}
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
func NewExpressionTreeBuilder ¶
func NewExpressionTreeBuilder() *Builder
func (*Builder) PeekOperand ¶
func (s *Builder) PeekOperand() pgsql.Expression
func (*Builder) PopOperand ¶
func (s *Builder) PopOperand(kindMapper *contextAwareKindMapper) (pgsql.Expression, error)
func (*Builder) PushOperand ¶
func (s *Builder) PushOperand(operand pgsql.Expression)
type Constraint ¶
type Constraint struct {
Dependencies *pgsql.IdentifierSet
Expression pgsql.Expression
}
Constraint is an extracted expression that contains an identifier set of symbols required to be in scope for this constraint to be solvable.
type ConstraintTracker ¶
type ConstraintTracker struct {
Constraints []*Constraint
}
ConstraintTracker is a tool for associating constraints (e.g. binary or unary expressions that constrain a set of identifiers) with the identifier set they constrain.
This is useful for rewriting a where-clause so that conjoined components can be isolated:
Where Clause:
where a.name = 'a' and b.name = 'b' and c.name = 'c' and a.num_a > 1 and a.ef = b.ef + c.ef
Isolated Constraints:
"a": a.name = 'a' and a.num_a > 1 "b": b.name = 'b' "c": c.name = 'c' "a", "b", "c": a.ef = b.ef + c.ef
func NewConstraintTracker ¶
func NewConstraintTracker() *ConstraintTracker
func (*ConstraintTracker) Constrain ¶
func (s *ConstraintTracker) Constrain(kindMapper *contextAwareKindMapper, dependencies *pgsql.IdentifierSet, constraintExpression pgsql.Expression) error
func (*ConstraintTracker) ConsumeAll ¶
func (s *ConstraintTracker) ConsumeAll(kindMapper *contextAwareKindMapper) (*Constraint, error)
func (*ConstraintTracker) ConsumeSet ¶
func (s *ConstraintTracker) ConsumeSet(kindMapper *contextAwareKindMapper, visible *pgsql.IdentifierSet) (*Constraint, error)
ConsumeSet takes a given scope (a set of identifiers considered in-scope) and locates all constraints that can be satisfied by the scope's identifiers.
```
visible := pgsql.IdentifierSet{
"a": struct{}{},
"b": struct{}{},
}
tracker := ConstraintTracker{
Constraints: []*Constraint{{
Dependencies: pgsql.IdentifierSet{
"a": struct{}{},
},
Expression: &pgsql.BinaryExpression{
Operator: pgsql.OperatorEquals,
LOperand: pgsql.CompoundIdentifier{"a", "name"},
ROperand: pgsql.Literal{
Value: "a",
},
},
}},
}
satisfiedConstraints, expression := tracker.ConsumeSet(visible)
```
func (*ConstraintTracker) HasConstraints ¶
func (s *ConstraintTracker) HasConstraints(scope *pgsql.IdentifierSet) (bool, error)
type Delete ¶
type Delete struct {
Frame *Frame
TargetBinding *BoundIdentifier
UpdateBinding *BoundIdentifier
}
type Expansion ¶
type Expansion struct {
Frame *Frame
PathBinding *BoundIdentifier
Options ExpansionOptions
PrimerNodeConstraints pgsql.Expression
PrimerNodeSatisfactionProjection pgsql.SelectItem
PrimerNodeJoinCondition pgsql.Expression
EdgeConstraints pgsql.Expression
EdgeJoinCondition pgsql.Expression
RecursiveConstraints pgsql.Expression
ExpansionNodeJoinCondition pgsql.Expression
TerminalNodeConstraints pgsql.Expression
TerminalNodeSatisfactionProjection pgsql.SelectItem
PrimerQueryParameter *BoundIdentifier
BackwardPrimerQueryParameter *BoundIdentifier
RecursiveQueryParameter *BoundIdentifier
BackwardRecursiveQueryParameter *BoundIdentifier
EdgeStartIdentifier pgsql.Identifier
EdgeStartColumn pgsql.CompoundIdentifier
EdgeEndIdentifier pgsql.Identifier
EdgeEndColumn pgsql.CompoundIdentifier
Projection []pgsql.SelectItem
}
func NewExpansionModel ¶
func NewExpansionModel(part *PatternPart, relationshipPattern *cypher.RelationshipPattern) *Expansion
func (*Expansion) CanExecuteBidirectionalSearch ¶
func (*Expansion) CompletePattern ¶
func (s *Expansion) CompletePattern(traversalStep *TraversalStep) error
func (*Expansion) FlipDirection ¶
func (s *Expansion) FlipDirection()
type ExpansionBuilder ¶
type ExpansionBuilder struct {
PrimerStatement pgsql.Select
RecursiveStatement pgsql.Select
ProjectionStatement pgsql.Select
// contains filtered or unexported fields
}
func NewExpansionBuilder ¶
func NewExpansionBuilder(queryParameters map[string]any, traversalStep *TraversalStep) (*ExpansionBuilder, error)
func (*ExpansionBuilder) Build ¶
func (s *ExpansionBuilder) Build(expansionIdentifier pgsql.Identifier) pgsql.Query
func (*ExpansionBuilder) BuildAllShortestPathsRoot ¶
func (s *ExpansionBuilder) BuildAllShortestPathsRoot() (pgsql.Query, error)
func (*ExpansionBuilder) BuildBiDirectionalAllShortestPathsRoot ¶
func (s *ExpansionBuilder) BuildBiDirectionalAllShortestPathsRoot() (pgsql.Query, error)
func (*ExpansionBuilder) BuildShortestPathsRoot ¶
func (s *ExpansionBuilder) BuildShortestPathsRoot() (pgsql.Query, error)
type ExpansionOptions ¶ added in v0.3.1
type ExpressionTreeTranslator ¶
type ExpressionTreeTranslator struct {
UserConstraints *ConstraintTracker
TranslationConstraints *ConstraintTracker
// contains filtered or unexported fields
}
func NewExpressionTreeTranslator ¶
func NewExpressionTreeTranslator(kindMapper *contextAwareKindMapper) *ExpressionTreeTranslator
func (*ExpressionTreeTranslator) AddTranslationConstraint ¶
func (s *ExpressionTreeTranslator) AddTranslationConstraint(requiredIdentifiers *pgsql.IdentifierSet, expression pgsql.Expression) error
func (*ExpressionTreeTranslator) AddUserConstraint ¶
func (s *ExpressionTreeTranslator) AddUserConstraint(requiredIdentifiers *pgsql.IdentifierSet, expression pgsql.Expression) error
func (*ExpressionTreeTranslator) CompleteBinaryExpression ¶
func (s *ExpressionTreeTranslator) CompleteBinaryExpression(scope *Scope, operator pgsql.Operator) error
func (*ExpressionTreeTranslator) ConstrainConjoinedOperandPair ¶
func (s *ExpressionTreeTranslator) ConstrainConjoinedOperandPair() error
func (*ExpressionTreeTranslator) ConstrainDisjointOperandPair ¶
func (s *ExpressionTreeTranslator) ConstrainDisjointOperandPair() error
func (*ExpressionTreeTranslator) ConsumeAllConstraints ¶
func (s *ExpressionTreeTranslator) ConsumeAllConstraints() (*Constraint, error)
func (*ExpressionTreeTranslator) ConsumeConstraintsFromVisibleSet ¶
func (s *ExpressionTreeTranslator) ConsumeConstraintsFromVisibleSet(visible *pgsql.IdentifierSet) (*Constraint, error)
func (*ExpressionTreeTranslator) PeekOperand ¶
func (s *ExpressionTreeTranslator) PeekOperand() pgsql.Expression
func (*ExpressionTreeTranslator) PopBinaryExpression ¶
func (s *ExpressionTreeTranslator) PopBinaryExpression(operator pgsql.Operator) (*pgsql.BinaryExpression, error)
func (*ExpressionTreeTranslator) PopOperand ¶
func (s *ExpressionTreeTranslator) PopOperand() (pgsql.Expression, error)
func (*ExpressionTreeTranslator) PopParenthetical ¶
func (s *ExpressionTreeTranslator) PopParenthetical() (*pgsql.Parenthetical, error)
func (*ExpressionTreeTranslator) PopRemainingExpressionsAsUserConstraints ¶
func (s *ExpressionTreeTranslator) PopRemainingExpressionsAsUserConstraints() error
func (*ExpressionTreeTranslator) PushOperand ¶
func (s *ExpressionTreeTranslator) PushOperand(expression pgsql.Expression)
func (*ExpressionTreeTranslator) PushParenthetical ¶
func (s *ExpressionTreeTranslator) PushParenthetical()
func (*ExpressionTreeTranslator) VisitOperator ¶
func (s *ExpressionTreeTranslator) VisitOperator(operator pgsql.Operator)
type Frame ¶
type Frame struct {
Previous *Frame
Binding *BoundIdentifier
Visible *pgsql.IdentifierSet
Exported *pgsql.IdentifierSet
// contains filtered or unexported fields
}
Frame represents a snapshot of all identifiers defined and visible in a given scope
func (*Frame) Export ¶
func (s *Frame) Export(identifier pgsql.Identifier)
func (*Frame) Known ¶
func (s *Frame) Known() *pgsql.IdentifierSet
func (*Frame) RestoreStashed ¶
func (s *Frame) RestoreStashed()
func (*Frame) Reveal ¶
func (s *Frame) Reveal(identifier pgsql.Identifier)
func (*Frame) Stash ¶
func (s *Frame) Stash(identifier pgsql.Identifier)
func (*Frame) Unexport ¶
func (s *Frame) Unexport(identifer pgsql.Identifier)
type FrameBindingRewriter ¶
type FrameBindingRewriter struct {
walk.Visitor[pgsql.SyntaxNode]
// contains filtered or unexported fields
}
func (*FrameBindingRewriter) Enter ¶
func (s *FrameBindingRewriter) Enter(node pgsql.SyntaxNode)
func (*FrameBindingRewriter) Exit ¶
func (s *FrameBindingRewriter) Exit(node pgsql.SyntaxNode)
type IdentifierGenerator ¶
IdentifierGenerator is a map that creates a unique identifier for each call with a given data type. This ensures that renamed identifiers in queries do not conflict with each other.
func NewIdentifierGenerator ¶
func NewIdentifierGenerator() IdentifierGenerator
func (IdentifierGenerator) NewIdentifier ¶
func (s IdentifierGenerator) NewIdentifier(dataType pgsql.DataType) (pgsql.Identifier, error)
type LabelAssignment ¶
type LabelAssignment struct {
Kinds pgsql.Expression
}
type Mutations ¶
type Mutations struct {
Deletions *graph.IndexedSlice[pgsql.Identifier, *Delete]
Updates *graph.IndexedSlice[pgsql.Identifier, *Update]
}
func NewMutations ¶
func NewMutations() *Mutations
func (*Mutations) AddDeletion ¶
func (*Mutations) AddKindAssignment ¶
func (*Mutations) AddKindRemoval ¶
func (*Mutations) AddPropertyAssignment ¶
func (s *Mutations) AddPropertyAssignment(scope *Scope, propertyLookup PropertyLookup, operator pgsql.Operator, assignmentValueExpression pgsql.Expression) error
func (*Mutations) AddPropertyRemoval ¶
func (s *Mutations) AddPropertyRemoval(scope *Scope, propertyLookup PropertyLookup) error
type NodeSelect ¶
type NodeSelect struct {
Frame *Frame
Binding *BoundIdentifier
Select pgsql.Select
Constraints pgsql.Expression
}
type Pattern ¶
type Pattern struct {
Parts []*PatternPart
}
func (*Pattern) CurrentPart ¶
func (s *Pattern) CurrentPart() *PatternPart
func (*Pattern) NewPart ¶
func (s *Pattern) NewPart() *PatternPart
type PatternConstraints ¶
type PatternConstraints struct {
LeftNode *Constraint
Edge *Constraint
RightNode *Constraint
}
PatternConstraints is a struct that represents all constraints that can be solved during a traversal step pattern: `()-[]->()`.
func (*PatternConstraints) FlipNodes ¶
func (s *PatternConstraints) FlipNodes()
func (*PatternConstraints) OptimizePatternConstraintBalance ¶
func (s *PatternConstraints) OptimizePatternConstraintBalance(scope *Scope, traversalStep *TraversalStep) error
OptimizePatternConstraintBalance considers the constraints that apply to a pattern segment's bound identifiers.
If only the right side of the pattern segment is constrained, this could result in an imbalanced expansion where one side of the traversal has an extreme disparity in search space.
In cases that match this heuristic, it's beneficial to begin the traversal with the most tightly constrained set of nodes. To accomplish this we flip the order of the traversal step.
type PatternPart ¶
type PatternPart struct {
IsTraversal bool
ShortestPath bool
AllShortestPaths bool
PatternBinding *BoundIdentifier
TraversalSteps []*TraversalStep
NodeSelect NodeSelect
Constraints *ConstraintTracker
}
func (*PatternPart) ContainsExpansions ¶
func (s *PatternPart) ContainsExpansions() bool
func (*PatternPart) LastStep ¶
func (s *PatternPart) LastStep() *TraversalStep
type Projection ¶
type Projection struct {
SelectItem pgsql.SelectItem
Alias models.Optional[pgsql.Identifier]
}
func (*Projection) SetAlias ¶
func (s *Projection) SetAlias(alias pgsql.Identifier)
func (*Projection) SetIdentifier ¶
func (s *Projection) SetIdentifier(identifier pgsql.Identifier)
type Projections ¶
type Projections struct {
Distinct bool
Frame *Frame
Constraints pgsql.Expression
Items []*Projection
GroupBy []pgsql.SelectItem
}
func (*Projections) Add ¶
func (s *Projections) Add(projection *Projection)
func (*Projections) Current ¶
func (s *Projections) Current() *Projection
type PropertyAssignment ¶
type PropertyAssignment struct {
Field string
Operator pgsql.Operator
ValueExpression pgsql.Expression
}
type PropertyLookup ¶
type PropertyLookup struct {
Reference pgsql.CompoundIdentifier
Field string
}
type QueryPart ¶
type QueryPart struct {
Model *pgsql.Query
Frame *Frame
Updates []*Mutations
SortItems []*pgsql.OrderBy
Skip pgsql.Expression
Limit pgsql.Expression
// contains filtered or unexported fields
}
func NewQueryPart ¶
func (*QueryPart) AddFromClause ¶
func (s *QueryPart) AddFromClause(clause pgsql.FromClause)
func (*QueryPart) AddPatternPredicateFuture ¶
func (*QueryPart) AddProperty ¶
func (s *QueryPart) AddProperty(key string, expression pgsql.Expression)
func (*QueryPart) ConsumeCurrentPattern ¶
func (*QueryPart) ConsumeFromClauses ¶
func (s *QueryPart) ConsumeFromClauses() []pgsql.FromClause
func (*QueryPart) ConsumeProperties ¶
func (s *QueryPart) ConsumeProperties() map[string]pgsql.Expression
func (*QueryPart) CurrentOrderBy ¶
func (*QueryPart) CurrentProjection ¶
func (s *QueryPart) CurrentProjection() *Projection
func (*QueryPart) HasDeletions ¶
func (*QueryPart) HasMutations ¶
func (*QueryPart) HasProjections ¶
func (*QueryPart) HasProperties ¶
func (*QueryPart) PrepareMutations ¶
func (s *QueryPart) PrepareMutations()
func (*QueryPart) PrepareProjection ¶
func (s *QueryPart) PrepareProjection()
func (*QueryPart) PrepareProjections ¶
func (*QueryPart) RestoreStashedPattern ¶
func (s *QueryPart) RestoreStashedPattern()
func (*QueryPart) StashCurrentPattern ¶
func (s *QueryPart) StashCurrentPattern()
type Scope ¶
type Scope struct {
// contains filtered or unexported fields
}
Scope contains all identifier definitions and their temporal resolutions in a []*Frame field.
Frames may be pushed onto the stack, advancing the scope of the query to the next component. Frames may be popped from the stack, rewinding visibility to an earlier temporal state. This is useful when navigating subqueries and nested expressions that require their own descendent scope lifecycle.
Each frame is associated with an identifier that represents the query AST element that contains all visible projections. This is required when disambiguating references that otherwise belong to a frame.
func (*Scope) Alias ¶
func (s *Scope) Alias(alias pgsql.Identifier, binding *BoundIdentifier)
func (*Scope) AliasedLookup ¶
func (s *Scope) AliasedLookup(identifier pgsql.Identifier) (*BoundIdentifier, bool)
func (*Scope) CurrentFrame ¶
func (*Scope) CurrentFrameBinding ¶
func (s *Scope) CurrentFrameBinding() *BoundIdentifier
func (*Scope) Declare ¶
func (s *Scope) Declare(identifier pgsql.Identifier)
func (*Scope) Define ¶
func (s *Scope) Define(identifier pgsql.Identifier, dataType pgsql.DataType) *BoundIdentifier
func (*Scope) DefineNew ¶
func (s *Scope) DefineNew(dataType pgsql.DataType) (*BoundIdentifier, error)
func (*Scope) IsMaterialized ¶
func (s *Scope) IsMaterialized(identifier pgsql.Identifier) bool
func (*Scope) Lookup ¶
func (s *Scope) Lookup(identifier pgsql.Identifier) (*BoundIdentifier, bool)
func (*Scope) LookupBindings ¶
func (s *Scope) LookupBindings(identifiers ...pgsql.Identifier) ([]*BoundIdentifier, error)
func (*Scope) LookupString ¶
func (s *Scope) LookupString(identifierString string) (*BoundIdentifier, bool)
func (*Scope) PreviousFrame ¶
func (*Scope) PruneDefinitions ¶
func (s *Scope) PruneDefinitions(protectedIdentifiers *pgsql.IdentifierSet) error
func (*Scope) ReferenceFrame ¶
func (*Scope) UnwindToFrame ¶
func (*Scope) Visible ¶
func (s *Scope) Visible() *pgsql.IdentifierSet
type Translator ¶
type Translator struct {
walk.Visitor[cypher.SyntaxNode]
// contains filtered or unexported fields
}
func NewTranslator ¶
func NewTranslator(ctx context.Context, kindMapper pgsql.KindMapper, parameters map[string]any) *Translator
func (*Translator) Enter ¶
func (s *Translator) Enter(expression cypher.SyntaxNode)
func (*Translator) Exit ¶
func (s *Translator) Exit(expression cypher.SyntaxNode)
type TraversalStep ¶
type TraversalStep struct {
Frame *Frame
Direction graph.Direction
Expansion *Expansion
LeftNode *BoundIdentifier
LeftNodeBound bool
LeftNodeConstraints pgsql.Expression
LeftNodeJoinCondition pgsql.Expression
Edge *BoundIdentifier
EdgeConstraints *Constraint
EdgeJoinCondition pgsql.Expression
RightNode *BoundIdentifier
RightNodeBound bool
RightNodeConstraints pgsql.Expression
RightNodeJoinCondition pgsql.Expression
Projection []pgsql.SelectItem
}
func (*TraversalStep) EndNode ¶
func (s *TraversalStep) EndNode() (*BoundIdentifier, error)
EndNode will find the terminal node of this pattern segment based on the segment's direction
func (*TraversalStep) FlipNodes ¶
func (s *TraversalStep) FlipNodes()
func (*TraversalStep) StartNode ¶
func (s *TraversalStep) StartNode() (*BoundIdentifier, error)
StartNode will find the root node of this pattern segment based on the segment's direction
type Update ¶
type Update struct {
Frame *Frame
JoinConstraint pgsql.Expression
Projection []pgsql.SelectItem
TargetBinding *BoundIdentifier
UpdateBinding *BoundIdentifier
Removals *graph.IndexedSlice[string, Removal]
PropertyAssignments *graph.IndexedSlice[string, PropertyAssignment]
KindRemovals graph.Kinds
KindAssignments graph.Kinds
}