Repository: mindsdb/dbt-mindsdb (language: python)

Issue:
add `database` materialization 
`create database` from dbt. Not sure if it is really useful or not


Discussion / hints:

Fix patch:
diff --git a/README.md b/README.md
index a51d263..e7cfb7c 100644
--- a/README.md
+++ b/README.md
@@ -42,6 +42,27 @@ mindsdb:
 ```    
     dbt init <project_name>
 ```
+- create a intergration with "database" materialization:
+```
+    {{
+    config(
+      materialized='database',
+      engine='trino',
+      parameters={
+        "user": env_var('TRINO_USER'),
+        "auth": "basic",
+        "http_scheme": "https",
+        "port": 443,
+        "password": env_var('TRINO_PASSWORD'),
+        "host": "trino.company.com",
+        "catalog": "hive",
+        "schema": "photorep_schema",
+        "with": "with (transactional = true)"
+      }
+    )
+    }}
+```
+
 - To create predictor add dbt model with "predictor" materialization: 
 Name of the model is used as name of predictor.
 Parameters:
diff --git a/dbt/include/mindsdb/macros/materialization/database.sql b/dbt/include/mindsdb/macros/materialization/database.sql
new file mode 100644
index 0000000..3d1bf07
--- /dev/null
+++ b/dbt/include/mindsdb/macros/materialization/database.sql
@@ -0,0 +1,21 @@
+{% materialization database, adapter='mindsdb' %}
+  {%- set database = model['alias'] -%}
+  {%- set engine = config.get('engine') -%}
+  {%- set parameters = config.get('parameters') -%}
+
+  -- build model
+  {%- call statement('main') -%}
+    DROP DATABASE IF EXISTS {{ database }};
+  {%- endcall -%}
+
+
+  {%- call statement('main') -%}
+    CREATE DATABASE {{ database }} WITH ENGINE='{{engine}}',
+    PARAMETERS={{parameters}}
+  {%- endcall -%}
+
+
+  -- Return the relations created in this materialization
+  {{ return({'relations': []}) }}
+{%- endmaterialization -%}
+


Test patch:
diff --git a/tests/unit/test_mindsdb_adapter.py b/tests/unit/test_mindsdb_adapter.py
index 52728ad..38d4b53 100644
--- a/tests/unit/test_mindsdb_adapter.py
+++ b/tests/unit/test_mindsdb_adapter.py
@@ -191,3 +191,46 @@ def test_prediction(self):
         queries = self.get_dbt_queries()
 
         assert expected in queries
+
+
+
+    def test_create_database(self):
+        model = '''
+        {{
+        config(
+          materialized='database',
+          engine='trino',
+          parameters={
+            "user": "user",
+            "auth": "basic",
+            "http_scheme": "https",
+            "port": 443,
+            "password": "password",
+            "host": "localhost",
+            "catalog": "catalog",
+            "schema": "schema",
+            "with": "with (transactional = true)"
+          }
+        )
+        }}
+        '''
+
+        expected1 = 'DROP DATABASE IF EXISTS new_database'
+
+        expected2 = '''
+        CREATE DATABASE new_database WITH ENGINE='trino',
+        PARAMETERS={'user': 'user', 'auth': 'basic', 'http_scheme': 'https', 'port': 443, 'password': 'password', 'host': 'localhost', 'catalog': 'catalog', 'schema': 'schema', 'with': 'with (transactional = true)'}
+        '''
+
+        expected2 = self.sql_line_format(expected2)
+
+        self.add_model('new_database', model)
+        queries = self.get_dbt_queries()
+
+        # queries exist
+        assert expected1 in queries
+        assert expected2 in queries
+
+        # right queries order
+        assert queries.index(expected1) < queries.index(expected2)
+