OmniSciDB  471d68cefb
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
com.mapd.parser.extension.ddl.SqlAlterTable Class Reference
+ Inheritance diagram for com.mapd.parser.extension.ddl.SqlAlterTable:
+ Collaboration diagram for com.mapd.parser.extension.ddl.SqlAlterTable:

Classes

enum  AlterType
 
class  Builder
 

Public Member Functions

 SqlAlterTable (final SqlParserPos pos, final SqlIdentifier name)
 
 SqlAlterTable (final SqlParserPos pos, final AlterType alterType, final String tableName, final String newTableName, final String columnName, final String newColumnName, final SqlNodeList columnList, final Map< String, String > options)
 
List< SqlNode > getOperandList ()
 
void unparse (SqlWriter writer, int leftPrec, int rightPrec)
 
String toString ()
 

Private Attributes

AlterType alterType
 
String tableName
 
String newTableName
 
String columnName
 
String newColumnName
 
String command
 
SqlNodeList columnList
 
Map< String, String > options
 

Static Private Attributes

static final SqlOperator OPERATOR
 

Detailed Description

Class that encapsulates all information associated with a ALTER TABLE DDL command.

Definition at line 43 of file SqlAlterTable.java.

Constructor & Destructor Documentation

com.mapd.parser.extension.ddl.SqlAlterTable.SqlAlterTable ( final SqlParserPos  pos,
final SqlIdentifier  name 
)
inline

Definition at line 146 of file SqlAlterTable.java.

References com.mapd.parser.extension.ddl.SqlAlterTable.OPERATOR.

Referenced by com.mapd.parser.extension.ddl.SqlAlterTable.Builder.build().

146  {
147  super(OPERATOR, pos);
148  this.tableName = name.toString();
149  }

+ Here is the caller graph for this function:

com.mapd.parser.extension.ddl.SqlAlterTable.SqlAlterTable ( final SqlParserPos  pos,
final AlterType  alterType,
final String  tableName,
final String  newTableName,
final String  columnName,
final String  newColumnName,
final SqlNodeList  columnList,
final Map< String, String >  options 
)
inline

Definition at line 151 of file SqlAlterTable.java.

References com.mapd.parser.extension.ddl.SqlAlterTable.alterType, com.mapd.parser.extension.ddl.SqlAlterTable.columnList, com.mapd.parser.extension.ddl.SqlAlterTable.columnName, com.mapd.parser.extension.ddl.SqlAlterTable.newColumnName, com.mapd.parser.extension.ddl.SqlAlterTable.newTableName, com.mapd.parser.extension.ddl.SqlAlterTable.OPERATOR, com.mapd.parser.extension.ddl.SqlAlterTable.options, and com.mapd.parser.extension.ddl.SqlAlterTable.tableName.

158  {
159  super(OPERATOR, pos);
160  this.alterType = alterType;
161  this.tableName = tableName;
162  this.newTableName = newTableName;
163  this.columnName = columnName;
164  this.newColumnName = newColumnName;
165  this.options = options;
166  this.columnList = columnList;
167  this.command = OPERATOR.getName();
168  }

Member Function Documentation

List<SqlNode> com.mapd.parser.extension.ddl.SqlAlterTable.getOperandList ( )
inline

Definition at line 171 of file SqlAlterTable.java.

171  {
172  // Add the operands here
173  return null;
174  }
String com.mapd.parser.extension.ddl.SqlAlterTable.toString ( )
inline

Definition at line 184 of file SqlAlterTable.java.

References com.mapd.parser.extension.ddl.SqlAlterTable.alterType, com.mapd.parser.extension.ddl.SqlAlterTable.columnList, and com.mapd.parser.extension.ddl.SqlAlterTable.columnName.

184  {
185  JsonBuilder jsonBuilder = new EscapedStringJsonBuilder();
186  Map<String, Object> map = jsonBuilder.map();
187 
188  map.put("command", "ALTER_TABLE");
189  map.put("tableName", this.tableName.toString());
190  switch (this.alterType) {
191  case RENAME_TABLE:
192  map.put("alterType", "RENAME_TABLE");
193  map.put("newTableName", this.newTableName.toString());
194  break;
195  case RENAME_COLUMN:
196  map.put("alterType", "RENAME_COLUMN");
197  map.put("columnName", this.columnName.toString());
198  map.put("newColumnName", this.newColumnName.toString());
199  break;
200  case ADD_COLUMN:
201  map.put("alterType", "ADD_COLUMN");
202  if (this.columnList != null) {
203  List<Object> elements_list = jsonBuilder.list();
204  for (SqlNode elementNode : this.columnList) {
205  if (!(elementNode instanceof SqlCall)) {
206  throw new CalciteException("Column definition for table "
207  + this.columnName.toString()
208  + " is invalid: " + elementNode.toString(),
209  null);
210  }
211  elements_list.add(elementNode);
212  }
213  map.put("columnData", elements_list);
214  }
215 
216  break;
217  case DROP_COLUMN:
218  map.put("alterType", "DROP_COLUMN");
219  map.put("columnData", this.columnList.toString());
220  break;
221  case ALTER_OPTIONS:
222  map.put("alterType", "ALTER_OPTIONS");
223  map.put("options", this.options);
224  break;
225  }
226 
227  Map<String, Object> payload = jsonBuilder.map();
228  payload.put("payload", map);
229  return jsonBuilder.toJsonString(payload);
230  }
void com.mapd.parser.extension.ddl.SqlAlterTable.unparse ( SqlWriter  writer,
int  leftPrec,
int  rightPrec 
)
inline

Definition at line 177 of file SqlAlterTable.java.

177  {
178  writer.keyword("ALTER");
179  writer.keyword("TABLE");
180  // add other options data here when/as necessary
181  }

Member Data Documentation

AlterType com.mapd.parser.extension.ddl.SqlAlterTable.alterType
private
SqlNodeList com.mapd.parser.extension.ddl.SqlAlterTable.columnList
private
String com.mapd.parser.extension.ddl.SqlAlterTable.columnName
private
String com.mapd.parser.extension.ddl.SqlAlterTable.command
private

Definition at line 140 of file SqlAlterTable.java.

String com.mapd.parser.extension.ddl.SqlAlterTable.newColumnName
private
String com.mapd.parser.extension.ddl.SqlAlterTable.newTableName
private
final SqlOperator com.mapd.parser.extension.ddl.SqlAlterTable.OPERATOR
staticprivate
Initial value:
=
new SqlSpecialOperator("ALTER_TABLE", SqlKind.OTHER_DDL)

Definition at line 44 of file SqlAlterTable.java.

Referenced by com.mapd.parser.extension.ddl.SqlAlterTable.SqlAlterTable().

Map<String, String> com.mapd.parser.extension.ddl.SqlAlterTable.options
private
String com.mapd.parser.extension.ddl.SqlAlterTable.tableName
private

The documentation for this class was generated from the following file: