From a05a87ce8342e988ad0d390d86c3955f6bfdec46 Mon Sep 17 00:00:00 2001
From: Jorge Vasquez Rojas <jorge.vasquezrojas@snowflake.com>
Date: Mon, 9 Dec 2024 07:48:15 -0600
Subject: [PATCH] Remove caching unnecessary functions and use default_schema

---
 src/snowflake/sqlalchemy/snowdialect.py | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/src/snowflake/sqlalchemy/snowdialect.py b/src/snowflake/sqlalchemy/snowdialect.py
index 0bc5e737..27352c86 100644
--- a/src/snowflake/sqlalchemy/snowdialect.py
+++ b/src/snowflake/sqlalchemy/snowdialect.py
@@ -685,12 +685,10 @@ def get_prefixes_from_data(self, n2i, row, **kw):
     @reflection.cache
     def _get_schema_tables_info(self, connection, schema=None, **kw):
         """
-        Gets all table names.
+        Retrieves information about all tables in the specified schema.
         """
 
         schema = schema or self.default_schema_name
-        _, default_schema = self._current_database_schema(connection, **kw)
-        schema = schema or default_schema
         result = connection.execute(
             text(
                 f"SHOW /* sqlalchemy:get_schema_tables_info */ TABLES IN SCHEMA {self._denormalize_quote_join(schema)}"
@@ -706,7 +704,6 @@ def _get_schema_tables_info(self, connection, schema=None, **kw):
 
         return tables
 
-    @reflection.cache
     def get_table_names(self, connection, schema=None, **kw):
         """
         Gets all table names.
@@ -766,9 +763,7 @@ def get_view_definition(self, connection, view_name, schema=None, **kw):
         return None
 
     def get_temp_table_names(self, connection, schema=None, **kw):
-        _, default_schema = self._current_database_schema(connection, **kw)
-
-        schema = schema or default_schema
+        schema = schema or self.default_schema_name
         cursor = connection.execute(
             text(
                 f"SHOW /* sqlalchemy:get_temp_table_names */ TABLES \
@@ -855,7 +850,6 @@ def get_table_comment(self, connection, table_name, schema=None, **kw):
             )
         }
 
-    @reflection.cache
     def get_table_names_with_prefix(
         self,
         connection,
@@ -882,8 +876,7 @@ def get_multi_indexes(
         """
         Gets the indexes definition
         """
-        _, default_schema = self._current_database_schema(connection, **kw)
-        schema = schema or default_schema
+        schema = schema or self.default_schema_name
         hybrid_table_names = self.get_table_names_with_prefix(
             connection,
             schema=schema,