Github user vdiravka commented on a diff in the pull request:

    https://github.com/apache/drill/pull/877#discussion_r129545316
  
    --- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/Metadata.java 
---
    @@ -132,25 +134,64 @@ public static ParquetTableMetadata_v3 
getParquetTableMetadata(FileSystem fs,
       }
     
       /**
    -   * Get the parquet metadata for a directory by reading the metadata file
    +   * Get the parquet metadata for the table by reading the metadata file
        *
    -   * @param fs
    +   * @param fs current file system
        * @param path The path to the metadata file, located in the directory 
that contains the parquet files
    -   * @return
    -   * @throws IOException
    +   * @param metaContext metadata context
    +   * @param formatConfig parquet format plugin configs
    +   * @return parquet table metadata
    +   * @throws IOException if metadata file can't be read or updated
        */
    -  public static ParquetTableMetadataBase readBlockMeta(FileSystem fs, 
String path, MetadataContext metaContext, ParquetFormatConfig formatConfig) 
throws IOException {
    +  public static @Nullable ParquetTableMetadataBase 
readBlockMeta(FileSystem fs, Path path, MetadataContext metaContext,
    +      ParquetFormatConfig formatConfig) {
    +    if (isMetadataFilesCorrupted(metaContext, path)) {
    +      return null;
    +    }
         Metadata metadata = new Metadata(fs, formatConfig);
         metadata.readBlockMeta(path, false, metaContext);
         return metadata.parquetTableMetadata;
       }
     
    -  public static ParquetTableMetadataDirs readMetadataDirs(FileSystem fs, 
String path, MetadataContext metaContext, ParquetFormatConfig formatConfig) 
throws IOException {
    +  /**
    +   * Get the parquet metadata for all subdirectories by reading the 
metadata file
    +   *
    +   * @param fs current file system
    +   * @param path The path to the metadata file, located in the directory 
that contains the parquet files
    +   * @param metaContext metadata context
    +   * @param formatConfig parquet format plugin configs
    +   * @return parquet metadata for a directory
    +   * @throws IOException if metadata file can't be read or updated
    +   */
    +  public static @Nullable ParquetTableMetadataDirs 
readMetadataDirs(FileSystem fs, Path path,
    +      MetadataContext metaContext, ParquetFormatConfig formatConfig) {
    +    if (isMetadataFilesCorrupted(metaContext, path)) {
    +      return null;
    +    }
         Metadata metadata = new Metadata(fs, formatConfig);
         metadata.readBlockMeta(path, true, metaContext);
         return metadata.parquetTableMetadataDirs;
       }
     
    +  /**
    +   * Checking whether metadata is corrupted
    +   *
    +   * @param metaContext metadata context
    +   * @param path The path to the metadata file, located in the directory 
that contains the parquet files
    +   * @return true if parquet metadata is corrupted, false otherwise
    +   */
    +  private static boolean isMetadataFilesCorrupted(MetadataContext 
metaContext, Path path) {
    --- End diff --
    
    Agree. Done


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to