Partitioning Data Objects

This topic explains how to partition data objects using the Unity API.

In this topic:

Introduction

Partitioning is a data management feature that subdivides the data in data objects into smaller pieces.

Use Cases

  • Improves query performance. When viewing data object records, you can filter your search by partitions. This reduces the time Oracle Unity needs to complete your search. Since you define specific partitions in the data object to search, Oracle Unity can skip irrelevant records and only search in the defined partitions.

  • Partition data objects by date. Partitions are defined to date-based data objects such as Event, Order, and Order Item. Partitioning a data object by date enables you to access specific partitions of the data object, querying by date. Using an Order data object as an example, you may want to view orders from a specific year, or specific month.

  • Efficiently manage data. Partitioning allows you to more efficiently manage your data by dividing the data into smaller, more manageable units.

Workflow

The workflow to partition a data object resembles:

  1. Identify the data object to partition (i.e. Event, Order, Purchase, etc.)

  2. Select a partition strategy (monthly, yearly, by order date, by event date, and so on)

  3. Partition the data object

Before You Begin

Note the following before you partition a data object:

  • Data object partitioning is supported by data objects that need to be processed by the Data warehouse job.

  • The "Date" partition strategy is the only available strategy.

  • The format of the strategy controls the size of the partitions. The two available formats in Oracle Unity are monthly and yearly partitions.

Important: Partitioning a Data Object is irreversible. The partition strategy for a data object can't be changed after it has been published.

Partitioning Data Objects

To partition a data object:

  1. Identify the data object to partition.

  2. Retrieve the data object metadata using the endpoint "GET /metadata/tables/<tableName>"

    Example

    Retrieve the order data object:

    GET http://{accountURL}/api-metadata/v1/<tenantAccessKey>/metadata/tables/order
  3. Send a request to update the data object's partition metadata using the endpoint "PUT /metadata/tables/<tableId>".

    Partition parameters

    Parameter Required? Data Type Description
    partitionStrategy Y String Determines the partition behavior. Must be "DATE".
    partitionFields Y Array Array of partition fields below.
    ptype Y String Partition type. Must be ".PartitionDateField"
    format Y String

    Determines the size of the partition. Must be one of:

    • "yyyyMM": Monthly partition

    • "yyyy": Yearly partition

     

    referenceField Y String

    Specify an attribute from the data object, which is used to determine the data object's partitions. This attribute must be a supported data type for the chosen partition strategy. For example, if the partition strategy is a DATE strategy, then the referenceField must be a date or timestamp data type.

    targetFieldName Y String

    Specify a name for a new attribute for the data object, which Unity generates and populates with the partition value for each data record in the data object. For example, if the partition strategy is DATE and its format is yyyyMM, Unity automatically extracts the year and month values from the referenceField attribute and uses them in the targetFieldName attribute.

    Example

    Update the "order" data object's partition strategy to monthly:

    PUT http://{accountURL}/api-metadata/v1/<tenantAccessKey>/metadata/tables/order

    Request body

    {
      "name": "Order",
      "tenantId": 0,
      "tableId": "Order",
      "tablePrimaryKey": "ID",
      "sourceAttribute": "SourceOrderD",
      "insertOnly": true,
      "resourceName": "orders",
      "scope": "DW",
      "categoryId": "Transactional",
      "partitions": [
        {
          "partitionStrategy": "DATE",
          "partitionFields": [
            {
              "ptype": ".PartitionDateField",
              "targetFieldName": "OrderDate",
              "format": "yyyyMM",
              "referenceField": "OrderTS"
            }
          ]
        }
      ]
    }
  4. Publish metadata changes.

Learn more

Data Objects API

Retrieve a data object

Update a data object