-
Notifications
You must be signed in to change notification settings - Fork 1.6k
GH-3696: Cache ParsedVersion in FileMetaData and use it in fromParquetMetadata #3700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
bc23cf5
51ca7b7
b6a87de
6973b84
8ac10c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,37 +70,67 @@ public static boolean shouldIgnoreStatistics(String createdBy, PrimitiveTypeName | |
|
|
||
| try { | ||
| ParsedVersion version = VersionParser.parse(createdBy); | ||
| return shouldIgnoreStatistics(version, createdBy, columnType); | ||
| } catch (RuntimeException | VersionParseException e) { | ||
| // couldn't parse the created_by field, log what went wrong, don't trust the | ||
| // stats, but don't make this fatal. | ||
| warnParseErrorOnce(createdBy, e); | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| if (!"parquet-mr".equals(version.application)) { | ||
| // assume other applications don't have this bug | ||
| return false; | ||
| } | ||
| /** | ||
| * Decides if the statistics from a file should be ignored because they are potentially corrupt. | ||
| * Use this when the writer version has already been parsed to avoid redundant parsing. | ||
| * | ||
| * @param writerVersion the pre-parsed writer version, or {@code null} if unknown/unparseable | ||
| * @param createdBy the original created-by string from the file footer (used for logging) | ||
| * @param columnType the type of the column that this is checking | ||
| * @return true if the statistics may be invalid and should be ignored, false otherwise | ||
| */ | ||
| public static boolean shouldIgnoreStatistics( | ||
| ParsedVersion writerVersion, String createdBy, PrimitiveTypeName columnType) { | ||
|
|
||
| if (Strings.isNullOrEmpty(version.version)) { | ||
| warnOnce("Ignoring statistics because created_by did not contain a semver (see PARQUET-251): " | ||
| + createdBy); | ||
| return true; | ||
| } | ||
| if (columnType != PrimitiveTypeName.BINARY && columnType != PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY) { | ||
| return false; | ||
| } | ||
|
|
||
| if (writerVersion == null) { | ||
| warnOnce("Ignoring statistics because created_by is null or empty! See PARQUET-251 and PARQUET-297"); | ||
| return true; | ||
| } | ||
|
|
||
| SemanticVersion semver = SemanticVersion.parse(version.version); | ||
| if (!"parquet-mr".equals(writerVersion.application)) { | ||
| return false; | ||
| } | ||
|
|
||
| if (Strings.isNullOrEmpty(writerVersion.version)) { | ||
| warnOnce("Ignoring statistics because created_by did not contain a semver (see PARQUET-251): " + createdBy); | ||
| return true; | ||
| } | ||
|
|
||
| if (semver.compareTo(PARQUET_251_FIXED_VERSION) < 0 | ||
| && !(semver.compareTo(CDH_5_PARQUET_251_FIXED_START) >= 0 | ||
| && semver.compareTo(CDH_5_PARQUET_251_FIXED_END) < 0)) { | ||
| warnOnce("Ignoring statistics because this file was created prior to " | ||
| + PARQUET_251_FIXED_VERSION | ||
| + ", see PARQUET-251"); | ||
| return true; | ||
| if (!writerVersion.hasSemanticVersion()) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| try { | ||
| SemanticVersion.parse(writerVersion.version); | ||
| } catch (SemanticVersionParseException e) { | ||
| warnParseErrorOnce(createdBy, e); | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| // this file was created after the fix | ||
| return false; | ||
| } catch (RuntimeException | SemanticVersionParseException | VersionParseException e) { | ||
| // couldn't parse the created_by field, log what went wrong, don't trust the stats, | ||
| // but don't make this fatal. | ||
| warnParseErrorOnce(createdBy, e); | ||
| SemanticVersion semver = writerVersion.getSemanticVersion(); | ||
|
Comment on lines
+112
to
+121
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| if (semver.compareTo(PARQUET_251_FIXED_VERSION) < 0 | ||
| && !(semver.compareTo(CDH_5_PARQUET_251_FIXED_START) >= 0 | ||
| && semver.compareTo(CDH_5_PARQUET_251_FIXED_END) < 0)) { | ||
| warnOnce("Ignoring statistics because this file was created prior to " | ||
| + PARQUET_251_FIXED_VERSION | ||
| + ", see PARQUET-251"); | ||
| return true; | ||
| } | ||
|
|
||
| // this file was created after the fix | ||
| return false; | ||
| } | ||
|
|
||
| private static void warnParseErrorOnce(String createdBy, Throwable e) { | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep the original comment.