jerryshao commented on code in PR #14915: URL: https://github.com/apache/gravitino/pull/14915#discussion_r4585396318
########## api/src/main/java/org/apache/gravitino/glossary/TermBinding.java: ########## @@ -0,0 +1,168 @@ +/* + * 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.glossary; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableSet; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import javax.annotation.Nullable; +import org.apache.commons.lang3.StringUtils; +import org.apache.gravitino.MetadataObject; +import org.apache.gravitino.annotation.Evolving; + +/** + * A binding links a glossary term to the data behind it. A binding is direct only: binding a table + * does not bind its columns. + * + * <p>This public value identifies targets by their names. The server resolves each target to its + * own stable ID for persistence, including a metric ID rather than its containing model's ID. The + * storage key does not include the metric name. A binding grants no access to its target, and a + * {@link Kind#USED_BY} binding does not by itself establish that the metric computes the term. + */ +@Evolving +public final class TermBinding { + + /** The kind of a binding. */ + public enum Kind { + /** The object stores or computes the term, for example a table or a column. */ + IMPLEMENTED_BY, + /** A metric of a semantic model is built from the term. */ + USED_BY + } + + /** The types of the metadata objects that can implement a term. */ + public static final Set<MetadataObject.Type> IMPLEMENTED_BY_TYPES = + ImmutableSet.of( + MetadataObject.Type.CATALOG, + MetadataObject.Type.SCHEMA, + MetadataObject.Type.TABLE, + MetadataObject.Type.VIEW, + MetadataObject.Type.COLUMN, + MetadataObject.Type.FILESET, + MetadataObject.Type.TOPIC, + MetadataObject.Type.MODEL); + + private final Kind kind; + private final MetadataObject object; + @Nullable private final String metric; + + private TermBinding(Kind kind, MetadataObject object, @Nullable String metric) { + this.kind = kind; + this.object = object; Review Comment: [P2] If a caller passes a `MetadataObjectDTO` for `dw.sales.orders` to `implementedBy` and later changes the DTO to `dw.sales.returns`, the existing binding also points at `returns`. This affects `usedBy` and bindings already returned in a `TermBindingPage`. Could the constructor snapshot the target’s parent, name and type into an immutable metadata object? A regression test that mutates the original target should verify that the binding keeps its original name and hash code. -- 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]
