Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

slight changes #25

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions dbt/adapters/mindsdb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from dbt.adapters.base import AdapterPlugin

from dbt.adapters.mindsdb.connections import MindsdbConnectionManager
from dbt.adapters.mindsdb.connections import MindsdbCredentials
from dbt.adapters.mindsdb.impl import MindsdbAdapter
from dbt.adapters.mindsdb.relation import MindsdbRelation

from dbt.adapters.base import AdapterPlugin
from dbt.adapters.mindsdb.impl import MindsdbAdapter
from dbt.include import mindsdb


Expand Down
4 changes: 2 additions & 2 deletions dbt/adapters/mindsdb/impl.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from dbt.adapters.sql import SQLAdapter
from dbt.adapters.mindsdb import MindsdbConnectionManager

from dbt.adapters.mindsdb import MindsdbConnectionManager, MindsdbRelation

LIST_SCHEMAS_MACRO_NAME = 'list_schemas'
LIST_RELATIONS_MACRO_NAME = 'list_relations_without_caching'

class MindsdbAdapter(SQLAdapter):
Relation = MindsdbRelation
ConnectionManager = MindsdbConnectionManager

@classmethod
Expand Down
4 changes: 2 additions & 2 deletions dbt/adapters/mindsdb/relation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dataclasses import dataclass
from dataclasses import dataclass,field
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need a space between 'dataclass, field'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks fore review and agreed


from dbt.adapters.base.relation import BaseRelation, Policy
from dbt.contracts.relation import ComponentName
Expand All @@ -13,7 +13,7 @@ class MindsdbQuotePolicy(Policy):

@dataclass(frozen=True, eq=False, repr=False)
class MindsdbRelation(BaseRelation):
quote_policy: MindsdbQuotePolicy = MindsdbQuotePolicy()
quote_policy: MindsdbQuotePolicy = field(default_factory=lambda: MindsdbQuotePolicy())

# Overridden as Mindsdb converts relation identifiers to lowercase
def _is_exactish_match(self, field: ComponentName, value: str) -> bool:
Expand Down
9 changes: 6 additions & 3 deletions dbt/include/mindsdb/macros/materialization/table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,24 @@
{%- endfor %}

-- final
{% set target_relation = target_relation_list | join('.') %}
{%- set target_relation = api.Relation.create(identifier=target_relation_list[1],
schema=target_relation_list[0],
type='table') -%}

-- ... setup database ...
-- ... run pre-hooks...
{{ run_hooks(pre_hooks) }}

-- build model
{% call statement('main') %}
{{ save_to_table_wrap(sql, target_relation) }}
{% endcall %}

-- ... run post-hooks ...
{{ run_hooks(post_hooks) }}
-- ... clean up the database...

-- Return the relations created in this materialization

{{ return({'relations': []}) }}
{{ return({'relations': [target_relation]}) }}

{%- endmaterialization -%}