Repository navigation
GH-53500: [Python][Parquet] Prevent crashes when comparing metadata with None - #55168
Open
nleerollergh wants to merge 1 commit into
Open
nleerollergh wants to merge 1 commit into
nleerollergh wants to merge 1 commit into
Conversation
…data with None Require non-null typed arguments in Statistics, ColumnChunkMetaData, RowGroupMetaData, ParquetSchema and ColumnSchema equals(), following the existing FileMetaData.equals() pattern, and add a regression test. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Author
Author
|
Why the call crashes In Cython, a parameter declared as Statistics other is checked to be a Statistics instance, but Why With |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Rationale for this change
Five Parquet metadata/schema
equals()wrappers (Statistics,ColumnChunkMetaData,RowGroupMetaData,ParquetSchema,ColumnSchema) acceptNonefor their typedotherargument and then dereference a native pointer on it, which can crash the interpreter. This follows the existingFileMetaData.equals()pattern, which already declaresother not None.What changes are included in this PR?
equals()methods.__eq__already catches the resultingTypeErrorand returnsNotImplemented, soobj == NoneisFalseandobj != NoneisTrue.==,!=and direct.equals(None)for all five wrappers.Are these changes tested?
Yes. I added a regression test and ran it locally: it passes with the fix and segfaults without it (details in the comment below).
flake8andcython-lintpass on the changed files.See comment for detailed testing evidence.
Are there any user-facing changes?
obj.equals(None)now raisesTypeErrorinstead of risking a crash.obj == NonereturnsFalse.This PR contains a "Critical Fix". It fixes a bug that causes a crash (category c): calling
equals(None), or comparing with==/!=againstNone, onStatistics,ColumnChunkMetaData,RowGroupMetaData,ParquetSchemaorColumnSchemacould dereference a null native pointer and crash the Python interpreter instead of raising an error.Was AI used for this PR?
Yes, I wrote the initial implementation (the
not Nonechange to the fiveequals()methods, following the existingFileMetaData.equals()pattern) and a first version of the regression test. I then used AI (Claude Code) to review and refine it before then structuring the commit message. The AI completed the test (added the!=and.equals(None)TypeErrorassertions and renamed a variable that shadowed a builtin) and drafted this PR description.PR code and description written by:
Reviewed before submission by: