jerryshao commented on code in PR #12499:
URL: https://github.com/apache/gravitino/pull/12499#discussion_r3829710877


##########
api/src/main/java/org/apache/gravitino/exceptions/InvalidSemanticModelException.java:
##########
@@ -0,0 +1,50 @@
+/*
+ * 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.exceptions;
+
+import com.google.errorprone.annotations.FormatMethod;
+import com.google.errorprone.annotations.FormatString;
+
+/** Exception thrown when a Semantic Model definition or change is invalid. */
+public class InvalidSemanticModelException extends IllegalArgumentException {

Review Comment:
   **Convention: naming inconsistent with sibling validation exceptions**
   
   `InvalidSemanticModelException extends IllegalArgumentException` directly, 
but every other validation-style exception in this package that extends 
`IllegalArgumentException` follows the `Illegal<Thing>Exception` naming 
convention (`IllegalNameIdentifierException`, `IllegalMetadataObjectException`, 
`IllegalPropertyException`, `IllegalNamespaceException`, 
`IllegalPrivilegeException`, `IllegalRoleException`, 
`IllegalStatisticNameException`, `IllegalJobTemplateOperationException`). This 
is the sole `Invalid*Exception` in the package. Functionally it still maps 
correctly through the generic `instanceof IllegalArgumentException` branch, but 
the naming break makes it harder to discover by convention. Consider renaming 
to `IllegalSemanticModelException` (or 
`IllegalSemanticModelDefinitionException`) to match the established family.



##########
api/src/main/java/org/apache/gravitino/semantic/SemanticModelDefinition.java:
##########
@@ -0,0 +1,265 @@
+/*
+ * 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.semantic;
+
+import com.google.common.base.Preconditions;
+import java.util.Arrays;
+import java.util.Objects;
+import javax.annotation.Nullable;
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * An immutable Semantic Model definition. This value groups the 
Ossie-compatible definition fields
+ * used when creating or replacing a Semantic Model and has no name or 
independent lifecycle.
+ */
+@Evolving
+public final class SemanticModelDefinition {

Review Comment:
   **Simplification: near-complete duplication of `SemanticModel`**
   
   `SemanticModelDefinition` duplicates almost the entire `SemanticModel` 
interface (`aiContext`, `datasets`, `relationships`, `metrics`, 
`customExtensions`) as a second class with its own Builder, defensive-copy 
accessors, and equals/hashCode/toString — two field lists / two builders that 
must be kept in sync by hand. The javadoc for the shared concepts is already 
subtly drifting between the two (e.g. "must return" vs "must override to 
return" a defensive copy). Consider having `SemanticModel` compose/wrap a 
`SemanticModelDefinition` (or the reverse) rather than maintaining two 
independent parallel structures.



-- 
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]

Reply via email to