diff --git a/search_service/api/table.py b/search_service/api/table.py index 0656d2be..b7035797 100644 --- a/search_service/api/table.py +++ b/search_service/api/table.py @@ -26,7 +26,8 @@ "badges": fields.List(fields.Nested(tag_fields)), # last etl timestamp as epoch "last_updated_timestamp": fields.Integer, - "display_name": fields.String + "display_name": fields.String, + "schema_description": fields.String } search_table_results = { diff --git a/search_service/models/table.py b/search_service/models/table.py index f5deb125..3c509f36 100644 --- a/search_service/models/table.py +++ b/search_service/models/table.py @@ -27,6 +27,7 @@ class Table(Base): column_descriptions: List[str] = [] # The following are search-only properties: total_usage: int = 0 + schema_description: Optional[str] = attr.ib(default=None) def get_id(self) -> str: # uses the table key as the document id in ES @@ -45,7 +46,8 @@ def get_attrs(cls) -> Set: 'tags', 'badges', 'last_updated_timestamp', - 'display_name' + 'display_name', + 'schema_description' } @staticmethod diff --git a/setup.py b/setup.py index 9d7b0c15..5b9f4102 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages -__version__ = '2.3.0' +__version__ = '2.3.1' requirements_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'requirements.txt') with open(requirements_path) as requirements_file: diff --git a/tests/unit/api/table/fixtures.py b/tests/unit/api/table/fixtures.py index 257daf1b..dbf9595c 100644 --- a/tests/unit/api/table/fixtures.py +++ b/tests/unit/api/table/fixtures.py @@ -13,7 +13,8 @@ def mock_proxy_results() -> Table: column_names=['col1', 'col2'], tags=[Tag(tag_name='tag')], badges=[Tag(tag_name='badge1')], - last_updated_timestamp=1568324871) + last_updated_timestamp=1568324871, + schema_description='schema description') def mock_json_response() -> dict: @@ -29,6 +30,7 @@ def mock_json_response() -> dict: "tags": [{'tag_name': 'tag'}], "badges": [{'tag_name': 'badge1'}], "last_updated_timestamp": 1568324871, + "schema_description": 'schema description', } @@ -45,4 +47,5 @@ def default_json_response() -> dict: "tags": None, "badges": None, "last_updated_timestamp": 0, + "schema_description": None, } diff --git a/tests/unit/proxy/test_elasticsearch.py b/tests/unit/proxy/test_elasticsearch.py index 71350270..9a63abeb 100644 --- a/tests/unit/proxy/test_elasticsearch.py +++ b/tests/unit/proxy/test_elasticsearch.py @@ -463,6 +463,7 @@ def test_search_with_one_user_result(self, def test_create_document_with_no_data(self) -> None: expected = '' result = self.es_proxy.create_document(data=None, index='table_search_index') + print('result: {}'.format(result)) self.assertEquals(expected, result) @patch('uuid.uuid4') @@ -476,11 +477,12 @@ def test_create_document(self, mock_uuid: MagicMock) -> None: schema='test_schema', description='A table for something', key='snowflake://blue.test_schema/bank_accounts', last_updated_timestamp=0, name='bank_accounts', tags=[], badges=self.mock_empty_badge, - column_descriptions=['desc']), + column_descriptions=['desc'], schema_description='schema description 1'), Table(cluster='blue', column_names=['5', '6'], database='snowflake', schema='test_schema', description='A table for lots of things!', key='snowflake://blue.test_schema/bitcoin_wallets', - last_updated_timestamp=0, name='bitcoin_wallets', tags=[], badges=self.mock_empty_badge) + last_updated_timestamp=0, name='bitcoin_wallets', tags=[], badges=self.mock_empty_badge, + schema_description='schema description 2') ] expected_data = [ { @@ -503,7 +505,8 @@ def test_create_document(self, mock_uuid: MagicMock) -> None: 'name': 'bank_accounts', 'tags': [], 'badges': [], - 'total_usage': 0 + 'total_usage': 0, + 'schema_description': 'schema description 1', }, { 'index': { @@ -525,7 +528,8 @@ def test_create_document(self, mock_uuid: MagicMock) -> None: 'name': 'bitcoin_wallets', 'tags': [], 'badges': [], - 'total_usage': 0 + 'total_usage': 0, + 'schema_description': 'schema description 2', } ] mock_elasticsearch.bulk.return_value = {'errors': False} @@ -552,7 +556,8 @@ def test_update_document(self, mock_uuid: MagicMock) -> None: Table(cluster='blue', column_names=['5', '6'], database='snowflake', schema='test_schema', description='A table for lots of things!', key=table_key, last_updated_timestamp=0, name='bitcoin_wallets', - tags=[], column_descriptions=['hello'], badges=self.mock_empty_badge) + tags=[], column_descriptions=['hello'], badges=self.mock_empty_badge, + schema_description='schema description 1') ] expected_data = [ { @@ -576,7 +581,8 @@ def test_update_document(self, mock_uuid: MagicMock) -> None: 'name': 'bitcoin_wallets', 'tags': [], 'badges': [], - 'total_usage': 0 + 'total_usage': 0, + 'schema_description': 'schema description 1', } } ]