Skip to main content

A Python SDK for building RisingWave data pipelines with PostgreSQL CDC and multiple sink destinations

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

RisingWave Pipeline SDK

A Python SDK for building RisingWave data pipelines with PostgreSQL CDC, automatic table discovery, and multiple sink destinations.

Features

  • PostgreSQL CDC Integration: Complete Change Data Capture support with automatic schema discovery
  • Flexible Table Selection: Pattern-based, interactive, or programmatic table selection
  • Multiple Sink Support: Iceberg, S3, and PostgreSQL destinations
  • Advanced CDC Configuration: SSL, backfilling, publication management, and more
  • SQL Generation: Automatically generates optimized RisingWave SQL statements

Installation

# Using uv (recommended)
uv add risingwave-pipeline-sdk

# Using pip
pip install risingwave-pipeline-sdk

Quick Start

from risingwave_pipeline_sdk import (
    RisingWaveClient,
    PipelineBuilder,
    PostgreSQLConfig,
    TableSelector
)

# Connect to RisingWave
client = RisingWaveClient("postgresql://root@localhost:4566/dev")

# Configure PostgreSQL CDC
config = PostgreSQLConfig(
    hostname="localhost",
    port=5432,
    username="postgres",
    password="secret",
    database="mydb",
    auto_schema_change=True
)

# Create pipeline with table selection
builder = PipelineBuilder(client)
result = builder.create_postgresql_pipeline(
    config=config,
    table_selector=TableSelector(include_patterns=["users", "orders"])
)

print(f"Created CDC source with {len(result['selected_tables'])} tables")

Table Discovery and Selection

Discover Available Tables

# Discover all available tables
available_tables = builder.discover_postgresql_tables(config)

for table in available_tables:
    print(f"{table.qualified_name} - {table.row_count} rows")

Flexible Table Selection

# Select specific tables
TableSelector(specific_tables=["users", "orders", "products"])

# Pattern-based selection
TableSelector(
    include_patterns=["user_*", "order_*"],
    exclude_patterns=["*_temp", "*_backup"]
)

# Include all tables except specific ones
TableSelector(
    include_all=True,
    exclude_patterns=["temp_*", "backup_*"]
)

PostgreSQL CDC Configuration

config = PostgreSQLConfig(
    # Connection details
    hostname="localhost",
    port=5432,
    username="postgres",
    password="secret",
    database="mydb",
    schema_name="public",

    # CDC settings
    auto_schema_change=True,
    publication_name="rw_publication",
    slot_name="rw_slot",

    # SSL configuration
    ssl_mode="require",
    ssl_root_cert="/path/to/ca.pem",

    # Performance tuning
    backfill_parallelism="8",
    backfill_num_rows_per_split="100000",
    backfill_as_even_splits=True
)

Sink Destinations

Iceberg Data Lake

from risingwave_pipeline_sdk import IcebergConfig

iceberg_config = IcebergConfig(
    sink_name="analytics_lake",
    warehouse_path="s3://my-warehouse/",
    database_name="analytics",
    table_name="events",
    catalog_type="storage",

    # S3 configuration
    s3_region="us-east-1",
    s3_access_key="your-access-key",
    s3_secret_key="your-secret-key",

    # Data type
    data_type="append-only",
    force_append_only=True
)

# Create sink
builder.create_sink(iceberg_config, ["events", "users"])

S3 Data Archive

from risingwave_pipeline_sdk import S3Config

s3_config = S3Config(
    sink_name="data_archive",
    bucket_name="my-data-bucket",
    path="raw-data/",
    region_name="us-east-1",
    access_key_id="your-access-key",
    secret_access_key="your-secret-key",

    # Format configuration
    format_type="PLAIN",
    encode_type="PARQUET"
)

builder.create_s3_sink(s3_config, ["users", "orders"])

PostgreSQL Analytics Database

from risingwave_pipeline_sdk import PostgreSQLSinkConfig

analytics_config = PostgreSQLSinkConfig(
    sink_name="analytics_db",
    hostname="analytics.example.com",
    port=5432,
    username="analytics_user",
    password="password",
    database="analytics",
    postgres_schema="real_time"
)

# Create sink with custom transformations
custom_queries = {
    "users": "SELECT id, name, email, created_at FROM users WHERE active = true",
    "orders": "SELECT * FROM orders WHERE status != 'cancelled'"
}

builder.create_postgresql_sink(
    analytics_config,
    ["users", "orders"],
    select_queries=custom_queries
)

Complete Pipeline Example

# 1. Set up CDC source
cdc_result = builder.create_postgresql_pipeline(
    config=postgres_config,
    table_selector=TableSelector(include_patterns=["user_*", "order_*"])
)

selected_tables = [t.qualified_name for t in cdc_result['selected_tables']]

# 2. Create multiple sinks
builder.create_s3_sink(s3_config, selected_tables)  # Data lake
builder.create_postgresql_sink(analytics_config, selected_tables)  # Analytics
builder.create_sink(iceberg_config, selected_tables)  # Iceberg warehouse

Examples

The examples/ directory contains complete working examples:

  • postgres_cdc_iceberg_pipeline.py - End-to-end CDC to Iceberg pipeline
  • interactive_discovery.py - Interactive table discovery and selection
  • env_config_example.py - Environment variable based configuration

Environment Configuration

Configure using environment variables for production deployments:

# RisingWave connection
export RW_HOST=localhost
export RW_PORT=4566
export RW_USER=root
export RW_DATABASE=dev

# PostgreSQL CDC source
export PG_HOST=localhost
export PG_PORT=5432
export PG_USER=postgres
export PG_PASSWORD=secret
export PG_DATABASE=mydb

# Table selection
export TABLE_PATTERNS="users,orders,products"

Development

# Clone and set up development environment
git clone https://github.com/risingwavelabs/risingwave-pipeline-sdk.git
cd risingwave-pipeline-sdk

# Install with development dependencies
uv venv
source .venv/bin/activate
uv pip install -e .[dev]

# Run tests
pytest

# Format code
ruff format .

Requirements

  • Python ≥ 3.10
  • RisingWave instance (local or cloud)
  • PostgreSQL with CDC enabled
  • Required Python packages: psycopg[binary], pydantic

License

Apache 2.0 License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

risingwave_pipeline_sdk-0.1.1.tar.gz (75.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

risingwave_pipeline_sdk-0.1.1-py3-none-any.whl (29.1 kB view details)

Uploaded Python 3

File details

Details for the file risingwave_pipeline_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: risingwave_pipeline_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 75.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for risingwave_pipeline_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3463b7a76f30c0f41c2dd9ed48ba4860b440be9941f6820dcc8fdfead29cf367
MD5 49512aeec03aee25cd459d33ce6072c1
BLAKE2b-256 f3417e04b45bf5ab3be60501473f63f2d9c72cb3d2051ffccdf321fa627d07fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for risingwave_pipeline_sdk-0.1.1.tar.gz:

Publisher: publish.yml on risingwavelabs/risingwave-pipeline-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file risingwave_pipeline_sdk-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for risingwave_pipeline_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7826ff46f64cd33b2b4147fb115004c681e4e680ef8768cd8c3b5f1d41dc77aa
MD5 ff0a8956b40ef245363b1292e83d661e
BLAKE2b-256 a67f47eb2de6b4411e9d7d005fe64b00168b77792278dbe0f04802acbed9190c

See more details on using hashes here.

Provenance

The following attestation bundles were made for risingwave_pipeline_sdk-0.1.1-py3-none-any.whl:

Publisher: publish.yml on risingwavelabs/risingwave-pipeline-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page