ColinLeeo commented on code in PR #13158:
URL: https://github.com/apache/iotdb/pull/13158#discussion_r1903210693
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/AuthorRStatement.java:
##########
@@ -0,0 +1,189 @@
+package org.apache.iotdb.db.queryengine.plan.relational.sql.ast;
+
+import org.apache.iotdb.commons.auth.entity.PrivilegeType;
+import org.apache.iotdb.db.queryengine.plan.analyze.QueryType;
+import org.apache.iotdb.db.queryengine.plan.relational.type.AuthorRType;
+
+import com.google.common.collect.ImmutableList;
+
+import java.util.List;
+import java.util.Objects;
+
+public class AuthorRStatement extends Statement {
+
+ private final AuthorRType authorType;
+
+ private String tableName;
+ private String database;
+ private String userName;
+ private String roleName;
+
+ private String password;
+
+ private PrivilegeType privilegeType;
+
+ private boolean grantOption;
+
+ public AuthorRStatement(
+ AuthorRType authorType,
+ String database,
+ String table,
+ PrivilegeType type,
+ String username,
+ String rolename,
+ boolean grantOption) {
+ super(null);
+ this.authorType = authorType;
+ this.database = database;
+ this.tableName = table;
+ this.privilegeType = type;
+ this.roleName = rolename;
+ this.userName = username;
+ this.grantOption = grantOption;
+ }
+
+ public AuthorRStatement(AuthorRType statementType) {
+ super(null);
+ this.authorType = statementType;
+ }
+
+ public AuthorRStatement(
+ AuthorRType statementType,
+ PrivilegeType type,
+ String username,
+ String roleName,
+ boolean grantOption) {
+ super(null);
+ this.authorType = statementType;
+ this.privilegeType = type;
+ this.userName = username;
+ this.roleName = roleName;
+ this.grantOption = grantOption;
+ this.tableName = null;
+ this.database = null;
+ }
+
+ public AuthorRType getAuthorType() {
+ return authorType;
+ }
+
+ public String getTableName() {
+ return tableName;
+ }
+
+ public String getDatabase() {
+ return this.database;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public String getRoleName() {
+ return roleName;
+ }
+
+ public String getPassword() {
+ return this.password;
+ }
+
+ public boolean hasGrantOption() {
+ return grantOption;
+ }
+
+ public PrivilegeType getPrivilegeType() {
+ return privilegeType;
+ }
+
+ public void setDatabase(String database) {
+ this.database = database;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public void setRoleName(String roleName) {
+ this.roleName = roleName;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ AuthorRStatement that = (AuthorRStatement) o;
+ return grantOption == that.grantOption
+ && authorType == that.authorType
+ && Objects.equals(database, that.database)
+ && Objects.equals(tableName, that.tableName)
+ && Objects.equals(userName, that.userName)
+ && Objects.equals(roleName, that.roleName);
+ }
+
+ @Override
+ public <R, C> R accept(AstVisitor<R, C> visitor, C context) {
+ return visitor.visitAuthorRPlan(this, context);
+ }
+
+ @Override
+ public List<Node> getChildren() {
+ return ImmutableList.of();
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(
+ authorType, database, tableName, privilegeType, userName, roleName,
grantOption);
+ }
+
+ public QueryType getQueryType() {
+ switch (this.authorType) {
+ case GRANT_ROLE_DB:
+ case GRANT_USER_DB:
+ case REVOKE_ROLE_DB:
+ case REVOKE_USER_DB:
+ case GRANT_ROLE_TB:
+ case GRANT_USER_TB:
+ case REVOKE_ROLE_TB:
+ case REVOKE_USER_TB:
+ case DROP_ROLE:
+ case DROP_USER:
+ case GRANT_USER_ROLE:
+ case GRANT_USER_SYS:
+ case GRANT_ROLE_SYS:
+ case CREATE_ROLE:
+ case CREATE_USER:
+ case REVOKE_ROLE_SYS:
+ case REVOKE_USER_SYS:
+ case REVOKE_USER_ROLE:
+ return QueryType.WRITE;
+ case LIST_ROLE:
+ case LIST_USER:
+ return QueryType.READ;
+ default:
+ throw new IllegalArgumentException("Unknow authorType:" +
this.authorType);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "auth statement: "
+ + authorType
+ + "to Database"
+ + database
+ + " "
+ + tableName
+ + "user name:"
+ + userName
+ + "role name"
Review Comment:
This file is not exist in this pr, see RelationalAuthorStatement.java.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]