prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Use `show objects in schema` on Snowflake
  ### Describe the feature
  dbt should leverage the `show terse objects in schema` query to list the tables and views in a database. Crucially, `show ....` queries _do not require a running warehouse_, so they will not queue in the virtual warehouse (leading to long perceived startup times).
  
  Caveats:
   - Snowflake's docs indicate that only 10k records can be returned from one of these queries. I'd like to talk to someone from Snowflake to get an understanding if this limit is still accurate, or if they have near-term plans to lift this restriction.
   - The existing info schema query gets away with a case-insensitive lookup using `ilike, but we'll need to quote and case the schema name exactly for this query to succeed.
  - Per [the docs](https://docs.snowflake.net/manuals/sql-reference/sql/show-objects.html), materialized views are returned with type `VIEW`, which is kind of unpleasant.
  - We should post-process the results in Python instead of using `result_scan`, because selecting from `result_scan` can queue
  
  </issue>
  <code>
  [start of plugins/snowflake/dbt/adapters/snowflake/impl.py]
  1 from typing import Mapping, Any, Optional, List
  2 
  3 import agate
  4 
  5 from dbt.adapters.sql import SQLAdapter
  6 from dbt.adapters.sql.impl import LIST_SCHEMAS_MACRO_NAME
  7 from dbt.adapters.snowflake import SnowflakeConnectionManager
  8 from dbt.adapters.snowflake import SnowflakeRelation
  9 from dbt.adapters.snowflake import SnowflakeColumn
  10 from dbt.contracts.graph.manifest import Manifest
  11 from dbt.exceptions import RuntimeException, DatabaseException
  12 from dbt.utils import filter_null_values
  13 
  14 
  15 class SnowflakeAdapter(SQLAdapter):
  16     Relation = SnowflakeRelation
  17     Column = SnowflakeColumn
  18     ConnectionManager = SnowflakeConnectionManager
  19 
  20     AdapterSpecificConfigs = frozenset(
  21         {"transient", "cluster_by", "automatic_clustering", "secure",
  22          "copy_grants", "snowflake_warehouse"}
  23     )
  24 
  25     @classmethod
  26     def date_function(cls):
  27         return "CURRENT_TIMESTAMP()"
  28 
  29     @classmethod
  30     def _catalog_filter_table(
  31         cls, table: agate.Table, manifest: Manifest
  32     ) -> agate.Table:
  33         # On snowflake, users can set QUOTED_IDENTIFIERS_IGNORE_CASE, so force
  34         # the column names to their lowercased forms.
  35         lowered = table.rename(
  36             column_names=[c.lower() for c in table.column_names]
  37         )
  38         return super()._catalog_filter_table(lowered, manifest)
  39 
  40     def _make_match_kwargs(self, database, schema, identifier):
  41         quoting = self.config.quoting
  42         if identifier is not None and quoting["identifier"] is False:
  43             identifier = identifier.upper()
  44 
  45         if schema is not None and quoting["schema"] is False:
  46             schema = schema.upper()
  47 
  48         if database is not None and quoting["database"] is False:
  49             database = database.upper()
  50 
  51         return filter_null_values(
  52             {"identifier": identifier, "schema": schema, "database": database}
  53         )
  54 
  55     def _get_warehouse(self) -> str:
  56         _, table = self.execute(
  57             'select current_warehouse() as warehouse',
  58             fetch=True
  59         )
  60         if len(table) == 0 or len(table[0]) == 0:
  61             # can this happen?
  62             raise RuntimeException(
  63                 'Could not get current warehouse: no results'
  64             )
  65         return str(table[0][0])
  66 
  67     def _use_warehouse(self, warehouse: str):
  68         """Use the given warehouse. Quotes are never applied."""
  69         self.execute('use warehouse {}'.format(warehouse))
  70 
  71     def pre_model_hook(self, config: Mapping[str, Any]) -> Optional[str]:
  72         default_warehouse = self.config.credentials.warehouse
  73         warehouse = config.get('snowflake_warehouse', default_warehouse)
  74         if warehouse == default_warehouse or warehouse is None:
  75             return None
  76         previous = self._get_warehouse()
  77         self._use_warehouse(warehouse)
  78         return previous
  79 
  80     def post_model_hook(
  81         self, config: Mapping[str, Any], context: Optional[str]
  82     ) -> None:
  83         if context is not None:
  84             self._use_warehouse(context)
  85 
  86     def list_schemas(self, database: str) -> List[str]:
  87         try:
  88             results = self.execute_macro(
  89                 LIST_SCHEMAS_MACRO_NAME,
  90                 kwargs={'database': database}
  91             )
  92         except DatabaseException as exc:
  93             msg = (
  94                 f'Database error while listing schemas in database '
  95                 f'"{database}"\n{exc}'
  96             )
  97             raise RuntimeException(msg)
  98         # this uses 'show terse schemas in database', and the column name we
  99         # want is 'name'
  100 
  101         return [row['name'] for row in results]
  102
  [end of plugins/snowflake/dbt/adapters/snowflake/impl.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/plugins/snowflake/dbt/adapters/snowflake/impl.py b/plugins/snowflake/dbt/adapters/snowflake/impl.py
  --- a/plugins/snowflake/dbt/adapters/snowflake/impl.py
  +++ b/plugins/snowflake/dbt/adapters/snowflake/impl.py
  @@ -3,7 +3,10 @@
   import agate
   
   from dbt.adapters.sql import SQLAdapter
  -from dbt.adapters.sql.impl import LIST_SCHEMAS_MACRO_NAME
  +from dbt.adapters.sql.impl import (
  +    LIST_SCHEMAS_MACRO_NAME,
  +    LIST_RELATIONS_MACRO_NAME,
  +)
   from dbt.adapters.snowflake import SnowflakeConnectionManager
   from dbt.adapters.snowflake import SnowflakeRelation
   from dbt.adapters.snowflake import SnowflakeColumn
  @@ -99,3 +102,43 @@
           # want is 'name'
   
           return [row['name'] for row in results]
  +
  +    def list_relations_without_caching(
  +            self, information_schema, schema
  +    ) -> List[SnowflakeRelation]:
  +        kwargs = {'information_schema': information_schema, 'schema': schema}
  +        try:
  +            results = self.execute_macro(
  +                LIST_RELATIONS_MACRO_NAME,
  +                kwargs=kwargs
  +            )
  +        except DatabaseException as exc:
  +            # if the schema doesn't exist, we just want to return.
  +            # Alternatively, we could query the list of schemas before we start
  +            # and skip listing the missing ones, which sounds expensive.
  +            if 'Object does not exist' in str(exc):
  +                return []
  +            raise
  +
  +        relations = []
  +        quote_policy = {
  +            'database': True,
  +            'schema': True,
  +            'identifier': True
  +        }
  +
  +        columns = ['database_name', 'schema_name', 'name', 'kind']
  +        for _database, _schema, _identifier, _type in results.select(columns):
  +            try:
  +                _type = self.Relation.get_relation_type(_type.lower())
  +            except ValueError:
  +                _type = self.Relation.External
  +            relations.append(self.Relation.create(
  +                database=_database,
  +                schema=_schema,
  +                identifier=_identifier,
  +                quote_policy=quote_policy,
  +                type=_type
  +            ))
  +
  +        return relations
  
verification_info: {"golden_diff": "diff --git a/plugins/snowflake/dbt/adapters/snowflake/impl.py b/plugins/snowflake/dbt/adapters/snowflake/impl.py\n--- a/plugins/snowflake/dbt/adapters/snowflake/impl.py\n+++ b/plugins/snowflake/dbt/adapters/snowflake/impl.py\n@@ -3,7 +3,10 @@\n import agate\n \n from dbt.adapters.sql import SQLAdapter\n-from dbt.adapters.sql.impl import LIST_SCHEMAS_MACRO_NAME\n+from dbt.adapters.sql.impl import (\n+    LIST_SCHEMAS_MACRO_NAME,\n+    LIST_RELATIONS_MACRO_NAME,\n+)\n from dbt.adapters.snowflake import SnowflakeConnectionManager\n from dbt.adapters.snowflake import SnowflakeRelation\n from dbt.adapters.snowflake import SnowflakeColumn\n@@ -99,3 +102,43 @@\n         # want is 'name'\n \n         return [row['name'] for row in results]\n+\n+    def list_relations_without_caching(\n+            self, information_schema, schema\n+    ) -> List[SnowflakeRelation]:\n+        kwargs = {'information_schema': information_schema, 'schema': schema}\n+        try:\n+            results = self.execute_macro(\n+                LIST_RELATIONS_MACRO_NAME,\n+                kwargs=kwargs\n+            )\n+        except DatabaseException as exc:\n+            # if the schema doesn't exist, we just want to return.\n+            # Alternatively, we could query the list of schemas before we start\n+            # and skip listing the missing ones, which sounds expensive.\n+            if 'Object does not exist' in str(exc):\n+                return []\n+            raise\n+\n+        relations = []\n+        quote_policy = {\n+            'database': True,\n+            'schema': True,\n+            'identifier': True\n+        }\n+\n+        columns = ['database_name', 'schema_name', 'name', 'kind']\n+        for _database, _schema, _identifier, _type in results.select(columns):\n+            try:\n+                _type = self.Relation.get_relation_type(_type.lower())\n+            except ValueError:\n+                _type = self.Relation.External\n+            relations.append(self.Relation.create(\n+                database=_database,\n+                schema=_schema,\n+                identifier=_identifier,\n+                quote_policy=quote_policy,\n+                type=_type\n+            ))\n+\n+        return relations\n", "issue": "Use `show objects in schema` on Snowflake\n### Describe the feature\r\ndbt should leverage the `show terse objects in schema` query to list the tables and views in a database. Crucially, `show ....` queries _do not require a running warehouse_, so they will not queue in the virtual warehouse (leading to long perceived startup times).\r\n\r\nCaveats:\r\n - Snowflake's docs indicate that only 10k records can be returned from one of these queries. I'd like to talk to someone from Snowflake to get an understanding if this limit is still accurate, or if they have near-term plans to lift this restriction.\r\n - The existing info schema query gets away with a case-insensitive lookup using `ilike, but we'll need to quote and case the schema name exactly for this query to succeed.\r\n- Per [the docs](https://docs.snowflake.net/manuals/sql-reference/sql/show-objects.html), materialized views are returned with type `VIEW`, which is kind of unpleasant.\r\n- We should post-process the results in Python instead of using `result_scan`, because selecting from `result_scan` can queue\n", "before_files": [{"content": "from typing import Mapping, Any, Optional, List\n\nimport agate\n\nfrom dbt.adapters.sql import SQLAdapter\nfrom dbt.adapters.sql.impl import LIST_SCHEMAS_MACRO_NAME\nfrom dbt.adapters.snowflake import SnowflakeConnectionManager\nfrom dbt.adapters.snowflake import SnowflakeRelation\nfrom dbt.adapters.snowflake import SnowflakeColumn\nfrom dbt.contracts.graph.manifest import Manifest\nfrom dbt.exceptions import RuntimeException, DatabaseException\nfrom dbt.utils import filter_null_values\n\n\nclass SnowflakeAdapter(SQLAdapter):\n    Relation = SnowflakeRelation\n    Column = SnowflakeColumn\n    ConnectionManager = SnowflakeConnectionManager\n\n    AdapterSpecificConfigs = frozenset(\n        {\"transient\", \"cluster_by\", \"automatic_clustering\", \"secure\",\n         \"copy_grants\", \"snowflake_warehouse\"}\n    )\n\n    @classmethod\n    def date_function(cls):\n        return \"CURRENT_TIMESTAMP()\"\n\n    @classmethod\n    def _catalog_filter_table(\n        cls, table: agate.Table, manifest: Manifest\n    ) -> agate.Table:\n        # On snowflake, users can set QUOTED_IDENTIFIERS_IGNORE_CASE, so force\n        # the column names to their lowercased forms.\n        lowered = table.rename(\n            column_names=[c.lower() for c in table.column_names]\n        )\n        return super()._catalog_filter_table(lowered, manifest)\n\n    def _make_match_kwargs(self, database, schema, identifier):\n        quoting = self.config.quoting\n        if identifier is not None and quoting[\"identifier\"] is False:\n            identifier = identifier.upper()\n\n        if schema is not None and quoting[\"schema\"] is False:\n            schema = schema.upper()\n\n        if database is not None and quoting[\"database\"] is False:\n            database = database.upper()\n\n        return filter_null_values(\n            {\"identifier\": identifier, \"schema\": schema, \"database\": database}\n        )\n\n    def _get_warehouse(self) -> str:\n        _, table = self.execute(\n            'select current_warehouse() as warehouse',\n            fetch=True\n        )\n        if len(table) == 0 or len(table[0]) == 0:\n            # can this happen?\n            raise RuntimeException(\n                'Could not get current warehouse: no results'\n            )\n        return str(table[0][0])\n\n    def _use_warehouse(self, warehouse: str):\n        \"\"\"Use the given warehouse. Quotes are never applied.\"\"\"\n        self.execute('use warehouse {}'.format(warehouse))\n\n    def pre_model_hook(self, config: Mapping[str, Any]) -> Optional[str]:\n        default_warehouse = self.config.credentials.warehouse\n        warehouse = config.get('snowflake_warehouse', default_warehouse)\n        if warehouse == default_warehouse or warehouse is None:\n            return None\n        previous = self._get_warehouse()\n        self._use_warehouse(warehouse)\n        return previous\n\n    def post_model_hook(\n        self, config: Mapping[str, Any], context: Optional[str]\n    ) -> None:\n        if context is not None:\n            self._use_warehouse(context)\n\n    def list_schemas(self, database: str) -> List[str]:\n        try:\n            results = self.execute_macro(\n                LIST_SCHEMAS_MACRO_NAME,\n                kwargs={'database': database}\n            )\n        except DatabaseException as exc:\n            msg = (\n                f'Database error while listing schemas in database '\n                f'\"{database}\"\\n{exc}'\n            )\n            raise RuntimeException(msg)\n        # this uses 'show terse schemas in database', and the column name we\n        # want is 'name'\n\n        return [row['name'] for row in results]\n", "path": "plugins/snowflake/dbt/adapters/snowflake/impl.py"}]}