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 REPOSITORY statement for StarRocks. 011 * 012 * Syntax: 013 * CREATE [READ ONLY] REPOSITORY <repository_name> 014 * WITH BROKER 015 * ON LOCATION "<repository_location>" 016 * PROPERTIES ("key"="value", ...) 017 * 018 * This statement creates a repository for storing backup snapshots. 019 * Supports HDFS, S3, GCS, Azure Blob, and MinIO storage backends. 020 */ 021public class TStarrocksCreateRepositoryStmt extends TCustomSqlStatement { 022 023 // Repository name 024 private TObjectName repositoryName; 025 026 // READ ONLY flag 027 private boolean readOnly; 028 029 // Location path (ON LOCATION clause) 030 private String repositoryLocation; 031 032 // PROPERTIES clause (credentials and storage options) 033 private TPTNodeList<TFlinkTableProperty> properties; 034 035 public TStarrocksCreateRepositoryStmt(EDbVendor dbvendor) { 036 super(dbvendor); 037 sqlstatementtype = ESqlStatementType.sststarrocksCreateRepository; 038 } 039 040 // Getters 041 public TObjectName getRepositoryName() { 042 return repositoryName; 043 } 044 045 public boolean isReadOnly() { 046 return readOnly; 047 } 048 049 public String getRepositoryLocation() { 050 return repositoryLocation; 051 } 052 053 public TPTNodeList<TFlinkTableProperty> getProperties() { 054 return properties; 055 } 056 057 @Override 058 public int doParseStatement(TCustomSqlStatement psql) { 059 if (rootNode == null) return -1; 060 super.doParseStatement(psql); 061 062 TCreateRepositorySqlNode node = (TCreateRepositorySqlNode) rootNode; 063 064 this.repositoryName = node.getRepositoryName(); 065 this.readOnly = node.isReadOnly(); 066 067 if (node.getRepositoryLocation() != null) { 068 this.repositoryLocation = node.getRepositoryLocation().toString(); 069 } 070 071 this.properties = node.getProperties(); 072 073 return 0; 074 } 075 076 @Override 077 public void accept(TParseTreeVisitor v) { 078 v.preVisit(this); 079 v.postVisit(this); 080 } 081 082 @Override 083 public void acceptChildren(TParseTreeVisitor v) { 084 v.preVisit(this); 085 v.postVisit(this); 086 } 087}