dawidwys commented on a change in pull request #13050: URL: https://github.com/apache/flink/pull/13050#discussion_r471355381
########## File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/utils/Expander.java ########## @@ -0,0 +1,126 @@ +/* + * 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.utils; + +import org.apache.flink.table.planner.calcite.FlinkPlannerImpl; + +import org.apache.flink.shaded.guava18.com.google.common.collect.ImmutableMap; + +import org.apache.calcite.sql.SqlIdentifier; +import org.apache.calcite.sql.SqlNode; +import org.apache.calcite.sql.parser.SqlParser; +import org.apache.calcite.sql.parser.SqlParserPos; +import org.apache.calcite.sql.util.SqlBasicVisitor; +import org.apache.calcite.sql.util.SqlShuttle; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.function.Function; + +/** + * Utility that expand SQL identifiers from a SQL query. + * + * <p>Simple use: + * + * <blockquote><code> + * final String sql =<br> + * "select ename from emp where deptno < 10";<br> + * final Expander.Expanded expanded =<br> + * Expander.create(planner).expanded(sql);<br> + * print(expanded); // "select `emp`.`ename` from `catalog`.`db`.`emp` where `emp`.`deptno` < 10" + * </code></blockquote> + * + * <p>Calling {@link Expanded#toString()} generates a string that is similar to + * SQL where a user has manually converted all identifiers as expanded, and + * which could then be persisted as expanded query of a Catalog view. + * + * <p>For more advanced formatting, use {@link Expanded#substitute(Function)}. + * + * <p>Adjust {@link SqlParser.Config} to use a different parser or parsing options. + */ +public class Expander { Review comment: The test you added uses a built-in function, which has a single part identifier which does not differ from not expanded one. Are you saying we never expanded identifiers for UDFs? ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org