ERPClimb logoERPClimb

Code examples · Business Data Cloud · Intermediate

Read an SAP data product in SAP Databricks and inspect its meaning and personal-data tags

The problem

A data scientist has been granted an SAP data product and wants to use it for a model.

How we solve it

  1. 1Read rowsSQL
  2. 2Read meaningcomments, keys, tags

The result

You know the columns, keys and personal-data tags of the product and have a first sample of rows.

Overview drawn by ERPClimb from this example. The steps are the same as in the code below.

1. The requirement

A data scientist has been granted an SAP data product and wants to use it for a model. Before using it she must know what each column means, which columns are keys and which carry personal data, so that she does not train on data she may not use.

2. How we design it

When a data product is shared to SAP Databricks it appears as a catalog in Unity Catalog. SAP also sends its meaning with it: table and column comments, keys and personal-data tags. We read the data with plain SQL first, then read the metadata with DESCRIBE and the information schema before any modelling.

Why we decided it this way

  1. 1Look before you modelThe comments and tags tell you what a column means and whether you may use it. Reading them takes a minute and avoids a compliance problem later.
  2. 2Use SQL on the shared catalogThe data product is read where it is shared. You do not load a copy, so you always read the data the owner published.
  3. 3Never edit the sap tagsSAP Business Data Cloud is the source of truth for this metadata. Changes in Databricks may be cleared, so change it at the source if it is wrong.

Before you start

  • Access to the data product has been requested in the BDC catalog and approved, and it has been shared to SAP Databricks so that it shows as a catalog in Catalog Explorer.
  • The permissions described in SAP's provisioning documentation. Without them the catalog is not visible.
  • In Catalog Explorer, note the catalog, schema and table names of your product.

3. The code, step by step

Step 1 of 3: Read a first sample of the data

See real rows and confirm the product is available.

SQL · SQL editor or notebook · sample query
-- Look at ten rows
SELECT *
FROM my_sap_catalog.my_schema.my_table
LIMIT 10;
Part by part (plain text)
  1. Look at ten rows. The three-part name is catalog.schema.table. Replace the placeholders with the names you noted in Catalog Explorer. LIMIT keeps the first look small and cheap.

Open in the portal

The SAP objects named in this code are linked in the code above and listed here. Each opens its page in the SAP Library.

4. The final outcome

You know the columns, keys and personal-data tags of the product and have a first sample of rows.

What you should see

Example output shape (your product has other names): Columns with comments, the table properties, and a list such as sap.PersonalData.* tags per table or column.

Try it and check the result

  • Run the first query. If the catalog is not found, check in Catalog Explorer that the data product was shared and that you have the permissions.
  • Run DESCRIBE and compare a column comment with the description of the product in the BDC catalog.
  • Run the tag queries. An empty result can be correct: it means the product carries no personal-data tags.

Common mistakes

  • Do not assign, change or delete tags in the sap namespace. The metadata is read-only and SAP Business Data Cloud is its source.
  • A missing comment is not proof that a column is harmless. Ask the product owner before using it.
  • Table and schema names depend on the product. Never copy the placeholder names.

Keep learning