Skip to content

Commit

Permalink
Fixed issue
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulgoyal2987 committed Dec 9, 2024
1 parent 81877b8 commit 3d46cea
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions dbt/adapters/spark/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,24 +207,39 @@ def list_relations_without_caching(self, schema_relation: BaseRelation) -> List[
logger.debug(f"{description} {schema_relation}: {e.msg}")
return []

def set_relation_information(self, relation: BaseRelation) -> BaseRelation:
if relation.information:
return relation
rows: List[agate.Row] = super().get_columns_in_relation(relation)
def _get_relation_information_using_describe(self, relation: BaseRelation) -> RelationInfo:
"""Relation info fetched using SHOW TABLES and an auxiliary DESCRIBE statement"""
_schema = relation.schema
name = relation.identifier
table_name = f"{_schema}.{name}"
try:
table_results = self.execute_macro(
DESCRIBE_TABLE_EXTENDED_MACRO_NAME, kwargs={"table_name": table_name}
)
except DbtRuntimeError as e:
logger.debug(f"Error while retrieving information about {table_name}: {e.msg}")
table_results = AttrDict()

information = ""
for info_row in rows:
info_type, info_value, _ = info_row.values()
for info_row in table_results:
info_type, info_value, _ = info_row
if not info_type.startswith("#"):
information += f"{info_type}: {info_value}\n"
return _schema, name, information

def set_relation_information(self, relation: BaseRelation) -> BaseRelation:
if relation.information:
return relation
_schema, name, information = self._get_relation_information_using_describe(relation)
rel_type: RelationType = (
RelationType.View if "Type: VIEW" in information else RelationType.Table
)
is_delta: bool = "Provider: delta" in information
is_hudi: bool = "Provider: hudi" in information
is_iceberg: bool = "Provider: iceberg" in information
updated_relation: BaseRelation = self.Relation.create(
schema=relation.schema,
identifier=relation.identifier,
schema=_schema,
identifier=name,
type=rel_type,
information=information,
is_delta=is_delta,
Expand Down

0 comments on commit 3d46cea

Please sign in to comment.