diff --git a/ibis/backends/snowflake/__init__.py b/ibis/backends/snowflake/__init__.py index a749db306eed..858e7d619741 100644 --- a/ibis/backends/snowflake/__init__.py +++ b/ibis/backends/snowflake/__init__.py @@ -507,6 +507,7 @@ def _get_temp_view_definition( def create_database(self, name: str, force: bool = False) -> None: current_database = self.current_database + current_schema = self.current_schema name = self._quote(name) if_not_exists = "IF NOT EXISTS " * force with self.begin() as con: @@ -514,8 +515,10 @@ def create_database(self, name: str, force: bool = False) -> None: # Snowflake automatically switches to the new database after creating # it per # https://docs.snowflake.com/en/sql-reference/sql/create-database#general-usage-notes - # so we switch back to the original database - con.exec_driver_sql(f"USE DATABASE {self._quote(current_database)}") + # so we switch back to the original database and schema + con.exec_driver_sql( + f"USE SCHEMA {self._quote(current_database)}.{self._quote(current_schema)}" + ) def drop_database(self, name: str, force: bool = False) -> None: current_database = self.current_database