Repository: firebolt-db/dbt-firebolt (language: python)

Issue:
upgrade to support dbt-core v1.2.0
We've just published the release cut of dbt-core 1.2.0, `dbt-core 1.2.0rc1` ([PyPI](https://pypi.org/project/dbt-core/1.2.0rc1/) | [GitHub release notes](https://github.com/dbt-labs/dbt-core/releases/tag/v1.2.0rc1)).

https://github.com/dbt-labs/dbt-core/discussions/5468 is an open discussion with more detailed information, and https://github.com/dbt-labs/dbt-core/issues/5474 is for keeping track of the communities progress on releasing 1.2.0

Below is a checklist of work that would enable a successful 1.2.0 release of your adapter.

- [x] migrate necessary cross-db macros into adapter and ensure they're tested accordingly
- [x] remove any copy-and-pasted materialization (if your adapter inherits from another adapter)
- [x] add new basic tests `BaseDocsGenerate` and `BaseDocsGenReferences`
- [x] consider checking and testing support for Python 3.10


https://github.com/dbt-labs/dbt-core/pull/5432 might make it into the second release cut in the next week, in which case, you'll also might want to:

- [x] implement method and tests for connection retry logic


Discussion / hints:

Fix patch:
diff --git a/dbt/include/firebolt/macros/adapters.sql b/dbt/include/firebolt/macros/adapters.sql
index 0ffcb19e6..0c3b5d44f 100644
--- a/dbt/include/firebolt/macros/adapters.sql
+++ b/dbt/include/firebolt/macros/adapters.sql
@@ -33,7 +33,7 @@
   {% endif %}
   {% call statement('list_schemas', fetch_result=True, auto_begin=False) %}
 
-      SELECT '{{target.schema}}' AS schema
+      SELECT 'public' AS schema
   {% endcall %}
   {{ return(load_result('list_schemas').table) }}
 {% endmacro %}
diff --git a/dbt/include/firebolt/macros/catalog.sql b/dbt/include/firebolt/macros/catalog.sql
index 5de463d7c..a29f0adbb 100644
--- a/dbt/include/firebolt/macros/catalog.sql
+++ b/dbt/include/firebolt/macros/catalog.sql
@@ -3,29 +3,31 @@ the columns (for instance, `is_nullable` is missing) but more could be added lat
 
 {% macro firebolt__get_catalog(information_schemas, schemas) -%}
   {%- call statement('catalog', fetch_result=True) %}
-     SELECT *, ROW_NUMBER() OVER ( PARTITION BY table_name ORDER BY table_name ASC ) as column_index FROM (
-          SELECT tbls.table_catalog AS table_database
-               , tbls.table_schema as table_schema
-               , table_type
-               , tbls.table_name
-               , cols.column_name
-               , cols.data_type AS column_type
-               , 'table' AS relation_type
-          FROM information_schema.tables tbls
-               JOIN information_schema.columns cols
-                    USING(table_name)
+     SELECT tbls.table_catalog AS table_database
+          , tbls.table_schema as table_schema
+          , table_type
+          , tbls.table_name as table_name
+          , cols.column_name as column_name
+          , cols.data_type AS column_type
+          , UPPER(tbls.table_type) as relation_type
+          , cols.ordinal_position as column_index
+     FROM  information_schema.tables tbls
+          JOIN information_schema.columns cols
+               USING(table_name)
 
-          UNION
+     UNION
 
-          SELECT views.table_catalog AS table_database
-               , views.table_schema as table_schema
-               , NULL AS table_type
-               , views.table_name
-               , NULL AS column_name
-               , NULL AS column_type
-               , 'view' AS relation_type
-          FROM information_schema.views views
-     )
+     SELECT views.table_catalog AS table_database
+          , views.table_schema as table_schema
+          , 'VIEW' AS table_type
+          , views.table_name as table_name
+          , cols.column_name AS column_name
+          , cols.data_type AS column_type
+          , 'VIEW' as relation_type
+          , cols.ordinal_position as column_index
+     FROM information_schema.views views
+          JOIN information_schema.columns cols
+               USING(table_name)
   {% endcall -%}
   {{ return(load_result('catalog').table) }}
 {%- endmacro %}


Test patch:
diff --git a/tests/functional/adapter/test_basic.py b/tests/functional/adapter/test_basic.py
index a07bf3b4a..a9c513fcb 100644
--- a/tests/functional/adapter/test_basic.py
+++ b/tests/functional/adapter/test_basic.py
@@ -1,5 +1,17 @@
+from dbt.tests.adapter.basic.expected_catalog import (
+    base_expected_catalog,
+    expected_references_catalog,
+    no_stats,
+)
 from dbt.tests.adapter.basic.test_adapter_methods import BaseAdapterMethod
 from dbt.tests.adapter.basic.test_base import BaseSimpleMaterializations
+from dbt.tests.adapter.basic.test_docs_generate import (
+    BaseDocsGenerate,
+    BaseDocsGenReferences,
+    models__model_sql,
+    models__readme_md,
+    models__schema_yml,
+)
 from dbt.tests.adapter.basic.test_empty import BaseEmpty
 from dbt.tests.adapter.basic.test_ephemeral import BaseEphemeral
 from dbt.tests.adapter.basic.test_generic_tests import BaseGenericTests
@@ -14,7 +26,7 @@
 from dbt.tests.adapter.basic.test_snapshot_timestamp import (
     BaseSnapshotTimestamp,
 )
-from pytest import mark
+from pytest import fixture, mark
 
 
 class TestSimpleMaterializationsFirebolt(BaseSimpleMaterializations):
@@ -58,3 +70,73 @@ class TestSnapshotTimestampFirebolt(BaseSnapshotTimestamp):
 @mark.skip('Requires investigation')
 class TestBaseAdapterMethod(BaseAdapterMethod):
     pass
+
+
+# Removing schema here in order for the second model to be written
+# to catalog. Firebolt does not support any schemas apart from
+# public. TODO: remove this override once schema support is added.
+models__second_model_sql = """
+{{
+    config(
+        materialized='view',
+    )
+}}
+
+select * from {{ ref('seed') }}
+"""
+
+
+class TestDocsGenerateFirebolt(BaseDocsGenerate):
+
+    # TODO: remove this override once schema support is added.
+    @fixture(scope='class')
+    def unique_schema(request, prefix) -> str:
+        return 'public'
+
+    @fixture(scope='class')
+    def models(self):
+        return {
+            'schema.yml': models__schema_yml,
+            'second_model.sql': models__second_model_sql,
+            'readme.md': models__readme_md,
+            'model.sql': models__model_sql,
+        }
+
+    @fixture(scope='class')
+    def expected_catalog(self, project, profile_user):
+        catalog = base_expected_catalog(
+            project,
+            role=None,  # No per-table roles in Firebolt
+            id_type='INT',
+            text_type='TEXT',
+            time_type='DATE',
+            view_type='VIEW',
+            table_type='DIMENSION',
+            model_stats=no_stats(),
+        )
+        # Can't have any other schema apart from public at the moment.
+        # TODO: remove once Firebolt supports schemas
+        catalog['nodes']['model.test.second_model']['metadata']['schema'] = 'public'
+        return catalog
+
+
+class TestDocsGenReferencesFirebolt(BaseDocsGenReferences):
+
+    # TODO: remove this override once schema support is added.
+    @fixture(scope='class')
+    def unique_schema(request, prefix) -> str:
+        return 'public'
+
+    @fixture(scope='class')
+    def expected_catalog(self, project, profile_user):
+        return expected_references_catalog(
+            project,
+            role=None,  # No per-table roles in Firebolt
+            id_type='INT',
+            text_type='TEXT',
+            time_type='DATE',
+            bigint_type='LONG',
+            view_type='VIEW',
+            table_type='DIMENSION',
+            model_stats=no_stats(),
+        )