tkalkirill commented on code in PR #13464: URL: https://github.com/apache/ignite/pull/13464#discussion_r3765946276
########## modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/IgniteRelFieldTrimmer.java: ########## @@ -0,0 +1,94 @@ +/* + * 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.ignite.internal.processors.query.calcite.prepare; + +import java.util.Set; +import org.apache.calcite.rel.RelCollation; +import org.apache.calcite.rel.RelFieldCollation; +import org.apache.calcite.rel.RelNode; +import org.apache.calcite.rel.core.Sort; +import org.apache.calcite.rel.type.RelDataTypeField; +import org.apache.calcite.rex.RexDynamicParam; +import org.apache.calcite.rex.RexLiteral; +import org.apache.calcite.rex.RexNode; +import org.apache.calcite.rex.RexUtil; +import org.apache.calcite.sql.validate.SqlValidator; +import org.apache.calcite.sql2rel.RelFieldTrimmer; +import org.apache.calcite.tools.RelBuilder; +import org.apache.calcite.util.ImmutableBitSet; +import org.apache.calcite.util.mapping.Mapping; +import org.apache.calcite.util.mapping.Mappings; +import org.jetbrains.annotations.Nullable; + +import static java.util.Collections.emptySet; + +/** Field trimmer that preserves expression-based FETCH nodes. */ +// TODO: https://issues.apache.org/jira/browse/CALCITE-7592 +// Remove this class and IgniteSqlToRelConvertor.newFieldTrimmer() after upgrading to Calcite 1.43. +public class IgniteRelFieldTrimmer extends RelFieldTrimmer { Review Comment: The check in `IgnitePlanner` would only handle a root `Sort`, while an expression-based `FETCH` may belong to a nested `Sort`, for example under a `Project` or inside a subquery. It would also disable field trimming for the whole tree. Overriding `SqlToRelConverter.newFieldTrimmer()` localizes the workaround to every affected `Sort` and keeps trimming enabled for the rest of the plan. The `TODO` already mentions removing both the custom trimmer and the override after upgrading to Calcite 1.43. -- 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]
