Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add alter columns for names and nullability #1903

Merged
merged 5 commits into from Feb 5, 2024

Conversation

wjones127
Copy link
Contributor

@wjones127 wjones127 commented Feb 2, 2024

Initial pass on alter_columns() API. This allows renaming columns and making them nullable. A future PR will allow casting the type of column.

Copy link
Contributor

@westonpace westonpace left a comment

Choose a reason for hiding this comment

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

Looks good!

let alterations = alterations
.iter()
.map(|obj| {
let obj = PyAny::downcast::<PyDict>(obj)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you not just say obj.downcast::<PyDict>()?

Comment on lines 1696 to 1697
/// If a column has an index, it's index will be preserved or transformed to
/// the new type as part of the operation.
Copy link
Contributor

Choose a reason for hiding this comment

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

Index transformation is only future right? Once we support data type changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I should remove that for now.

Comment on lines +623 to +630
- "name": str, optional
The new name of the column. If not specified, the column name is
not changed.
- "nullable": bool, optional
Whether the column should be nullable. If not specified, the column
nullability is not changed. Only non-nullable columns can be changed
to nullable. Currently, you cannot change a nullable column to
non-nullable.
Copy link
Contributor

Choose a reason for hiding this comment

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

If the column is already nullable, or already has the desired name, is it a no-op or a failure? From the code it looks like a no-op correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it should be a no-op.

@wjones127 wjones127 merged commit 33bf813 into lancedb:main Feb 5, 2024
14 checks passed
@wjones127 wjones127 deleted the alter-columns branch February 5, 2024 21:54
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.

None yet

2 participants