Jackie-Jiang commented on code in PR #15692: URL: https://github.com/apache/pinot/pull/15692#discussion_r2071895037
########## pinot-broker/src/main/java/org/apache/pinot/broker/routing/BrokerRoutingManager.java: ########## @@ -102,7 +103,7 @@ public class BrokerRoutingManager implements RoutingManager, ClusterChangeHandle private static final Logger LOGGER = LoggerFactory.getLogger(BrokerRoutingManager.class); private final BrokerMetrics _brokerMetrics; - private final Map<String, RoutingEntry> _routingEntryMap = new ConcurrentHashMap<>(); + private final Map<String, RoutingEntry> _routingEntryMap; Review Comment: Let's not touch this class because it is shared for both SSE and MSE. The contract is by reaching this class the table name should already be resolved to the case sensitive form using `TableCache.getActualTableName()` ########## pinot-common/src/main/java/org/apache/pinot/common/catalog/PinotNameMatcher.java: ########## @@ -0,0 +1,119 @@ +/** + * 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.pinot.common.catalog; + +import com.google.common.collect.ImmutableList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; +import org.apache.calcite.rel.type.RelDataType; +import org.apache.calcite.rel.type.RelDataTypeField; +import org.apache.calcite.sql.validate.SqlNameMatcher; +import org.checkerframework.checker.nullness.qual.Nullable; Review Comment: We usually use `import javax.annotation.Nullable;` ########## pinot-common/src/main/java/org/apache/pinot/common/catalog/PinotNameMatcher.java: ########## @@ -0,0 +1,119 @@ +/** + * 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.pinot.common.catalog; + +import com.google.common.collect.ImmutableList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; +import org.apache.calcite.rel.type.RelDataType; +import org.apache.calcite.rel.type.RelDataTypeField; +import org.apache.calcite.sql.validate.SqlNameMatcher; +import org.checkerframework.checker.nullness.qual.Nullable; + + +/** + * A custom name matcher that, although matches names based on config-provided case-sensitiveness, always reports to be + * case-sensitive so Calcite does not transform identifiers to lower case. + */ +public class PinotNameMatcher implements SqlNameMatcher { + + private final boolean _caseSensitive; + + public PinotNameMatcher(boolean caseSensitive) { + _caseSensitive = caseSensitive; + } + + @Override + public boolean isCaseSensitive() { + return true; + } + + @Override + public boolean matches(String string, String name) { + return _caseSensitive ? string.equals(name) : string.equalsIgnoreCase(name); + } + + @Override + public <K extends List<String>, V> @Nullable V get(Map<K, V> map, List<String> prefixNames, List<String> names) { Review Comment: (minor) We usually put `@Nullable` above `@Override` ########## pinot-server/src/main/java/org/apache/pinot/server/starter/helix/HelixInstanceDataManager.java: ########## @@ -79,7 +82,7 @@ public class HelixInstanceDataManager implements InstanceDataManager { private static final Logger LOGGER = LoggerFactory.getLogger(HelixInstanceDataManager.class); - private final ConcurrentHashMap<String, TableDataManager> _tableDataManagerMap = new ConcurrentHashMap<>(); + private Map<String, TableDataManager> _tableDataManagerMap; Review Comment: Same here. Table name should already be resolved to case sensitive form when reaching here ########## pinot-query-planner/src/main/java/org/apache/pinot/query/QueryEnvironment.java: ########## @@ -124,15 +132,10 @@ public QueryEnvironment(Config config) { String database = config.getDatabase(); _catalog = new PinotCatalog(config.getTableCache(), database); CalciteSchema rootSchema = CalciteSchema.createRootSchema(false, false, database, _catalog); - Properties connectionConfigProperties = new Properties(); Review Comment: Why are we changing this? ########## pinot-query-planner/src/main/java/org/apache/pinot/query/catalog/PinotCatalog.java: ########## @@ -81,15 +85,8 @@ public Table getTable(String name) { */ @Override public Set<String> getTableNames() { - Set<String> result = new HashSet<>(); - for (String tableName: _tableCache.getTableNameMap().keySet()) { - if (DatabaseUtils.isPartOfDatabase(tableName, _databaseName)) { - result.add(tableName); - // if table has no prefix the next add(n) will have no effect - result.add(DatabaseUtils.removeDatabasePrefix(tableName, _databaseName)); - } - } - return result; + return _tableCache.getTableNameMap().keySet().stream().filter(n -> DatabaseUtils.isPartOfDatabase(n, _databaseName)) Review Comment: I don't follow this change. Will this break database support? -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org