cube
cube copied to clipboard
Use Redshift-appropriate query for information schema discovery
Describe the bug
The RedshiftDriver
class inherits createSchemaIfNotExists()
from the BaseDriver
class, by way of the PostgresDriver
class. The implementation of that method doesn't error on Redshift, but it only returns results for schemas owned by the querying user. This results in breakage when Cube.js accesses Redshift with credentials that can access a schema but is not the owner of the schema, because the existing implementation of createSchemaIfNotExists()
will return no results, and will then attempt to create the pre-aggregation schema. If the calling user does not have permission to create schemas, this will result in an error being thrown without any explanation of which query failed.
To Reproduce Steps to reproduce the behavior:
- Provision a Redshift cluster
- Create a
pre_aggregation
schema in that cluster - Create a user in that cluster, with access to the
pre_aggregation
schema (e.g.,GRANT USAGE ON SCHEMA pre_aggregation TO ...;
- Create a Cube.js app with a one-cube schema containing a simple pre-aggregation
- Run the Cube.js app configured for scheduled refresh, to use the Redshift cluster as the default source DB and to use credentials for the user created in step 3
- Watch it fail with a permission error
Expected behavior
Expected Cube.js to function correctly when running as a user with appropriate permissions in the pre-aggregation schema (SELECT
, CREATE TABLE
, etc).
Screenshots
n/a
Version:
0.29.15