You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/07/16 03:10:39 UTC

[GitHub] [superset] john-bodley commented on a diff in pull request #20729: fix: Ensure Presto database engine spec correctly handles Trino

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


##########
superset/db_engine_specs/presto.py:
##########
@@ -906,21 +906,23 @@ def extra_table_metadata(
         indexes = database.get_indexes(table_name, schema_name)
         if indexes:
             cols = indexes[0].get("column_names", [])
-            full_table_name = table_name
-            if schema_name and "." not in table_name:
-                full_table_name = "{}.{}".format(schema_name, table_name)
-            pql = cls._partition_query(full_table_name, database)
-            col_names, latest_parts = cls.latest_partition(
-                table_name, schema_name, database, show_first=True
-            )
+            
+            if cols:
+                full_table_name = table_name

Review Comment:
   Same logic as previous just indented under the `if cols:` statement. Unlike Presto where `get_indexes` returns `[]` for a non-partition table, Trino returns `[{'name': 'partition', 'column_names': [], 'unique': False}]`. Rather than overriding the engine specific `normalize_indexes` method I though it would be more prudent to make this method more robust given there was already an expectation that there may be no columns associated with the index, i.e., a non-partitioned table.



##########
superset/db_engine_specs/presto.py:
##########
@@ -940,20 +942,19 @@ def get_create_view(
         :param schema: Schema name
         :param table: Table (view) name
         """
-        # pylint: disable=import-outside-toplevel
-        from pyhive.exc import DatabaseError
 
         engine = cls.get_engine(database, schema)
         with closing(engine.raw_connection()) as conn:
             cursor = conn.cursor()
             sql = f"SHOW CREATE VIEW {schema}.{table}"
             try:
                 cls.execute(cursor, sql)
+                return cls.fetch_data(cursor, 1)[0][0]

Review Comment:
   This should never have been a `pyhive.exc` exception to begin with.



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org