|
| 1 | +// Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +// or more contributor license agreements. See the NOTICE file |
| 3 | +// distributed with this work for additional information |
| 4 | +// regarding copyright ownership. The ASF licenses this file |
| 5 | +// to you under the Apache License, Version 2.0 (the |
| 6 | +// "License"); you may not use this file except in compliance |
| 7 | +// with the License. You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, |
| 12 | +// software distributed under the License is distributed on an |
| 13 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +// KIND, either express or implied. See the License for the |
| 15 | +// specific language governing permissions and limitations |
| 16 | +// under the License. |
| 17 | + |
| 18 | +package org.apache.doris.nereids.trees.plans.commands; |
| 19 | + |
| 20 | +import org.apache.doris.catalog.Env; |
| 21 | +import org.apache.doris.common.AnalysisException; |
| 22 | +import org.apache.doris.nereids.trees.plans.PlanType; |
| 23 | +import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor; |
| 24 | +import org.apache.doris.qe.ConnectContext; |
| 25 | +import org.apache.doris.qe.StmtExecutor; |
| 26 | + |
| 27 | +import com.google.common.base.Strings; |
| 28 | + |
| 29 | +import java.util.Objects; |
| 30 | + |
| 31 | +/** |
| 32 | + * Represents the command for ALTER CATALOG MODIFY COMMENT. |
| 33 | + */ |
| 34 | +public class AlterCatalogCommentCommand extends AlterCatalogCommand { |
| 35 | + |
| 36 | + private final String comment; |
| 37 | + |
| 38 | + public AlterCatalogCommentCommand(String catalogName, String comment) { |
| 39 | + super(PlanType.ALTER_CATALOG_COMMENT_COMMAND, catalogName); |
| 40 | + this.comment = Objects.requireNonNull(comment, "Comment cannot be null"); |
| 41 | + } |
| 42 | + |
| 43 | + @Override |
| 44 | + public void doRun(ConnectContext ctx, StmtExecutor executor) throws Exception { |
| 45 | + // Validate the catalog name |
| 46 | + if (Strings.isNullOrEmpty(comment)) { |
| 47 | + throw new AnalysisException("New comment is not set."); |
| 48 | + } |
| 49 | + |
| 50 | + // Fetch and modify the catalog's comment |
| 51 | + Env.getCurrentEnv().getCatalogMgr().alterCatalogComment(catalogName, comment); |
| 52 | + } |
| 53 | + |
| 54 | + @Override |
| 55 | + public <R, C> R accept(PlanVisitor<R, C> visitor, C context) { |
| 56 | + return visitor.visitAlterCatalogCommentCommand(this, context); |
| 57 | + } |
| 58 | +} |
0 commit comments