zabetak commented on code in PR #5249: URL: https://github.com/apache/hive/pull/5249#discussion_r1685373539
########## ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/CommonTableExpressionRegistry.java: ########## @@ -0,0 +1,54 @@ +/* + * 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.hadoop.hive.ql.optimizer.calcite; + +import org.apache.calcite.rel.RelNode; +import org.apache.hadoop.hive.common.classification.InterfaceAudience; + +import java.util.HashMap; +import java.util.Map; +import java.util.stream.Stream; + +/** + * A registry of common table expressions for a given query. + * <p>The registry is only meant to hold common expressions for a single query.</p> + * <p>The class is not thread-safe.</p> + */ [email protected] +public final class CommonTableExpressionRegistry { + /** + * A unique collection of common table expressions. + * <p>The expressions may contain internal planning concepts such as {@link org.apache.calcite.plan.hep.HepRelVertex}. + * </p> + */ + private final Map<String, RelNode> ctes = new HashMap<>(); Review Comment: Weighting and ranking CTEs definitely makes sense and I see this as a responsibility of the `CommonTableExpressionSuggester`; concrete implementations of the interface could trade off speed for quality or the opposite. Furthermore, the `CommonTableExpressionSuggester` interface currently accepts a `Configuration` object so it is technically possible to pass arbitrary user-specified properties all the way to the suggester (e.g., `set mysupersuggester.cte.limit=5`) and fine tune specific aspects of its behavior. -- 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]
