Skip to content

Commit 992b85b

Browse files
mfernestclaudegithub-actions[bot]
authored
docs(DOC-1806): document sql_insert static fields and sql_raw for dynamic SQL (#389)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent aa33b9a commit 992b85b

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

docs-data/connect-diff-4.79.0_to_4.81.0.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"comparison": {
33
"oldVersion": "4.79.0",
44
"newVersion": "4.81.0",
5-
"timestamp": "2026-03-13T22:52:48.391Z"
5+
"timestamp": "2026-03-17T19:12:59.240Z"
66
},
77
"summary": {
88
"newComponents": 0,

modules/components/pages/outputs/sql_insert.adoc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,35 @@ include::components:example$advanced/outputs/sql_insert.yaml[]
4141

4242
include::redpanda-connect:components:partial$examples/outputs/sql_insert.adoc[]
4343

44+
== Dynamic SQL operations
45+
46+
The `table` and `columns` fields are static strings — they do not support Bloblang interpolation. For dynamic table names, dynamic column lists, DELETE operations, or any other SQL that `sql_insert` cannot express, use the xref:components:outputs/sql_raw.adoc[`sql_raw` output] instead.
47+
48+
There is no dedicated `sql_delete` output. To delete rows, use `sql_raw` with a DELETE statement:
49+
50+
[source,yaml]
51+
----
52+
output:
53+
sql_raw:
54+
driver: postgres
55+
dsn: postgres://user:pass@localhost:5432/mydb?sslmode=disable
56+
query: "DELETE FROM my_table WHERE id = $1"
57+
args_mapping: root = [ this.id ]
58+
----
59+
60+
To insert into a table determined at runtime, use `sql_raw` with `unsafe_dynamic_query: true`, which enables Bloblang interpolation in the `query` field. Use this with caution: interpolating user-supplied values into a query can introduce SQL injection risks. Always validate or sanitize the interpolated value beforehand.
61+
62+
[source,yaml]
63+
----
64+
output:
65+
sql_raw:
66+
driver: postgres
67+
dsn: postgres://user:pass@localhost:5432/mydb?sslmode=disable
68+
unsafe_dynamic_query: true
69+
query: 'INSERT INTO ${! this.table_name } (id, value) VALUES ($1, $2)'
70+
args_mapping: root = [ this.id, this.value ]
71+
----
72+
4473
include::redpanda-connect:components:partial$fields/outputs/sql_insert.adoc[]
4574

4675
// end::single-source[]

modules/components/pages/processors/sql_insert.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ If the insert fails to execute then the message will still remain unchanged and
4343

4444
include::redpanda-connect:components:partial$examples/processors/sql_insert.adoc[]
4545

46+
== Dynamic SQL operations
47+
48+
The `table` and `columns` fields are static strings — they do not support Bloblang interpolation. For dynamic table names, dynamic column lists, DELETE operations, or any other SQL that `sql_insert` cannot express, use the xref:components:processors/sql_raw.adoc[`sql_raw` processor] instead. To use Bloblang interpolation inside `sql_raw`'s `query` field, you must enable `unsafe_dynamic_query: true`. Use this with caution, as interpolating unsanitized values into a query can introduce SQL injection risks.
49+
4650
include::redpanda-connect:components:partial$fields/processors/sql_insert.adoc[]
4751

4852
// end::single-source[]

0 commit comments

Comments
 (0)