Skip to content

Commit

Permalink
Create space on folder creation
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpannek committed Feb 22, 2025
1 parent a5de7f8 commit 6d03064
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 21 deletions.
3 changes: 3 additions & 0 deletions dbt/adapters/dremio/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 2 additions & 13 deletions dbt/include/dremio/macros/get_custom_name/get_custom_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,18 @@ 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 -%}

{{ default_schema }}

{%- else -%}

{{ custom_schema_name }}
{{default_schema}}.{{ custom_schema_name }}

{%- endif -%}
{%- endmacro %}
10 changes: 2 additions & 8 deletions tests/utils/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 = {
Expand All @@ -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,
Expand Down

0 comments on commit 6d03064

Please sign in to comment.