This blog explains how to use Python SDK for publishing data products in SAP Business Data Cloud so that it becomes discoverable by other consumer applications in SAP Business Data Cloud, for example by SAP Datasphere.
For a Delta Share to be exposed for downstream processing in SAP Databricks, it needs to be published as a data product with rich metadata. This can be done using an iPython Notebook available in your SAP Databricks Workspace. For further details on how to describe the data product, see Appendix A.
To install this SDK use the following pip command:
pip install sap-bdc-connect-sdk
uv tool install sap-bdc-connect-sdk
A share is a mechanism for distributing and accessing data across different systems. Creating or updating a share involves including specific attributes, such as @openResourceDiscoveryV1, in the request body, aligning with the Open Resource Discovery protocol. This procedure ensures that the share is properly structured and described according to specified standards, facilitating effective data sharing and management.
Copy the below code snippet and paste it to the cell, then provide the share-name, title, shortDescription and description of your share.
from bdc_connect_sdk.auth import BdcConnectClient
from bdc_connect_sdk.auth import DatabricksClient
bdc_connect_client = BdcConnectClient(DatabricksClient(dbutils, "<recipient-name>"))
share_name = "<share-name>"
open_resource_discovery_information = {
"@openResourceDiscoveryV1": {
"title": "<title>",
"shortDescription": "<short-description>",
"description": "<description>"
}
}
bdc_connect_client.create_or_update_share(
share_name,
open_resource_discovery_information
)from bdc_connect_sdk.auth import BdcConnectClient
from bdc_connect_sdk.auth import DatabricksClient
from bdc_connect_sdk.utils import csn_generator
bdc_connect_client = BdcConnectClient(DatabricksClient(dbutils, "<recipient-name>"))
share_name = "<share-name>"
csn_schema = csn_generator.generate_csn_template(share_name)
bdc_connect_client.create_or_update_share_csn(
share_name,
csn_schema
)If the generated CSN needs to be modified for any reason, it can be written to a file for editing, for example.
from bdc_connect_sdk.utils import csn_generator
import json
share_name = "<share-name>"
csn_schema = csn_generator.generate_csn_template(share_name)
file_path = f"csn_{share_name}.json"
with open(file_path, "w") as csn_file:
csn_file.write(json.dumps(csn_schema, indent=2))
# change the file
with open(file_path, "r") as csn_file:
changed_csn_schema = csn_file.read()
csn_schema = changed_csn_schema
from bdc_connect_sdk.auth import BdcConnectClient
from bdc_connect_sdk.auth import DatabricksClient
bdc_connect_client = BdcConnectClient(DatabricksClient(dbutils, "<recipient-name>"))
share_name = "<share-name>"
bdc_connect_client.publish_data_product(
share_name
)from bdc_connect_sdk.auth import BdcConnectClient
from bdc_connect_sdk.auth import DatabricksClient
bdc_connect_client = BdcConnectClient(DatabricksClient(dbutils, "<recipient-name>"))
share_name = "<share-name>"
bdc_connect_client.delete_share(
share_name
)
Follow me for more updates - https://profile.sap.com/u/Yogananda
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 28 | |
| 14 | |
| 11 | |
| 9 | |
| 9 | |
| 9 | |
| 9 | |
| 9 | |
| 8 | |
| 8 |