1 | /* | |
2 | * Copyright OpenSearch Contributors | |
3 | * SPDX-License-Identifier: Apache-2.0 | |
4 | */ | |
5 | ||
6 | ||
7 | package org.opensearch.sql.planner.logical; | |
8 | ||
9 | import com.google.common.collect.ImmutableList; | |
10 | import java.util.List; | |
11 | import lombok.EqualsAndHashCode; | |
12 | import lombok.Getter; | |
13 | import lombok.ToString; | |
14 | import org.opensearch.sql.expression.LiteralExpression; | |
15 | ||
16 | /** | |
17 | * Logical operator which is a sequence of literal rows (like a relation). | |
18 | * Basically, Values operator is used to create rows of constant literals | |
19 | * "out of nothing" which is corresponding with VALUES clause in SQL. | |
20 | * Mostly all rows must have the same number of literals and each column should | |
21 | * have same type or can be converted implicitly. | |
22 | * In particular, typical use cases include: | |
23 | * 1. Project without relation involved. | |
24 | * 2. Defining query or insertion without a relation. | |
25 | * Take the following logical plan for example: | |
26 | * <pre> | |
27 | * LogicalProject(expr=[log(2),true,1+2]) | |
28 | * |_ LogicalValues([[]]) #an empty row so that Project can evaluate its expressions in next() | |
29 | * </pre> | |
30 | */ | |
31 | @ToString | |
32 | @Getter | |
33 | @EqualsAndHashCode(callSuper = true) | |
34 | public class LogicalValues extends LogicalPlan { | |
35 | ||
36 | private final List<List<LiteralExpression>> values; | |
37 | ||
38 | /** | |
39 | * Constructor of LogicalValues. | |
40 | */ | |
41 | public LogicalValues( | |
42 | List<List<LiteralExpression>> values) { | |
43 | super(ImmutableList.of()); | |
44 | this.values = values; | |
45 | } | |
46 | ||
47 | @Override | |
48 | public <R, C> R accept(LogicalPlanNodeVisitor<R, C> visitor, C context) { | |
49 |
1
1. accept : replaced return value with null for org/opensearch/sql/planner/logical/LogicalValues::accept → KILLED |
return visitor.visitValues(this, context); |
50 | } | |
51 | ||
52 | } | |
Mutations | ||
49 |
1.1 |