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: [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]