|
| 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.properties.UnboundLogicalProperties; |
| 24 | +import org.apache.doris.nereids.trees.expressions.Expression; |
| 25 | +import org.apache.doris.nereids.trees.expressions.NamedExpression; |
| 26 | +import org.apache.doris.nereids.trees.expressions.Slot; |
| 27 | +import org.apache.doris.nereids.trees.plans.BlockFuncDepsPropagation; |
| 28 | +import org.apache.doris.nereids.trees.plans.Plan; |
| 29 | +import org.apache.doris.nereids.trees.plans.PlanType; |
| 30 | +import org.apache.doris.nereids.trees.plans.algebra.Sink; |
| 31 | +import org.apache.doris.nereids.trees.plans.commands.info.DMLCommandType; |
| 32 | +import org.apache.doris.nereids.trees.plans.logical.UnboundLogicalSink; |
| 33 | +import org.apache.doris.nereids.util.Utils; |
| 34 | + |
| 35 | +import java.util.List; |
| 36 | +import java.util.Objects; |
| 37 | +import java.util.Optional; |
| 38 | + |
| 39 | +/** |
| 40 | + * Represent an external table sink plan node that has not been bound. |
| 41 | + */ |
| 42 | +public abstract class UnboundBaseExternalTableSink<CHILD_TYPE extends Plan> extends UnboundLogicalSink<CHILD_TYPE> |
| 43 | + implements Unbound, Sink, BlockFuncDepsPropagation { |
| 44 | + List<String> hints; |
| 45 | + List<String> partitions; |
| 46 | + |
| 47 | + /** |
| 48 | + * constructor |
| 49 | + */ |
| 50 | + public UnboundBaseExternalTableSink(List<String> nameParts, |
| 51 | + PlanType type, |
| 52 | + List<NamedExpression> outputExprs, |
| 53 | + Optional<GroupExpression> groupExpression, |
| 54 | + Optional<LogicalProperties> logicalProperties, |
| 55 | + List<String> colNames, |
| 56 | + DMLCommandType dmlCommandType, |
| 57 | + CHILD_TYPE child, |
| 58 | + List<String> hints, |
| 59 | + List<String> partitions) { |
| 60 | + super(nameParts, type, outputExprs, groupExpression, |
| 61 | + logicalProperties, colNames, dmlCommandType, child); |
| 62 | + this.hints = Utils.copyRequiredList(hints); |
| 63 | + this.partitions = Utils.copyRequiredList(partitions); |
| 64 | + } |
| 65 | + |
| 66 | + public List<String> getColNames() { |
| 67 | + return colNames; |
| 68 | + } |
| 69 | + |
| 70 | + public List<String> getPartitions() { |
| 71 | + return partitions; |
| 72 | + } |
| 73 | + |
| 74 | + public List<String> getHints() { |
| 75 | + return hints; |
| 76 | + } |
| 77 | + |
| 78 | + @Override |
| 79 | + public UnboundBaseExternalTableSink<CHILD_TYPE> withOutputExprs(List<NamedExpression> outputExprs) { |
| 80 | + throw new UnboundException("could not call withOutputExprs on " + this.getClass().getSimpleName()); |
| 81 | + } |
| 82 | + |
| 83 | + @Override |
| 84 | + public List<? extends Expression> getExpressions() { |
| 85 | + throw new UnsupportedOperationException(this.getClass().getSimpleName() + " don't support getExpression()"); |
| 86 | + } |
| 87 | + |
| 88 | + @Override |
| 89 | + public boolean equals(Object o) { |
| 90 | + if (this == o) { |
| 91 | + return true; |
| 92 | + } |
| 93 | + if (o == null || getClass() != o.getClass()) { |
| 94 | + return false; |
| 95 | + } |
| 96 | + UnboundBaseExternalTableSink<?> that = (UnboundBaseExternalTableSink<?>) o; |
| 97 | + return Objects.equals(nameParts, that.nameParts) |
| 98 | + && Objects.equals(colNames, that.colNames) |
| 99 | + && Objects.equals(hints, that.hints) |
| 100 | + && Objects.equals(partitions, that.partitions); |
| 101 | + } |
| 102 | + |
| 103 | + @Override |
| 104 | + public int hashCode() { |
| 105 | + return Objects.hash(nameParts, colNames, hints, partitions); |
| 106 | + } |
| 107 | + |
| 108 | + @Override |
| 109 | + public LogicalProperties computeLogicalProperties() { |
| 110 | + return UnboundLogicalProperties.INSTANCE; |
| 111 | + } |
| 112 | + |
| 113 | + @Override |
| 114 | + public List<Slot> computeOutput() { |
| 115 | + throw new UnboundException("output"); |
| 116 | + } |
| 117 | +} |
0 commit comments