Skip to content

Commit

Permalink
Merge branch 'main' into lucasmmota/dae-63-handle-exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Fonseca committed Jan 27, 2021
2 parents d247abe + 41eca7b commit 74f975a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
3 changes: 2 additions & 1 deletion docs/source/getstarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ the [`HiveMetastoreClient`](https://github.com/quintoandar/hive-metastore-client

- [`add_columns_to_table`](https://hive-metastore-client.readthedocs.io/en/latest/hive_metastore_client.html#hive_metastore_client.hive_metastore_client.HiveMetastoreClient.add_columns_to_table)
- [`drop_columns_from_table`](https://hive-metastore-client.readthedocs.io/en/latest/hive_metastore_client.html#hive_metastore_client.hive_metastore_client.HiveMetastoreClient.drop_columns_from_table)
- [`add_partitions_if_not_exists`](https://hive-metastore-client.readthedocs.io/en/latest/hive_metastore_client.html#hive_metastore_client.hive_metastore_client.HiveMetastoreClient.add_partitions_if_not_exists)
- [`add_partitions_if_not_exists`](https://hive-metastore-client.readthedocs.io/en/latest/hive_metastore_client.html#hive_metastore_client.hive_metastore_client.HiveMetastoreClient.add_partitions_if_not_exists)
- [`create_database_if_not_exists`](https://hive-metastore-client.readthedocs.io/en/latest/hive_metastore_client.html#hive_metastore_client.hive_metastore_client.HiveMetastoreClient.create_database_if_not_exists)
5 changes: 2 additions & 3 deletions hive_metastore_client/hive_metastore_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def add_partitions_if_not_exists(
except AlreadyExistsException:
pass

def create_database_if_not_exists(self, database: Database) -> bool:
def create_database_if_not_exists(self, database: Database) -> None:
"""
Creates the table in Hive Metastore if it does not exist.
Expand All @@ -156,9 +156,8 @@ def create_database_if_not_exists(self, database: Database) -> bool:
"""
try:
self.create_database(database)
return True
except AlreadyExistsException:
return False
pass

@staticmethod
def _format_partitions_location(
Expand Down
10 changes: 2 additions & 8 deletions tests/unit/hive_metastore_client/test_hive_metastore_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,9 @@ def test_create_database_if_not_exists_with_nonexistent_database(
mocked_database_obj = Mock()

# act
return_value = hive_metastore_client.create_database_if_not_exists(
mocked_database_obj
)
hive_metastore_client.create_database_if_not_exists(mocked_database_obj)

# assert
assert return_value
mocked_create_database.assert_called_once_with(mocked_database_obj)

@mock.patch.object(HiveMetastoreClient, "create_database")
Expand All @@ -294,10 +291,7 @@ def test_create_database_if_not_exists_with_existent_database(
mocked_create_database.side_effect = AlreadyExistsException()

# act
return_value = hive_metastore_client.create_database_if_not_exists(
mocked_database_obj
)
hive_metastore_client.create_database_if_not_exists(mocked_database_obj)

# assert
assert not return_value
mocked_create_database.assert_called_once_with(mocked_database_obj)

0 comments on commit 74f975a

Please sign in to comment.