|
| 1 | +// Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +// or more contributor license agreements. See the NOTICE file |
| 3 | +// distributed with this work for additional information |
| 4 | +// regarding copyright ownership. The ASF licenses this file |
| 5 | +// to you under the Apache License, Version 2.0 (the |
| 6 | +// "License"); you may not use this file except in compliance |
| 7 | +// with the License. You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, |
| 12 | +// software distributed under the License is distributed on an |
| 13 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +// KIND, either express or implied. See the License for the |
| 15 | +// specific language governing permissions and limitations |
| 16 | +// under the License. |
| 17 | + |
| 18 | +package org.apache.doris.nereids.analyzer; |
| 19 | + |
| 20 | +import org.apache.doris.nereids.exceptions.UnboundException; |
| 21 | +import org.apache.doris.nereids.memo.GroupExpression; |
| 22 | +import org.apache.doris.nereids.properties.LogicalProperties; |
| 23 | +import org.apache.doris.nereids.trees.expressions.Expression; |
| 24 | +import org.apache.doris.nereids.trees.expressions.NamedExpression; |
| 25 | +import org.apache.doris.nereids.trees.expressions.Slot; |
| 26 | +import org.apache.doris.nereids.trees.plans.BlockFuncDepsPropagation; |
| 27 | +import org.apache.doris.nereids.trees.plans.Plan; |
| 28 | +import org.apache.doris.nereids.trees.plans.PlanType; |
| 29 | +import org.apache.doris.nereids.trees.plans.algebra.InlineTable; |
| 30 | +import org.apache.doris.nereids.trees.plans.logical.LogicalLeaf; |
| 31 | +import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor; |
| 32 | +import org.apache.doris.nereids.util.Utils; |
| 33 | + |
| 34 | +import com.google.common.collect.ImmutableList; |
| 35 | + |
| 36 | +import java.util.List; |
| 37 | +import java.util.Objects; |
| 38 | +import java.util.Optional; |
| 39 | + |
| 40 | +/** UnboundInlineTable */ |
| 41 | +public class UnboundInlineTable extends LogicalLeaf implements InlineTable, BlockFuncDepsPropagation, UnboundPlan { |
| 42 | + private final List<List<NamedExpression>> constantExprsList; |
| 43 | + |
| 44 | + public UnboundInlineTable(List<List<NamedExpression>> constantExprsList) { |
| 45 | + super(PlanType.LOGICAL_UNBOUND_INLINE_TABLE, Optional.empty(), Optional.empty()); |
| 46 | + this.constantExprsList = Utils.fastToImmutableList( |
| 47 | + Objects.requireNonNull(constantExprsList, "constantExprsList can not be null") |
| 48 | + ); |
| 49 | + } |
| 50 | + |
| 51 | + public List<List<NamedExpression>> getConstantExprsList() { |
| 52 | + return constantExprsList; |
| 53 | + } |
| 54 | + |
| 55 | + @Override |
| 56 | + public <R, C> R accept(PlanVisitor<R, C> visitor, C context) { |
| 57 | + return visitor.visitUnboundInlineTable(this, context); |
| 58 | + } |
| 59 | + |
| 60 | + @Override |
| 61 | + public List<? extends Expression> getExpressions() { |
| 62 | + ImmutableList.Builder<Expression> expressions = ImmutableList.builderWithExpectedSize( |
| 63 | + constantExprsList.size() * constantExprsList.get(0).size()); |
| 64 | + |
| 65 | + for (List<NamedExpression> namedExpressions : constantExprsList) { |
| 66 | + expressions.addAll(namedExpressions); |
| 67 | + } |
| 68 | + |
| 69 | + return expressions.build(); |
| 70 | + } |
| 71 | + |
| 72 | + @Override |
| 73 | + public Plan withGroupExpression(Optional<GroupExpression> groupExpression) { |
| 74 | + return this; |
| 75 | + } |
| 76 | + |
| 77 | + @Override |
| 78 | + public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression, |
| 79 | + Optional<LogicalProperties> logicalProperties, List<Plan> children) { |
| 80 | + return this; |
| 81 | + } |
| 82 | + |
| 83 | + @Override |
| 84 | + public List<Slot> computeOutput() { |
| 85 | + throw new UnboundException("output"); |
| 86 | + } |
| 87 | +} |
0 commit comments