Skip to main content
Ctrl+K

ibm-watsonx-data-integration SDK for Python Version 2.0.0

  • Welcome
    • Prerequisites
    • Installation and Versioning
    • Supported Products
  • Overview
    • What’s new
    • Known Issues and Limitations
    • Get Help
  • Getting Started
    • Authentication
    • Platform
    • Service Instances
    • Code Generation (Batch)
    • Code Generation (Streaming)
    • Code Generation for Connections
    • HTTP Retry Management
  • Integration Assets
    • Projects
    • Jobs
    • Environments (Streaming)
    • Engines (Streaming)
  • Preparing Data
    • Batch
      • Flows
      • Compilation Modes
      • Stages
      • Wrapped Stages
      • Schemas
      • Link Partitioning
      • Data Definitions
      • XML Schema Libraries
      • Hierarchical Data Stage
      • Subflows
    • Streaming
      • Flows
      • Stages
    • UDI (Unstructured Data Integration)
      • Flows
    • Datasource Type
    • Connections
    • Parameter Sets
    • Files
    • Examples
  • Access Control
    • On-Prem Access Control
      • Users
      • Access Groups
      • Roles
    • SaaS Access Control
      • Accounts
      • Users
      • Access Groups
      • Roles
      • Service IDs
      • Trusted Profiles
    • AWS Access Control
      • Accounts
      • Users
    • Project Collaborators
  • MCP Server
    • MCP Server Setup
    • MCP Server Tools
    • MCP Server Skills
  • API Reference
    • Models

Link Partitioning

Section Contents

  • Setting Partitioning
  • Adding Partition Keys
  • Removing Partition Keys
  • Inspecting Partitioning Configuration

Link Partitioning#

Link partitioning controls how data is distributed across parallel processing nodes in DataStage batch flows. The SDK provides methods to configure partitioning on Link objects between stages.

Setting Partitioning#

To configure partitioning on a link, use the Link.set_partitioning() method. You must specify a part_type parameter, and can optionally provide perform_sort, part_stable, and part_unique parameters. This method returns the Link object for method chaining.

Valid part_type values are: 'auto', 'hash', 'modulus', 'range', 'roundrobin', 'entire', 'same', and 'random'.

>>> batch_flow = project.create_flow(name='Partitioning Example', flow_type='batch')
>>> source = batch_flow.add_stage('Row Generator', 'Source')
>>> target = batch_flow.add_stage('Peek', 'Target')
>>> link = source.connect_output_to(target)
>>> link.name = 'Link_1'
>>> link.set_partitioning(part_type='hash', perform_sort=True)
Link_1 (src='Source', dest='Target')

The perform_sort parameter is only valid for 'hash', 'range', and 'modulus' partitioning types.

Note

When using modulus partitioning with perform_sort=False, only one partition key is allowed. The SDK automatically sets the key_col_select attribute to the partition key column name. When perform_sort=True, multiple keys are allowed and key_col_select is set to 'default'.

Adding Partition Keys#

After setting the partitioning type, use the Link.add_partition_key() method to specify which columns to use for partitioning. This method requires a key_col parameter and accepts optional parameters for sorting configuration. This method returns the Link object for method chaining.

>>> link.add_partition_key('CUSTOMER_ID', sorting=True, sort_order='asc')
Link_1 (src='Source', dest='Target')
>>> link.add_partition_key('ORDER_DATE', sorting=True, sort_order='desc')
Link_1 (src='Source', dest='Target')
>>> link.add_partition_key('REGION', sorting=False, case_sensitive=False)
Link_1 (src='Source', dest='Target')

You can also chain these method calls together:

>>> link.set_partitioning(part_type='hash', perform_sort=True).add_partition_key('CUSTOMER_ID', sorting=True).add_partition_key('ORDER_DATE', sorting=True)
Link_1 (src='Source', dest='Target')

Removing Partition Keys#

To remove a partition key from a link, use the Link.remove_partition_key() method with the column name. This method also returns the Link object for method chaining.

>>> link.remove_partition_key('REGION')
Link_1 (src='Source', dest='Target')

Inspecting Partitioning Configuration#

You can inspect the partitioning configuration of a link by accessing its part_type and key_cols_part attributes.

>>> link.part_type
'hash'
>>> link.perform_sort
True
>>> len(link.key_cols_part)
2
>>> link.key_cols_part[0]
{'keyCol': 'CUSTOMER_ID', 'partitioning': True, 'sorting': True, 'ci-cs': 'cs', 'asc-desc': 'asc'}

previous

Schemas

next

Data Definitions

Section Contents
  • Setting Partitioning
  • Adding Partition Keys
  • Removing Partition Keys
  • Inspecting Partitioning Configuration

© Copyright 2026, IBM.