OmniSciDB  91042dcc5b
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SqlDropPolicy.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.SqlDrop;
6 import org.apache.calcite.sql.SqlIdentifier;
7 import org.apache.calcite.sql.SqlKind;
8 import org.apache.calcite.sql.SqlNode;
9 import org.apache.calcite.sql.SqlOperator;
10 import org.apache.calcite.sql.SqlSpecialOperator;
11 import org.apache.calcite.sql.parser.SqlParserPos;
13 import org.apache.calcite.util.JsonBuilder;
14 
15 import java.util.List;
16 import java.util.Map;
17 
21 public class SqlDropPolicy extends SqlDrop implements JsonSerializableDdl {
22  private static final SqlOperator OPERATOR =
23  new SqlSpecialOperator("DROP_POLICY", SqlKind.OTHER_DDL);
24 
25  @Expose
26  private String command;
27  @Expose
28  private List<String> columnName;
29  @Expose
30  private SqlIdentifier granteeName;
31 
32  public SqlDropPolicy(final SqlParserPos pos,
33  final List<String> columnName,
34  final SqlIdentifier granteeName) {
35  super(OPERATOR, pos, /*ifExists=*/false);
36  this.command = OPERATOR.getName();
37  this.columnName = columnName;
38  this.granteeName = granteeName;
39  }
40 
41  @Override
42  public List<SqlNode> getOperandList() {
43  return null;
44  }
45 
46  @Override
47  public String toString() {
48  return toJsonString();
49  }
50 
51  @Override
52  public String toJsonString() {
53  JsonBuilder jsonBuilder = new EscapedStringJsonBuilder();
54  Map<String, Object> map = jsonBuilder.map();
55 
56  map.put("command", this.command);
57  map.put("columnName", this.columnName);
58  map.put("granteeName", this.granteeName.toString());
59 
60  Map<String, Object> payload = jsonBuilder.map();
61  payload.put("payload", map);
62 
63  // To Debug:
64  // System.out.println(jsonBuilder.toJsonString(payload))
65 
66  return jsonBuilder.toJsonString(payload);
67  }
68 }
SqlDropPolicy(final SqlParserPos pos, final List< String > columnName, final SqlIdentifier granteeName)