yashmayya commented on code in PR #16626: URL: https://github.com/apache/pinot/pull/16626#discussion_r2301045464
########## pinot-common/src/main/java/org/apache/pinot/common/config/provider/TableCacheProvider.java: ########## @@ -0,0 +1,174 @@ +/** + * 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.config.provider; + +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; +import javax.annotation.Nullable; +import org.apache.commons.collections4.MapUtils; +import org.apache.pinot.common.request.Expression; +import org.apache.pinot.spi.config.provider.LogicalTableConfigChangeListener; +import org.apache.pinot.spi.config.provider.SchemaChangeListener; +import org.apache.pinot.spi.config.provider.TableConfigChangeListener; +import org.apache.pinot.spi.config.table.QueryConfig; +import org.apache.pinot.spi.config.table.TableConfig; +import org.apache.pinot.spi.data.LogicalTableConfig; +import org.apache.pinot.spi.data.Schema; +import org.apache.pinot.spi.utils.TimestampIndexUtils; +import org.apache.pinot.sql.parsers.CalciteSqlParser; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public interface TableCacheProvider { + Logger LOGGER = LoggerFactory.getLogger(TableCacheProvider.class); + boolean isIgnoreCase(); + + @Nullable + String getActualTableName(String tableName); + + + @Nullable + String getActualLogicalTableName(String logicalTableName); + + + Map<String, String> getTableNameMap(); + + + Map<String, String> getLogicalTableNameMap(); + + + List<String> getAllDimensionTables(); + + + Map<String, String> getColumnNameMap(String rawTableName); + + + Map<Expression, Expression> getExpressionOverrideMap(String physicalOrLogicalTableName); + + + Set<String> getTimestampIndexColumns(String tableNameWithType); + + + List<LogicalTableConfig> getLogicalTableConfigs(); + + + boolean isLogicalTable(String logicalTableName); Review Comment: nit: bunch of extra empty lines here, can you format this using Pinot checkstyle? ########## pinot-common/src/main/java/org/apache/pinot/common/config/provider/TableCacheProvider.java: ########## @@ -0,0 +1,95 @@ +/** + * 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.config.provider; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import javax.annotation.Nullable; +import org.apache.pinot.common.request.Expression; +import org.apache.pinot.spi.config.provider.PinotConfigProvider; +import org.apache.pinot.spi.data.LogicalTableConfig; + + +public interface TableCacheProvider extends PinotConfigProvider { + + /** + * Returns {@code true} if the TableCache is case-insensitive, {@code false} otherwise. + */ Review Comment: @deepthi912 looks like the Javadocs are still spread across TableCacheProvider (the interface) and TableCache (the implementation) - can you consolidate them into the interface? ########## pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/MultiStageEngineIntegrationTest.java: ########## @@ -1721,6 +1721,133 @@ public void testValidateQueryApiError() assertFalse(result.get("errorMessage").isNull()); } + @Test + public void testValidateQueryApiSuccessfulQueries() throws Exception { + JsonNode tableConfigsNode = JsonUtils.stringToJsonNode( + sendGetRequest(getControllerBaseApiUrl() + "/tables/mytable")); + JsonNode schemaNode = JsonUtils.stringToJsonNode( + sendGetRequest(getControllerBaseApiUrl() + "/schemas/mytable")); + + String[] successfulQueries = { + "SELECT COUNT(*) FROM mytable", + "SELECT DivAirportSeqIDs, COUNT(*) FROM mytable GROUP BY DivAirportSeqIDs", + "SELECT DivAirportSeqIDs FROM mytable WHERE arrayToMV(DivAirportSeqIDs) > 0 LIMIT 10", + "SELECT DivAirportSeqIDs, AirlineID FROM mytable ORDER BY DivAirportSeqIDs LIMIT 5", + "SELECT SUM(arrayToMV(DivAirportSeqIDs)) AS total FROM mytable", + "SELECT AVG(arrayToMV(DivAirportSeqIDs)) FROM mytable WHERE AirlineID IS NOT NULL" + }; + + List<String> configs = new ArrayList<>(); + JsonNode offlineConfig = tableConfigsNode.get("OFFLINE"); + if (offlineConfig != null && !offlineConfig.isMissingNode() && !offlineConfig.isEmpty()) { + configs.add(offlineConfig.toString()); + } + JsonNode realtimeConfig = tableConfigsNode.get("REALTIME"); + if (realtimeConfig != null && !realtimeConfig.isMissingNode() && !realtimeConfig.isEmpty()) { + configs.add(realtimeConfig.toString()); + } + String tableConfigsJson = String.join(",", configs); + + for (String query : successfulQueries) { + String requestJson = String.format( + "{ \"sql\": \"%s\", \"tableConfigs\": [%s], \"schemas\": [%s], \"ignoreCase\": false }", + query, tableConfigsJson, schemaNode.toString()); Review Comment: We should use `MultiStageQueryValidationRequest` for JSON serde instead of mangling strings (similarly for other tests too). -- 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]
