john-bodley commented on code in PR #26355:
URL: https://github.com/apache/superset/pull/26355#discussion_r1446756788


##########
superset/db_engine_specs/trino.py:
##########
@@ -58,7 +58,10 @@ def extra_table_metadata(
         table_name: str,
         schema_name: str | None,
     ) -> dict[str, Any]:
-        metadata = {}
+        metadata: dict[str, Any] = {}
+
+        if not database.has_table_by_name(table_name):

Review Comment:
   @Khrol the issue with this method is it only checks physical tables (as 
opposed to tables and views).
   
   Is there any reason not to implement my previous suggestion and override the 
`TrinoEngineSpec.get_indexes()` method? In addition to working both for tables 
and views  itwould actually be more efficient as well as it requires one fewer 
checks, i.e., asking for forgiveness (via a `try`/`except` block) instead of 
for permission (via the `has_table_by_name()` method).



##########
tests/integration_tests/databases/api_tests.py:
##########
@@ -1340,6 +1340,22 @@ def test_get_invalid_table_table_extra_metadata(self):
         self.assertEqual(rv.status_code, 200)
         self.assertEqual(data, {})
 
+    def test_get_invalid_table_table_extra_metadata_trino(self):

Review Comment:
   If I were you, I would add it to 
`tests/integration_tests/db_engine_specs/test_trino.py`. Assuming you augment 
the `get_indexes()` method—per my previous comment—you can see other test cases 
where the `get_indexes()` method is being tested. You'll have to mock 
SQLAlchemy's `get_indexes()` method in a similar fashion to 
[this](https://github.com/apache/superset/blob/ea4e9a6403086d4e1de84e8197c08e8114dceeed/tests/integration_tests/db_engine_specs/base_engine_spec_tests.py#L530-L550)
 test.
   
    



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to