Document null binary operator semantics explicitly - #23604
Conversation
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cpp/include/cudf/ast/ast_operator.hpp`:
- Around line 39-40: Update every NOT_EQUAL enum entry to explicitly document
that it returns NULL when either operand is NULL, otherwise returns whether the
operands are unequal: cpp/include/cudf/ast/ast_operator.hpp lines 39-40,
java/src/main/java/ai/rapids/cudf/ast/BinaryOperator.java lines 25-28, and
java/src/main/java/ai/rapids/cudf/BinaryOp.java lines 36-37. Keep the existing
NULL_EQUAL documentation unchanged.
In `@cpp/include/cudf/binaryop.hpp`:
- Around line 73-88: Update the shared output-validity documentation for all
three binary_operation overloads to match the null-aware operator semantics:
NULL_EQUALS and NULL_NOT_EQUALS always produce valid results, while
NULL_LOGICAL_AND and NULL_LOGICAL_OR produce valid results for decisive
false/true cases respectively and null otherwise. Preserve the existing
logical-AND validity rule for other operators and the NULL_MIN/NULL_MAX
exceptions.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: fa155177-3442-4bb5-b326-a327e7f75bd3
📒 Files selected for processing (4)
cpp/include/cudf/ast/ast_operator.hppcpp/include/cudf/binaryop.hppjava/src/main/java/ai/rapids/cudf/BinaryOp.javajava/src/main/java/ai/rapids/cudf/ast/BinaryOperator.java
87621eb to
a612eae
Compare
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe change updates C++ and Java documentation for binary operator null handling and three-valued logic. Enum values, identifiers, API declarations, and runtime behavior remain unchanged. ChangesOperator semantics documentation
Estimated code review effort: 1 (Trivial) | ~4 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Comment |
The null-aware binary operators deferred to "Spark rules for null inputs", requiring the reader to already know what those are. Describe the behavior explicitly instead. Spell out the null-propagating behavior of the plain EQUAL, NOT_EQUAL, LOGICAL_AND, and LOGICAL_OR operators. Keep the wording consistent across the codebase (C++ and Java).
a612eae to
55f7341
Compare
| NULL_LOGICAL_AND(32), // three-valued (Kleene) &&: if any operand is false, returns false; if both | ||
| // operands are true, returns true; otherwise returns null | ||
| NULL_LOGICAL_OR(33); // three-valued (Kleene) ||: if any operand is true, returns true; if both | ||
| // operands are false, returns false; otherwise returns null |
There was a problem hiding this comment.
As a follow-up I think we could replace ordinary code comments with javadoc / markdown comments.
Description
The null-aware binary operators deferred to "Spark rules for null inputs", requiring the reader to already know what those are. Describe the behavior explicitly instead. Spell out the null-propagating behavior of the plain EQUAL, NOT_EQUAL, LOGICAL_AND, and LOGICAL_OR operators. Keep the wording consistent across the codebase (C++ and Java).
Checklist