001package gudusoft.gsqlparser.stmt;
002
003import gudusoft.gsqlparser.EDbVendor;
004import gudusoft.gsqlparser.ESqlStatementType;
005import gudusoft.gsqlparser.TCustomSqlStatement;
006import gudusoft.gsqlparser.nodes.*;
007import gudusoft.gsqlparser.nodes.flink.TFlinkTableProperty;
008
009/**
010 * Statement class for StarRocks ALTER RESOURCE GROUP.
011 *
012 * Syntax:
013 * ALTER RESOURCE GROUP resource_group_name
014 * {
015 *   ADD CLASSIFIER1, CLASSIFIER2, ...
016 *   | DROP (CLASSIFIER_ID_1, CLASSIFIER_ID_2, ...)
017 *   | DROP ALL
018 *   | WITH (resource_limit1, resource_limit2, ...)
019 * };
020 */
021public class TStarrocksAlterResourceGroupStmt extends TCustomSqlStatement {
022
023    private TObjectName resourceGroupName;
024    private TAlterResourceGroupSqlNode.EAlterResourceGroupAction actionType;
025    private TPTNodeList<TParseTreeNode> classifierList;
026    private TPTNodeList<TExpression> classifierIdList;
027    private TPTNodeList<TFlinkTableProperty> resourceLimits;
028
029    public TStarrocksAlterResourceGroupStmt(EDbVendor dbvendor) {
030        super(dbvendor);
031        sqlstatementtype = ESqlStatementType.sststarrocksAlterResourceGroup;
032    }
033
034    @Override
035    public int doParseStatement(TCustomSqlStatement psql) {
036        if (rootNode == null) return -1;
037
038        super.doParseStatement(psql);
039
040        TAlterResourceGroupSqlNode node = (TAlterResourceGroupSqlNode) rootNode;
041
042        this.resourceGroupName = node.getResourceGroupName();
043        this.actionType = node.getActionType();
044        this.classifierList = node.getClassifierList();
045        this.classifierIdList = node.getClassifierIdList();
046        this.resourceLimits = node.getResourceLimits();
047
048        return 0;
049    }
050
051    public TObjectName getResourceGroupName() {
052        return resourceGroupName;
053    }
054
055    public TAlterResourceGroupSqlNode.EAlterResourceGroupAction getActionType() {
056        return actionType;
057    }
058
059    public TPTNodeList<TParseTreeNode> getClassifierList() {
060        return classifierList;
061    }
062
063    public TPTNodeList<TExpression> getClassifierIdList() {
064        return classifierIdList;
065    }
066
067    public TPTNodeList<TFlinkTableProperty> getResourceLimits() {
068        return resourceLimits;
069    }
070
071    @Override
072    public void accept(TParseTreeVisitor v) {
073        v.preVisit(this);
074        v.postVisit(this);
075    }
076
077    @Override
078    public void acceptChildren(TParseTreeVisitor v) {
079        v.preVisit(this);
080        v.postVisit(this);
081    }
082}