OmniSciDB  a575cb28ea
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SqlAlterForeignTable.java
Go to the documentation of this file.
1 package com.mapd.parser.extension.ddl;
2 
3 import com.google.gson.annotations.Expose;
4 
5 import org.apache.calcite.sql.SqlDdl;
6 import org.apache.calcite.sql.SqlKind;
7 import org.apache.calcite.sql.SqlNode;
8 import org.apache.calcite.sql.SqlOperator;
9 import org.apache.calcite.sql.SqlSpecialOperator;
10 import org.apache.calcite.sql.parser.SqlParserPos;
11 
12 import java.util.List;
13 import java.util.Map;
14 
19 public class SqlAlterForeignTable extends SqlDdl implements JsonSerializableDdl {
20  private static final SqlOperator OPERATOR =
21  new SqlSpecialOperator("ALTER_FOREIGN_TABLE", SqlKind.OTHER_DDL);
22 
33  public enum AlterType { RENAME_TABLE, RENAME_COLUMN, ALTER_OPTIONS }
34 
35  public static class Builder extends SqlOptionsBuilder {
36  private SqlParserPos pos;
38  private String tableName;
39  private String newTableName;
40  private String oldColumnName;
41  private String newColumnName;
42 
43  public void setPos(final SqlParserPos pos) {
44  this.pos = pos;
45  }
46 
47  public void setTableName(final String tableName) {
48  this.tableName = tableName;
49  }
50 
51  public void alterOptions(final Map<String, String> options) {
52  this.alterType = AlterType.ALTER_OPTIONS;
53  this.options = options;
54  }
55 
56  public void alterTableName(final String newName) {
57  this.alterType = AlterType.RENAME_TABLE;
58  this.newTableName = newName;
59  }
60 
61  public void alterColumnName(final String oldName, final String newName) {
62  this.alterType = AlterType.RENAME_COLUMN;
63  this.oldColumnName = oldName;
64  this.newColumnName = newName;
65  }
66 
68  return new SqlAlterForeignTable(pos,
69  alterType,
70  tableName,
74  super.options);
75  }
76  }
77 
78  @Expose
80  @Expose
81  private String tableName;
82  @Expose
83  private String newTableName;
84  @Expose
85  private String oldColumnName;
86  @Expose
87  private String newColumnName;
88  @Expose
89  private String command;
90  @Expose
91  private Map<String, String> options;
92 
93  public SqlAlterForeignTable(final SqlParserPos pos,
94  final AlterType alterType,
95  final String tableName,
96  final String newTableName,
97  final String oldColumnName,
98  final String newColumnName,
99  final Map<String, String> options) {
100  super(OPERATOR, pos);
101  this.alterType = alterType;
102  this.tableName = tableName;
103  this.newTableName = newTableName;
104  this.oldColumnName = oldColumnName;
105  this.newColumnName = newColumnName;
106  this.options = options;
107  this.command = OPERATOR.getName();
108  }
109 
110  @Override
111  public List<SqlNode> getOperandList() {
112  return null;
113  }
114 
115  @Override
116  public String toString() {
117  return toJsonString();
118  }
119 }
void alterColumnName(final String oldName, final String newName)
SqlAlterForeignTable(final SqlParserPos pos, final AlterType alterType, final String tableName, final String newTableName, final String oldColumnName, final String newColumnName, final Map< String, String > options)
void alterOptions(final Map< String, String > options)