Skip to content

[#9113] feat(lance-rest): Support drop and rename column for Lance table#9127

Open
yuqi1129 wants to merge 15 commits intoapache:mainfrom
yuqi1129:issue_9113
Open

[#9113] feat(lance-rest): Support drop and rename column for Lance table#9127
yuqi1129 wants to merge 15 commits intoapache:mainfrom
yuqi1129:issue_9113

Conversation

@yuqi1129
Copy link
Contributor

What changes were proposed in this pull request?

Support drop columns for the Lance table

Why are the changes needed?

It's a common need for Lance tables.

Fix: #9113

Does this PR introduce any user-facing change?

N/A

How was this patch tested?

UTs and ITs

@yuqi1129 yuqi1129 marked this pull request as draft November 14, 2025 11:51
@yuqi1129 yuqi1129 changed the base branch from branch-lance-namespace-dev to main November 28, 2025 11:50
@yuqi1129 yuqi1129 closed this Nov 28, 2025
@yuqi1129 yuqi1129 reopened this Nov 28, 2025
@yuqi1129
Copy link
Contributor Author

There are some things we need to dicuss before doing the add column API as the parameter differs from that in Gravitino, and more important, the transition betwwen them are not so easy.

@yuqi1129 yuqi1129 self-assigned this Jan 7, 2026
@yuqi1129 yuqi1129 marked this pull request as ready for review January 7, 2026 12:04
Copilot AI review requested due to automatic review settings January 7, 2026 12:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for dropping columns and altering columns (rename) in Lance tables, addressing issue #9113. The implementation provides both REST API endpoints and underlying catalog operations.

Key Changes

  • Added REST endpoints /drop_columns and /alter_columns for table column operations
  • Implemented drop columns and alter columns functionality across REST server, Gravitino operations, and catalog layers
  • Comprehensive test coverage with both unit tests and integration tests

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
lance/lance-common/src/main/java/org/apache/gravitino/lance/common/ops/LanceTableOperations.java Added interface methods for drop columns, alter columns, and add columns operations
lance/lance-common/src/main/java/org/apache/gravitino/lance/common/ops/gravitino/GravitinoLanceTableOperations.java Implemented drop/alter column operations by translating Lance requests to Gravitino TableChange operations
lance/lance-rest-server/src/main/java/org/apache/gravitino/lance/service/rest/LanceTableOperations.java Added REST endpoints for drop_columns and alter_columns with input validation
catalogs/catalog-lakehouse-generic/src/main/java/org/apache/gravitino/catalog/lakehouse/lance/LanceTableOperations.java Refactored alterTable to handle drop columns and rename columns alongside existing add index support
lance/lance-rest-server/src/test/java/org/apache/gravitino/lance/service/rest/TestLanceNamespaceOperations.java Added comprehensive unit tests for drop columns and alter columns operations including error scenarios
lance/lance-rest-server/src/test/java/org/apache/gravitino/lance/integration/test/LanceRESTServiceIT.java Added integration tests validating drop columns and alter columns functionality end-to-end

@jerryshao jerryshao requested a review from mchades January 8, 2026 09:15
@yuqi1129 yuqi1129 changed the title [#9113] feat(lance-rest): Support drop columns for Lance table [#9113] feat(lance-rest): Support drop and rename column for Lance table Jan 8, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 11 comments.

@jerryshao
Copy link
Contributor

@mchades can you please help to review?

// More please see: https://docs.lancedb.com/api-reference/data/add-columns
throw new UnsupportedOperationException("Adding columns is not supported yet.");
}

Copy link
Contributor

Choose a reason for hiding this comment

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

The implementation of these 3 methods are basically the same; can they be merged together?

Copy link
Contributor Author

@yuqi1129 yuqi1129 Jan 28, 2026

Choose a reason for hiding this comment

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

Do you mean we can define the following interface to replace them all?

    @Override
  public AlterTableAlterColumnsResponse alterTableOperations(
      String tableId, String delimiter, Object request) {
    if (request instanceof AlterTableAddColumnsRequest addColumnsRequest) {
      // add column
    } else if (request instanceof AlterTableAlterColumnsRequest alterColumnsRequest) {
      return alterTableAlterColumns(tableId, delimiter, alterColumnsRequest);
    } else if (request instanceof AlterTableDropColumnsRequest dropColumnsRequest) {
      // drop column
      return alterTableDropColumns(tableId, delimiter, dropColumnsRequest);
    }
  }

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, something like this. Since most of the logic are similar, if we continue to add more alter-related operations, there will be lots of duplicated codes.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

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.

[Subtask] Add table column related APIs

3 participants