Skip to content

Comments

fix: handle type mismatches in native c2r conversion#3583

Open
andygrove wants to merge 6 commits intoapache:mainfrom
andygrove:fix/c2r-type-mismatch
Open

fix: handle type mismatches in native c2r conversion#3583
andygrove wants to merge 6 commits intoapache:mainfrom
andygrove:fix/c2r-type-mismatch

Conversation

@andygrove
Copy link
Member

@andygrove andygrove commented Feb 24, 2026

Closes #3482

Summary

  • Fixes native columnar-to-row conversion crash when Spark generates default column values with physical types (e.g. Int32) that differ from logical schema types (e.g. Date32)
  • Changes the fallback arm in maybe_cast_to_schema_type to attempt an Arrow cast for any type mismatch, rather than silently passing through the mismatched array
  • This prevents similar issues for other data types in the future
  • Confirmed that the fuzz test suite now passes when native C2R is enabled

When Spark generates default column values, it can produce Arrow arrays
with physical types (e.g. Int32) that differ from the logical schema
type (e.g. Date32). The c2r converter's maybe_cast_to_schema_type
previously passed these through silently, causing downcast failures.

Now the fallback arm attempts an Arrow cast for any type mismatch,
fixing the immediate Date32 bug and preventing similar issues for
other data types.

Closes apache#3482
/**
* Checks if native columnar to row conversion is enabled.
*/
def isEnabled: Boolean = CometConf.COMET_NATIVE_COLUMNAR_TO_ROW_ENABLED.get()
Copy link
Member Author

Choose a reason for hiding this comment

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

This was unused

@andygrove andygrove marked this pull request as ready for review February 24, 2026 19:59
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.

Native c2r bugs

1 participant