suxiaogang223 commented on code in PR #68320: URL: https://github.com/apache/doris/pull/68320#discussion_r4115955770
########## fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ShortCircuitIf.java: ########## @@ -0,0 +1,38 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.doris.nereids.trees.expressions.functions.scalar; + +import org.apache.doris.nereids.trees.expressions.Expression; +import org.apache.doris.nereids.trees.expressions.functions.RequiresShortCircuitEvaluation; + +import com.google.common.base.Preconditions; + +import java.util.List; + +/** IF expression with statement-independent short-circuit semantics. */ +public class ShortCircuitIf extends If implements RequiresShortCircuitEvaluation { Review Comment: Addressed in e63f7f2b529. Mandatory short-circuit expressions now block bottom-up child rewriting and FE child folding until branch selection; FoldConstantTest covers an unselected strict-cast failure. ########## fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/ConnectorChangelogPlanBuilder.java: ########## @@ -0,0 +1,563 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.doris.nereids.rules.analysis; + +import org.apache.doris.catalog.Column; +import org.apache.doris.connector.spi.write.ConnectorChangelogMode; +import org.apache.doris.nereids.CascadesContext; +import org.apache.doris.nereids.analyzer.Scope; +import org.apache.doris.nereids.analyzer.UnboundAlias; +import org.apache.doris.nereids.analyzer.UnboundSlot; +import org.apache.doris.nereids.exceptions.AnalysisException; +import org.apache.doris.nereids.trees.expressions.Alias; +import org.apache.doris.nereids.trees.expressions.Cast; +import org.apache.doris.nereids.trees.expressions.EqualTo; +import org.apache.doris.nereids.trees.expressions.Expression; +import org.apache.doris.nereids.trees.expressions.LessThanEqual; +import org.apache.doris.nereids.trees.expressions.NamedExpression; +import org.apache.doris.nereids.trees.expressions.Not; +import org.apache.doris.nereids.trees.expressions.Slot; +import org.apache.doris.nereids.trees.expressions.WindowExpression; +import org.apache.doris.nereids.trees.expressions.functions.agg.AnyValue; +import org.apache.doris.nereids.trees.expressions.functions.agg.Count; +import org.apache.doris.nereids.trees.expressions.functions.scalar.AssertTrue; +import org.apache.doris.nereids.trees.expressions.literal.BigIntLiteral; +import org.apache.doris.nereids.trees.expressions.literal.IntegerLiteral; +import org.apache.doris.nereids.trees.expressions.literal.NullLiteral; +import org.apache.doris.nereids.trees.expressions.literal.TinyIntLiteral; +import org.apache.doris.nereids.trees.expressions.literal.VarcharLiteral; +import org.apache.doris.nereids.trees.plans.commands.ConnectorWriteSchemaUtils; +import org.apache.doris.nereids.trees.plans.commands.info.ConnectorChangelogRowChangeSpec; +import org.apache.doris.nereids.trees.plans.commands.merge.MergeMatchedClause; +import org.apache.doris.nereids.trees.plans.commands.merge.MergeNotMatchedClause; +import org.apache.doris.nereids.trees.plans.commands.merge.MergeUtils; +import org.apache.doris.nereids.trees.plans.logical.LogicalAggregate; +import org.apache.doris.nereids.trees.plans.logical.LogicalFilter; +import org.apache.doris.nereids.trees.plans.logical.LogicalJoin; +import org.apache.doris.nereids.trees.plans.logical.LogicalPlan; +import org.apache.doris.nereids.trees.plans.logical.LogicalProject; +import org.apache.doris.nereids.trees.plans.logical.LogicalWindow; +import org.apache.doris.nereids.types.BigIntType; +import org.apache.doris.nereids.types.DataType; +import org.apache.doris.nereids.types.IntegerType; +import org.apache.doris.nereids.util.ExpressionUtils; +import org.apache.doris.nereids.util.TypeCoercionUtils; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; + +/** Builds the operation-column plus full-row projection used by changelog-oriented connectors. */ +public final class ConnectorChangelogPlanBuilder { + private static final String BRANCH_LABEL = "__DORIS_CHANGELOG_BRANCH__"; + + private ConnectorChangelogPlanBuilder() { + } + + /** Builds a changelog plan for the requested connector row-level operation. */ + public static LogicalPlan build(List<Column> schema, List<String> primaryKeys, + ConnectorChangelogMode mode, ConnectorChangelogRowChangeSpec spec, + LogicalPlan child, CascadesContext context) { + if (spec instanceof ConnectorChangelogRowChangeSpec.Update) { + return buildUpdate(schema, mode, (ConnectorChangelogRowChangeSpec.Update) spec, + child, context); + } + if (spec instanceof ConnectorChangelogRowChangeSpec.Delete) { + return buildDelete(schema, primaryKeys, mode, + (ConnectorChangelogRowChangeSpec.Delete) spec, child, context); + } + if (spec instanceof ConnectorChangelogRowChangeSpec.Merge) { + return new MergeBuilder(schema, primaryKeys, mode, + (ConnectorChangelogRowChangeSpec.Merge) spec, child, context).build(); + } + throw new AnalysisException("Unsupported connector changelog specification: " + + spec.getClass().getSimpleName()); + } + + private static LogicalPlan buildUpdate(List<Column> schema, ConnectorChangelogMode mode, + ConnectorChangelogRowChangeSpec.Update update, LogicalPlan child, + CascadesContext context) { + Map<String, Expression> changes = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER); + for (EqualTo assignment : update.getAssignments()) { + List<String> parts = ((UnboundSlot) assignment.left()).getNameParts(); + String name = parts.get(parts.size() - 1); + if (changes.put(name, assignment.right()) != null) { + throw new AnalysisException("Duplicate column name in connector UPDATE: " + name); + } + } + ExpressionAnalyzer analyzer = analyzer(child, context); + List<NamedExpression> projects = new ArrayList<>(); + projects.add(operation(mode.getOperationColumnName(), mode.getUpdateValue())); + for (Column column : schema) { + Expression value = changes.remove(column.getName()); + if (value == null) { + value = targetSlot(update.getTargetNameInPlan(), column.getName()); + } + projects.add(bindColumn(analyzer, value, column)); Review Comment: Addressed in f691053d615. Changelog UPDATE and matched MERGE UPDATE now resolve explicit and referenced DEFAULT values against the pinned writer schema before expression binding, with coverage for both paths. ########## be/src/exec/operator/exchange_sink_operator.cpp: ########## @@ -535,20 +567,16 @@ Status ExchangeSinkOperatorX::sink_impl(RuntimeState* state, Block* block, bool _part_type == TPartitionType::BUCKET_SHFFULE_HASH_PARTITIONED || _part_type == TPartitionType::OLAP_TABLE_SINK_HASH_PARTITIONED || _part_type == TPartitionType::HIVE_TABLE_SINK_HASH_PARTITIONED || + _part_type == TPartitionType::EXTERNAL_TABLE_SINK_HASH_PARTITIONED || _part_type == TPartitionType::MERGE_PARTITIONED) { RETURN_IF_ERROR(local_state._writer->write(state, block, eos)); - } else if (_part_type == TPartitionType::HIVE_TABLE_SINK_UNPARTITIONED) { + } else if (_part_type == TPartitionType::HIVE_TABLE_SINK_UNPARTITIONED || + _part_type == TPartitionType::EXTERNAL_TABLE_SINK_UNPARTITIONED) { // Control the number of channels according to the flow, thereby controlling the number of table sink writers. RETURN_IF_ERROR(send_to_current_channel()); - _data_processed += block->bytes(); - if (_writer_count < local_state.channels.size()) { - if (_data_processed >= - _writer_count * - config::table_sink_non_partition_write_scaling_data_processed_threshold) { - _writer_count++; - } - } - local_state.current_channel_idx = (local_state.current_channel_idx + 1) % _writer_count; + const auto writer_count = + _update_writer_scaling(block->bytes(), local_state.channels.size()); Review Comment: Addressed in 983d739c427. The local exchange path snapshots block bytes before move-send; ExchangeSinkOperatorTest covers all-local external-unpartitioned writer scaling. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
