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 * CREATE RESOURCE GROUP statement for StarRocks. 011 * 012 * Syntax: 013 * CREATE RESOURCE GROUP resource_group_name 014 * TO CLASSIFIER1, CLASSIFIER2, ... 015 * WITH (resource_limit1, resource_limit2, ...) 016 * 017 * This statement creates a resource group for workload isolation in StarRocks. 018 * Resource groups control CPU, memory, and concurrency limits for queries 019 * matching specific classifiers. 020 */ 021public class TStarrocksCreateResourceGroupStmt extends TCustomSqlStatement { 022 023 // Resource group name 024 private TObjectName resourceGroupName; 025 026 // Classifiers (TO clause) 027 private TPTNodeList<TResourceGroupClassifier> classifierList; 028 029 // Resource limits (WITH clause) 030 private TPTNodeList<TFlinkTableProperty> resourceLimits; 031 032 public TStarrocksCreateResourceGroupStmt(EDbVendor dbvendor) { 033 super(dbvendor); 034 sqlstatementtype = ESqlStatementType.sststarrocksCreateResourceGroup; 035 } 036 037 // Getters 038 public TObjectName getResourceGroupName() { 039 return resourceGroupName; 040 } 041 042 public TPTNodeList<TResourceGroupClassifier> getClassifierList() { 043 return classifierList; 044 } 045 046 public TPTNodeList<TFlinkTableProperty> getResourceLimits() { 047 return resourceLimits; 048 } 049 050 @Override 051 @SuppressWarnings("unchecked") 052 public int doParseStatement(TCustomSqlStatement psql) { 053 if (rootNode == null) return -1; 054 super.doParseStatement(psql); 055 056 TCreateResourceGroupSqlNode node = (TCreateResourceGroupSqlNode) rootNode; 057 058 this.resourceGroupName = node.getResourceGroupName(); 059 060 if (node.getClassifierList() != null) { 061 this.classifierList = (TPTNodeList<TResourceGroupClassifier>) (TPTNodeList<?>) node.getClassifierList(); 062 } 063 064 this.resourceLimits = node.getResourceLimits(); 065 066 return 0; 067 } 068 069 @Override 070 public void accept(TParseTreeVisitor v) { 071 v.preVisit(this); 072 v.postVisit(this); 073 } 074 075 @Override 076 public void acceptChildren(TParseTreeVisitor v) { 077 v.preVisit(this); 078 v.postVisit(this); 079 } 080}