From 6d0306458fb64a95dda36991f16b44a0f139dd88 Mon Sep 17 00:00:00 2001 From: Simon Pannek Date: Sat, 22 Feb 2025 15:16:47 +0000 Subject: [PATCH] Create space on folder creation --- dbt/adapters/dremio/connections.py | 3 +++ .../macros/get_custom_name/get_custom_schema.sql | 15 ++------------- tests/utils/util.py | 10 ++-------- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/dbt/adapters/dremio/connections.py b/dbt/adapters/dremio/connections.py index 5f590e71..0ff477e8 100644 --- a/dbt/adapters/dremio/connections.py +++ b/dbt/adapters/dremio/connections.py @@ -229,6 +229,9 @@ def create_catalog(self, relation): if database != credentials.datalake: logger.debug(f"Creating folder(s): {database}.{schema}") self._create_folders(database, schema, rest_client) + else: + logger.debug(f"Creating folder(s): {credentials.database}.{schema}") + self._create_folders(credentials.database, schema, rest_client) return # dbt docs integration with Dremio wikis and tags diff --git a/dbt/include/dremio/macros/get_custom_name/get_custom_schema.sql b/dbt/include/dremio/macros/get_custom_name/get_custom_schema.sql index e616caea..18d8624b 100644 --- a/dbt/include/dremio/macros/get_custom_name/get_custom_schema.sql +++ b/dbt/include/dremio/macros/get_custom_name/get_custom_schema.sql @@ -13,21 +13,10 @@ See the License for the specific language governing permissions and limitations under the License.*/ {% macro dremio__generate_schema_name(custom_schema_name, node) -%} - {%- set default_schema = target.schema if not is_datalake_node(node) - else target.root_path -%} - {%- set custom_schema_name = custom_schema_name if not is_datalake_node(node) - else node.config.root_path -%} - {%- set custom_schema_name = append_schema(default_schema, custom_schema_name) if not is_datalake_node(node) - else append_schema(custom_schema_name or default_schema, node.config.schema) -%} + {%- set default_schema = target.schema -%} {{ generate_schema_name_impl(default_schema, custom_schema_name, node) }} {%- endmacro %} -{% macro append_schema(base_path, custom_schema) -%} - {{ base_path if custom_schema is none - else custom_schema if base_path in [none, 'no_schema'] - else base_path ~ '.' ~ custom_schema}} -{%- endmacro %} - {% macro generate_schema_name_impl(default_schema, custom_schema_name=none, node=none) -%} {%- if custom_schema_name is none -%} @@ -35,7 +24,7 @@ limitations under the License.*/ {%- else -%} - {{ custom_schema_name }} + {{default_schema}}.{{ custom_schema_name }} {%- endif -%} {%- endmacro %} diff --git a/tests/utils/util.py b/tests/utils/util.py index 46d86b67..9c6a7b7a 100644 --- a/tests/utils/util.py +++ b/tests/utils/util.py @@ -21,9 +21,6 @@ logger = AdapterLogger("dremio") -import logging -LOGGER = logging.getLogger(__name__) - # Ensure we do not include dashes in our source # https://github.com/dremio/dbt-dremio/issues/68 BUCKET = "dbtdremios3" @@ -51,14 +48,13 @@ def relation_from_name(adapter, name: str, materialization=""): # only identifier was supplied. # if the relation is a view then use database - LOGGER.info(f"Credentials: {credentials}") if materialization == "view" or "view" in name: relation_parts.insert(0, credentials.database) - relation_parts.insert(1, credentials.schema) else: relation_parts.insert(0, credentials.datalake) - relation_parts.insert(1, credentials.root_path) + relation_parts.insert(1, credentials.schema) + relation_type = "table" if materialization != "view" and "view" not in name else "view" kwargs = { @@ -68,8 +64,6 @@ def relation_from_name(adapter, name: str, materialization=""): "type": relation_type, } - LOGGER.info(f"Relation kwargs: {kwargs}") - relation = cls.create( include_policy=include_policy, quote_policy=quote_policy,