-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Enhancement] (nereids)implement alterCatalogRenameCommand in nereids
- Loading branch information
1 parent
8956279
commit 0670ddc
Showing
8 changed files
with
146 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...rc/main/java/org/apache/doris/nereids/trees/plans/commands/AlterCatalogRenameCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package org.apache.doris.nereids.trees.plans.commands; | ||
|
||
import org.apache.doris.catalog.Env; | ||
import org.apache.doris.nereids.trees.plans.PlanType; | ||
import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor; | ||
import org.apache.doris.qe.ConnectContext; | ||
import org.apache.doris.qe.StmtExecutor; | ||
|
||
/** | ||
* Represents the command for ALTER CATALOG RENAME. | ||
*/ | ||
public class AlterCatalogRenameCommand extends AlterCatalogCommand { | ||
private final String newCatalogName; | ||
|
||
public AlterCatalogRenameCommand(String catalogName, String newName) { | ||
super(PlanType.ALTER_CATALOG_RENAME_COMMAND, catalogName); | ||
this.newCatalogName = newName; | ||
} | ||
|
||
@Override | ||
public void doRun(ConnectContext ctx, StmtExecutor executor) throws Exception { | ||
validate(ctx); | ||
Env.getCurrentEnv().getCatalogMgr().alterCatalogName(catalogName, newCatalogName); | ||
} | ||
|
||
@Override | ||
public <R, C> R accept(PlanVisitor<R, C> visitor, C context) { | ||
return visitor.visitAlterCatalogRenameCommand(this, context); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
regression-test/data/nereids_p0/test_alter_catalog_rename_command.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !cmd -- | ||
test_alter_catalog_rename \nCREATE CATALOG `test_alter_catalog_rename`\nCOMMENT "Catalog for renaming test"\n PROPERTIES (\n"type" = "es",\n"hosts" = "http://127.0.0.1:9200"\n); | ||
|
||
-- !cmd -- | ||
test_altered_catalog \nCREATE CATALOG `test_altered_catalog`\nCOMMENT "Catalog for renaming test"\n PROPERTIES (\n"type" = "es",\n"hosts" = "http://127.0.0.1:9200"\n); | ||
|
55 changes: 55 additions & 0 deletions
55
regression-test/suites/nereids_p0/test_alter_catalog_rename_command.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
suite("test_alter_catalog_rename_command", "nereids_p0") { | ||
def originalCatalogName = "test_alter_catalog_rename" | ||
def renamedCatalogName = "test_altered_catalog" | ||
def catalogProperties = "\"type\"=\"es\", \"hosts\"=\"http://127.0.0.1:9200\"" | ||
|
||
try { | ||
// Drop catalogs if they already exist | ||
sql("DROP CATALOG IF EXISTS ${originalCatalogName}") | ||
sql("DROP CATALOG IF EXISTS ${renamedCatalogName}") | ||
|
||
// Create the original catalog | ||
sql( | ||
""" | ||
CREATE CATALOG ${originalCatalogName} | ||
COMMENT 'Catalog for renaming test' | ||
PROPERTIES (${catalogProperties}) | ||
""" | ||
) | ||
// Verify the catalog was created | ||
checkNereidsExecute("""SHOW CREATE CATALOG ${originalCatalogName}""") | ||
qt_cmd("""SHOW CREATE CATALOG ${originalCatalogName}""") | ||
|
||
// Rename the catalog | ||
checkNereidsExecute( | ||
""" | ||
ALTER CATALOG ${originalCatalogName} RENAME ${renamedCatalogName} | ||
""" | ||
) | ||
// Verify the catalog was renamed | ||
checkNereidsExecute("""SHOW CREATE CATALOG ${renamedCatalogName}""") | ||
qt_cmd("""SHOW CREATE CATALOG ${renamedCatalogName}""") | ||
|
||
} finally { | ||
// Clean up | ||
sql("DROP CATALOG IF EXISTS ${originalCatalogName}") | ||
sql("DROP CATALOG IF EXISTS ${renamedCatalogName}") | ||
} | ||
} |