docs/src/main/sphinx/connector/singlestore.md
The SingleStore (formerly known as MemSQL) connector allows querying and creating tables in an external SingleStore database.
To connect to SingleStore, you need:
(singlestore-configuration)=
To configure the SingleStore connector, create a catalog properties file in
etc/catalog named, for example, example.properties, to mount the
SingleStore connector as the example catalog. Create the file with the
following contents, replacing the connection properties as appropriate for your
setup:
connector.name=singlestore
connection-url=jdbc:singlestore://example.net:3306
connection-user=root
connection-password=secret
The connection-url defines the connection information and parameters to pass
to the SingleStore JDBC driver. The supported parameters for the URL are
available in the SingleStore JDBC driver
documentation.
The connection-user and connection-password are typically required and
determine the user credentials for the connection, often a service user. You can
use {doc}secrets </security/secrets> to avoid actual values in the catalog
properties files.
(singlestore-tls)=
If you have TLS configured with a globally-trusted certificate installed on your
data source, you can enable TLS between your cluster and the data
source by appending a parameter to the JDBC connection string set in the
connection-url catalog configuration property.
Enable TLS between your cluster and SingleStore by appending the useSsl=true
parameter to the connection-url configuration property:
connection-url=jdbc:singlestore://example.net:3306/?useSsl=true
For more information on TLS configuration options, see the JDBC driver documentation.
You can have as many catalogs as you need, so if you have additional
SingleStore servers, simply add another properties file to etc/catalog
with a different name (making sure it ends in .properties). For
example, if you name the property file sales.properties, Trino
will create a catalog named sales using the configured connector.
The SingleStore connector provides a schema for every SingleStore database.
You can see the available SingleStore databases by running SHOW SCHEMAS:
SHOW SCHEMAS FROM example;
If you have a SingleStore database named web, you can view the tables
in this database by running SHOW TABLES:
SHOW TABLES FROM example.web;
You can see a list of the columns in the clicks table in the web
database using either of the following:
DESCRIBE example.web.clicks;
SHOW COLUMNS FROM example.web.clicks;
Finally, you can access the clicks table in the web database:
SELECT * FROM example.web.clicks;
If you used a different name for your catalog properties file, use
that catalog name instead of example in the above examples.
(singlestore-type-mapping)=
Because Trino and Singlestore each support types that the other does not, this
connector {ref}modifies some types <type-mapping-overview> when reading or
writing data. Data types may not map the same way in both directions between
Trino and the data source. Refer to the following sections for type mapping in
each direction.
The connector maps Singlestore types to the corresponding Trino types following this table:
:::{list-table} Singlestore to Trino type mapping :widths: 30, 30, 40 :header-rows: 1
BITBOOLEANBOOLEANBOOLEANTINYINTTINYINTTINYINT UNSIGNEDSMALLINTSMALLINTSMALLINTSMALLINT UNSIGNEDINTEGERINTEGERINTEGERINTEGER UNSIGNEDBIGINTBIGINTBIGINTBIGINT UNSIGNEDDECIMAL(20, 0)DOUBLEDOUBLEREALDOUBLEDECIMAL(p, s)DECIMAL(p, s) or NUMBERDECIMAL when p ≤ 38. Otherwise, maps to NUMBER.CHAR(n)CHAR(n)TINYTEXTVARCHAR(255)TEXTVARCHAR(65535)MEDIUMTEXTVARCHAR(16777215)LONGTEXTVARCHARVARCHAR(n)VARCHAR(n)LONGBLOBVARBINARYDATEDATETIMETIME(0)TIME(6)TIME(6)DATETIMETIMESTAMP(0)DATETIME(6)TIMESTAMP(6)JSONJSON:::
No other types are supported.
The connector maps Trino types to the corresponding Singlestore types following this table:
:::{list-table} Trino to Singlestore type mapping :widths: 30, 30, 40 :header-rows: 1
BOOLEANBOOLEANTINYINTTINYINTSMALLINTSMALLINTINTEGERINTEGERBIGINTBIGINTDOUBLEDOUBLEREALFLOATDECIMAL(p, s)DECIMAL(p, s)CHAR(n)CHAR(n)VARCHAR(65535)TEXTVARCHAR(16777215)MEDIUMTEXTVARCHARLONGTEXTVARCHAR(n)VARCHAR(n)VARBINARYLONGBLOBDATEDATETIME(0)TIMETIME(6)TIME(6)TIMESTAMP(0)DATETIMETIMESTAMP(6)DATETIME(6)JSONJSON:::
No other types are supported.
(singlestore-sql-support)=
The connector provides read access and write access to data and metadata in
a SingleStore database. In addition to the {ref}globally available <sql-globally-available> and {ref}read operation <sql-read-operations>
statements, the connector supports the following features:
(singlestore-insert)=
(singlestore-update)=
(singlestore-delete)=
(singlestore-alter-table)=
(singlestore-procedures)=
The connector includes a number of performance improvements, detailed in the following sections.
(singlestore-pushdown)=
The connector supports pushdown for a number of operations:
join-pushdownlimit-pushdowntopn-pushdown