Skip to content

Commit 85453e1

Browse files
committed
feat: add spec field for postgres source notification
1 parent 1bdcaab commit 85453e1

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

python/cocoindex/sources.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ class AzureBlob(op.SourceSpec):
7070
account_access_key: TransientAuthEntryReference[str] | None = None
7171

7272

73+
class PostgresNotification:
74+
"""Notification for a PostgreSQL table."""
75+
76+
# Optional: name of the PostgreSQL notify function to use.
77+
# If not provided, the default notify function will be used.
78+
notify_function_name: str | None = None
79+
80+
7381
class Postgres(op.SourceSpec):
7482
"""Import data from a PostgreSQL table."""
7583

@@ -87,3 +95,6 @@ class Postgres(op.SourceSpec):
8795
# Optional: column name to use for ordinal tracking (for incremental updates)
8896
# Should be a timestamp, serial, or other incrementing column
8997
ordinal_column: str | None = None
98+
99+
# Optional: when set, supports change capture from PostgreSQL notification.
100+
notification: PostgresNotification | None = None

src/ops/sources/postgres.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ struct FieldSchemaInfo {
1313
decoder: PgValueDecoder,
1414
}
1515

16+
#[derive(Debug, Deserialize)]
17+
pub struct NotificationSpec {
18+
notify_function_name: Option<String>,
19+
}
20+
1621
#[derive(Debug, Deserialize)]
1722
pub struct Spec {
1823
/// Table name to read from (required)
@@ -23,6 +28,8 @@ pub struct Spec {
2328
included_columns: Option<Vec<String>>,
2429
/// Optional: ordinal column for tracking changes
2530
ordinal_column: Option<String>,
31+
/// Optional: notification for change capture
32+
notification: Option<NotificationSpec>,
2633
}
2734

2835
#[derive(Clone)]

0 commit comments

Comments
 (0)