What is a DirectQuery connector?
A DirectQuery connector lets Atoti run queries on an external database. Atoti generates these queries from the cube and the operations requested by users. The database runs each query and returns the result to Atoti. The connector holds the information needed to reach the database:- The address of the database, usually a connection string.
- The credentials of the database user.
- Settings that control how DirectQuery queries the database, such as query timeouts.
- Atoti Java SDK: each connector is a Maven module added to the Atoti application.
The application creates a
DirectQueryConnectorwith the connector factory of the database. - Atoti Python SDK: each connector is a plugin installed as a Python package.
The plugin adds the Java connector to the Java engine underneath, so both SDKs use the same connector.
Session.connect_to_external_database()sets up the connector and returns anExternalDatabaseConnection. Despite its name, this object represents the connector, not a single connection to the database.
What does “external database” mean in DirectQuery?
In DirectQuery, the external database is the data source that holds the fact-level data. Atoti queries this data where it is stored, without loading it into the in-memory Atoti Datastore. The Atoti Content Server can also store its content in a relational database. That database holds dashboards, calculated measures, and user settings, not the data queried by the cube. The Content Server database is not an external database in the DirectQuery sense. For more information, read Atoti Content Server.What does the connector expose?
A DirectQuery connector exposes the tables of the external database. Atoti can discover these tables and their columns through the connector. The application then selects the tables it needs and adds them to the DirectQuery schema.Which permissions does the database user need?
The connector authenticates as a user of the external database. This user is not a person: it is the database account of the Atoti application. The database sets the available authentication methods, such as a password, a key file, or a token. The database-side requirements are the same in the Atoti Java SDK and the Atoti Python SDK. Both SDKs use the same DirectQuery connector, so the database sees the same user and the same queries. At a minimum, the database user needs the permissions to:- Connect to the database, and to the warehouse or compute resource where one is required.
- Read the schemas and tables used by the application.
- Run queries on the database.
How does DirectQuery manage connections to the database?
To run a query, the connector opens a connection to the database: a session that sends SQL and receives the results. Most DirectQuery connectors use a connection pool. A connection pool keeps a set of open connections and reuses them across queries. Reusing connections avoids the cost of opening a new connection for every query. The connectors that use the JDBC standard use the HikariCP connection pool:- Amazon Redshift
- Databricks
- Generic JDBC
- Microsoft Azure Synapse
- Microsoft SQL Server
- Snowflake
- Connections are opened on demand, when a query needs one.
- The maximum number of connections is set automatically, based on the number of CPU cores available.
- Atoti Java SDK: the
hikaricp.configurationFileJava system property - Atoti Python SDK:
java_options, with-Dhikaricp.configurationFile=<path>
Where is the connection setup for each database?
Find out how to connect to each database with:- Atoti Java SDK:
- Atoti Python SDK (
ConnectionConfig):