You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2020/08/29 02:29:04 UTC

[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #5910: 5804: Prints file name of invalid json file when parsing

Jackie-Jiang commented on a change in pull request #5910:
URL: https://github.com/apache/incubator-pinot/pull/5910#discussion_r479596007



##########
File path: pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/CreateSegmentCommand.java
##########
@@ -252,7 +252,8 @@ public boolean execute()
             if (j < _retry) {
               LOGGER.warn("Caught exception while creating/verifying segment, will retry", e);
             } else {
-              throw e;
+              final String exceptionMessage = String.format("%s. File: %s", e.getMessage(), dataFiles.get(sequenceId));
+              throw new Exception(exceptionMessage, e);

Review comment:
       ```suggestion
                 throw new RuntimeException("Caught exception while generating segment from file: " + dataFiles.get(sequenceId), e);
   ```

##########
File path: pinot-tools/src/test/java/org/apache/pinot/tools/TestCreateSegmentCommand.java
##########
@@ -0,0 +1,64 @@
+/**
+ * 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.tools;
+
+import com.google.common.base.Preconditions;
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import org.apache.pinot.spi.config.table.TableConfig;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.data.Schema;
+import org.apache.pinot.spi.data.readers.FileFormat;
+import org.apache.pinot.spi.utils.builder.TableConfigBuilder;
+import org.apache.pinot.tools.admin.command.CreateSegmentCommand;
+import org.testng.annotations.Test;
+
+
+public class TestCreateSegmentCommand {
+  private static final File JSON_INVALID_SAMPLE_DATA_FILE = new File(Preconditions
+      .checkNotNull(TestCreateSegmentCommand.class.getClassLoader().getResource("test_data/test_invalid_data.json"))
+      .getFile());
+
+  private static CreateSegmentCommand _createSegmentCommand = new CreateSegmentCommand();
+
+  @Test(
+    expectedExceptions = Exception.class,
+    expectedExceptionsMessageRegExp = "^.*test_invalid_data.json.*$"
+  )
+  public void testReadingInvalidJsonFile()
+      throws Exception {
+    final String fileDirectoryPath = JSON_INVALID_SAMPLE_DATA_FILE.getParent();

Review comment:
       (nit) We don't usually put `final` for local variables




----------------------------------------------------------------
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.

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