OmniSciDB  a987f07e93
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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.SqlKind;
7 import org.apache.calcite.sql.SqlSpecialOperator;
8 import org.apache.calcite.sql.parser.SqlParserPos;
9 
10 import java.util.Map;
11 
16 public class SqlAlterForeignTable extends SqlCustomDdl {
17  private static final SqlOperator OPERATOR =
18  new SqlSpecialOperator("ALTER_FOREIGN_TABLE", SqlKind.OTHER_DDL);
19 
30  public enum AlterType { RENAME_TABLE, RENAME_COLUMN, ALTER_OPTIONS }
31 
32  public static class Builder extends SqlOptionsBuilder {
33  private SqlParserPos pos;
35  private String tableName;
36  private String newTableName;
37  private String oldColumnName;
38  private String newColumnName;
39 
40  public void setPos(final SqlParserPos pos) {
41  this.pos = pos;
42  }
43 
44  public void setTableName(final String tableName) {
45  this.tableName = tableName;
46  }
47 
48  public void alterOptions(final Map<String, String> options) {
49  this.alterType = AlterType.ALTER_OPTIONS;
50  this.options = options;
51  }
52 
53  public void alterTableName(final String newName) {
54  this.alterType = AlterType.RENAME_TABLE;
55  this.newTableName = newName;
56  }
57 
58  public void alterColumnName(final String oldName, final String newName) {
59  this.alterType = AlterType.RENAME_COLUMN;
60  this.oldColumnName = oldName;
61  this.newColumnName = newName;
62  }
63 
65  return new SqlAlterForeignTable(pos,
66  alterType,
67  tableName,
71  super.options);
72  }
73  }
74 
75  @Expose
77  @Expose
78  private String tableName;
79  @Expose
80  private String newTableName;
81  @Expose
82  private String oldColumnName;
83  @Expose
84  private String newColumnName;
85  @Expose
86  private Map<String, String> options;
87 
88  public SqlAlterForeignTable(final SqlParserPos pos,
89  final AlterType alterType,
90  final String tableName,
91  final String newTableName,
92  final String oldColumnName,
93  final String newColumnName,
94  final Map<String, String> options) {
95  super(OPERATOR, pos);
96  this.alterType = alterType;
97  this.tableName = tableName;
98  this.newTableName = newTableName;
99  this.oldColumnName = oldColumnName;
100  this.newColumnName = newColumnName;
101  this.options = options;
102  }
103 }
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)