From 8aa17aad883dade5ab996c2282724f691259135e Mon Sep 17 00:00:00 2001 From: Pierre Villard Date: Sat, 23 May 2026 21:40:21 +0200 Subject: [PATCH] fix: parameterize schema and publication name in postgres-cdc-demo init SQL - Add Publication Name parameter (default: demo_publication) - Replace hardcoded demo_postgres schema with #{Schema Name} in init SQL - Replace hardcoded demo_publication with #{Publication Name} in init SQL - Update documentation to include Publication Name parameter .... Generated with [Cortex Code](https://docs.snowflake.com/en/user-guide/cortex-code/cortex-code) Co-Authored-By: Cortex Code --- flows/data-generator/postgres-cdc-demo.json | 10 ++++++++-- flows/data-generator/postgres-cdc-demo.md | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/flows/data-generator/postgres-cdc-demo.json b/flows/data-generator/postgres-cdc-demo.json index 30dbdef..767ddc6 100644 --- a/flows/data-generator/postgres-cdc-demo.json +++ b/flows/data-generator/postgres-cdc-demo.json @@ -830,7 +830,7 @@ "Max Batch Size": "1", "Connection Pooling Service": "ce22d3a0-f94b-3a61-ffff-ffff82c298f6", "Max Content Reference Size": "32 KB", - "SQL": "CREATE SCHEMA IF NOT EXISTS demo_postgres;\n\nCREATE TABLE IF NOT EXISTS demo_postgres.customers (\n customer_id INTEGER PRIMARY KEY,\n first_name VARCHAR(100) NOT NULL,\n last_name VARCHAR(100) NOT NULL,\n email VARCHAR(255),\n phone VARCHAR(50),\n updated_at TIMESTAMP DEFAULT NOW()\n);\n\nCREATE TABLE IF NOT EXISTS demo_postgres.orders (\n order_id INTEGER PRIMARY KEY,\n customer_id INTEGER NOT NULL,\n order_status VARCHAR(50) DEFAULT 'pending',\n total_amount NUMERIC(10,2),\n shipping_address TEXT,\n updated_at TIMESTAMP DEFAULT NOW()\n);\n\nCREATE TABLE IF NOT EXISTS demo_postgres.order_items (\n item_id SERIAL PRIMARY KEY,\n order_id INTEGER NOT NULL,\n product_name VARCHAR(255) NOT NULL,\n quantity INTEGER DEFAULT 1,\n unit_price NUMERIC(10,2)\n);\n\nDO $$\nBEGIN\n IF NOT EXISTS (SELECT 1 FROM pg_publication WHERE pubname = 'demo_publication') THEN\n CREATE PUBLICATION demo_publication FOR TABLE\n demo_postgres.customers,\n demo_postgres.orders,\n demo_postgres.order_items;\n END IF;\nEND\n$$;" + "SQL": "CREATE SCHEMA IF NOT EXISTS #{Schema Name};\n\nCREATE TABLE IF NOT EXISTS #{Schema Name}.customers (\n customer_id INTEGER PRIMARY KEY,\n first_name VARCHAR(100) NOT NULL,\n last_name VARCHAR(100) NOT NULL,\n email VARCHAR(255),\n phone VARCHAR(50),\n updated_at TIMESTAMP DEFAULT NOW()\n);\n\nCREATE TABLE IF NOT EXISTS #{Schema Name}.orders (\n order_id INTEGER PRIMARY KEY,\n customer_id INTEGER NOT NULL,\n order_status VARCHAR(50) DEFAULT 'pending',\n total_amount NUMERIC(10,2),\n shipping_address TEXT,\n updated_at TIMESTAMP DEFAULT NOW()\n);\n\nCREATE TABLE IF NOT EXISTS #{Schema Name}.order_items (\n item_id SERIAL PRIMARY KEY,\n order_id INTEGER NOT NULL,\n product_name VARCHAR(255) NOT NULL,\n quantity INTEGER DEFAULT 1,\n unit_price NUMERIC(10,2)\n);\n\nDO $$\nBEGIN\n IF NOT EXISTS (SELECT 1 FROM pg_publication WHERE pubname = '#{Publication Name}') THEN\n CREATE PUBLICATION #{Publication Name} FOR TABLE\n #{Schema Name}.customers,\n #{Schema Name}.orders,\n #{Schema Name}.order_items;\n END IF;\nEND\n$$;" }, "propertyDescriptors": { "Max Batch Size": { @@ -1616,7 +1616,6 @@ "flowFileOutboundPolicy": "STREAM_WHEN_AVAILABLE", "componentType": "PROCESS_GROUP" }, - "externalControllerServices": {}, "parameterContexts": { "CDC Postgres Demo - Data Generator": { "name": "CDC Postgres Demo - Data Generator", @@ -1660,6 +1659,13 @@ "sensitive": false, "provided": false, "value": "demo_postgres" + }, + { + "name": "Publication Name", + "description": "Name of the PostgreSQL publication to create for CDC. Must match the publication name used by the CDC connector.", + "sensitive": false, + "provided": false, + "value": "demo_publication" } ], "description": "", diff --git a/flows/data-generator/postgres-cdc-demo.md b/flows/data-generator/postgres-cdc-demo.md index 0f92690..a023bbf 100644 --- a/flows/data-generator/postgres-cdc-demo.md +++ b/flows/data-generator/postgres-cdc-demo.md @@ -13,7 +13,9 @@ The flow automatically creates the required Postgres schema, tables, and publica | `Database Connection URL` | JDBC URL to the Postgres instance | | `Database Name` | Postgres database name | | `Database User` | Postgres username | -| `Schema Name` | Schema for the generated tables | +| `Database Password` | Postgres password (sensitive) | +| `Schema Name` | Schema for the generated tables (used in CREATE SCHEMA, CREATE TABLE, and CREATE PUBLICATION) | +| `Publication Name` | Name of the PostgreSQL publication created for CDC. Must match the publication name configured in the CDC connector. Default: `demo_publication` | | `Database Driver` | JDBC driver asset (postgresql-42.7.10.jar) | ## Deployment