This is an automated email from the ASF dual-hosted git repository.

jiacai2050 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-horaedb.git


The following commit(s) were added to refs/heads/main by this push:
     new e5c9923b feat(horaemeta): drop metadata of partition table by http api 
(#1477)
e5c9923b is described below

commit e5c9923baf84be45a54c724f3f146c77de91b999
Author: chunshao.rcs <[email protected]>
AuthorDate: Fri Apr 26 14:46:05 2024 +0800

    feat(horaemeta): drop metadata of partition table by http api (#1477)
    
    ## Rationale
    Currently, not suppport to delete a partitioned table through HTTP API,
    as it results in a "shard not found" error.
    
    ## Detailed Changes
    Since the partition table is not assigned to a shard, deleting the table
    metadata directly.
    
    ## Test Plan
     Manual test.
---
 horaemeta/server/cluster/manager.go | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/horaemeta/server/cluster/manager.go 
b/horaemeta/server/cluster/manager.go
index beaea50d..648236bd 100644
--- a/horaemeta/server/cluster/manager.go
+++ b/horaemeta/server/cluster/manager.go
@@ -307,6 +307,17 @@ func (m *managerImpl) DropTable(ctx context.Context, 
clusterName, schemaName, ta
                return errors.WithMessage(err, "get table")
        }
 
+       // If the table is partitioned, delete the table metadata directly.
+       if table.IsPartitioned() {
+               _, err = cluster.metadata.DropTableMetadata(ctx, schemaName, 
tableName)
+               if err != nil {
+                       return errors.WithMessage(err, "cluster drop table 
metadata")
+               }
+               return nil
+       }
+
+       // If the table is not a partition table, delete the table metadata and 
remove the table from the shard.
+       // So we need to check if the table has been assigned to a shard.
        getShardNodeResult, err := 
cluster.metadata.GetShardNodeByTableIDs([]storage.TableID{table.ID})
        if err != nil {
                return errors.WithMessage(err, "get shard node by tableID")


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to