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 * ALTER ROUTINE LOAD statement for StarRocks. 011 * 012 * Syntax: 013 * ALTER ROUTINE LOAD FOR [db_name.]job_name 014 * [load_properties] 015 * [job_properties] 016 * FROM data_source 017 * [data_source_properties] 018 * 019 * load_properties: 020 * [COLUMNS TERMINATED BY '<column_separator>'] 021 * [ROWS TERMINATED BY '<row_separator>'] 022 * [COLUMNS (<column1_name>[, <column2_name>, <column_assignment>, ...])] 023 * [WHERE <expr>] 024 * [PARTITION (<partition1_name>[, <partition2_name>, ...])] 025 * 026 * job_properties: 027 * PROPERTIES ("key" = "value"[, ...]) 028 * 029 * data_source: 030 * FROM KAFKA ("key" = "value"[, ...]) 031 */ 032public class TAlterRoutineLoadStmt extends TCustomSqlStatement { 033 034 // Job identification 035 private TObjectName jobName; 036 037 // Load properties 038 private String columnSeparator; 039 private String rowSeparator; 040 private TObjectNameList columnList; 041 private TExpression filterExpression; 042 private TObjectNameList partitionList; 043 private TObjectNameList temporaryPartitionList; 044 045 // Job properties (PROPERTIES clause) 046 private TPTNodeList<TFlinkTableProperty> jobProperties; 047 048 // Data source 049 private String dataSourceType; // KAFKA, PULSAR, etc. 050 private TPTNodeList<TFlinkTableProperty> dataSourceProperties; 051 052 public TAlterRoutineLoadStmt(EDbVendor dbvendor) { 053 super(dbvendor); 054 sqlstatementtype = ESqlStatementType.sststarrocksAlterRoutineLoad; 055 } 056 057 // Getters 058 public TObjectName getJobName() { 059 return jobName; 060 } 061 062 public String getColumnSeparator() { 063 return columnSeparator; 064 } 065 066 public String getRowSeparator() { 067 return rowSeparator; 068 } 069 070 public TObjectNameList getColumnList() { 071 return columnList; 072 } 073 074 public TExpression getFilterExpression() { 075 return filterExpression; 076 } 077 078 public TObjectNameList getPartitionList() { 079 return partitionList; 080 } 081 082 public TObjectNameList getTemporaryPartitionList() { 083 return temporaryPartitionList; 084 } 085 086 public TPTNodeList<TFlinkTableProperty> getJobProperties() { 087 return jobProperties; 088 } 089 090 public String getDataSourceType() { 091 return dataSourceType; 092 } 093 094 public TPTNodeList<TFlinkTableProperty> getDataSourceProperties() { 095 return dataSourceProperties; 096 } 097 098 @Override 099 public int doParseStatement(TCustomSqlStatement psql) { 100 if (rootNode == null) return -1; 101 super.doParseStatement(psql); 102 103 TAlterRoutineLoadSqlNode node = (TAlterRoutineLoadSqlNode) rootNode; 104 105 this.jobName = node.getJobName(); 106 107 if (node.getColumnSeparator() != null) { 108 this.columnSeparator = node.getColumnSeparator().toString(); 109 } 110 111 if (node.getRowSeparator() != null) { 112 this.rowSeparator = node.getRowSeparator().toString(); 113 } 114 115 this.columnList = node.getColumnList(); 116 this.filterExpression = node.getWhereClause(); 117 this.partitionList = node.getPartitionList(); 118 this.temporaryPartitionList = node.getTemporaryPartitionList(); 119 this.jobProperties = node.getJobProperties(); 120 121 if (node.getDataSourceType() != null) { 122 this.dataSourceType = node.getDataSourceType().toString(); 123 } 124 125 this.dataSourceProperties = node.getDataSourceProperties(); 126 127 return 0; 128 } 129 130 @Override 131 public void accept(TParseTreeVisitor v) { 132 v.preVisit(this); 133 v.postVisit(this); 134 } 135 136 @Override 137 public void acceptChildren(TParseTreeVisitor v) { 138 v.preVisit(this); 139 v.postVisit(this); 140 } 141}