Copilot commented on code in PR #13788:
URL: https://github.com/apache/gravitino/pull/13788#discussion_r4247004483


##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/CatalogConnectorMetadata.java:
##########
@@ -268,6 +327,8 @@ private void applyAlter(SchemaTableName tableName, 
TableChange... change) {
     } catch (NoSuchTableException e) {
       throw new TrinoException(
           GravitinoErrorCode.GRAVITINO_TABLE_NOT_EXISTS, "Table does not 
exist");
+    } catch (ForbiddenException e) {
+      throw toTrinoException(e);
     } catch (IllegalArgumentException e) {
       // TODO yuhui need improve get the error message. From 
IllegalArgumentException.
       // At present, the IllegalArgumentException cannot get the error 
information clearly from the

Review Comment:
   `applyAlter` now uses `toTrinoException` for `ForbiddenException` but keeps 
bespoke `IllegalArgumentException` handling (with a TODO). Since 
`toTrinoException` was introduced to standardize user-facing 
classification/messages, consider routing `IllegalArgumentException` through 
`toTrinoException` here as well to avoid duplicated/ diverging exception 
mapping logic.



##########
trino-connector/trino-connector/src/test/java/org/apache/gravitino/trino/connector/catalog/TestCatalogConnectorMetadataView.java:
##########
@@ -0,0 +1,98 @@
+/*
+ * 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.trino.connector.catalog;
+
+import static io.trino.spi.StandardErrorCode.PERMISSION_DENIED;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import io.trino.spi.TrinoException;
+import org.apache.gravitino.Catalog;
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.SupportsSchemas;
+import org.apache.gravitino.client.GravitinoMetalake;
+import org.apache.gravitino.exceptions.ForbiddenException;
+import org.apache.gravitino.exceptions.NoSuchSchemaException;
+import org.apache.gravitino.rel.TableCatalog;
+import org.apache.gravitino.rel.ViewCatalog;
+import org.junit.jupiter.api.Test;
+
+public class TestCatalogConnectorMetadataView {
+
+  @Test
+  public void testViewExists() {
+    ViewCatalog viewCatalog = mock(ViewCatalog.class);
+    when(viewCatalog.viewExists(NameIdentifier.of("s", "v"))).thenReturn(true);
+
+    assertTrue(createMetadata(viewCatalog).viewExists("s", "v"));

Review Comment:
   This stub relies on `NameIdentifier.of(\"s\", \"v\")` matching exactly via 
`equals()`. To make the test less brittle (and consistent with the other tests 
in this file), prefer stubbing with `any()` and, if needed, verify the exact 
identifier separately.



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