src/LogicalPlanner/LogicalPlan.cs
/// <summary>
/// Create logical operator for AST node type SingleQueryNode
/// </summary>
/// <param name="treeNode"></param>
/// <returns></returns>
Create logical operator for AST node type SingleQueryNode
Create logical operator for AST node type SingleQueryNode
private LogicalOperator CreateLogicalTree(SingleQueryNode treeNode, ISet<LogicalOperator> allLogicalOps)
        {
            var stack = new Stack<PartialQueryNode>();
            PartialQueryNode lastVisited = treeNode.PipedData;
            while (lastVisited != null)
            {
                stack.Push(lastVisited);
                lastVisited = lastVisited.PipedData;
            }
            LogicalOperator lastOperator = null;
            PartialQueryNode lastNode = null;
            while (stack.Any())
            {
                var curNode = stack.Pop();
                lastOperator = CreateLogicalTree(curNode, lastOperator, allLogicalOps, lastNode);
                lastNode = curNode;
            }
            Debug.Assert(lastOperator != null);
            Debug.Assert((treeNode.EntityPropertySelected?.Count ?? 0) > 0);
            var finalProjectedExprs = treeNode.EntityPropertySelected;
            if (finalProjectedExprs.Any(p => p.TryGetDirectlyExposedEntity() != null))
            {
                throw new TranspilerNotSupportedException
                    ($"Please returning fields only. Returning node or relationship entity {treeNode.EntityPropertySelected.First(p => p.TryGetDirectlyExposedEntity() != null).Alias}");
            }
            lastOperator = CreateLogicalTree(
                    lastOperator,
                    treeNode.IsDistinct,
                    finalProjectedExprs,
                    lastNode?.ProjectedExpressions,
                    treeNode.Limit,
                    treeNode.OrderByClause,
                    null, 
                    allLogicalOps
                    );
            return lastOperator;
        }
private LogicalOperator CreateLogicalTree ( SingleQueryNode treeNode , ISet < LogicalOperator > allLogicalOps ) { var stack = new Stack < PartialQueryNode > ( ) ; PartialQueryNode lastVisited = treeNode . PipedData ; while ( lastVisited != null ) { stack . Push ( lastVisited ) ; lastVisited = lastVisited . PipedData ; } LogicalOperator lastOperator = null ; PartialQueryNode lastNode = null ; while ( stack . Any ( ) ) { var curNode = stack . Pop ( ) ; lastOperator = CreateLogicalTree ( curNode , lastOperator , allLogicalOps , lastNode ) ; lastNode = curNode ; } Debug . Assert ( lastOperator != null ) ; Debug . Assert ( ( treeNode . EntityPropertySelected ? . Count ?? 0 ) > 0 ) ; var finalProjectedExprs = treeNode . EntityPropertySelected ; if ( finalProjectedExprs . Any ( p => p . TryGetDirectlyExposedEntity ( ) != null ) ) { throw new TranspilerNotSupportedException ( $" Please returning fields only. Returning node or relationship entity  { treeNode . EntityPropertySelected . First ( p => p . TryGetDirectlyExposedEntity ( ) != null ) . Alias } " ) ; } lastOperator = CreateLogicalTree ( lastOperator , treeNode . IsDistinct , finalProjectedExprs , lastNode ? . ProjectedExpressions , treeNode . Limit , treeNode . OrderByClause , null , allLogicalOps ) ; return lastOperator ; }
Create logical operator for AST node type SingleQueryNode
Create logical operator for AST node type SingleQueryNode
// Start from the leaf node query part to create logical plan for the single query // Parser should guarantee the case we have at least one clause before RETURN // Parser should catch the case that at least one projected field // Special to RETURN clause: block any attempt to return entities, as none of our downstream renderer // support it right now // RETURN has no WHERE conditions
None
treeNode
SingleQueryNode
None
allLogicalOps
ISet<LogicalOperator>