Skip to content

Commit f49635d

Browse files
committed
Compare parquet-mr version with SemanticVersion in ValidInt96Stats
String.compareTo is lexicographic: "1.15.1".compareTo("1.16.0") returns -1, which incorrectly rejected parquet-mr 1.15.1 (caught by testParquetMrValid) and also accepted hypothetical pre-1.15 versions like 1.5.0 (since '5' > '1' at position 2). Use SemanticVersion compareTo with a 1.15.0 lower bound; strict > so 1.15.0 itself stays invalid, matching testParquetMrInvalid.
1 parent ad7c4ec commit f49635d

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

parquet-column/src/main/java/org/apache/parquet/ValidInt96Stats.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ public class ValidInt96Stats {
3434

3535
private static final Logger LOG = LoggerFactory.getLogger(ValidInt96Stats.class);
3636

37+
// parquet-mr started emitting correct INT96 min/max statistics after 1.15.0,
38+
// so only releases strictly greater than 1.15.0 are trusted.
39+
private static final SemanticVersion MINIMUM_PARQUET_MR_VERSION = new SemanticVersion(1, 15, 0);
40+
3741
/**
3842
* Decides if the statistics from a file created by createdBy (the created_by field from parquet format)
3943
* should be trusted for INT96 columns.
@@ -50,7 +54,8 @@ public static boolean hasValidInt96Stats(String createdBy) {
5054
try {
5155
ParsedVersion version = VersionParser.parse(createdBy);
5256
if ("parquet-mr".equals(version.application)) {
53-
return version.version != null && version.version.compareTo("1.16.0") > 0;
57+
return version.hasSemanticVersion()
58+
&& version.getSemanticVersion().compareTo(MINIMUM_PARQUET_MR_VERSION) > 0;
5459
}
5560
if ("parquet-mr compatible Photon".equals(version.application)) {
5661
return true;

0 commit comments

Comments
 (0)