DirectQuery

The DirectQuery feature is designed to connect the Atoti Server implementation to an external database as a data repository. The core API categorizes the different implementations of the DirectQuery interface based on the underlying database. The Business Solutions are intended to connect to any supported database without any additional effort compared to the in-memory datastore.

To bridge the gap between the separated Atoti Server API and the need for a unified API, the common lib provides tools to abstract the specifics of each API. It also provides tools to migrate the In-Memory schema and generate a database schema.

Database Connection

The connection sequence is the only specific code that needs to be instanced. For each database there is an implementation base class and a Spring parameter set and a Spring conditional.

Database Implementation class Spring parameters Conditional
ClickHouse ClickHouseToolbox ClickhouseSpringProperties @ConditionalOnClickHouse
Databricks DatabricksToolbox DatabricksSpringProperties @ConditionalOnDatabricks
MSSQL MSSQLToolbox MSSQLSpringProperties @ConditionalOnMSSQL
Snowflake SnowflakeToolbox SnowflakeSpringProperties @ConditionalOnSnowflake

Here is the example of a Spring connection class:

@Configuration
@Import(value = SnowflakeSpringProperties.class)
@ConditionalOnSnowflake
public class SnowflakeSessionConfig {
	@Bean
	public IToolbox toolbox(SnowflakeSpringProperties snowflakeProperties) {
		return SnowflakeToolbox.createSessionToolsFromSpring(snowflakeProperties);
	}
}

DirectQuery toolbox

The toolbox provides a common way to access the DirectQuery feature while being agnostic of the database type. The base toolbox instance is provided by the connection layer. To manipulate the DirectQuery objects, you need to use a more generic interface common to all implementations.

For instance, the specific table interfaces are:

  • com.activeviam.directquery.clickhouse.api.Table for Clickhouse
  • com.activeviam.directquery.databricks.api.Table for Databricks
  • com.activeviam.directquery.mssql.api.Table for MSSQL
  • com.activeviam.directquery.snowflake.api.Table for Snowflake

The common interface is com.activeviam.database.api.schema.IDataTable but is read-only, so to manipulate a table you need to go through the ITableToolbox API.

Specific instance Generic interface Toolbox subsection Subsection call
Table IDataTable ITableToolbox toolbox.getTableToolbox()
Field IDataTableField IFieldToolbox toolbox.getFieldToolbox()
Database IDirectQueryDatabase IDatabaseToolbox toolbox.getDatabaseToolbox()
Schema IDatabaseSchema ISchemaToolbox toolbox.getSchemaToolbox()
Session N/A ISession toolbox.getSession()

The Session is a singleton and has no generic interface, so the session manipulation is done as a proxy and not as a toolbox. The ISession instance contains the session object instance, so its method doesn’t need the session as a parameter.

Extra methods and services from the toolbox

  • schemaBuilder(): The function that returns a compatible and generic object that behaves as Schema.builder().
  • sqlDialect(): The access to the SQL generation tools compatible with the underlying database.
  • isNativeVectorSupport(): Returns true if the underlying database handles the vector types natively.

REST

Cube update and database check

directquery/refresh

Refreshes the data based on the latest version of the underlying database.

directquery/validateSchema

Validates the underlying database content against the specified schema constraints.