cube-js / cube-js/cube

Separate database for preaggregations

Open
#5,563 2 comments 0 reactions 0 assignees View on GitHub
driver:mssql
Dominant language
Rust
Stars
20.8k
Forks
2.1k
Avg merge
1d 2h
Merged PRs (30d)
181

Description

I am using CubeJS against read-only replica of the MS SQL database (I imagine it is a very common scenario).
Regardless of schema, the database is read-only, so CubeJS can not create temporary preaggreation tables.

I need a way to specify a database name (on the same server) for preaggregations. I tried providing preaggregation schema with '.' in it (i.e. 'cubejsdb.preagg_schema') but got an error about table name having an extra '.' or something like that.

I was able to work around this issue as follows:
1. Point CUBEJS_DB_NAME to an empty R/W database that will receive preaggregations
2. In schema files add a dbname prefix to all tables: Instead of 'select .. from my_table1 join mytable2 ' I have 'select ... from actual_db..my_table1 join actual_db..my_table2' . (where actual_db is my R/O replica)

Since the databases are on the same server, 'insert from select' statements that cubejs uses work fine.
This solution is messy since I have to deploy these template files to various environments that have possibly different database names.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.