lll-hhh opened a new pull request, #55720:
URL: https://github.com/apache/arrow/pull/55720

   ### Rationale for this change
   
   Fixes #37219.
   
   `ProjectionDescr::FromExpressions` copies field nullability and metadata 
only for a bare `field_ref`. A projection such as 
`dataset.field("id").cast(int64())` therefore produced a nested field with the 
default `nullable=true` and dropped the source field's metadata, even though a 
safe cast preserves the source values and cannot introduce nulls when the 
source is required.
   
   ### What changes are included in this PR?
   
   - When building a projection, follow a chain of single-argument `cast` calls 
back to its field reference.
   - Preserve the source field's nullability and metadata while still using the 
cast's output type.
   - Add a regression covering required `int32 -> int64` (including metadata) 
and optional `int16 -> float64`.
   
   ### Are these changes tested?
   
   Yes, against an editable Arrow C++ 27.0.0-SNAPSHOT build in WSL.
   
   - A standalone C++ harness against the unmodified base printed `nullable=1 
metadata_preserved=0`.
   - The same harness against the changed library printed `nullable=0 
metadata_preserved=1`.
   - The `arrow-dataset-scanner-test` test translation unit compiles 
successfully with C++20.
   - The Arrow C++ shared library built and installed successfully.
   - `clang-format==18.1.8 --dry-run --Werror` and `git diff --check` passed.
   
   The full local test executable was not linked because this minimal build 
lacked the optional Boost test dependency; the focused upstream regression is 
included for CI.
   
   ### Are there any user-facing changes?
   
   Yes. Dataset projections that cast a field now retain that field's declared 
nullability and metadata. The output data type, values, and cast behavior are 
unchanged.
   
   ### Was AI used for this PR?
   
   In accordance with the AI generation guidelines, AI was used for 
implementation, tests, and description. The behavior was reproduced against the 
unmodified base and validated against a local Arrow build before submission.
   
   **PR code and description written by:**
   
   - [ ] Human
   - [x] AI
   
   **Reviewed before submission by:**
   
   - [ ] Human
   - [x] AI
   - [ ] Not reviewed
   
   * GitHub Issue: #37219
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to