Github user paul-rogers commented on a diff in the pull request: https://github.com/apache/drill/pull/877#discussion_r128683724 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/Metadata.java --- @@ -132,23 +135,57 @@ 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, Path path, MetadataContext metaContext, ParquetFormatConfig formatConfig) throws IOException { - Metadata metadata = new Metadata(fs, formatConfig); - metadata.readBlockMeta(path, false, metaContext); - return metadata.parquetTableMetadata; + public static @Nullable ParquetTableMetadataBase readBlockMeta(FileSystem fs, Path path, MetadataContext metaContext, + ParquetFormatConfig formatConfig) { + if (metaContext.isMetaCacheFileCorrect) { + Metadata metadata = new Metadata(fs, formatConfig); + try { + metadata.readBlockMeta(path, false, metaContext); + return metadata.parquetTableMetadata; + } catch (IOException e) { + logger.error(e.toString()); + metaContext.isMetaCacheFileCorrect = false; + } + } + logger.warn("Ignoring unsupported or corrupted metadata file version. Query performance may be slow. Make sure " + + "the cache file is up-to-date by running the REFRESH TABLE METADATA command"); + return null; } - public static ParquetTableMetadataDirs readMetadataDirs(FileSystem fs, Path path, MetadataContext metaContext, ParquetFormatConfig formatConfig) throws IOException { - Metadata metadata = new Metadata(fs, formatConfig); - metadata.readBlockMeta(path, true, metaContext); - return metadata.parquetTableMetadataDirs; + /** + * 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 (metaContext.isMetaDirsCacheFileCorrect) { + Metadata metadata = new Metadata(fs, formatConfig); + try { + metadata.readBlockMeta(path, true, metaContext); + return metadata.parquetTableMetadataDirs; + } catch (IOException e) { + logger.error(e.toString()); + metaContext.isMetaDirsCacheFileCorrect = false; + } + } + logger.warn("Ignoring corrupted metadata file. Query performance may be slow. Make sure the cache file" + --- End diff -- Maybe move the message to constant so it does not have to be maintained in two places? And, maybe add the file or directory that is corrupt?
--- 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. ---