lincoln-lil commented on code in PR #20359: URL: https://github.com/apache/flink/pull/20359#discussion_r933950487
########## flink-table/flink-table-planner/src/main/java/org/apache/calcite/rel/logical/LogicalTableScan.java: ########## @@ -103,7 +105,9 @@ public RelNode copy(RelTraitSet traitSet, List<RelNode> inputs) { // This file should be remove once CALCITE-4581 is fixed. @Override public RelWriter explainTerms(RelWriter pw) { - return super.explainTerms(pw).itemIf("hints", getHints(), !getHints().isEmpty()); + List<RelHint> hintWithoutAlias = FlinkHints.getHintsWithoutAlias(getHints()); + return super.explainTerms(pw) + .itemIf("hints", hintWithoutAlias, !hintWithoutAlias.isEmpty()); Review Comment: Is it as expected that alias hint non-empty when alias is not declared? Too many plan changes because of this ########## flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/alias/SubQueryAliasNodeClearShuttle.java: ########## @@ -0,0 +1,69 @@ +/* + * 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.flink.table.planner.alias; + +import org.apache.flink.table.planner.hint.FlinkHints; +import org.apache.flink.table.planner.plan.nodes.calcite.SubQueryAlias; + +import org.apache.calcite.rel.RelNode; +import org.apache.calcite.rel.RelShuttleImpl; +import org.apache.calcite.rel.hint.Hintable; +import org.apache.calcite.rel.hint.RelHint; +import org.apache.calcite.rel.logical.LogicalFilter; +import org.apache.calcite.rex.RexNode; +import org.apache.calcite.rex.RexShuttle; +import org.apache.calcite.rex.RexSubQuery; + +import java.util.Collections; + +/** A shuttle to remove sub-query alias node and add the alias hint on the child node. */ +public class SubQueryAliasNodeClearShuttle extends RelShuttleImpl { + @Override + public RelNode visit(RelNode node) { + if (node instanceof SubQueryAlias) { + RelHint aliasTag = + RelHint.builder(FlinkHints.HINT_ALIAS) + .hintOption(((SubQueryAlias) node).getAliasName()) + .build(); + RelNode newNode = + ((Hintable) ((SubQueryAlias) node).getInput()) Review Comment: Input node may not be a `SubQueryAlias` instance -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org