jtuglu1 commented on code in PR #19718: URL: https://github.com/apache/druid/pull/19718#discussion_r3635515223
########## sql/src/main/java/org/apache/druid/sql/calcite/schema/SystemSchemaFilters.java: ########## @@ -0,0 +1,184 @@ +/* + * 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.druid.sql.calcite.schema; + +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Range; +import com.google.common.collect.Sets; +import org.apache.calcite.rex.RexCall; +import org.apache.calcite.rex.RexInputRef; +import org.apache.calcite.rex.RexLiteral; +import org.apache.calcite.rex.RexNode; +import org.apache.calcite.util.NlsString; +import org.apache.calcite.util.Sarg; + +import javax.annotation.Nullable; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * Helpers for pushing a simple string-column predicate down from a {@code ProjectableFilterableTable} + * system-table scan (e.g. {@code datasource} for sys.segments, {@code server}/{@code service_name} for + * sys.server_properties) into that table's data source, so the scan materializes only the matching + * rows instead of the whole cluster. + * + * <p>All extraction is best-effort. The filters are left in the planner's filter list, so Calcite + * still applies them as a post-filter; correctness therefore holds even if extraction returns a + * conservative (over-broad) set - the caller just does a bit of extra work - or {@code null} (no + * constraint), which retains a full scan. The extractor never returns a set narrower than the true + * constraint on the column, so pushing it down can never drop a matching row. + */ +final class SystemSchemaFilters Review Comment: added -- 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]
