yuqi1129 commented on code in PR #13478: URL: https://github.com/apache/gravitino/pull/13478#discussion_r4227953447
########## core/src/main/java/org/apache/gravitino/policy/expression/CanonicalExpression.java: ########## @@ -0,0 +1,888 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.gravitino.policy.expression; + +import com.google.common.base.Preconditions; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Locale; +import java.util.Objects; + +/** + * A node in an unresolved {@code restricted-rego-v1} expression tree. + * + * <p>The tree contains only the source constructs allowlisted by the read-restriction contract. + * Column and context references remain symbolic until the effective-policy resolver binds them to a + * table schema and request context. + */ +public interface CanonicalExpression { + + /** + * Validates this expression node and all of its children. + * + * @throws IllegalArgumentException if the expression is malformed or outside the allowlisted + * source profile + */ + void validate() throws IllegalArgumentException; + + /** + * Returns the source operation depth defined by {@code restricted-rego-v1}. + * + * @return expression depth + */ + int depth(); + + /** Operators supported by {@code restricted-rego-v1}. */ + enum Operator { + /** Equality comparison. */ + EQ("eq"), + /** Inequality comparison. */ + NEQ("neq"), + /** Less-than comparison. */ + LT("lt"), + /** Less-than-or-equal comparison. */ + LTE("lte"), + /** Greater-than comparison. */ + GT("gt"), + /** Greater-than-or-equal comparison. */ + GTE("gte"), + /** Literal-array membership comparison. */ + IN("in"), + /** Boolean conjunction. */ + AND("and"), + /** Boolean disjunction. */ + OR("or"), + /** Boolean negation. */ + NOT("not"); + + private final String value; + + Operator(String value) { + this.value = value; + } + + /** + * Parses a source or canonical operator value. + * + * @param value operator value + * @return parsed operator + */ + public static Operator fromValue(String value) { Review Comment: For EQ, is the value `==` or `eq`? It's not consistent with the enum value you defined. -- 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]
