diff --git a/gooddata-sdk/gooddata_sdk/catalog/data_source/declarative_model/physical_model/table.py b/gooddata-sdk/gooddata_sdk/catalog/data_source/declarative_model/physical_model/table.py index 30ad76088..abce3e539 100644 --- a/gooddata-sdk/gooddata_sdk/catalog/data_source/declarative_model/physical_model/table.py +++ b/gooddata-sdk/gooddata_sdk/catalog/data_source/declarative_model/physical_model/table.py @@ -2,7 +2,7 @@ from __future__ import annotations from pathlib import Path -from typing import List, Type +from typing import List, Optional, Type import attr @@ -18,6 +18,7 @@ class CatalogDeclarativeTable(Base): type: str path: List[str] columns: List[CatalogDeclarativeColumn] + name_prefix: Optional[str] = None @staticmethod def client_class() -> Type[DeclarativeTable]: diff --git a/gooddata-sdk/gooddata_sdk/catalog/data_source/entity_model/content_objects/table.py b/gooddata-sdk/gooddata_sdk/catalog/data_source/entity_model/content_objects/table.py index 528554e50..3efb2329c 100644 --- a/gooddata-sdk/gooddata_sdk/catalog/data_source/entity_model/content_objects/table.py +++ b/gooddata-sdk/gooddata_sdk/catalog/data_source/entity_model/content_objects/table.py @@ -1,52 +1,32 @@ # (C) 2022 GoodData Corporation from __future__ import annotations -from typing import Any, List +from typing import List, Optional -from gooddata_sdk.catalog.entity import CatalogEntity +import attr +from gooddata_sdk.catalog.base import Base -class CatalogDataSourceTable(CatalogEntity): - @property - def table_type(self) -> str: - return self._e["type"] - @property - def path(self) -> List[str]: - return self._e["path"] +@attr.s(auto_attribs=True, kw_only=True) +class CatalogDataSourceTable(Base): + id: str + type: str + attributes: CatalogDataSourceTableAttributes - @property - def columns(self) -> List[CatalogDataSourceTableColumn]: - return [CatalogDataSourceTableColumn(c) for c in self._e["columns"]] - @property - def username(self) -> str: - return self._e["username"] +@attr.s(auto_attribs=True, kw_only=True) +class CatalogDataSourceTableAttributes(Base): + columns: List[CatalogDataSourceTableColumn] + name_prefix: Optional[str] = None + path: Optional[List[str]] = None + type: Optional[str] = None - def __repr__(self) -> str: - return f"{self.__class__.__name__}(id={self.id}, path={str(self.path)})" - -class CatalogDataSourceTableColumn: - def __init__(self, column: dict[str, Any]) -> None: - self._c = column - - @property - def name(self) -> str: - return self._c["name"] - - @property - def data_type(self) -> str: - return self._c["dataType"] - - @property - def referenced_table_id(self) -> str: - return self._c["referencedTableId"] - - @property - def referenced_table_column(self) -> str: - return self._c["referencedTableColumn"] - - @property - def primary_key(self) -> str: - return self._c["primaryKey"] +@attr.s(auto_attribs=True, kw_only=True) +class CatalogDataSourceTableColumn(Base): + name: str + data_type: str + is_primary_key: Optional[bool] = None + referenced_table_column: Optional[str] = None + referenced_table_id: Optional[str] = None diff --git a/gooddata-sdk/gooddata_sdk/catalog/data_source/service.py b/gooddata-sdk/gooddata_sdk/catalog/data_source/service.py index 1b71bf839..9fe89027a 100644 --- a/gooddata-sdk/gooddata_sdk/catalog/data_source/service.py +++ b/gooddata-sdk/gooddata_sdk/catalog/data_source/service.py @@ -26,7 +26,7 @@ from gooddata_sdk.catalog.entity import TokenCredentialsFromFile from gooddata_sdk.catalog.workspace.declarative_model.workspace.logical_model.ldm import CatalogDeclarativeModel from gooddata_sdk.client import GoodDataApiClient -from gooddata_sdk.utils import load_all_entities, read_layout_from_file +from gooddata_sdk.utils import load_all_entities, load_all_entities_dict, read_layout_from_file class CatalogDataSourceService(CatalogServiceBase): @@ -52,8 +52,8 @@ def list_data_source_tables(self, data_source_id: str) -> List[CatalogDataSource data_source_id, _check_return_type=False, ) - data_source_tables = load_all_entities(get_data_source_tables) - return [CatalogDataSourceTable(dst) for dst in data_source_tables.data] + data_source_tables = load_all_entities_dict(get_data_source_tables, camel_case=False) + return [CatalogDataSourceTable.from_dict(dst, camel_case=False) for dst in data_source_tables["data"]] def create_or_update_data_source( self, diff --git a/gooddata-sdk/tests/catalog/fixtures/data_sources/demo_data_source_tables.json b/gooddata-sdk/tests/catalog/fixtures/data_sources/demo_data_source_tables.json index a4b3cb21d..db6e7aea4 100644 --- a/gooddata-sdk/tests/catalog/fixtures/data_sources/demo_data_source_tables.json +++ b/gooddata-sdk/tests/catalog/fixtures/data_sources/demo_data_source_tables.json @@ -27,65 +27,65 @@ "Cache-Control": [ "no-cache, no-store, max-age=0, must-revalidate" ], - "Server": [ - "nginx" + "Content-Security-Policy": [ + "default-src 'self' *.wistia.com *.wistia.net; script-src 'self' 'unsafe-inline' 'unsafe-eval' *.wistia.com *.wistia.net src.litix.io matomo.anywhere.gooddata.com code.jquery.com unpkg.com cdn.jsdelivr.net cdnjs.cloudflare.com; img-src 'self' data: blob: *.wistia.com *.wistia.net embedwistia-a.akamaihd.net privacy-policy.truste.com www.gooddata.com; style-src 'self' 'unsafe-inline' fonts.googleapis.com cdn.jsdelivr.net fast.fonts.net; font-src 'self' data: fonts.gstatic.com *.alicdn.com *.wistia.com cdn.jsdelivr.net info.gooddata.com; frame-src 'self'; object-src 'none'; worker-src 'self' blob:; child-src blob:; connect-src 'self' *.tiles.mapbox.com *.mapbox.com *.litix.io *.wistia.com embedwistia-a.akamaihd.net matomo.anywhere.gooddata.com; media-src 'self' blob: data: *.wistia.com *.wistia.net embedwistia-a.akamaihd.net" + ], + "Set-Cookie": [ + "SPRING_SEC_SECURITY_CONTEXT=; Max-Age=0; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; HttpOnly" + ], + "Expires": [ + "0" + ], + "X-Frame-Options": [ + "DENY" ], "Access-Control-Expose-Headers": [ "Content-Disposition, Content-Length, Content-Range, Set-Cookie" ], - "X-Content-Type-Options": [ - "nosniff" + "Server": [ + "nginx" ], - "Date": [ - "Thu, 16 Jun 2022 16:04:37 GMT" + "Permission-Policy": [ + "geolocation 'none'; midi 'none'; sync-xhr 'none'; microphone 'none'; camera 'none'; magnetometer 'none'; gyroscope 'none'; fullscreen 'none'; payment 'none';" ], - "Set-Cookie": [ - "SPRING_SEC_SECURITY_CONTEXT=; Max-Age=0; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; HttpOnly" + "X-Content-Type-Options": [ + "nosniff" ], - "Content-Security-Policy": [ - "default-src 'self' *.wistia.com *.wistia.net; script-src 'self' 'unsafe-inline' 'unsafe-eval' *.wistia.com *.wistia.net src.litix.io matomo.anywhere.gooddata.com code.jquery.com unpkg.com cdn.jsdelivr.net cdnjs.cloudflare.com; img-src 'self' data: blob: *.wistia.com *.wistia.net embedwistia-a.akamaihd.net privacy-policy.truste.com www.gooddata.com; style-src 'self' 'unsafe-inline' fonts.googleapis.com cdn.jsdelivr.net fast.fonts.net; font-src 'self' data: fonts.gstatic.com *.alicdn.com *.wistia.com cdn.jsdelivr.net info.gooddata.com; frame-src 'self'; object-src 'none'; worker-src 'self' blob:; child-src blob:; connect-src 'self' *.tiles.mapbox.com *.mapbox.com *.litix.io *.wistia.com embedwistia-a.akamaihd.net matomo.anywhere.gooddata.com; media-src 'self' blob: data: *.wistia.com *.wistia.net embedwistia-a.akamaihd.net" + "Pragma": [ + "no-cache" ], "GoodData-Deployment": [ "aio" ], - "Transfer-Encoding": [ - "chunked" - ], - "Access-Control-Allow-Credentials": [ - "true" + "X-XSS-Protection": [ + "1; mode=block" ], "Vary": [ "Origin", "Access-Control-Request-Method", "Access-Control-Request-Headers" ], - "X-GDC-TRACE-ID": [ - "7c59c7181fc82ff8" - ], - "Content-Type": [ - "application/vnd.gooddata.api+json" - ], - "X-Frame-Options": [ - "DENY" - ], - "X-XSS-Protection": [ - "1; mode=block" - ], - "Pragma": [ - "no-cache" + "Date": [ + "Wed, 22 Jun 2022 13:10:33 GMT" ], - "Permission-Policy": [ - "geolocation 'none'; midi 'none'; sync-xhr 'none'; microphone 'none'; camera 'none'; magnetometer 'none'; gyroscope 'none'; fullscreen 'none'; payment 'none';" + "Transfer-Encoding": [ + "chunked" ], - "Expires": [ - "0" + "Access-Control-Allow-Credentials": [ + "true" ], "Connection": [ "keep-alive" + ], + "Content-Type": [ + "application/vnd.gooddata.api+json" + ], + "X-GDC-TRACE-ID": [ + "a3348090b8470ae9" ] }, "body": { - "string": "{\"data\":[{\"attributes\":{\"path\":[\"demo\",\"campaign_channels\"],\"type\":\"TABLE\",\"columns\":[{\"name\":\"budget\",\"dataType\":\"NUMERIC\",\"referencedTableId\":null,\"referencedTableColumn\":null,\"primaryKey\":false},{\"name\":\"campaign_channel_id\",\"dataType\":\"STRING\",\"referencedTableId\":null,\"referencedTableColumn\":null,\"primaryKey\":true},{\"name\":\"campaign_id\",\"dataType\":\"INT\",\"referencedTableId\":\"campaigns\",\"referencedTableColumn\":\"campaign_id\",\"primaryKey\":false},{\"name\":\"category\",\"dataType\":\"STRING\",\"referencedTableId\":null,\"referencedTableColumn\":null,\"primaryKey\":false},{\"name\":\"spend\",\"dataType\":\"NUMERIC\",\"referencedTableId\":null,\"referencedTableColumn\":null,\"primaryKey\":false},{\"name\":\"type\",\"dataType\":\"STRING\",\"referencedTableId\":null,\"referencedTableColumn\":null,\"primaryKey\":false}]},\"id\":\"campaign_channels\",\"links\":{\"self\":\"http://localhost:3000/api/v1/entities/dataSources/demo-test-ds/dataSourceTables/campaign_channels\"},\"type\":\"dataSourceTable\"},{\"attributes\":{\"path\":[\"demo\",\"campaigns\"],\"type\":\"TABLE\",\"columns\":[{\"name\":\"campaign_id\",\"dataType\":\"INT\",\"referencedTableId\":null,\"referencedTableColumn\":null,\"primaryKey\":true},{\"name\":\"campaign_name\",\"dataType\":\"STRING\",\"referencedTableId\":null,\"referencedTableColumn\":null,\"primaryKey\":false}]},\"id\":\"campaigns\",\"links\":{\"self\":\"http://localhost:3000/api/v1/entities/dataSources/demo-test-ds/dataSourceTables/campaigns\"},\"type\":\"dataSourceTable\"},{\"attributes\":{\"path\":[\"demo\",\"customers\"],\"type\":\"TABLE\",\"columns\":[{\"name\":\"customer_id\",\"dataType\":\"INT\",\"referencedTableId\":null,\"referencedTableColumn\":null,\"primaryKey\":true},{\"name\":\"customer_name\",\"dataType\":\"STRING\",\"referencedTableId\":null,\"referencedTableColumn\":null,\"primaryKey\":false},{\"name\":\"geo__state__location\",\"dataType\":\"STRING\",\"referencedTableId\":null,\"referencedTableColumn\":null,\"primaryKey\":false},{\"name\":\"region\",\"dataType\":\"STRING\",\"referencedTableId\":null,\"referencedTableColumn\":null,\"primaryKey\":false},{\"name\":\"state\",\"dataType\":\"STRING\",\"referencedTableId\":null,\"referencedTableColumn\":null,\"primaryKey\":false}]},\"id\":\"customers\",\"links\":{\"self\":\"http://localhost:3000/api/v1/entities/dataSources/demo-test-ds/dataSourceTables/customers\"},\"type\":\"dataSourceTable\"},{\"attributes\":{\"path\":[\"demo\",\"order_lines\"],\"type\":\"TABLE\",\"columns\":[{\"name\":\"campaign_id\",\"dataType\":\"INT\",\"referencedTableId\":\"campaigns\",\"referencedTableColumn\":\"campaign_id\",\"primaryKey\":false},{\"name\":\"customer_id\",\"dataType\":\"INT\",\"referencedTableId\":\"customers\",\"referencedTableColumn\":\"customer_id\",\"primaryKey\":false},{\"name\":\"date\",\"dataType\":\"DATE\",\"referencedTableId\":null,\"referencedTableColumn\":null,\"primaryKey\":false},{\"name\":\"order_id\",\"dataType\":\"STRING\",\"referencedTableId\":null,\"referencedTableColumn\":null,\"primaryKey\":false},{\"name\":\"order_line_id\",\"dataType\":\"STRING\",\"referencedTableId\":null,\"referencedTableColumn\":null,\"primaryKey\":true},{\"name\":\"order_status\",\"dataType\":\"STRING\",\"referencedTableId\":null,\"referencedTableColumn\":null,\"primaryKey\":false},{\"name\":\"price\",\"dataType\":\"NUMERIC\",\"referencedTableId\":null,\"referencedTableColumn\":null,\"primaryKey\":false},{\"name\":\"product_id\",\"dataType\":\"INT\",\"referencedTableId\":\"products\",\"referencedTableColumn\":\"product_id\",\"primaryKey\":false},{\"name\":\"quantity\",\"dataType\":\"NUMERIC\",\"referencedTableId\":null,\"referencedTableColumn\":null,\"primaryKey\":false},{\"name\":\"wdf__region\",\"dataType\":\"STRING\",\"referencedTableId\":null,\"referencedTableColumn\":null,\"primaryKey\":false},{\"name\":\"wdf__state\",\"dataType\":\"STRING\",\"referencedTableId\":null,\"referencedTableColumn\":null,\"primaryKey\":false}]},\"id\":\"order_lines\",\"links\":{\"self\":\"http://localhost:3000/api/v1/entities/dataSources/demo-test-ds/dataSourceTables/order_lines\"},\"type\":\"dataSourceTable\"},{\"attributes\":{\"path\":[\"demo\",\"products\"],\"type\":\"TABLE\",\"columns\":[{\"name\":\"category\",\"dataType\":\"STRING\",\"referencedTableId\":null,\"referencedTableColumn\":null,\"primaryKey\":false},{\"name\":\"product_id\",\"dataType\":\"INT\",\"referencedTableId\":null,\"referencedTableColumn\":null,\"primaryKey\":true},{\"name\":\"product_name\",\"dataType\":\"STRING\",\"referencedTableId\":null,\"referencedTableColumn\":null,\"primaryKey\":false}]},\"id\":\"products\",\"links\":{\"self\":\"http://localhost:3000/api/v1/entities/dataSources/demo-test-ds/dataSourceTables/products\"},\"type\":\"dataSourceTable\"}],\"links\":{\"self\":\"http://localhost:3000/api/v1/entities/dataSources/demo-test-ds/dataSourceTables?page=0&size=500\",\"next\":\"http://localhost:3000/api/v1/entities/dataSources/demo-test-ds/dataSourceTables?page=1&size=500\"}}" + "string": "{\"data\":[{\"attributes\":{\"path\":[\"demo\",\"campaign_channels\"],\"type\":\"TABLE\",\"columns\":[{\"name\":\"budget\",\"dataType\":\"NUMERIC\",\"isPrimaryKey\":false,\"referencedTableId\":null,\"referencedTableColumn\":null},{\"name\":\"campaign_channel_id\",\"dataType\":\"STRING\",\"isPrimaryKey\":true,\"referencedTableId\":null,\"referencedTableColumn\":null},{\"name\":\"campaign_id\",\"dataType\":\"INT\",\"isPrimaryKey\":false,\"referencedTableId\":\"campaigns\",\"referencedTableColumn\":\"campaign_id\"},{\"name\":\"category\",\"dataType\":\"STRING\",\"isPrimaryKey\":false,\"referencedTableId\":null,\"referencedTableColumn\":null},{\"name\":\"spend\",\"dataType\":\"NUMERIC\",\"isPrimaryKey\":false,\"referencedTableId\":null,\"referencedTableColumn\":null},{\"name\":\"type\",\"dataType\":\"STRING\",\"isPrimaryKey\":false,\"referencedTableId\":null,\"referencedTableColumn\":null}]},\"id\":\"campaign_channels\",\"links\":{\"self\":\"http://localhost:3000/api/v1/entities/dataSources/demo-test-ds/dataSourceTables/campaign_channels\"},\"type\":\"dataSourceTable\"},{\"attributes\":{\"path\":[\"demo\",\"campaigns\"],\"type\":\"TABLE\",\"columns\":[{\"name\":\"campaign_id\",\"dataType\":\"INT\",\"isPrimaryKey\":true,\"referencedTableId\":null,\"referencedTableColumn\":null},{\"name\":\"campaign_name\",\"dataType\":\"STRING\",\"isPrimaryKey\":false,\"referencedTableId\":null,\"referencedTableColumn\":null}]},\"id\":\"campaigns\",\"links\":{\"self\":\"http://localhost:3000/api/v1/entities/dataSources/demo-test-ds/dataSourceTables/campaigns\"},\"type\":\"dataSourceTable\"},{\"attributes\":{\"path\":[\"demo\",\"customers\"],\"type\":\"TABLE\",\"columns\":[{\"name\":\"customer_id\",\"dataType\":\"INT\",\"isPrimaryKey\":true,\"referencedTableId\":null,\"referencedTableColumn\":null},{\"name\":\"customer_name\",\"dataType\":\"STRING\",\"isPrimaryKey\":false,\"referencedTableId\":null,\"referencedTableColumn\":null},{\"name\":\"geo__state__location\",\"dataType\":\"STRING\",\"isPrimaryKey\":false,\"referencedTableId\":null,\"referencedTableColumn\":null},{\"name\":\"region\",\"dataType\":\"STRING\",\"isPrimaryKey\":false,\"referencedTableId\":null,\"referencedTableColumn\":null},{\"name\":\"state\",\"dataType\":\"STRING\",\"isPrimaryKey\":false,\"referencedTableId\":null,\"referencedTableColumn\":null}]},\"id\":\"customers\",\"links\":{\"self\":\"http://localhost:3000/api/v1/entities/dataSources/demo-test-ds/dataSourceTables/customers\"},\"type\":\"dataSourceTable\"},{\"attributes\":{\"path\":[\"demo\",\"order_lines\"],\"type\":\"TABLE\",\"columns\":[{\"name\":\"campaign_id\",\"dataType\":\"INT\",\"isPrimaryKey\":false,\"referencedTableId\":\"campaigns\",\"referencedTableColumn\":\"campaign_id\"},{\"name\":\"customer_id\",\"dataType\":\"INT\",\"isPrimaryKey\":false,\"referencedTableId\":\"customers\",\"referencedTableColumn\":\"customer_id\"},{\"name\":\"date\",\"dataType\":\"DATE\",\"isPrimaryKey\":false,\"referencedTableId\":null,\"referencedTableColumn\":null},{\"name\":\"order_id\",\"dataType\":\"STRING\",\"isPrimaryKey\":false,\"referencedTableId\":null,\"referencedTableColumn\":null},{\"name\":\"order_line_id\",\"dataType\":\"STRING\",\"isPrimaryKey\":true,\"referencedTableId\":null,\"referencedTableColumn\":null},{\"name\":\"order_status\",\"dataType\":\"STRING\",\"isPrimaryKey\":false,\"referencedTableId\":null,\"referencedTableColumn\":null},{\"name\":\"price\",\"dataType\":\"NUMERIC\",\"isPrimaryKey\":false,\"referencedTableId\":null,\"referencedTableColumn\":null},{\"name\":\"product_id\",\"dataType\":\"INT\",\"isPrimaryKey\":false,\"referencedTableId\":\"products\",\"referencedTableColumn\":\"product_id\"},{\"name\":\"quantity\",\"dataType\":\"NUMERIC\",\"isPrimaryKey\":false,\"referencedTableId\":null,\"referencedTableColumn\":null},{\"name\":\"wdf__region\",\"dataType\":\"STRING\",\"isPrimaryKey\":false,\"referencedTableId\":null,\"referencedTableColumn\":null},{\"name\":\"wdf__state\",\"dataType\":\"STRING\",\"isPrimaryKey\":false,\"referencedTableId\":null,\"referencedTableColumn\":null}]},\"id\":\"order_lines\",\"links\":{\"self\":\"http://localhost:3000/api/v1/entities/dataSources/demo-test-ds/dataSourceTables/order_lines\"},\"type\":\"dataSourceTable\"},{\"attributes\":{\"path\":[\"demo\",\"products\"],\"type\":\"TABLE\",\"columns\":[{\"name\":\"category\",\"dataType\":\"STRING\",\"isPrimaryKey\":false,\"referencedTableId\":null,\"referencedTableColumn\":null},{\"name\":\"product_id\",\"dataType\":\"INT\",\"isPrimaryKey\":true,\"referencedTableId\":null,\"referencedTableColumn\":null},{\"name\":\"product_name\",\"dataType\":\"STRING\",\"isPrimaryKey\":false,\"referencedTableId\":null,\"referencedTableColumn\":null}]},\"id\":\"products\",\"links\":{\"self\":\"http://localhost:3000/api/v1/entities/dataSources/demo-test-ds/dataSourceTables/products\"},\"type\":\"dataSourceTable\"}],\"links\":{\"self\":\"http://localhost:3000/api/v1/entities/dataSources/demo-test-ds/dataSourceTables?page=0&size=500\",\"next\":\"http://localhost:3000/api/v1/entities/dataSources/demo-test-ds/dataSourceTables?page=1&size=500\"}}" } } } diff --git a/gooddata-sdk/tests/catalog/fixtures/data_sources/demo_test_scan_model_with_table_prefix.json b/gooddata-sdk/tests/catalog/fixtures/data_sources/demo_test_scan_model_with_table_prefix.json new file mode 100644 index 000000000..2eddcfa38 --- /dev/null +++ b/gooddata-sdk/tests/catalog/fixtures/data_sources/demo_test_scan_model_with_table_prefix.json @@ -0,0 +1,96 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "POST", + "uri": "http://localhost:3000/api/v1/actions/dataSources/demo-test-ds/scan", + "body": "{\"scanTables\": true, \"scanViews\": false, \"separator\": \"_\", \"tablePrefix\": \"order\"}", + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ], + "X-Requested-With": [ + "XMLHttpRequest" + ], + "X-GDC-VALIDATE-RELATIONS": [ + "true" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Fri, 17 Jun 2022 10:33:45 GMT" + ], + "Connection": [ + "keep-alive" + ], + "Referrer-Policy": [ + "no-referrer" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Pragma": [ + "no-cache" + ], + "Access-Control-Expose-Headers": [ + "Content-Disposition, Content-Length, Content-Range, Set-Cookie" + ], + "GoodData-Deployment": [ + "aio" + ], + "Content-Length": [ + "922" + ], + "X-XSS-Protection": [ + "1 ; mode=block" + ], + "X-GDC-TRACE-ID": [ + "be6ce1bb196a21d9" + ], + "Vary": [ + "Origin", + "Access-Control-Request-Method", + "Access-Control-Request-Headers" + ], + "Cache-Control": [ + "no-cache, no-store, max-age=0, must-revalidate" + ], + "Expires": [ + "0" + ], + "Permission-Policy": [ + "geolocation 'none'; midi 'none'; sync-xhr 'none'; microphone 'none'; camera 'none'; magnetometer 'none'; gyroscope 'none'; fullscreen 'none'; payment 'none';" + ], + "Content-Security-Policy": [ + "default-src 'self' *.wistia.com *.wistia.net; script-src 'self' 'unsafe-inline' 'unsafe-eval' *.wistia.com *.wistia.net src.litix.io matomo.anywhere.gooddata.com code.jquery.com unpkg.com cdn.jsdelivr.net cdnjs.cloudflare.com; img-src 'self' data: blob: *.wistia.com *.wistia.net embedwistia-a.akamaihd.net privacy-policy.truste.com www.gooddata.com; style-src 'self' 'unsafe-inline' fonts.googleapis.com cdn.jsdelivr.net fast.fonts.net; font-src 'self' data: fonts.gstatic.com *.alicdn.com *.wistia.com cdn.jsdelivr.net info.gooddata.com; frame-src 'self'; object-src 'none'; worker-src 'self' blob:; child-src blob:; connect-src 'self' *.tiles.mapbox.com *.mapbox.com *.litix.io *.wistia.com embedwistia-a.akamaihd.net matomo.anywhere.gooddata.com; media-src 'self' blob: data: *.wistia.com *.wistia.net embedwistia-a.akamaihd.net" + ], + "Content-Type": [ + "application/json" + ], + "Server": [ + "nginx" + ], + "Set-Cookie": [ + "SPRING_REDIRECT_URI=; Path=/; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; HttpOnly; SameSite=Lax" + ] + }, + "body": { + "string": "{\"pdm\":{\"tables\":[{\"columns\":[{\"dataType\":\"INT\",\"isPrimaryKey\":false,\"name\":\"campaign_id\",\"referencedTableColumn\":\"campaign_id\"},{\"dataType\":\"INT\",\"isPrimaryKey\":false,\"name\":\"customer_id\",\"referencedTableColumn\":\"customer_id\"},{\"dataType\":\"DATE\",\"isPrimaryKey\":false,\"name\":\"date\"},{\"dataType\":\"STRING\",\"isPrimaryKey\":false,\"name\":\"order_id\"},{\"dataType\":\"STRING\",\"isPrimaryKey\":true,\"name\":\"order_line_id\"},{\"dataType\":\"STRING\",\"isPrimaryKey\":false,\"name\":\"order_status\"},{\"dataType\":\"NUMERIC\",\"isPrimaryKey\":false,\"name\":\"price\"},{\"dataType\":\"INT\",\"isPrimaryKey\":false,\"name\":\"product_id\",\"referencedTableColumn\":\"product_id\"},{\"dataType\":\"NUMERIC\",\"isPrimaryKey\":false,\"name\":\"quantity\"},{\"dataType\":\"STRING\",\"isPrimaryKey\":false,\"name\":\"wdf__region\"},{\"dataType\":\"STRING\",\"isPrimaryKey\":false,\"name\":\"wdf__state\"}],\"id\":\"order_lines\",\"namePrefix\":\"order\",\"path\":[\"demo\",\"order_lines\"],\"type\":\"TABLE\"}]},\"warnings\":[]}" + } + } + } + ] +} diff --git a/gooddata-sdk/tests/catalog/test_catalog_data_source.py b/gooddata-sdk/tests/catalog/test_catalog_data_source.py index 284347743..f14de36ae 100644 --- a/gooddata-sdk/tests/catalog/test_catalog_data_source.py +++ b/gooddata-sdk/tests/catalog/test_catalog_data_source.py @@ -282,7 +282,7 @@ def test_catalog_data_source_table(test_config): assert len(data_source_tables) == 5 order_lines = next(filter(lambda x: x.id == "order_lines", data_source_tables)) - assert len(order_lines.columns) == 11 + assert len(order_lines.attributes.columns) == 11 @gd_vcr.use_cassette(str(_fixtures_dir / "declarative_data_sources.json")) @@ -453,12 +453,22 @@ def test_scan_model(test_config): with pytest.raises(ValueError): CatalogScanModelRequest(scan_tables=False, scan_views=False) - CatalogScanModelRequest(scan_tables=False, scan_views=False) # TODO - how to simulate warnings in AIO? assert len(scan_result.warnings) == 0 +@gd_vcr.use_cassette(str(_fixtures_dir / "demo_test_scan_model_with_table_prefix.json")) +def test_scan_mode_with_table_prefix(test_config): + sdk = GoodDataSdk.create(host_=test_config["host"], token_=test_config["token"]) + data_source_id = test_config["data_source"] + request = CatalogScanModelRequest(table_prefix="order", separator="_") + + scan_result = sdk.catalog_data_source.scan_data_source(data_source_id, request) + assert len(scan_result.pdm.tables) == 1 + assert scan_result.pdm.tables[0].name_prefix == "order" + + @gd_vcr.use_cassette(str(_fixtures_dir / "demo_test_scan_and_put_declarative_pdm.json")) def test_scan_and_put_declarative_pdm(test_config): sdk = GoodDataSdk.create(host_=test_config["host"], token_=test_config["token"])