Attention: The code in this repository is intended for experimental use only and is not fully tested, documented, or supported by SingleStore. Visit the SingleStore Forums to ask questions about this repository.
This is a simple Python program that illustrates a SingleStore collocated process using the binary protocol (via Unix sockets and shared memory) and the efficient ROWDAT_1 format.
It simply returns each row it receives with the prefix HELLO
.
To run this example, you'll need to do the following:
- Copy this program to each node of your database cluster.
- Run this program on each node of your database cluster using
python3 xfunc.py
.
Once the example is running, you can create the external function in SQL like this:
CREATE EXTERNAL FUNCTION xfunc(a text) RETURNS TEXT AS COLLOCATED SERVICE '/tmp/xfunc_pipe' FORMAT ROWDAT_1;
Finally, you can run the following SQL commands to test it:
CREATE DATABASE test;
CREATE TABLE foobar(a TEXT);
INSERT INTO foobar(a) VALUES ('one'), ('two'), ('three'), ('four'), ('five'), ('six'), ('seven'), ('eight'), ('nine'), ('ten');
CREATE EXTERNAL FUNCTION xfunc(a text) RETURNS TEXT AS COLLOCATED SERVICE '/tmp/xfunc_pipe' FORMAT ROWDAT_1;
SELECT xfunc(a) FROM foobar;