Skip to content

Conversation

@Xuanwo
Copy link
Collaborator

@Xuanwo Xuanwo commented Dec 29, 2025

This PR will add alter column nullable to non-nullable support


Parts of this PR were drafted with assistance from Codex (with gpt-5.2) and fully reviewed and edited by me. I take full responsibility for all changes.

@github-actions
Copy link
Contributor

Code Review

P1: Bug - Nested column validation will fail

In validate_no_nulls_before_making_non_nullable, the code uses batch.column_by_name(path) where path can be a nested path like "b.c". However, RecordBatch::column_by_name only searches top-level column names, not nested paths.

When you call scanner.project(&["b.c"]), the resulting batch schema depends on how Lance handles nested projections - the column won't be accessible via batch.column_by_name("b.c").

Suggestion: Consider using the batch's first (and only) column directly since the projection contains exactly one column:

let col = batch.column(0);

Or alternatively, extract the leaf field name from the path:

let leaf_name = path.rsplit('.').next().unwrap_or(path);
let col = batch.column_by_name(leaf_name)...

Recommendation: Add a test for nested columns

The current tests only cover top-level columns. Given that alter_columns explicitly supports nested paths (as seen in test_rename_columns at line 1324), please add a test case for making a nested nullable column non-nullable.


Otherwise the implementation looks correct - the validation approach of scanning all data to check for nulls before allowing the schema change is sound.

@wjones127
Copy link
Contributor

+1 on the review comment. Would like to have this supported in nested columns.

@wjones127 wjones127 self-assigned this Dec 30, 2025
Copy link
Contributor

@wjones127 wjones127 left a comment

Choose a reason for hiding this comment

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

Add a test for nested columns for this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants