This is an automated email from the ASF dual-hosted git repository. gortiz pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push: new 935be1ea65 MSE: Return partial stats on errors send by servers (#15910) 935be1ea65 is described below commit 935be1ea6565b91bcf0107fac8969e9e444ddc92 Author: Gonzalo Ortiz Jaureguizar <gor...@users.noreply.github.com> AuthorDate: Wed May 28 10:37:54 2025 +0200 MSE: Return partial stats on errors send by servers (#15910) --- pinot-query-runtime/pom.xml | 10 ++++++++ .../query/service/dispatch/QueryDispatcher.java | 16 +++++++----- .../query/runtime/queries/QueryRunnerTest.java | 30 +++++++++------------- 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/pinot-query-runtime/pom.xml b/pinot-query-runtime/pom.xml index 9e3680e1f8..8fb294c742 100644 --- a/pinot-query-runtime/pom.xml +++ b/pinot-query-runtime/pom.xml @@ -87,5 +87,15 @@ <artifactId>h2</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.jetbrains</groupId> + <artifactId>annotations</artifactId> + <scope>test</scope> + </dependency> </dependencies> </project> diff --git a/pinot-query-runtime/src/main/java/org/apache/pinot/query/service/dispatch/QueryDispatcher.java b/pinot-query-runtime/src/main/java/org/apache/pinot/query/service/dispatch/QueryDispatcher.java index e212e38f02..6b3749640b 100644 --- a/pinot-query-runtime/src/main/java/org/apache/pinot/query/service/dispatch/QueryDispatcher.java +++ b/pinot-query-runtime/src/main/java/org/apache/pinot/query/service/dispatch/QueryDispatcher.java @@ -645,18 +645,20 @@ public class QueryDispatcher { if (block.isError()) { Map<QueryErrorCode, String> queryExceptions = ((ErrorMseBlock) block).getErrorMessages(); + String errorMessage; + Map.Entry<QueryErrorCode, String> error; if (queryExceptions.size() == 1) { - Map.Entry<QueryErrorCode, String> error = queryExceptions.entrySet().iterator().next(); - QueryErrorCode errorCode = error.getKey(); - throw errorCode.asException("Received 1 error from servers: " + error.getValue()); + error = queryExceptions.entrySet().iterator().next(); + errorMessage = "Received 1 error from servers: " + error.getValue(); } else { - Map.Entry<QueryErrorCode, String> highestPriorityError = queryExceptions.entrySet().stream() + error = queryExceptions.entrySet().stream() .max(QueryDispatcher::compareErrors) .orElseThrow(); - throw highestPriorityError.getKey() - .asException("Received " + queryExceptions.size() + " errors from servers. " - + "The one with highest priority is: " + highestPriorityError.getValue()); + errorMessage = "Received " + queryExceptions.size() + " errors from servers. " + + "The one with highest priority is: " + error.getValue(); } + QueryProcessingException processingEx = new QueryProcessingException(error.getKey().getId(), errorMessage); + return new QueryResult(processingEx, queryStats, System.currentTimeMillis() - startTimeMs); } assert block.isSuccess(); return new QueryResult(new ResultTable(resultSchema, resultRows), queryStats, diff --git a/pinot-query-runtime/src/test/java/org/apache/pinot/query/runtime/queries/QueryRunnerTest.java b/pinot-query-runtime/src/test/java/org/apache/pinot/query/runtime/queries/QueryRunnerTest.java index f01f0b623f..fb3d6d3889 100644 --- a/pinot-query-runtime/src/test/java/org/apache/pinot/query/runtime/queries/QueryRunnerTest.java +++ b/pinot-query-runtime/src/test/java/org/apache/pinot/query/runtime/queries/QueryRunnerTest.java @@ -26,12 +26,12 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; -import java.util.regex.Pattern; import org.apache.pinot.common.response.broker.ResultTable; import org.apache.pinot.query.QueryEnvironmentTestBase; import org.apache.pinot.query.QueryServerEnclosure; import org.apache.pinot.query.mailbox.MailboxService; import org.apache.pinot.query.routing.QueryServerInstance; +import org.apache.pinot.query.service.dispatch.QueryDispatcher; import org.apache.pinot.query.testutils.MockInstanceDataManagerFactory; import org.apache.pinot.query.testutils.QueryTestUtils; import org.apache.pinot.spi.config.table.TableType; @@ -42,6 +42,8 @@ import org.apache.pinot.spi.env.PinotConfiguration; import org.apache.pinot.spi.utils.CommonConstants; import org.apache.pinot.spi.utils.JsonUtils; import org.apache.pinot.spi.utils.builder.TableNameBuilder; +import org.assertj.core.api.Assertions; +import org.intellij.lang.annotations.Language; import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -191,29 +193,21 @@ public class QueryRunnerTest extends QueryRunnerTestBase { * Test compares against its desired exceptions. */ @Test(dataProvider = "testDataWithSqlExecutionExceptions") - public void testSqlWithExceptionMsgChecker(String sql, String expectedError) { + public void testSqlWithExceptionMsgChecker(String sql, @Language("regexp") String expectedError) { try { // query pinot - ResultTable resultTable = queryRunner(sql, false).getResultTable(); + QueryDispatcher.QueryResult queryResult = queryRunner(sql, false); + if (queryResult.getProcessingException() != null) { + throw new RuntimeException(queryResult.getProcessingException().getMessage()); + } + ResultTable resultTable = queryResult.getResultTable(); Assert.fail("Expected error with message '" + expectedError + "'. But instead rows were returned: " + JsonUtils.objectToPrettyString(resultTable)); } catch (Exception e) { - // NOTE: The actual message is (usually) something like: - // Received error query execution result block: {200=QueryExecutionError: - // Query execution error on: Server_localhost_12345 - // java.lang.IllegalArgumentException: Illegal Json Path: $['path'] does not match document - // In some cases there is no prefix. String exceptionMessage = e.getMessage(); - boolean isFromQueryDispatcher = Pattern.compile("^Received \\d+ errors? from servers?.*", Pattern.MULTILINE) - .matcher(exceptionMessage) - .find(); - Assert.assertTrue( - exceptionMessage.startsWith("Error occurred during stage submission") - || exceptionMessage.equals(expectedError) - || isFromQueryDispatcher, - "Exception message didn't start with proper heading: " + exceptionMessage); - Assert.assertTrue(exceptionMessage.contains(expectedError), - "Exception should contain: " + expectedError + ", but found: " + exceptionMessage); + Assertions.assertThat(exceptionMessage) + .withFailMessage("Exception should contain: " + expectedError + ", but found: " + exceptionMessage) + .contains(expectedError); } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org