github.com/vescale/zgraph@v0.0.0-20230410094002-959c02d50f95/planner/insert.go (about)

     1  // Copyright 2022 zGraph Authors. All rights reserved.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package planner
    16  
    17  import (
    18  	"github.com/vescale/zgraph/catalog"
    19  	"github.com/vescale/zgraph/expression"
    20  	"github.com/vescale/zgraph/parser/ast"
    21  )
    22  
    23  // Insert represents the plan of INSERT statement.
    24  type Insert struct {
    25  	basePlan
    26  
    27  	Graph      *catalog.Graph
    28  	Insertions []*ElementInsertion
    29  	MatchPlan  Plan
    30  }
    31  
    32  // ElementInsertion represents a graph insertion element.
    33  type ElementInsertion struct {
    34  	Type ast.InsertionType
    35  	// INSERT EDGE e BETWEEN x AND y FROM MATCH (x) , MATCH (y) WHERE id(x) = 1 AND id(y) = 2
    36  	// FromIDExpr and ToIDExpr are the expressions to get the ID of the source and destination vertex.
    37  	FromIDExpr  expression.Expression
    38  	ToIDExpr    expression.Expression
    39  	Labels      []*catalog.Label
    40  	Assignments []*expression.Assignment
    41  }