walterddr commented on code in PR #9539: URL: https://github.com/apache/pinot/pull/9539#discussion_r988464899
########## pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/SSBQueryIntegrationTest.java: ########## @@ -0,0 +1,287 @@ +/** + * 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.integration.tests; + +import com.google.common.collect.ImmutableMap; +import java.io.File; +import java.net.URL; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import org.apache.commons.io.FileUtils; +import org.apache.pinot.client.Connection; +import org.apache.pinot.client.ConnectionFactory; +import org.apache.pinot.client.ResultSetGroup; +import org.apache.pinot.common.datatable.DataTableFactory; +import org.apache.pinot.core.common.datatable.DataTableBuilderFactory; +import org.apache.pinot.query.service.QueryConfig; +import org.apache.pinot.spi.env.PinotConfiguration; +import org.apache.pinot.spi.utils.CommonConstants; +import org.apache.pinot.tools.BootstrapTableTool; +import org.apache.pinot.util.TestUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.Assert; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + + +public class SSBQueryIntegrationTest extends BaseClusterIntegrationTest { + private static final Logger LOGGER = LoggerFactory.getLogger(SSBQueryIntegrationTest.class); + private static final Map<String, String> SSB_QUICKSTART_TABLE_RESOURCES = ImmutableMap.of( + "customer", "examples/batch/ssb/customer", + "dates", "examples/batch/ssb/dates", + "lineorder", "examples/batch/ssb/lineorder", + "part", "examples/batch/ssb/part", + "supplier", "examples/batch/ssb/supplier"); + + @BeforeClass + public void setUp() + throws Exception { + TestUtils.ensureDirectoriesExistAndEmpty(_tempDir, _segmentDir, _tarDir); + + // Start the Pinot cluster + startZk(); + startController(); + startBroker(); + startServer(); + + // Setting data table version to 4 + DataTableBuilderFactory.setDataTableVersion(DataTableFactory.VERSION_4); + + // load all SSB tables to Pinot. + loadSSBToPinot(); + + // load all SSB tables to H2. + loadSSBToH2(); + } + + @Test(dataProvider = "ssbQueryDataProvider") + public void testSSBQueries(String query) + throws Exception { + testSSBQuery(query); + } + + private void testSSBQuery(String query) + throws Exception { + // connection response + ResultSetGroup pinotResultSetGroup = getPinotConnection().execute(query); + org.apache.pinot.client.ResultSet resultTableResultSet = pinotResultSetGroup.getResultSet(0); + int numRows = resultTableResultSet.getRowCount(); + int numColumns = resultTableResultSet.getColumnCount(); + + // h2 response + Assert.assertNotNull(_h2Connection); + Statement h2statement = _h2Connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); + h2statement.execute(query); + ResultSet h2ResultSet = h2statement.getResultSet(); + + // compare results. + Assert.assertEquals(numColumns, h2ResultSet.getMetaData().getColumnCount()); + if (h2ResultSet.first()) { + for (int i = 0; i < numRows; i++) { + for (int c = 0; c < numColumns; c++) { + String h2Value = h2ResultSet.getString(c + 1); + String pinotValue = resultTableResultSet.getString(i, c); + boolean error = ClusterIntegrationTestUtils.fuzzyCompare(h2Value, pinotValue, pinotValue); + if (error) { + throw new RuntimeException("Value: " + c + " does not match at (" + i + ", " + c + "), " + + "expected h2 value: " + h2Value + ", actual Pinot value: " + pinotValue); + } else { + System.out.println("Value match at (" + i + ", " + c + "), " + "expected h2 value: " + h2Value + + ", actual Pinot value: " + pinotValue); Review Comment: ```suggestion LOGGER.warn("Value match at (" + i + ", " + c + "), " + "expected h2 value: " + h2Value + ", actual Pinot value: " + pinotValue); ``` -- 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]
