1. Introduction

Redis SQL Trino is a Trino connector which allows access to RediSearch data from Trino.

This guide provides documentation and usage information across the following topics:

2. Installation

2.1. Trino

Trino installation instructions are available at https://trino.io/docs/current/installation.html.

2.2. RediSearch connector

Download latest release and unzip without any directory structure under:

<trino>/plugin/redisearch

Create a RediSearch connector configuration file and change/add properties as needed.

3. Configuration

To configure the RediSearch connector, create a catalog properties file and change/add properties as needed.

etc/catalog/redisearch.properties
connector.name=redisearch
redisearch.uri=redis://localhost:6379
Table 1. Connector properties
Property name Description Default

redisearch.default-schema-name

The schema that contains all tables defined without a qualifying schema name.

default

redisearch.case-insensitive-names

Match index names case insensitively.

false

redisearch.default-limit

Max number of documents returned by FT.SEARCH and FT.AGGREGATE when no limit is present in the SQL query.

10000

redisearch.cursor-count

Number of rows read during each aggregation cursor fetch.

1000

Table 2. Redis connection properties
Property name Description Default

redisearch.uri

A Redis connection string. Redis URI syntax.

redisearch.username

Redis connection username.

redisearch.password

Redis connection password.

redisearch.cluster

Connect to a Redis Cluster.

false

redisearch.resp2

Force Redis protocol version to RESP2.

false

The RediSearch connector provides additional security options to support Redis servers with TLS mode.

Table 3. TLS properties
Property name Description Default

redisearch.insecure

Allow insecure connections (e.g. invalid certificates) when using SSL.

false

redisearch.cacert-path

X.509 CA certificate file to verify with.

redisearch.key-path

PKCS#8 private key file to authenticate with (PEM format).

redisearch.key-password

Password of the private key file, or null if it’s not password-protected.

redisearch.cert-path

X.509 certificate chain file to authenticate with (PEM format).

4. Clients

4.1. JDBC Driver

The Trino JDBC driver allows users to access Trino from Java-based applications, and other non-Java applications running in a JVM.

Refer to the Trino documentation for setup instructions.

The following is an example of a JDBC URL used to create a connection to Redis SQL Trino:

jdbc:trino://example.net:8080/redisearch/default

4.2. Tableau

Refer to the Tableau documentation for setup instructions.

4.3. Trino CLI

Refer to the Trino CLI documentation for setup instructions.

5. Build

Run these commands to build the Trino connector for RediSearch from source (requires Java 17+):

git clone https://github.com/redis-field-engineering/redis-sql-trino.git
cd Redis SQL Trino
./mvnw clean package -DskipTests

6. Complete Walkthrough

Follow these step-by-step instructions to deploy a single-node Trino server on Ubuntu.

6.1. Install Java

Trino requires a 64-bit version of Java 17. It is recommended to use Azul Zulu as the JDK.

$ java -version
openjdk version "17.0.4.1" 2022-08-12 LTS
OpenJDK Runtime Environment Zulu17.36+17-CA (build 17.0.4.1+1-LTS)
OpenJDK 64-Bit Server VM Zulu17.36+17-CA (build 17.0.4.1+1-LTS, mixed mode, sharing)

6.2. Set up Trino

Download the Trino server tarball and unpack it.

wget https://repo1.maven.org/maven2/io/trino/trino-server/403/trino-server-403.tar.gz
mkdir /usr/lib/trino
tar xzvf trino-server-403.tar.gz --directory /usr/lib/trino --strip-components 1

Trino needs a data directory for storing logs, etc. It is recommended to create a data directory outside of the installation directory, which allows it to be easily preserved when upgrading Trino.

Create a data directory
mkdir -p /var/trino

Create an etc directory inside the installation directory to hold configuration files.

mkdir /usr/lib/trino/etc

Create a node.properties file.

/usr/lib/trino/etc/node.properties
node.environment=production
node.id=ffffffff-ffff-ffff-ffff-ffffffffffff
node.data-dir=/var/trino

Create a JVM config file.

/usr/lib/trino/etc/jvm.config
-server
-Xmx16G
-XX:InitialRAMPercentage=80
-XX:MaxRAMPercentage=80
-XX:G1HeapRegionSize=32M
-XX:+ExplicitGCInvokesConcurrent
-XX:+ExitOnOutOfMemoryError
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-XX:ReservedCodeCacheSize=512M
-XX:PerMethodRecompilationCutoff=10000
-XX:PerBytecodeRecompilationCutoff=10000
-Djdk.attach.allowAttachSelf=true
-Djdk.nio.maxCachedBufferSize=2000000
-XX:+UnlockDiagnosticVMOptions
-XX:+UseAESCTRIntrinsics

Create a config properties file.

/usr/lib/trino/etc/config.properties
coordinator=true
node-scheduler.include-coordinator=true
http-server.http.port=8080
discovery.uri=http://localhost:8080

Create a logging configuration file.

/usr/lib/trino/etc/log.properties
io.trino=INFO

6.3. Set up Redis SQL Trino

Download latest release and unzip without any directory structure under plugin/redisearch:

wget https://github.com/redis-field-engineering/redis-sql-trino/releases/download/v0.3.4/redis-sql-trino-0.3.4.zip
unzip -j redis-sql-trino-0.3.4.zip -d /usr/lib/trino/plugin/redisearch

Create a etc/catalog subdirectory:

mkdir /usr/lib/trino/etc/catalog

Create a RediSearch connector configuration file:

/usr/lib/trino/etc/catalog/redisearch.properties
connector.name=redisearch
redisearch.uri=redis://localhost:6379

Change and/or add properties as needed.

6.4. Start Trino

Start the Trino server:

/usr/lib/trino/bin/launcher run

6.5. Run Trino CLI

Download and run trino-cli-403-executable.jar:

wget https://repo1.maven.org/maven2/io/trino/trino-cli/403/trino-cli-403-executable.jar -O /usr/local/bin/trino
chmod +x /usr/local/bin/trino
trino --catalog redisearch --schema default

Run a SQL query:

trino:default> select * from mySearchIndex;