You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "bziobrowski (via GitHub)" <gi...@apache.org> on 2024/11/05 08:59:48 UTC

[PR] Add table and column information to query errors [pinot]

bziobrowski opened a new pull request, #14388:
URL: https://github.com/apache/pinot/pull/14388

   At the moment exceptions thrown during query execution are often missing basic table and column information, making it hard diagnose issues. 
   
   For example, if  dat is a string column containing dates then issuing following query :
   ```sql
   select key , max(dat) as last_seen_date 
   from table
   group by key
   limit 10
   ```
   might return 
   `NumberFormatException: For input string: "2021-10-01T09:01:00-0800"`.
   
   This PR adds table/alias and column/expression information to conversion errors, e.g. 
   
   Error when processing table.dat: NumberFormatException: For input string: "2021-10-01T09:01:00-0800".
   
   


-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Add table and column information to query errors [pinot]

Posted by "bziobrowski (via GitHub)" <gi...@apache.org>.
bziobrowski commented on code in PR #14388:
URL: https://github.com/apache/pinot/pull/14388#discussion_r1829272975


##########
pinot-core/src/main/java/org/apache/pinot/core/operator/docvalsets/ProjectionBlockValSet.java:
##########
@@ -135,6 +139,9 @@ public double[] getDoubleValuesSV() {
     try (InvocationScope scope = Tracing.getTracer().createScope(ProjectionBlockValSet.class)) {
       recordReadValues(scope, DataType.DOUBLE, true);
       return _dataBlockCache.getDoubleValuesForSVColumn(_column);
+    } catch (RuntimeException re) {

Review Comment:
   Probably because it's really hard to trigger those conversions in both engines :)
   You're right, I'll add them and try to test with stub aggregate. 



-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Add table and column information to query errors [pinot]

Posted by "bziobrowski (via GitHub)" <gi...@apache.org>.
bziobrowski commented on code in PR #14388:
URL: https://github.com/apache/pinot/pull/14388#discussion_r1828975156


##########
pinot-core/src/test/java/org/apache/pinot/core/query/QueryParseErrorReportingTest.java:
##########
@@ -0,0 +1,228 @@
+package org.apache.pinot.core.query;
+
+import java.util.Arrays;
+import java.util.List;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.request.context.FunctionContext;
+import org.apache.pinot.core.common.PinotRuntimeException;
+import org.apache.pinot.core.query.aggregation.function.AbstractAggregationFunctionTest;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunctionFactory;
+import org.apache.pinot.core.query.aggregation.function.TestAggregationFunction;
+import org.apache.pinot.queries.FluentQueryTest;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.data.DateTimeFormatSpec;
+import org.apache.pinot.spi.data.FieldSpec;
+import org.apache.pinot.spi.data.Schema;
+import org.apache.pinot.spi.utils.builder.TableConfigBuilder;
+import org.mockito.ArgumentMatcher;
+import org.mockito.MockedStatic;
+import org.mockito.Mockito;
+import org.testng.Assert;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+
+public class QueryParseErrorReportingTest extends AbstractAggregationFunctionTest {
+
+  private static final String RAW_TABLE_NAME = "parkingData";
+
+  private static final String IS_OCCUPIED_COLUMN = "isOccupied";
+  private static final String LEVEL_ID_COLUMN = "levelId";
+  private static final String LOT_ID_COLUMN = "lotId";
+  private static final String EVENT_TIME_COLUMN = "eventTime";
+
+  private static final DateTimeFormatSpec FORMATTER =
+      new DateTimeFormatSpec("1:MILLISECONDS:SIMPLE_DATE_FORMAT:yyyy-MM-dd HH:mm:ss.SSS");
+
+  @Test
+  public void testNoKeyAggregateConversionError() {
+    FluentQueryTest.withBaseDir(_baseDir)
+                   .withNullHandling(false)
+                   .givenTable(SINGLE_FIELD_NULLABLE_DIMENSION_SCHEMAS.get(FieldSpec.DataType.STRING),
+                       SINGLE_FIELD_TABLE_CONFIG)
+                   .onFirstInstance(
+                       new Object[]{"A"}
+                   )
+                   .andOnSecondInstance(
+                       new Object[]{"1A"}
+                   )
+                   .whenQuery("select max(myField) from testTable")
+                   .thenResultIsException(
+                       "Error when processing testTable.myField.*NumberFormatException: For input string:", 2);
+  }
+
+  @Test
+  public void testKeyedAggregateConversionError() {
+    FluentQueryTest.withBaseDir(_baseDir)
+                   .withNullHandling(false)
+                   .givenTable(
+                       new Schema.SchemaBuilder()
+                           .setSchemaName("testTable")
+                           .setEnableColumnBasedNullHandling(true)
+                           .addDimensionField("key", FieldSpec.DataType.STRING)
+                           .addDimensionField("value", FieldSpec.DataType.STRING)
+                           .build(), SINGLE_FIELD_TABLE_CONFIG)
+                   .onFirstInstance(
+                       new Object[]{"k1", "v10"}
+                   )
+                   .andOnSecondInstance(
+                       new Object[]{"k2", "20v"}
+                   )
+                   .whenQuery("select key, max(value) from testTable group by key")
+                   .thenResultIsException(
+                       "Error when processing testTable.value.*NumberFormatException: For input string:", 2);
+  }
+
+  @Test(dataProvider = "dataTypes")
+  public void testGapFillConversionError(FieldSpec.DataType functionType, boolean nullHandlingEnabled) {
+    String query = "SELECT "
+        + " time_col, TEST_AGG( occupied, '" + functionType + "' ) as occupied_slots_count "
+        + "FROM ( "
+        + "  SELECT GapFill(time_col, '1:MILLISECONDS:EPOCH', '1636257600000',  '1636286400000', '1:HOURS',"
+        + "                 FILL( occupied, 'FILL_PREVIOUS_VALUE'), "
+        + "                 TIMESERIESON(levelId, lotId) ) AS time_col,"
+        + "         occupied , lotId, levelId"
+        + "  FROM ("
+        + "    SELECT DATETRUNC('hour', eventTime, 'milliseconds') AS time_col, "
+        + "           lastWithTime(isOccupied, eventTime, 'STRING') as occupied, "
+        + "           lotId, levelId "
+        + "    FROM parkingData "
+        + "    GROUP BY time_col, levelId, lotId"
+        + "    LIMIT 200 "
+        + "  ) "
+        + "  LIMIT 200 "
+        + ") "
+        + " GROUP BY time_col ";
+

Review Comment:
   I think it might be better to add test function to registry but make it work only if a system flag is set, e.g. enableTestFunctions, than to rely on fragile mocks. 



-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Add table and column information to query errors [pinot]

Posted by "gortiz (via GitHub)" <gi...@apache.org>.
gortiz closed pull request #14388: Add table and column information to query errors
URL: https://github.com/apache/pinot/pull/14388


-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Add table and column information to query errors [pinot]

Posted by "bziobrowski (via GitHub)" <gi...@apache.org>.
bziobrowski commented on code in PR #14388:
URL: https://github.com/apache/pinot/pull/14388#discussion_r1829262997


##########
pinot-core/src/main/java/org/apache/pinot/core/operator/query/NonScanBasedAggregationOperator.java:
##########
@@ -153,26 +154,30 @@ protected AggregationResultsBlock getNextBlock() {
   private static Double getMinValue(DataSource dataSource) {
     Dictionary dictionary = dataSource.getDictionary();
     if (dictionary != null) {
-      return toDouble(dictionary.getMinVal());
+      return toDouble(dictionary.getMinVal(), dataSource);
     }
-    return toDouble(dataSource.getDataSourceMetadata().getMinValue());
+    return toDouble(dataSource.getDataSourceMetadata().getMinValue(), dataSource);
   }
 
   private static Double getMaxValue(DataSource dataSource) {
     Dictionary dictionary = dataSource.getDictionary();
     if (dictionary != null) {
-      return toDouble(dictionary.getMaxVal());
+      return toDouble(dictionary.getMaxVal(), dataSource);
     }
-    return toDouble(dataSource.getDataSourceMetadata().getMaxValue());
+    return toDouble(dataSource.getDataSourceMetadata().getMaxValue(), dataSource);
   }
 
-  private static Double toDouble(Comparable<?> value) {
-    if (value instanceof Double) {
-      return (Double) value;
-    } else if (value instanceof Number) {
-      return ((Number) value).doubleValue();
-    } else {
-      return Double.parseDouble(value.toString());
+  private static Double toDouble(Comparable<?> value, DataSource dataSource) {

Review Comment:
   I guess so but I'm not sure how sensitive the place and tried to minimize potential overhead. 



-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Add table and column information to query errors [pinot]

Posted by "bziobrowski (via GitHub)" <gi...@apache.org>.
bziobrowski commented on code in PR #14388:
URL: https://github.com/apache/pinot/pull/14388#discussion_r1829271254


##########
pinot-core/src/main/java/org/apache/pinot/core/common/PinotRuntimeException.java:
##########
@@ -0,0 +1,73 @@
+/**
+ * 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.core.common;
+
+/**
+ *  Simple runtime query exception containing useful contextual information, e.g. table or column name.
+ */
+public class PinotRuntimeException extends RuntimeException {
+
+  //table name or alias
+  private String _tableName;
+
+  // column or expression name
+  private String _columnName;
+
+  private PinotRuntimeException(Throwable e) {
+    super(e);
+  }
+
+  public static PinotRuntimeException create(Throwable e) {
+    if (e instanceof PinotRuntimeException) {
+      return (PinotRuntimeException) e;
+    } else {
+      return new PinotRuntimeException(e);
+    }
+  }
+
+  public PinotRuntimeException withColumnName(String columnName) {
+    _columnName = columnName;
+    return this;
+  }
+
+  public PinotRuntimeException withTableName(String tableName) {
+    _tableName = tableName;
+    return this;
+  }
+
+  @Override
+  public String getMessage() {
+    StringBuilder message = new StringBuilder("Error when processing");
+    if (_tableName != null) {
+      message.append(" ").append(_tableName);
+    }
+    if (_columnName != null) {
+      if (_tableName != null) {
+        message.append(".");
+      } else {
+        message.append(" ");
+      }
+      message.append(_columnName);
+    }
+    message.append(": ");
+    message.append(super.getMessage());
+
+    return message.toString();

Review Comment:
   I'm open to suggestions. We've to keep in mind that table could actually mean alias and column - an expression - e.g. `max(x)` so it should be generic but still readable :).
   I guess we can add more useful bits of context data. 



-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Add table and column information to query errors [pinot]

Posted by "bziobrowski (via GitHub)" <gi...@apache.org>.
bziobrowski commented on code in PR #14388:
URL: https://github.com/apache/pinot/pull/14388#discussion_r1828978972


##########
pinot-core/src/main/java/org/apache/pinot/core/common/PinotRuntimeException.java:
##########
@@ -0,0 +1,73 @@
+/**
+ * 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.core.common;
+

Review Comment:
   This one's a just a simple exception that makes it possible to fetch important context information spread throught the stack.
   
   I'd be good to discuss how to integrate the approach with other exceptions and re-organize exceptions thrown by the engine. There are many more places that don't report conversion errors properly (e.g. plenty of parse calls for function arguments that won't report which argument they failed for).



-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Add table and column information to query errors [pinot]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #14388:
URL: https://github.com/apache/pinot/pull/14388#issuecomment-2456782984

   ## [Codecov](https://app.codecov.io/gh/apache/pinot/pull/14388?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   All modified and coverable lines are covered by tests :white_check_mark:
   > Project coverage is 0.00%. Comparing base [(`59551e4`)](https://app.codecov.io/gh/apache/pinot/commit/59551e45224f1535c4863fd577622b37366ccc97?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`19001a7`)](https://app.codecov.io/gh/apache/pinot/commit/19001a7117c903d2764a5ad7c3f5b2dcf9d1555c?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   > Report is 1287 commits behind head on master.
   
   > :exclamation:  There is a different number of reports uploaded between BASE (59551e4) and HEAD (19001a7). Click for more details.
   > 
   > <details><summary>HEAD has 48 uploads less than BASE</summary>
   >
   >| Flag | BASE (59551e4) | HEAD (19001a7) |
   >|------|------|------|
   >|integration|7|2|
   >|integration2|3|2|
   >|temurin|12|2|
   >|java-21|7|2|
   >|skip-bytebuffers-true|3|1|
   >|skip-bytebuffers-false|7|1|
   >|unittests|5|0|
   >|unittests1|2|0|
   >|java-11|5|0|
   >|unittests2|3|0|
   >|integration1|2|0|
   >|custom-integration1|2|0|
   ></details>
   
   <details><summary>Additional details and impacted files</summary>
   
   
   ```diff
   @@              Coverage Diff              @@
   ##             master   #14388       +/-   ##
   =============================================
   - Coverage     61.75%    0.00%   -61.76%     
   =============================================
     Files          2436        3     -2433     
     Lines        133233        6   -133227     
     Branches      20636        0    -20636     
   =============================================
   - Hits          82274        0    -82274     
   + Misses        44911        6    -44905     
   + Partials       6048        0     -6048     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/pinot/pull/14388/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [custom-integration1](https://app.codecov.io/gh/apache/pinot/pull/14388/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [integration](https://app.codecov.io/gh/apache/pinot/pull/14388/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `0.00% <ø> (-0.01%)` | :arrow_down: |
   | [integration1](https://app.codecov.io/gh/apache/pinot/pull/14388/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [integration2](https://app.codecov.io/gh/apache/pinot/pull/14388/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `0.00% <ø> (ø)` | |
   | [java-11](https://app.codecov.io/gh/apache/pinot/pull/14388/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [java-21](https://app.codecov.io/gh/apache/pinot/pull/14388/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `0.00% <ø> (-61.63%)` | :arrow_down: |
   | [skip-bytebuffers-false](https://app.codecov.io/gh/apache/pinot/pull/14388/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `0.00% <ø> (-61.75%)` | :arrow_down: |
   | [skip-bytebuffers-true](https://app.codecov.io/gh/apache/pinot/pull/14388/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `0.00% <ø> (-27.73%)` | :arrow_down: |
   | [temurin](https://app.codecov.io/gh/apache/pinot/pull/14388/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `0.00% <ø> (-61.76%)` | :arrow_down: |
   | [unittests](https://app.codecov.io/gh/apache/pinot/pull/14388/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [unittests1](https://app.codecov.io/gh/apache/pinot/pull/14388/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [unittests2](https://app.codecov.io/gh/apache/pinot/pull/14388/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/pinot/pull/14388?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   


-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Add table and column information to query errors [pinot]

Posted by "bziobrowski (via GitHub)" <gi...@apache.org>.
bziobrowski commented on code in PR #14388:
URL: https://github.com/apache/pinot/pull/14388#discussion_r1828978972


##########
pinot-core/src/main/java/org/apache/pinot/core/common/PinotRuntimeException.java:
##########
@@ -0,0 +1,73 @@
+/**
+ * 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.core.common;
+

Review Comment:
   I'd be good to discuss how to integrate the approach with other exceptions and re-organize exceptions thrown by the engine. There are many more places that don't report conversion errors properly (e.g. plenty of parse calls for function arguments that won't report which argument they failed for).



-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Add table and column information to query errors [pinot]

Posted by "yashmayya (via GitHub)" <gi...@apache.org>.
yashmayya commented on code in PR #14388:
URL: https://github.com/apache/pinot/pull/14388#discussion_r1829242951


##########
pinot-core/src/main/java/org/apache/pinot/core/operator/docvalsets/ProjectionBlockValSet.java:
##########
@@ -127,6 +128,9 @@ public float[] getFloatValuesSV() {
     try (InvocationScope scope = Tracing.getTracer().createScope(ProjectionBlockValSet.class)) {
       recordReadValues(scope, DataType.FLOAT, true);
       return _dataBlockCache.getFloatValuesForSVColumn(_column);
+    } catch (RuntimeException re) {
+      //add column information, then later enrich it with table name

Review Comment:
   > then later enrich it with table name
   
   I presume this means we don't have access to the table name information in this class currently?



##########
pinot-core/src/main/java/org/apache/pinot/core/operator/docvalsets/ProjectionBlockValSet.java:
##########
@@ -135,6 +139,9 @@ public double[] getDoubleValuesSV() {
     try (InvocationScope scope = Tracing.getTracer().createScope(ProjectionBlockValSet.class)) {
       recordReadValues(scope, DataType.DOUBLE, true);
       return _dataBlockCache.getDoubleValuesForSVColumn(_column);
+    } catch (RuntimeException re) {

Review Comment:
   Why is the error handling only added for float and double here?



##########
pinot-core/src/main/java/org/apache/pinot/core/operator/query/NonScanBasedAggregationOperator.java:
##########
@@ -153,26 +154,30 @@ protected AggregationResultsBlock getNextBlock() {
   private static Double getMinValue(DataSource dataSource) {
     Dictionary dictionary = dataSource.getDictionary();
     if (dictionary != null) {
-      return toDouble(dictionary.getMinVal());
+      return toDouble(dictionary.getMinVal(), dataSource);
     }
-    return toDouble(dataSource.getDataSourceMetadata().getMinValue());
+    return toDouble(dataSource.getDataSourceMetadata().getMinValue(), dataSource);
   }
 
   private static Double getMaxValue(DataSource dataSource) {
     Dictionary dictionary = dataSource.getDictionary();
     if (dictionary != null) {
-      return toDouble(dictionary.getMaxVal());
+      return toDouble(dictionary.getMaxVal(), dataSource);
     }
-    return toDouble(dataSource.getDataSourceMetadata().getMaxValue());
+    return toDouble(dataSource.getDataSourceMetadata().getMaxValue(), dataSource);
   }
 
-  private static Double toDouble(Comparable<?> value) {
-    if (value instanceof Double) {
-      return (Double) value;
-    } else if (value instanceof Number) {
-      return ((Number) value).doubleValue();
-    } else {
-      return Double.parseDouble(value.toString());
+  private static Double toDouble(Comparable<?> value, DataSource dataSource) {

Review Comment:
   We could just pass in the column name directly here I suppose?



##########
pinot-core/src/main/java/org/apache/pinot/core/common/PinotRuntimeException.java:
##########
@@ -0,0 +1,73 @@
+/**
+ * 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.core.common;
+
+/**
+ *  Simple runtime query exception containing useful contextual information, e.g. table or column name.
+ */
+public class PinotRuntimeException extends RuntimeException {
+
+  //table name or alias
+  private String _tableName;
+
+  // column or expression name
+  private String _columnName;
+
+  private PinotRuntimeException(Throwable e) {
+    super(e);
+  }
+
+  public static PinotRuntimeException create(Throwable e) {
+    if (e instanceof PinotRuntimeException) {
+      return (PinotRuntimeException) e;
+    } else {
+      return new PinotRuntimeException(e);
+    }
+  }
+
+  public PinotRuntimeException withColumnName(String columnName) {
+    _columnName = columnName;
+    return this;
+  }
+
+  public PinotRuntimeException withTableName(String tableName) {
+    _tableName = tableName;
+    return this;
+  }
+
+  @Override
+  public String getMessage() {
+    StringBuilder message = new StringBuilder("Error when processing");
+    if (_tableName != null) {
+      message.append(" ").append(_tableName);
+    }
+    if (_columnName != null) {
+      if (_tableName != null) {
+        message.append(".");
+      } else {
+        message.append(" ");
+      }
+      message.append(_columnName);
+    }
+    message.append(": ");
+    message.append(super.getMessage());
+
+    return message.toString();

Review Comment:
   Might be clearer to change this to something like `Error when processing column "abc" in table "xyz"`?



##########
pinot-core/src/main/java/org/apache/pinot/core/common/PinotRuntimeException.java:
##########
@@ -0,0 +1,73 @@
+/**
+ * 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.core.common;
+

Review Comment:
   I think this is a really nice improvement! IMO we could add similar custom runtime exceptions for different classes of processing errors as a subsequent enhancement. Although in that case it might be nice to name this class something more specific than `PinotRuntimeException`, WDYT?



-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Add table and column information to query errors [pinot]

Posted by "gortiz (via GitHub)" <gi...@apache.org>.
gortiz commented on code in PR #14388:
URL: https://github.com/apache/pinot/pull/14388#discussion_r1829241167


##########
pinot-core/src/main/java/org/apache/pinot/core/common/PinotRuntimeException.java:
##########
@@ -0,0 +1,73 @@
+/**
+ * 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.core.common;
+

Review Comment:
   I completely agree we need to have our own family of exceptions, but I think it will need more discussion.
   
   My initial suggestion is to reserve `PinotRuntimeException` name for a marker exception that extends `RuntimeException`, then add another for queries (something like `QueryException`) and then 
   
   
   ```mermaid
   ---
   config:
     look: handDrawn
     theme: neutral
   ---
   classDiagram
       RuntimeException
       note for RuntimeException "From JDK"
   
       PinotRuntimeException
       note for PinotRuntimeException "All new Pinot exceptions"
   
       QException
       note for QException "All new Pinot exceptions"
   
       QException <|-- ParsingQException
       QException <|-- OptimizationQException
   
       ExecutionQException
       note for ExecutionQException "Exceptions thrown by Operators"
   
       RuntimeException <|-- PinotRuntimeException
       PinotRuntimeException <|-- QException
       QException <|-- ExecutionQException
       ExecutionQException <|-- ColumnExecutionQException
       
       class ExecutionQException {
           +stage
       }
   
       class ColumnExecutionQException {
           +table
           +column
       }
       note for ColumnExecutionQException "Execution exception dealing with a column"
   ```



-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Add table and column information to query errors [pinot]

Posted by "bziobrowski (via GitHub)" <gi...@apache.org>.
bziobrowski commented on code in PR #14388:
URL: https://github.com/apache/pinot/pull/14388#discussion_r1828978972


##########
pinot-core/src/main/java/org/apache/pinot/core/common/PinotRuntimeException.java:
##########
@@ -0,0 +1,73 @@
+/**
+ * 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.core.common;
+

Review Comment:
   This one's a just a simple exception that makes it possible to fetch important context information spread throught the stack.
   
   I'd be good to discuss how to integrate the approach with other exceptions and re-organize exceptions thrown by the engine. There are many more places that don't report conversion errors properly (e.g. plenty of parse calls for function arguments that won't report which argument they failed for).
   
   @Jackie-Jiang  @gortiz @yashmayya @vrajat 



-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Add table and column information to query errors [pinot]

Posted by "bziobrowski (via GitHub)" <gi...@apache.org>.
bziobrowski commented on code in PR #14388:
URL: https://github.com/apache/pinot/pull/14388#discussion_r1829267773


##########
pinot-core/src/main/java/org/apache/pinot/core/operator/docvalsets/ProjectionBlockValSet.java:
##########
@@ -127,6 +128,9 @@ public float[] getFloatValuesSV() {
     try (InvocationScope scope = Tracing.getTracer().createScope(ProjectionBlockValSet.class)) {
       recordReadValues(scope, DataType.FLOAT, true);
       return _dataBlockCache.getFloatValuesForSVColumn(_column);
+    } catch (RuntimeException re) {
+      //add column information, then later enrich it with table name

Review Comment:
   I think table name was missing when I debugged some cases.
   Let me double check .



-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Add table and column information to query errors [pinot]

Posted by "vrajat (via GitHub)" <gi...@apache.org>.
vrajat commented on code in PR #14388:
URL: https://github.com/apache/pinot/pull/14388#discussion_r1830634421


##########
pinot-core/src/main/java/org/apache/pinot/core/common/DataBlockCache.java:
##########
@@ -129,7 +129,11 @@ public int[] getIntValuesForSVColumn(String column) {
         intValues = new int[_length];
         putValues(FieldSpec.DataType.INT, column, intValues);
       }
-      _dataFetcher.fetchIntValues(column, _docIds, _length, intValues);
+      try {

Review Comment:
   This is a nit: Have you considered adding the catch block in https://github.com/apache/pinot/blob/969bbf00d4ab0a421beaf75fdad9b189997f0e59/pinot-core/src/main/java/org/apache/pinot/core/operator/docvalsets/ProjectionBlockValSet.java#L110-L110 instead since there is a try block already ? 
   
   



##########
pinot-core/src/main/java/org/apache/pinot/core/operator/combine/BaseCombineOperator.java:
##########
@@ -122,12 +123,13 @@ public void runJob() {
             // NOTE: We need to handle Error here, or the execution threads will die without adding the execution
             //       exception into the query response, and the main thread might wait infinitely (until timeout) or
             //       throw unexpected exceptions (such as NPE).
+            PinotRuntimeException pe = PinotRuntimeException.create(t).withTableName(_queryContext.getTableName());

Review Comment:
   One issue is that other types of exceptions like NPE may get missed when looking at stack traces. I know that the NPE will still appear in the stack trace etc. However as on-call our senses are trained to certain exception types in the top message. Is there an example of how the error looks like ? Maybe you can simulate by forcibly throwing an NPE ? 



##########
pinot-core/src/main/java/org/apache/pinot/core/operator/docvalsets/FilteredRowBasedBlockValSet.java:
##########
@@ -131,16 +139,20 @@ public long[] getLongValuesSV() {
       return values;
     }
     PeekableIntIterator iterator = _matchedBitmap.getIntIterator();
-    for (int matchedRowId = 0; matchedRowId < _numMatchedRows; matchedRowId++) {
-      int rowId = iterator.next();
-      if (_matchedNullBitmap != null && _matchedNullBitmap.contains(matchedRowId)) {
-        continue;
-      }
-      if (_storedType.isNumeric()) {
-        values[matchedRowId] = ((Number) _rows.get(rowId)[_colId]).longValue();
-      } else {
-        values[matchedRowId] = Long.parseLong((String) _rows.get(rowId)[_colId]);
+    try {

Review Comment:
   I cant comment at the right line no. In line 136, column names maybe useful in Precondition checks as well. I dont know how often they are triggered though. 



-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org