diff --git a/superset/db_engine_specs/hive.py b/superset/db_engine_specs/hive.py index 3c541c357ea59..60786e417be6f 100644 --- a/superset/db_engine_specs/hive.py +++ b/superset/db_engine_specs/hive.py @@ -225,22 +225,23 @@ def _get_hive_type(dtype: np.dtype) -> str: ) as file: pq.write_table(pa.Table.from_pandas(df), where=file.name) - engine.execute( - text( - f""" - CREATE TABLE {str(table)} ({schema_definition}) - STORED AS PARQUET - LOCATION :location - """ - ), - location=upload_to_s3( - filename=file.name, - upload_prefix=current_app.config[ - "CSV_TO_HIVE_UPLOAD_DIRECTORY_FUNC" - ](database, g.user, table.schema), - table=table, - ), - ) + with cls.get_engine(database) as engine: + engine.execute( + text( + f""" + CREATE TABLE {str(table)} ({schema_definition}) + STORED AS PARQUET + LOCATION :location + """ + ), + location=upload_to_s3( + filename=file.name, + upload_prefix=current_app.config[ + "CSV_TO_HIVE_UPLOAD_DIRECTORY_FUNC" + ](database, g.user, table.schema), + table=table, + ), + ) @classmethod def convert_dttm(