-
Notifications
You must be signed in to change notification settings - Fork 166
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
chore: make Cast's logic reusable for other projects #716
Conversation
Spark-compatible "Cast" is implemented as a physical expr in Comet, but other downstream projects might like to use it as a logical expr. To facilitate it, this makes the core logic invokable through pub fn spark_cast_array.
native/spark-expr/src/lib.rs
Outdated
@@ -24,7 +24,7 @@ mod temporal; | |||
pub mod timezone; | |||
pub mod utils; | |||
|
|||
pub use cast::Cast; | |||
pub use cast::{Cast, spark_cast_array}; |
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.
the export is not needed by comet, but it allows others (eg. us) to use spark_cast_array directly
native/spark-expr/src/cast.rs
Outdated
} | ||
}; | ||
Ok(spark_cast(cast_result?, from_type, to_type)) | ||
pub fn spark_cast_array( |
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.
If we are making this public, we should add some documentation. I think there is a clippy lint that we should turn on to make sure all pub items have rustdocs.
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.
added some in eaf224d! Though not sure what exactly would be useful here, lmk if you had anything specifc in mind :)
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #716 +/- ##
=============================================
- Coverage 53.66% 33.63% -20.04%
- Complexity 810 827 +17
=============================================
Files 107 110 +3
Lines 10265 42557 +32292
Branches 1930 9358 +7428
=============================================
+ Hits 5509 14312 +8803
- Misses 3781 25291 +21510
- Partials 975 2954 +1979 ☔ View full report in Codecov by Sentry. |
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.
LGTM. Thanks @Blizzara
(cherry picked from commit 8482150)
Which issue does this PR close?
N/A
Rationale for this change
Spark-compatible "Cast" is implemented as a physical expr in Comet, but other downstream projects might like to use it as a logical expr. To facilitate it, this makes the core logic invokable through
pub fn spark_cast
.What changes are included in this PR?
Makes some
Cast
struct's functions static, and moves those plus a bunch existing of static functions out of Cast impl.Moves ColumnarValue handling logic out of Cast::evaluate into
spark_cast
, and makes that public.Exports
spark_cast
from spark-expr/libRecommend reviewing with "Hide whitespace" ON.
How are these changes tested?
Existing tests