Skip to content

Latest commit

 

History

History
41 lines (27 loc) · 2.05 KB

File metadata and controls

41 lines (27 loc) · 2.05 KB

Example: SingleStore Collocated Service Using Binary Protocol

Summary

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 .

Usage

To run this example, you'll need to do the following:

  1. Copy this program to each node of your database cluster.
  2. 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;

Product Documentation:

External Functions Collocated Service ROWDAT_1 Format