Skip to content

Conversation

cfmcgrady
Copy link
Contributor

@cfmcgrady cfmcgrady commented Sep 19, 2025

Which issue does this PR close?

Closes #2410 .

Rationale for this change

What changes are included in this PR?

Implement array-to-string cast support

How are these changes tested?

Added UTs

@codecov-commenter
Copy link

codecov-commenter commented Sep 19, 2025

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 22.14%. Comparing base (f09f8af) to head (ad1cdc8).
⚠️ Report is 596 commits behind head on main.

Files with missing lines Patch % Lines
...scala/org/apache/comet/expressions/CometCast.scala 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##               main    #2425       +/-   ##
=============================================
- Coverage     56.12%   22.14%   -33.99%     
+ Complexity      976      438      -538     
=============================================
  Files           119      146       +27     
  Lines         11743    13626     +1883     
  Branches       2251     2362      +111     
=============================================
- Hits           6591     3017     -3574     
- Misses         4012    10050     +6038     
+ Partials       1140      559      -581     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cfmcgrady cfmcgrady force-pushed the cast-array-to-string branch 2 times, most recently from 2f160fc to c104e3f Compare September 26, 2025 22:20
@cfmcgrady cfmcgrady force-pushed the cast-array-to-string branch from f4ff894 to a2b7590 Compare October 6, 2025 16:25
@cfmcgrady cfmcgrady changed the title [WIP]feat: Implement array-to-string cast support feat: Implement array-to-string cast support Oct 9, 2025
@cfmcgrady
Copy link
Contributor Author

This PR is ready for review. Please have a look when you have some time. @andygrove

} else {
str.clear();
let value_ref = array.value(row_index);
let native_cast_result = cast_array(value_ref, &Utf8, spark_cast_options).unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

It may be more efficient to call cast_array once on array.values before the for loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I updated cast_array_to_string to cast array.values() once before the loop.
BTW, does Rust/Comet have any tool for running micro‑benchmarks?

Copy link
Member

Choose a reason for hiding this comment

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

BTW, does Rust/Comet have any tool for running micro‑benchmarks?

There is a documentation for cargo-bench: https://datafusion.apache.org/comet/contributor-guide/profiling_native_code.html#running-micro-benchmarks-with-cargo-bench

@cfmcgrady cfmcgrady force-pushed the cast-array-to-string branch from 68d9abc to 56e5316 Compare October 10, 2025 16:17

test("cast ArrayType to StringType") {
val hasIncompatibleType = (dt: DataType) =>
if (CometConf.COMET_NATIVE_SCAN_IMPL.get() == "auto") {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For cases where the test is run without setting the environment variable COMET_PARQUET_SCAN_IMPL, such as when developing in IntelliJ IDEA.

val result: DataFrame = Dataset.ofRows(spark, analyzed)
CometCast.isSupported(field.dataType, DataTypes.StringType, Some(spark.sessionState.conf.sessionLocalTimeZone), CometEvalMode.TRY) match {
case _: Compatible => checkSparkAnswerAndOperator(result)
case _: Compatible if CometScanTypeChecker(CometConf.COMET_NATIVE_SCAN_IMPL.get()).isTypeSupported(field.dataType, field.name, ListBuffer.empty) =>
Copy link
Member

Choose a reason for hiding this comment

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

The code style is incorrect, reformat it after #2557

@cfmcgrady cfmcgrady requested a review from andygrove October 13, 2025 17:21
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.

Implement array-to-string cast support

4 participants