1 package com.mapd.parser.extension.ddl;
3 import static java.util.Objects.requireNonNull;
5 import com.google.gson.annotations.Expose;
7 import org.apache.calcite.sql.SqlDdl;
8 import org.apache.calcite.sql.SqlKind;
9 import org.apache.calcite.sql.SqlNode;
10 import org.apache.calcite.sql.SqlNodeList;
12 import org.apache.calcite.sql.SqlSpecialOperator;
13 import org.apache.calcite.sql.parser.SqlParserPos;
15 import org.apache.calcite.util.JsonBuilder;
17 import java.util.List;
22 new SqlSpecialOperator(
"GRANT_ROLE", SqlKind.OTHER_DDL);
31 requireNonNull(roles);
44 Map<String, Object> map = jsonBuilder.map();
46 if (this.
roles != null) {
47 List<Object> roles_list = jsonBuilder.list();
48 for (SqlNode role : this.
roles) {
49 roles_list.add(role.toString());
51 map.put(
"roles", roles_list);
55 List<Object> grantee_list = jsonBuilder.list();
56 for (SqlNode grantee : this.
grantees) {
57 grantee_list.add(grantee.toString());
59 map.put(
"grantees", grantee_list);
62 map.put(
"command",
"GRANT_ROLE");
63 Map<String, Object> payload = jsonBuilder.map();
64 payload.put(
"payload", map);
65 return jsonBuilder.toJsonString(payload);
static final SqlOperator OPERATOR
List< SqlNode > getOperandList()
SqlGrantRole(SqlParserPos pos, SqlNodeList roles, SqlNodeList grantees)