How to Create Automated Data Upload from Databricks

Aim of This Article

Explains how to create an Automated Data Upload that reads a table from Databricks. Each run loads the table into the selected Pricefx entity in one of two load modes. Full snapshot reads the whole table on every run. Delta — timestamp watermark reads only the rows with a newer timestamp than at the last successful run. When newer rows exist, the run also re-reads a short lookback period.

Related sections: Databricks Integration (overview), How to Create Automated Data Upload (file-based uploads), How to Create Databricks Connection.

Prerequisites

  • The use-automated-loads and use-databricks-source feature flags are enabled for the account.

  • The account's IaaS configuration uses IntegrationManager 8.3.0 or newer. Runs fail on older versions.

  • A Databricks connection exists on the partition. See How to Create Databricks Connection.

  • You have the Partition Data Management – edit permission.

  • The source is a Unity Catalog table. For the Full snapshot load mode, the table is in Delta Lake format. For the supported sources, see Databricks Integration.

  • For the Delta — timestamp watermark load mode, the Databricks table has a timestamp column (TIMESTAMP, TIMESTAMP_NTZ, or TIMESTAMP_LTZ).

  • For the Delta — timestamp watermark load mode, a Pricefx user can modify the partition configuration. This user belongs to the connection that the IaaS job uses on the partition. A run stores its watermark through this connection. This user is not your PlatformManager user and not the Databricks service principal. Ask a partition administrator to check this permission before the first run.

Choose a Load Mode for a Databricks Data Upload

The load mode of a Databricks data upload sets how each run reads the table. You select it in Step 2 and cannot change it after you create the upload.

Load mode

What each run reads

Use it when

Full snapshot

The whole table.

You want Pricefx to receive the whole table on every run. Reading the whole table does not remove rows from Pricefx. To remove deleted rows, see Delete original data in Step 4.

Delta — timestamp watermark

The rows with a newer value in the Watermark column than the stored watermark. The first run reads the whole table. When newer rows exist, the run also re-reads a lookback period before the stored watermark, 5 minutes by default. If no newer value exists, the run loads nothing, including rows within the lookback period. Pricefx loads a row committed late with an older timestamp only when a newer row arrives.

You want to load only the changed rows, and the table has a timestamp column that changes when a row changes. Pricefx does not remove the rows that you delete in Databricks.

Delete original data is not available when the entity type is DMDS, LPG, XLPG, PLI, XPLI, U, or CRCS. For these entity types, Pricefx keeps the rows that you delete in Databricks in both load modes.

In the Delta — timestamp watermark load mode, no run loads a row where the Watermark column is empty, not even the first run. When the selected column can be empty, the wizard shows the warning "Rows with an empty {column} are not loaded". To load every row, fill the column, or change the column in Databricks so that it cannot be empty.

For how the timestamp watermark works, see Databricks Integration.

Step 1: General

  1. Go to Account > Partitions > {PartitionName} > Data Management > Data Uploads.

  2. Click New Data Upload > Automated Upload.

  3. Enter a Name.

  4. In Data source, select Databricks.

  5. In Destination Of Upload, select the Entity Type. If the Entity Name field appears, select the table.

  6. Click Next.

Step 2: Data Source

Data Source step with a Databricks table selected and the preview loaded
Data Source step with a Databricks table selected and the preview loaded
  1. Select the Connection. Only this partition's Databricks connections are listed.

  2. Select the Catalog, Schema, and Table. Each list is enabled after you select the previous one.

    • For a large schema, the table list fills in gradually. Type into Table to search.

    • If a schema has more than 10,000 tables, a message says that some tables are missing from the list and from search. Select a smaller schema.

    • If a table is missing, click Refresh tables.

    • Pricefx cannot load a view. To load the data of a view, create a table in Databricks that contains the rows you need, and select that table.

    • If you change the Connection, Catalog, Schema, or Table later, the wizard clears the column mapping of Step 3. For Delta — timestamp watermark, the wizard also clears the Watermark column and Business key. Select them again.

  3. Review the Preview. It shows the first rows of the table and the number of discovered columns. If the SQL warehouse is stopped, the preview shows "The SQL warehouse is not running. Start it and preview again." A stopped SQL warehouse can take several minutes to start.

  4. In the Load mode section, under How each run reads the table, select Full snapshot or Delta — timestamp watermark. The section appears after you select a table. The wizard selects Full snapshot by default. To compare the modes, see Choose a Load Mode for a Databricks Data Upload.

  5. For Delta — timestamp watermark, select the Watermark column. The list contains every TIMESTAMP, TIMESTAMP_NTZ, and TIMESTAMP_LTZ column of the table, including columns that can be empty.

    You must select a Watermark column. The list labels a column that can be empty as "{column} — can be empty". When you select such a column, the wizard shows the warning "Rows with an empty {column} are not loaded". If the table has no timestamp column, the list shows "This table has no timestamp column. Watermark loading needs one." Select Full snapshot, or add a timestamp column to the table in Databricks.

  6. For Delta — timestamp watermark, select one or more Business key columns. The Business key columns identify a row in the source table. The Business key list does not contain columns of type ARRAY, MAP, STRUCT, BINARY, or VARIANT.

  7. Optional: To load only some rows, set Filter (optional) in Builder or SQL mode.

    • Each run loads only the rows that match the filter, in both load modes. Leave the filter empty to load the whole table.

    • In SQL mode, enter one Databricks SQL condition, the part after the WHERE keyword. In this field, Enter adds a new line.

    • For a Delta — timestamp watermark upload, you cannot change the filter after you create the upload.

  8. If you set a filter, click Apply filter to check the filter in the preview.

  9. Click Next.

Columns with Databricks types that Pricefx cannot store (ARRAY, MAP, STRUCT, BINARY, VARIANT) are mapped as text. The page lists them in an info message.

Step 3: Data Mapping

Map the table columns to Pricefx fields the same way as for a file upload. See How to Create Automated Data Upload, Step 3.

Databricks types map to Pricefx types as follows:

Databricks

Pricefx

STRING, VARCHAR, CHAR

Text

TINYINT, SMALLINT, INT, BIGINT

Integer

FLOAT, DOUBLE, DECIMAL

Number

BOOLEAN

Boolean

DATE

Date

TIMESTAMP, TIMESTAMP_NTZ, TIMESTAMP_LTZ

Date and time

Step 4: Additional Options

The options are the same as for a file upload, with these differences:

  • Upload Schedule: a Databricks upload always runs at regular intervals. There is no option to run when a file appears.

  • File Archiving: not available, because there are no files.

The Before upload and After upload options of Delete original data delete existing records of the entity. Before upload replaces the data with the data of this upload. After upload deletes the records that the upload did not update.

  • Delete original data for a Full snapshot upload: the default is Never – Adds new lines and updates the existing ones. With this value, rows that you delete in Databricks stay in Pricefx. To remove them, select the Before upload or After upload option. For the entity types without this field, see Choose a Load Mode for a Databricks Data Upload.

  • Delete original data for a Delta — timestamp watermark upload: not shown. The value is always Never – Adds new lines and updates the existing ones. A delta run loads only part of the table.

Step 5: Create

Click Create. The upload appears in the Data Uploads list with type Databricks Table. No SFTP user is created.

Running and Monitoring

  • Run Now in the row menu starts a run immediately. If another run of the same upload is in progress, PlatformManager does not start the run. PlatformManager shows the error "A run of data upload '{name}' is still in progress". Two runs of the same upload can still overlap when you click Run Now at the moment a scheduled run starts. Runs can also overlap when a run expired in PlatformManager while its IaaS job still runs. For a Delta — timestamp watermark upload, an overlap can leave an older version of a row in Pricefx until the row changes again in Databricks. When Run Now starts a run, PlatformManager shows "Run of {name} started. Its result will show in the history of runs."

  • History Of Runs shows each run. The Source column shows the full name of the table: the catalog, schema and table names, separated by dots. To open the runs of one upload, select History Of Runs in the row menu of that upload. The global history that opens from the Data Management widget has no Window column. For the other columns, see History of Runs.

  • The line under the History Of Runs title of a Databricks upload shows the source, the table, the load mode, and the schedule.

  • Before each run of a Delta — timestamp watermark upload, Pricefx checks the Watermark column again. If the column no longer exists in Databricks or is no longer a timestamp column, the run does not start. To load the table with another timestamp column, create a new upload.

  • If a column that the filter uses no longer exists in Databricks or has changed type, the run does not start. For a Full snapshot upload, edit the filter. For a Delta — timestamp watermark upload, create a new upload with a different filter.

  • After each Delta — timestamp watermark run, check the Failed Records column. Rows that Pricefx rejects do not stop the watermark from advancing. Manual Price List items, price items, and users are the exception. For these entity types, a failed batch fails the run. The next run then reads the same window again.

  • To reload rejected rows of a timestamp watermark upload, expand the run in History Of Runs and click Export CSV. The export contains up to 10,000 errors. Fix the source data or the mapping. Then set the Watermark column value of each corrected row later than the watermark in the Window tooltip. After the next run, check Failed Records again.

  • If a scheduled run cannot start, Pricefx skips the run and you get a notification. For example, someone changed the connection, the feature is disabled, or a run of the same upload is still in progress.

  • If a run fails, the status details start with a failure code:

Code

What to check

AUTH

The client ID and secret on the connection.

WAREHOUSE_STOPPED

The SQL warehouse is running.

PERMISSION_DENIED

The service principal has SELECT on the table.

SCHEMA_DRIFT

A mapped column was removed or renamed in Databricks. Update the mapping.

HISTORY_UNAVAILABLE

The table history in Databricks is available (it may have been vacuumed).

STATEMENT_FAILED

The table still exists and can be queried.

LOAD_FAILED

The data matches the target entity and mapping.

In the History Of Runs of a Delta — timestamp watermark upload, the Window column, after the Type column, shows which rows each run read. Hover over the value to see whether the watermark moved and, if it moved, its new value. Watermark values are in UTC. A Full snapshot upload has no Window column.

Window shows

Meaning

What to do

Initial snapshot

The first run read the whole table.

If it loaded no rows, check that the table has rows with a Watermark column value.

"> {timestamp} UTC"

The run read the rows newer than this time. When newer rows existed, the run also re-read the lookback period before this time, 5 minutes by default. If the tooltip says "The watermark did not move", the run found no newer rows and loaded nothing.

Nothing.

Not advanced

The run failed. The next run reads the same rows again, so the upload skips no rows.

Fix the cause of the failure, using the failure code in the status details of the run.

A run can advance the watermark even when some rows failed to load. After each run, check Failed Records. For how the watermark works, see Databricks Integration.

Editing an Upload

You can change the mapping, schedule, and advanced options. You can change the filter of a Full snapshot upload. You cannot change the name, connection, catalog, schema, or table; create a new upload instead.

After you create a Databricks upload, you cannot change the Load mode, Watermark column, or Business key fields. For a Delta — timestamp watermark upload, you also cannot change the filter. A wider filter would add rows older than the stored watermark, and the upload would never load them. To use different load settings or a different filter, create a new upload. A new upload starts without a watermark, so its first run reads the whole table. When the Watermark column can be empty, the edit form still shows the warning "Rows with an empty {column} are not loaded".

Create A Copy, SFTP User Management, Archived Files, and Send file are not available for Databricks uploads.

See Also