Skip to content
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

Merged
merged 2 commits into from
Jul 27, 2024

Conversation

Blizzara
Copy link
Contributor

@Blizzara Blizzara commented Jul 24, 2024

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/lib

Recommend reviewing with "Hide whitespace" ON.

How are these changes tested?

Existing tests

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.
@@ -24,7 +24,7 @@ mod temporal;
pub mod timezone;
pub mod utils;

pub use cast::Cast;
pub use cast::{Cast, spark_cast_array};
Copy link
Contributor Author

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

@Blizzara Blizzara marked this pull request as ready for review July 24, 2024 17:11
}
};
Ok(spark_cast(cast_result?, from_type, to_type))
pub fn spark_cast_array(
Copy link
Member

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.

Copy link
Contributor Author

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-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 33.63%. Comparing base (c1b7c7d) to head (4245a9c).
Report is 2 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

Copy link
Member

@andygrove andygrove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @Blizzara

@andygrove andygrove merged commit 8482150 into apache:main Jul 27, 2024
75 checks passed
@Blizzara Blizzara deleted the avo/make-cast-reusable branch July 28, 2024 10:14
himadripal pushed a commit to himadripal/datafusion-comet that referenced this pull request Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants