Skip to content

Commit 7cc29e1

Browse files
committed
no message
1 parent 2d4cfb6 commit 7cc29e1

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

dbt-spark/src/dbt/adapters/spark/impl.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ def _build_spark_relation_list(
201201
self,
202202
row_list: "agate.Table",
203203
relation_info_func: Callable[["agate.Row"], RelationInfo],
204+
schema_relation: Optional[BaseRelation] = None,
204205
) -> List[BaseRelation]:
205206
"""Aggregate relations with format metadata included."""
206207
relations = []
@@ -217,6 +218,7 @@ def _build_spark_relation_list(
217218
is_iceberg: bool = "Provider: iceberg" in information
218219

219220
relation: BaseRelation = self.Relation.create(
221+
database=schema_relation.database if schema_relation else None,
220222
schema=_schema,
221223
identifier=name,
222224
type=rel_type,
@@ -241,6 +243,7 @@ def list_relations_without_caching(self, schema_relation: BaseRelation) -> List[
241243
return self._build_spark_relation_list(
242244
row_list=show_table_extended_rows,
243245
relation_info_func=self._get_relation_information,
246+
schema_relation=schema_relation,
244247
)
245248
except DbtRuntimeError as e:
246249
errmsg = getattr(e, "msg", "")
@@ -258,6 +261,7 @@ def list_relations_without_caching(self, schema_relation: BaseRelation) -> List[
258261
return self._build_spark_relation_list(
259262
row_list=show_table_rows,
260263
relation_info_func=self._get_relation_information_using_describe,
264+
schema_relation=schema_relation,
261265
)
262266
except DbtRuntimeError as e:
263267
description = "Error while retrieving information about"
@@ -270,9 +274,6 @@ def list_relations_without_caching(self, schema_relation: BaseRelation) -> List[
270274
return []
271275

272276
def get_relation(self, database: str, schema: str, identifier: str) -> Optional[BaseRelation]:
273-
if not self.Relation.get_default_include_policy().database:
274-
database = None # type: ignore
275-
276277
return super().get_relation(database, schema, identifier)
277278

278279
def parse_describe_extended(

dbt-spark/src/dbt/include/spark/macros/adapters.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@
294294

295295
{% macro spark__list_relations_without_caching(relation) %}
296296
{% call statement('list_relations_without_caching', fetch_result=True) -%}
297-
show table extended in {{ relation.schema }} like '*'
297+
show table extended in {{ relation.include(identifier=false) }} like '*'
298298
{% endcall %}
299299

300300
{% do return(load_result('list_relations_without_caching').table) %}
@@ -305,7 +305,7 @@
305305
{#-- V2 iceberg tables #}
306306
{#-- https://issues.apache.org/jira/browse/SPARK-33393 #}
307307
{% call statement('list_relations_without_caching_show_tables', fetch_result=True) -%}
308-
show tables in {{ schema_relation.schema }} like '*'
308+
show tables in {{ schema_relation.include(identifier=false) }} like '*'
309309
{% endcall %}
310310

311311
{% do return(load_result('list_relations_without_caching_show_tables').table) %}
@@ -323,7 +323,7 @@
323323

324324
{% macro spark__list_schemas(database) -%}
325325
{% call statement('list_schemas', fetch_result=True, auto_begin=False) %}
326-
show databases
326+
show databases {% if database %}in {{ database }}{% endif %}
327327
{% endcall %}
328328
{{ return(load_result('list_schemas').table) }}
329329
{% endmacro %}
@@ -350,7 +350,7 @@
350350

351351

352352
{% macro spark__generate_database_name(custom_database_name=none, node=none) -%}
353-
{% do return(None) %}
353+
{{ return(default__generate_database_name(custom_database_name, node)) }}
354354
{%- endmacro %}
355355

356356
{% macro spark__persist_docs(relation, model, for_relation, for_columns) -%}

0 commit comments

Comments
 (0)