OmniSciDB  c0231cc57d
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SqlCreatePolicy.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.SqlCreate;
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.SqlNodeList;
11 import org.apache.calcite.sql.SqlSpecialOperator;
12 import org.apache.calcite.sql.parser.SqlParserPos;
14 import org.apache.calcite.util.JsonBuilder;
15 
16 import java.util.List;
17 import java.util.Map;
18 
22 public class SqlCreatePolicy extends SqlCreate {
23  private static final SqlOperator OPERATOR =
24  new SqlSpecialOperator("CREATE_POLICY", SqlKind.OTHER_DDL);
25 
26  @Expose
27  private String command;
28  @Expose
29  private List<String> columnName;
30  @Expose
31  private SqlNodeList valuesList;
32  @Expose
33  private SqlIdentifier granteeName;
34 
35  public SqlCreatePolicy(final SqlParserPos pos,
36  final List<String> columnName,
37  final SqlNodeList valuesList,
38  final SqlIdentifier granteeName) {
39  super(OPERATOR, pos, false, false);
40  this.command = OPERATOR.getName();
41  this.columnName = columnName;
42  this.valuesList = valuesList;
43  this.granteeName = granteeName;
44  }
45 
46  @Override
47  public List<SqlNode> getOperandList() {
48  return null;
49  }
50 
51  @Override
52  public String toString() {
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 
59  List<Object> v = jsonBuilder.list();
60  if (this.valuesList != null) {
61  for (SqlNode n : this.valuesList) {
62  v.add(n.toString());
63  }
64  }
65  jsonBuilder.put(map, "valuesList", v);
66 
67  map.put("granteeName", this.granteeName.toString());
68 
69  Map<String, Object> payload = jsonBuilder.map();
70  payload.put("payload", map);
71 
72  // To Debug:
73  // System.out.println(jsonBuilder.toJsonString(payload))
74 
75  return jsonBuilder.toJsonString(payload);
76  }
77 }
constexpr double n
Definition: Utm.h:38
SqlCreatePolicy(final SqlParserPos pos, final List< String > columnName, final SqlNodeList valuesList, final SqlIdentifier granteeName)