| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -19,7 +19,6 @@ | |
| package org.apache.parquet; | ||
|
|
||
| import java.util.concurrent.atomic.AtomicBoolean; | ||
| import org.apache.parquet.SemanticVersion.SemanticVersionParseException; | ||
| import org.apache.parquet.VersionParser.ParsedVersion; | ||
| import org.apache.parquet.VersionParser.VersionParseException; | ||
| import org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName; | ||
| Expand Down Expand Up | @@ -70,37 +69,63 @@ 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; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * 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 (!"parquet-mr".equals(version.application)) { | ||
| // assume other applications don't have this bug | ||
| return false; | ||
| } | ||
|
|
||
| if (Strings.isNullOrEmpty(version.version)) { | ||
| warnOnce("Ignoring statistics because created_by did not contain a semver (see PARQUET-251): " | ||
| + createdBy); | ||
| return true; | ||
| } | ||
|
|
||
| SemanticVersion semver = SemanticVersion.parse(version.version); | ||
|
|
||
| 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 | ||
| if (columnType != PrimitiveTypeName.BINARY && columnType != PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY) { | ||
| 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); | ||
| } | ||
|
|
||
| if (writerVersion == null) { | ||
| warnOnce("Ignoring statistics because created_by is null or empty! See PARQUET-251 and PARQUET-297"); | ||
| return true; | ||
| } | ||
|
|
||
| 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 (!writerVersion.hasSemanticVersion()) { | ||
|
Comment thread
Copy link
Copy Markdown
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityParsedVersion has already swallowed SemanticVersionParseException here, so this no longer preserves the old warnParseErrorOnce(createdBy, e) behavior. Could we keep the original string and parse exception for this path?
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualitycreatedBy string is now passed as a parameter, and the !hasSemanticVersion() branch re-parses writerVersion.version to recreate the SemanticVersionParseException for warnParseErrorOnce(createdBy, e). This gives exact log parity (original string + stack trace). The re-parse only fires when the ParsedVersion fails to parse it, so zero performance impact on the hot path.
Sorry, something went wrong.
All reactions
|
||
| warnParseErrorOnce(createdBy, writerVersion.getSemanticVersionParseFailure()); | ||
| return true; | ||
| } | ||
|
|
||
| SemanticVersion semver = writerVersion.getSemanticVersion(); | ||
|
Comment thread
Comment on lines
+111
to
+116
Copy link
Copy Markdown
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityParsedVersion eagerly parses and caches the SemanticVersion in its constructor, so getSemanticVersion() avoids the redundant SemanticVersion.parse(version.version) that the String-based overload previously performed on every call. The left and right spikes in flame graph are for parsing SemanticVersion twice.
Sorry, something went wrong.
All reactions
|
||
|
|
||
| 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) { | ||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityLet's keep the original comment.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.