Overall sequence
To connect to a remote database using DirectQuery you need to complete these steps:- Configure your remote database in Atoti FRTB’s expected Database format
- Set the Atoti FRTB configuration properties
- Deploy Atoti FRTB in Horizontal Distribution
Database schema
Your remote Database must be configured in the same format as Atoti FRTB’s in-memory datastores. This means the same tables and field types will need to be replicated. You can do this by defining the tables as outlined in the Database documentation. Alternatively, you can expose views on your database in the same expected Database format.All of the database tables must be present either as actual tables or views on your connected database.
Required DirectQuery properties
The following properties must be configured to get started with DirectQuery.Maven profile
The frtb-directquery module is not included in the classpath by default. You will need to enable thedirect-query Maven profile to add the frtb-directquery
module into the classpath. This will need to be completed when building the JAR file.
Disable unsupported IMA cubes
For this preview implementation, only SA is supported when running with DirectQuery. To disable IMA, add the following property either to the frtb.properties file or as a command-line argument with the prefix-D as shown:
application.properties:
Command-line argument:
Database configuration
The application.yaml file contains specific properties for enabling and connecting to a remote database.- ClickHouse
- Databricks
- MSSQL
- Snowflake
ClickhouseSpringProperties java class.username
Full property name:directquery.database.clickhouse.usernameThe username associated with the database.password
Full property name:directquery.database.clickhouse.passwordThe password associated with the username.port
Full property name:directquery.database.clickhouse.portThe port where the ClickHouse instance is located.hostName
Full property name:directquery.database.clickhouse.hostNameThe name of the host where the ClickHouse application is running.database
Full property name:directquery.database.clickhouse.databaseThe name of the ClickHouse Database.schema
Full property name:directquery.database.clickhouse.schemaThe name of the ClickHouse Schema to use.Snowflake key-pair authentication
Snowflake is deprecating single-factor password authentication. Atoti FRTB therefore connects to Snowflake using key-pair authentication instead of a password. The base64-encoded private key is supplied through thedirectquery.database.snowflake.additional-options.private-key-base64 property.
Set up the key pair
-
Generate an unencrypted PKCS#8 RSA private key and its matching public key. The following commands create the
rsa_key.p8private key and thersa_key.pubpublic key in the current directory. -
Register the public key on the Snowflake user. Open
rsa_key.puband copy the key value. Strip the PEM header, the PEM footer, and all line breaks from the copied value. Run the following statement under a role that can alter the user, such asSECURITYADMIN. -
Base64-encode the private key and expose it to Atoti FRTB. The following command encodes the entire
rsa_key.p8file. The resulting value feeds thedirectquery.database.snowflake.additional-options.private-key-base64property.
Keep the private key secret. Provide it only through the
SNOWFLAKE_PRIVATE_KEY_BASE64 environment variable or a secret store, never in source control. To rotate the key, generate a new key pair, register the new public key on the Snowflake user, then update the environment variable with the new base64-encoded private key.Deployment options
We provide two main options to run with DirectQuery:| Option | How to run Atoti FRTB |
|---|---|
| Operate with some data loaded in-memory and the rest available through DirectQuery | In Horizontal Distribution with in-memory database |
| Run purely on DirectQuery remote data | In a Single JVM on DirectQuery only |
Dates to include filter configuration
The data nodes are distributed by AsOfDate, so no two data nodes can contain the same partition. This means that one AsOfDate cannot be present in another node. To prevent any issues, the directQueryDatesToIncludeFilter bean is used to set which dates to include in the DirectQuery data node.This property must be provided with the same values to both data nodes.
Horizontal distribution
In Horizontal Distribution you have access to the in-memory tools such as What-If, data updates and Sign-Off for the data loaded in-memory. You also have access to a large number of historical dates. When running in Horizontal Distribution you need to run three nodes:- Query node
- In-memory data node
- DirectQuery data node
JVM With Query Node
This JVM consists of the StandardisedApproachCube query node and the CombinedCube query node. Start the JVM by specifying the following parameters to the Atoti FRTB application, either in a .properties file or through command-line arguments (add-D before each property).
JVM With In-Memory Data Node
This JVM consists of the in-memory data node only. Start the JVM by specifying the following parameters to the Atoti FRTB application, either in a .properties file or through command-line arguments (add-D before each property).
JVM With DirectQuery Data Node
Once the JVM with the query and in-memory data node is running, you can start a second JVM with the DirectQuery data node with the following configuration properties either in a .properties file or through command-line arguments (add-D before each property).
- ClickHouse
- Databricks
- MSSQL
- Snowflake
Single JVM
You can run a single JVM consisting of only DirectQuery. By running in a single JVM with DirectQuery only, you can now see the DirectQuery data in the StandardisedApproachCube.Properties
To run the Single JVM node, only configure the Database Properties and Disable Unsupported IMA Cubes and run the application as normal. There are no distributed nodes to configure when running in a single JVM. Here is an example of the properties to use:- ClickHouse
- Databricks
- MSSQL
- Snowflake
Single JVM limitations
Running with a single JVM runs purely on DirectQuery. This comes at the compromise of query performance of Trade level queries while also not having access to in-memory only tools such as Atoti What-If and Atoti Sign-Off.Running both an in-memory data node and DirectQuery data node under a single JVM is not currently supported.
Reference database
- ClickHouse
- Databricks
- MSSQL
- Snowflake
Atoti FRTB ships with the SQL and data needed to initialize a ClickHouse database that can be used for testing. The table-creation script and reference data are
located within the directory:
frtb-application-tests/src/test/resources/db/liquibase/clickhouse/. The DirectQuery tests start the database in a Docker container through Testcontainers.