You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/sql-create-external-stream.md
+90Lines changed: 90 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,6 +55,96 @@ Please check the [Pulsar External Stream](/pulsar-source) for more details.
55
55
56
56
Please check the [NATS JetStream External Stream](/nats-jetstream-source) for more details.
57
57
58
+
## Python External Stream
59
+
60
+
Python External Stream lets you read from and write to arbitrary sources by embedding a Python body directly in the DDL. It is available in **Timeplus Enterprise 3.1.1+**.
61
+
62
+
The `init_function_name`, `deinit_function_name`, and `init_function_parameters` lifecycle hooks require **Timeplus Enterprise 3.2.1+**.
mode ='auto'-- 'auto' (default), 'streaming', or 'batch'
89
+
```
90
+
91
+
Settings:
92
+
***type**: must be `'python'`. Required.
93
+
***read_function_name**: name of the Python function used when the stream is read from. Defaults to the stream name.
94
+
***write_function_name**: name of the Python function used when the stream is written to (sink). Defaults to `read_function_name`.
95
+
***init_function_name***(Timeplus Enterprise 3.2.1+)*: name of a Python function called once before read/write processing begins. Use it to open connections, warm caches, or stash state on `builtins` for the entry function to consume.
96
+
***init_function_parameters***(Timeplus Enterprise 3.2.1+)*: a single string passed as the only argument to the init function. Any format works (JSON, `key=value`, or a plain string) — parsing is up to your Python code. Requires `init_function_name`; otherwise the stream fails to create with `Setting 'init_function_parameters' requires 'init_function_name' to be configured`.
97
+
***deinit_function_name***(Timeplus Enterprise 3.2.1+)*: name of a Python function called once after read/write processing completes, for cleanup.
Attempting to use `init_function_name`, `deinit_function_name`, or `init_function_parameters` on versions earlier than 3.2.1 fails with:
102
+
```
103
+
Code: 115. DB::Exception: Unknown setting init_function_name: for storage ExternalStream.
104
+
```
105
+
Upgrade to 3.2.1 or later to use these hooks.
106
+
:::
107
+
108
+
### Local API credentials *(Timeplus Enterprise 3.2.2+)*
109
+
110
+
When the local API user is enabled on the server, Timeplus injects two module-level globals into every Python External Stream module so your code can authenticate back to the same timeplusd over the native TCP protocol or the REST HTTP interface without hard-coding credentials:
111
+
112
+
*`__timeplus_local_api_user` — the ephemeral local API username.
113
+
*`__timeplus_local_api_password` — the matching token. Treat this as a secret; do not log it.
114
+
115
+
Both globals are available as bare names inside the Python body — no `os.environ` lookup needed. They are regenerated on every server restart and never written to disk.
0 commit comments