Skip to content

feat: add serialization test for list element name and metadata support#37

Merged
Swoorup merged 1 commit into
mainfrom
sj-metadata-support
Feb 10, 2026
Merged

feat: add serialization test for list element name and metadata support#37
Swoorup merged 1 commit into
mainfrom
sj-metadata-support

Conversation

@Swoorup
Copy link
Copy Markdown
Owner

@Swoorup Swoorup commented Feb 10, 2026

No description provided.

@Swoorup Swoorup merged commit 921159f into main Feb 10, 2026
5 checks passed
@gooroo-dev
Copy link
Copy Markdown

gooroo-dev Bot commented Feb 10, 2026

Please double check the following review of the pull request:

🐞Mistake 🤪Typo 🚨Security 🚀Performance 💪Best Practices 📖Readability ❓Others
0 0 0 0 0 1 0

Changes in the diff

  • ➕ Added a new test test_serialize_respects_list_element_name_and_metadata to verify serialization respects list element name and metadata attributes.
  • ➕ Added a helper function align_struct_values in derive_struct.rs to cast struct field arrays to their expected data types during serialization.
  • 🛠️ Integrated align_struct_values call in two places inside expand_serialize to ensure type alignment before creating StructArray.
  • 📖 Used Rust's new pattern matching let ... else syntax in the test for better readability.

Identified Issues

ID Type Details Severity Confidence
1 💪Best Practices In align_struct_values, panicking on cast failure may be harsh; better error handling or returning Result would be more robust. (arrow_convert_derive/src/derive_struct.rs lines 297-314) 🟡 Low 🟡 Low

Issue ID 1

Explanation

In arrow_convert_derive/src/derive_struct.rs (lines ~297-314), the function align_struct_values attempts to cast arrays to expected data types. If casting fails, it panics with a message. Panicking in procedural macros or serialization code can cause abrupt failures and poor error reporting.

Suggested fix

Change the function to return a Result<Vec<arrow::array::ArrayRef>, arrow::error::ArrowError> or a custom error type instead of panicking. Propagate the error upwards to allow graceful handling.

Code fix example

fn align_struct_values(
    values: Vec<arrow::array::ArrayRef>,
    fields: &arrow::datatypes::Fields,
) -> Result<Vec<arrow::array::ArrayRef>, arrow::error::ArrowError> {
    values
        .into_iter()
        .zip(fields.iter())
        .map(|(value, field)| {
            if value.data_type() == field.data_type() {
                Ok(value)
            } else {
                arrow::compute::cast(value.as_ref(), field.data_type()).map_err(|e| {
                    arrow::error::ArrowError::ComputeError(format!(
                        "failed to cast field '{}' from {:?} to {:?}: {}",
                        field.name(),
                        value.data_type(),
                        field.data_type(),
                        e
                    ))
                })
            }
        })
        .collect()
}

Then update call sites to handle the Result.

Explanation of the fix

This change avoids panics and allows the caller to handle errors properly, improving robustness and debuggability.


Missing tests

The added test in test_schema.rs covers the new feature well. No additional tests are strictly required.


Summary

The PR adds a useful test and improves serialization by aligning struct field arrays to expected types. The only recommendation is to avoid panics in align_struct_values and use error handling instead for better robustness. Otherwise, the changes are well-structured and clear.

Summon me to re-review when updated! Yours, Gooroo.dev
React or reply to let me know what you think!

@github-actions github-actions Bot mentioned this pull request Feb 10, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.03%. Comparing base (51bd911) to head (f80f256).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #37      +/-   ##
==========================================
+ Coverage   93.95%   94.03%   +0.07%     
==========================================
  Files          10       10              
  Lines        2018     2045      +27     
==========================================
+ Hits         1896     1923      +27     
  Misses        122      122              

☔ 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.

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.

2 participants