Skip to main content

Module postgres_source

Module postgres_source 

Source
Expand description

PostgreSQL lookup source with connection pooling and predicate pushdown. PostgreSQL lookup source implementation.

Provides a LookupSource backed by PostgreSQL with connection pooling via deadpool-postgres and predicate pushdown support.

§Features

  • Connection pooling: Efficient connection reuse via deadpool-postgres
  • Predicate pushdown: Translates Predicate variants to SQL WHERE clauses (except NotEq, which is always evaluated locally)
  • Projection pushdown: SELECT only requested columns
  • Batch lookups: WHERE pk = ANY($1) for single-column primary keys, WHERE (pk1, pk2) IN (...) for composite keys

§Example

use std::sync::Arc;
use arrow_schema::{DataType, Field, Schema};
use laminar_connectors::lookup::postgres_source::{
    PostgresLookupSource, PostgresLookupSourceConfig,
};

let config = PostgresLookupSourceConfig {
    connection_string: "host=localhost dbname=mydb user=app".into(),
    table_name: "customers".into(),
    primary_key_columns: vec!["id".into()],
    ..Default::default()
};
let schema = Arc::new(Schema::new(vec![
    Field::new("id", DataType::Int64, false),
    Field::new("name", DataType::Utf8, true),
]));
let source = PostgresLookupSource::new(config, schema)?;

Structs§

PostgresLookupSource
PostgreSQL implementation of the LookupSource trait.
PostgresLookupSourceConfig
Configuration for the PostgreSQL lookup source.

Functions§

build_query
Build a SQL query from table name, primary keys, lookup keys, predicates, and an optional projection.