Jackie-Jiang commented on code in PR #12763: URL: https://github.com/apache/pinot/pull/12763#discussion_r1589727439
########## pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/loader/defaultcolumn/BaseDefaultColumnHandler.java: ########## @@ -582,20 +582,39 @@ private void createDerivedColumnV1Indices(String column, FunctionEvaluator funct int numDocs = _segmentMetadata.getTotalDocs(); Object[] outputValues = new Object[numDocs]; PinotDataType outputValueType = null; + int loggedErrorCount = 0; + long lastLoggedTime = System.currentTimeMillis(); + + FieldSpec fieldSpec = _schema.getFieldSpecFor(column); + Object defaultNullValue = fieldSpec.getDefaultNullValue(); for (int i = 0; i < numDocs; i++) { for (int j = 0; j < numArguments; j++) { inputValues[j] = valueReaders.get(j).getValue(i); } - Object outputValue = functionEvaluator.evaluate(inputValues); - outputValues[i] = outputValue; + try { + Object outputValue = functionEvaluator.evaluate(inputValues); + outputValues[i] = outputValue; + } catch (Exception e) { + if (!errorOnFailure) { + // Try to not flush the logger, sample every 1000 errors or 10 seconds Review Comment: We can consider only log one line after processing all the values for the column ########## pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/loader/defaultcolumn/BaseDefaultColumnHandler.java: ########## @@ -582,20 +582,39 @@ private void createDerivedColumnV1Indices(String column, FunctionEvaluator funct int numDocs = _segmentMetadata.getTotalDocs(); Object[] outputValues = new Object[numDocs]; PinotDataType outputValueType = null; + int loggedErrorCount = 0; + long lastLoggedTime = System.currentTimeMillis(); + + FieldSpec fieldSpec = _schema.getFieldSpecFor(column); + Object defaultNullValue = fieldSpec.getDefaultNullValue(); for (int i = 0; i < numDocs; i++) { for (int j = 0; j < numArguments; j++) { inputValues[j] = valueReaders.get(j).getValue(i); } - Object outputValue = functionEvaluator.evaluate(inputValues); - outputValues[i] = outputValue; + try { + Object outputValue = functionEvaluator.evaluate(inputValues); + outputValues[i] = outputValue; + } catch (Exception e) { + if (!errorOnFailure) { + // Try to not flush the logger, sample every 1000 errors or 10 seconds + if (loggedErrorCount++ % 10000 == 0 || System.currentTimeMillis() - lastLoggedTime > 10000) { + LOGGER.warn("Caught exception while evaluating derived column: {} with function: {} and arguments: {}", + column, functionEvaluator, inputValues, e); + lastLoggedTime = System.currentTimeMillis(); + } + outputValues[i] = defaultNullValue; + } else { + throw e; + } + } + if (outputValueType == null) { - Class<?> outputValueClass = outputValue.getClass(); + Class<?> outputValueClass = outputValues[i].getClass(); Review Comment: This can cause problem when the value is default. We need to skip the type casting for default values. -- 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-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org