Skip to content

Commit

Permalink
Merge pull request #159 from cultureamp/sa/cast-table-owner
Browse files Browse the repository at this point in the history
Cast table_owner to str
  • Loading branch information
jtcohen6 authored Apr 12, 2021
2 parents 6ad164b + 818d43c commit fe785c9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## dbt next

### Fixes

- Cast `table_owner` to string to avoid errors generating docs ([#159](https://github.com/fishtown-analytics/dbt-spark/pull/159))

## dbt-spark 0.19.1 (Release TBD)

## dbt-spark 0.19.1b2 (February 26, 2021)
Expand Down
2 changes: 1 addition & 1 deletion dbt/adapters/spark/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def parse_describe_extended(
table_schema=relation.schema,
table_name=relation.name,
table_type=relation.type,
table_owner=metadata.get(KEY_TABLE_OWNER),
table_owner=str(metadata.get(KEY_TABLE_OWNER)),
table_stats=table_stats,
column=column['col_name'],
column_index=idx,
Expand Down
27 changes: 27 additions & 0 deletions test/unit/test_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,33 @@ def test_parse_relation(self):
'char_size': None
})

def test_parse_relation_with_integer_owner(self):
self.maxDiff = None
rel_type = SparkRelation.get_relation_type.Table

relation = SparkRelation.create(
schema='default_schema',
identifier='mytable',
type=rel_type
)
assert relation.database is None

# Mimics the output of Spark with a DESCRIBE TABLE EXTENDED
plain_rows = [
('col1', 'decimal(22,0)'),
('# Detailed Table Information', None),
('Owner', 1234)
]

input_cols = [Row(keys=['col_name', 'data_type'], values=r)
for r in plain_rows]

config = self._get_target_http(self.project_cfg)
rows = SparkAdapter(config).parse_describe_extended(
relation, input_cols)

self.assertEqual(rows[0].to_column_dict().get('table_owner'), '1234')

def test_parse_relation_with_statistics(self):
self.maxDiff = None
rel_type = SparkRelation.get_relation_type.Table
Expand Down

0 comments on commit fe785c9

Please sign in to comment.