-
Notifications
You must be signed in to change notification settings - Fork 0
2760: docs: Add documentation for supported casts with complex types #16
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: main
Are you sure you want to change the base?
Conversation
WalkthroughAdds documentation section for Complex Type Casting under Unsupported Casts, covering support rules for casting complex types including arrays, structs, and maps with nested structures, recursive validation semantics, and example CAST expressions. Changes
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR Review: Documentation for Supported Casts with Complex TypesThank you for adding this documentation! This is a valuable addition to the compatibility guide. Here's my detailed review: ✅ Strengths
🔍 Issues & Recommendations1. Missing Struct Field Count Validation in DocumentationIssue: The documentation states that struct-to-struct casts require "the same number of fields," but I don't see this validation in the implementation at case (from_struct: StructType, to_struct: StructType) =>
from_struct.fields.zip(to_struct.fields).foreach { case (a, b) =>
isSupported(a.dataType, b.dataType, timeZoneId, evalMode) match {
case Compatible(_) =>
// all good
case other =>
return other
}
}
Compatible()Problem: The
Recommendation: Either:
2. Missing Array-to-Array Cast DocumentationIssue: The documentation mentions "Array to Array" casting (
Recommendation: Add test coverage for array-to-array casts: test("cast ArrayType to ArrayType") {
// Test: CAST(array(1, 2, 3) AS ARRAY<BIGINT>)
// Test: CAST(array(1.0, 2.0) AS ARRAY<STRING>)
// Test nested arrays: CAST(array(array(1, 2)) AS ARRAY<ARRAY<BIGINT>>)
}3. Technical Accuracy: Struct Cast CompatibilityCurrent Implementation (
Documentation Claim:
Verdict: ✅ Accurate - The implementation matches the documentation. 4. Documentation Formatting & ClaritySuggested Improvements:
🧪 Test Coverage AssessmentCurrent State:
Recommendation: Before merging this documentation, add basic array-to-array cast tests to ensure the documented behavior is actually implemented and correct. 🔒 Security & Performance
📋 Action ItemsBefore merging:
Nice to have:
🎯 Overall AssessmentThis is a valuable documentation addition that improves user understanding of complex type casting. The main concerns are:
Once these are addressed, this PR will be ready to merge. Rating: 7/10 (would be 9/10 with the suggested fixes) Review conducted by Claude Code - generated based on code analysis and best practices |
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.
Review completed. 1 suggestions posted.
Comment augment review to trigger a new review at any time.
|
|
||
| - **Array to Array**: Arrays can be cast to other array types if the element types are compatible. | ||
| - Recursively validates that the source element type can be cast to the target element type | ||
| - Example: `CAST(array(1, 2, 3) AS ARRAY<BIGINT>)` → `array(1L, 2L, 3L)` |
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.
“NullType elements (empty arrays)” is misleading: Comet treats any Array (including arrays of nulls, not just empty arrays) as castable to any array type; consider clarifying the parenthetical.
🤖 Was this useful? React with 👍 or 👎
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.
value:good-to-have; category:documentation; feedback:The Augment AI reviewer is correct that "empty arrays" here is not correct. The array is not empty but it is full with NullType elements only
value:useful; category:documentation; feedback:The Claude AI reviewer is correct that the implementation does not match the documentation. The implementation is not that strict about the same length of the struct fields. The finding prevents confusion in the reader |
value:useful; category:documentation; feedback:The Claude AI reviewer is correct that there are no tests validating the claim that the cast from ArrayType to ArrayType is actually supported. https://github.com/apache/datafusion-comet/blob/e77998ad2228b758d0a93588c57325e56bda83bc/spark/src/main/scala/org/apache/comet/expressions/CometCast.scala#L118-L124 shows that it is supposed to work but having tests will make sure there are no regressions. |
2760: To review by AI