ege-st commented on code in PR #12151: URL: https://github.com/apache/pinot/pull/12151#discussion_r1428227636
########## pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/SegmentColumnarIndexCreator.java: ########## @@ -315,11 +316,14 @@ public void indexRow(GenericRow row) FieldSpec fieldSpec = _schema.getFieldSpecFor(columnName); SegmentDictionaryCreator dictionaryCreator = _dictionaryCreatorMap.get(columnName); - - if (fieldSpec.isSingleValueField()) { - indexSingleValueRow(dictionaryCreator, columnValueToIndex, creatorsByIndex); - } else { - indexMultiValueRow(dictionaryCreator, (Object[]) columnValueToIndex, creatorsByIndex); + try { + if (fieldSpec.isSingleValueField()) { + indexSingleValueRow(dictionaryCreator, columnValueToIndex, creatorsByIndex); + } else { + indexMultiValueRow(dictionaryCreator, (Object[]) columnValueToIndex, creatorsByIndex); + } + } catch (JsonParseException jpe) { Review Comment: That makes sense, this seems like the best place to put the exception without doing some major refactoring. ########## pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/ColumnJsonParserException.java: ########## @@ -0,0 +1,55 @@ +/** + * 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.segment.local.segment.creator.impl; + +import com.fasterxml.jackson.core.JsonLocation; +import com.fasterxml.jackson.core.JsonParseException; + +public class ColumnJsonParserException extends JsonParseException { + /** + * Exception type for parsing problems when + * processing JSON content in a column + * Sub-class of {@link com.fasterxml.jackson.core.JsonParseException}. + */ + + final String _columnName; + + protected ColumnJsonParserException(String columnName, JsonParseException jpe) { + super(jpe.getProcessor(), jpe.getOriginalMessage(), jpe.getCause()); + _columnName = columnName; + } + + /** + * Default method overridden so that we can add column and location information + */ + @Override + public String getMessage() { + StringBuilder sb = new StringBuilder(); + sb.append("Column: "); + sb.append(_columnName); + sb.append("\n"); + sb.append(super.getMessage()); Review Comment: I believe the Java compiler will automatically using StringBuilder when concatenating strings, so you can have this as `"Column: " + _columnName + "\n" + super.getMessage()` and the compiler will create the StringBuilder code for you. (Actually, from some reading the Compiler will pick between StringBuilder and StringBuffer based upon which is more optimized for the situation). Though, I'm curious: why not use `String.format("Column: %s\n%s", _columnName, super.getMessage())`? -- 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