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 * EXPORT TABLE statement for StarRocks. 011 * 012 * Syntax: 013 * EXPORT TABLE <table_name> 014 * [PARTITION (<partition_name>[, ...])] 015 * [(<column_name>[, ...])] 016 * TO <export_path> 017 * [PROPERTIES ("<key>"="<value>", ...)] 018 * WITH BROKER [broker_name] [(broker_properties)] 019 * 020 * This statement exports table data to external storage like S3, HDFS, etc. 021 * The operation is asynchronous - use SHOW EXPORT to monitor progress. 022 */ 023public class TStarrocksExportStmt extends TCustomSqlStatement { 024 025 // Source table 026 private TTable sourceTable; 027 028 // Optional partition filter 029 private TObjectNameList partitionList; 030 031 // Optional column list 032 private TObjectNameList columnList; 033 034 // Export destination path 035 private String exportPath; 036 037 // Export properties (column_separator, line_delimiter, etc.) 038 private TPTNodeList<TFlinkTableProperty> exportProperties; 039 040 // Optional broker name (null for broker-free exports in v2.5+) 041 private TObjectName brokerName; 042 043 // Broker connection properties (credentials, etc.) 044 private TPTNodeList<TFlinkTableProperty> brokerProperties; 045 046 public TStarrocksExportStmt(EDbVendor dbvendor) { 047 super(dbvendor); 048 sqlstatementtype = ESqlStatementType.sststarrocksExport; 049 } 050 051 // Getters 052 public TTable getSourceTable() { 053 return sourceTable; 054 } 055 056 public TObjectNameList getPartitionList() { 057 return partitionList; 058 } 059 060 public TObjectNameList getColumnList() { 061 return columnList; 062 } 063 064 public String getExportPath() { 065 return exportPath; 066 } 067 068 public TPTNodeList<TFlinkTableProperty> getExportProperties() { 069 return exportProperties; 070 } 071 072 public TObjectName getBrokerName() { 073 return brokerName; 074 } 075 076 public TPTNodeList<TFlinkTableProperty> getBrokerProperties() { 077 return brokerProperties; 078 } 079 080 @Override 081 public int doParseStatement(TCustomSqlStatement psql) { 082 if (rootNode == null) return -1; 083 super.doParseStatement(psql); 084 085 TExportSqlNode node = (TExportSqlNode) rootNode; 086 087 if (node.getTableName() != null) { 088 TFromTable fromTable = new TFromTable(); 089 fromTable.init(node.getTableName()); 090 this.sourceTable = this.analyzeFromTable(fromTable, true); 091 } 092 093 this.partitionList = node.getPartitionList(); 094 this.columnList = node.getColumnList(); 095 096 if (node.getExportPath() != null) { 097 this.exportPath = node.getExportPath().toString(); 098 } 099 100 this.exportProperties = node.getExportProperties(); 101 this.brokerName = node.getBrokerName(); 102 this.brokerProperties = node.getBrokerProperties(); 103 104 return 0; 105 } 106 107 @Override 108 public void accept(TParseTreeVisitor v) { 109 v.preVisit(this); 110 v.postVisit(this); 111 } 112 113 @Override 114 public void acceptChildren(TParseTreeVisitor v) { 115 v.preVisit(this); 116 v.postVisit(this); 117 } 118}