001package gudusoft.gsqlparser.nodes;
002
003import gudusoft.gsqlparser.nodes.flink.TFlinkTableProperty;
004
005/**
006 * AST node for StarRocks ALTER RESOURCE GROUP statement.
007 *
008 * Syntax:
009 * ALTER RESOURCE GROUP resource_group_name
010 * {
011 *   ADD CLASSIFIER1, CLASSIFIER2, ...
012 *   | DROP (CLASSIFIER_ID_1, CLASSIFIER_ID_2, ...)
013 *   | DROP ALL
014 *   | WITH (resource_limit1, resource_limit2, ...)
015 * };
016 *
017 * Example:
018 * ALTER RESOURCE GROUP rg1 ADD (user='alice', query_type in ('select'));
019 * ALTER RESOURCE GROUP rg1 DROP (300040, 300041);
020 * ALTER RESOURCE GROUP rg1 DROP ALL;
021 * ALTER RESOURCE GROUP rg1 WITH (cpu_weight=10, mem_limit=0.5);
022 */
023public class TAlterResourceGroupSqlNode extends TParseTreeNode {
024
025    /**
026     * Enum for ALTER RESOURCE GROUP action types.
027     */
028    public enum EAlterResourceGroupAction {
029        ADD,      // Add classifiers
030        DROP,     // Drop specific classifiers by ID
031        DROP_ALL, // Drop all classifiers
032        WITH      // Modify resource limits
033    }
034
035    // Resource group name
036    private TObjectName resourceGroupName;
037
038    // Action type (ADD, DROP, DROP_ALL, WITH)
039    private EAlterResourceGroupAction actionType;
040
041    // Classifiers to add (for ADD action)
042    private TParseTreeNode classifierList;
043
044    // Classifier IDs to drop (for DROP action)
045    private TParseTreeNode classifierIdList;
046
047    // Resource limits (for WITH action)
048    private TParseTreeNode resourceLimits;
049
050    // Getters and setters
051    public TObjectName getResourceGroupName() {
052        return resourceGroupName;
053    }
054
055    public void setResourceGroupName(TObjectName resourceGroupName) {
056        this.resourceGroupName = resourceGroupName;
057    }
058
059    public EAlterResourceGroupAction getActionType() {
060        return actionType;
061    }
062
063    public void setActionType(EAlterResourceGroupAction actionType) {
064        this.actionType = actionType;
065    }
066
067    @SuppressWarnings("unchecked")
068    public TPTNodeList<TParseTreeNode> getClassifierList() {
069        return (TPTNodeList<TParseTreeNode>) classifierList;
070    }
071
072    public void setClassifierList(TParseTreeNode classifierList) {
073        this.classifierList = classifierList;
074    }
075
076    @SuppressWarnings("unchecked")
077    public TPTNodeList<TExpression> getClassifierIdList() {
078        return (TPTNodeList<TExpression>) classifierIdList;
079    }
080
081    public void setClassifierIdList(TParseTreeNode classifierIdList) {
082        this.classifierIdList = classifierIdList;
083    }
084
085    @SuppressWarnings("unchecked")
086    public TPTNodeList<TFlinkTableProperty> getResourceLimits() {
087        return (TPTNodeList<TFlinkTableProperty>) resourceLimits;
088    }
089
090    public void setResourceLimits(TParseTreeNode resourceLimits) {
091        this.resourceLimits = resourceLimits;
092    }
093
094    public void init(Object arg1) {
095        this.resourceGroupName = (TObjectName) arg1;
096    }
097}