Specifying Trino Schemas
You can specify the Trino schemas that correspond to the Aerospike sets your client applications will query.
Because it is a SQL engine, Trino requires the schema of the data that you want to query. However, Aerospike is schemaless and has no native meta-store for storing schemas. There are two ways that the Trino connector provides schemas to Trino for running SQL queries against data in Aerospike:
Inferring schemas
By default, the Trino connector uses heuristics to rapidly infer schemas without the need for you to specify them. Client applications can issue all supported types of SQL statements. However, column ordering is alphabetical only.
Using provided schemas
The Trino connector uses JSON files that you provide.
Procedure
To provide schemas for the Trino connector to use, follow these steps:
Provide the schema for each table
For each table, create a JSON file with the name of the schema, which corresponds to the Aerospike namespace, and defines the schema of the table, which corresponds to the Aerospike set. For example, here is a JSON file that defines table1
in schema
:
{
"schemaName": "schema1",
"tableName": "table1",
"columns":[
{
"name": "id",
"type": "varchar",
"hidden": false
},
{
"name": "int",
"type": "bigint",
"hidden": false
},
{
"name": "list",
"type": "json",
"hidden": false
},
{
"name": "map",
"type": "json",
"hidden": false
}
]
}
If you want to include, in one file, multiple schemas for more than one Aerospike set in a single Aerospike namespace, enclose the comma-separated list of the definitions by using square brackets.
Specify the location of the JSON files
If you are setting up a non-Dockerized environment, follow these steps:
- Place the JSON files in a single directory.
- In the file
<trino_dir>/etc/catalog/aerospike.properties
, add the propertyaerospike.table-desc-dir
and set its value to the path of the directory.
If you are setting up a Dockerized environment, place the JSON files in a single directory. When you deploy a Trino cluster, you mount that directory to each container that you create with the docker run
command.
Update the corresponding JSON files whenever you change the schema of the data in Aerospike. The Trino connector cannot detect changes to the schema automatically.
What to do next
Return to step 5 in "Deploying Trino Clusters and the Trino Connector in Docker".