cube icon indicating copy to clipboard operation
cube copied to clipboard

Use Redshift-appropriate query for information schema discovery

Open emmanuel opened this issue 3 years ago • 2 comments

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:

  1. Provision a Redshift cluster
  2. Create a pre_aggregation schema in that cluster
  3. Create a user in that cluster, with access to the pre_aggregation schema (e.g., GRANT USAGE ON SCHEMA pre_aggregation TO ...;
  4. Create a Cube.js app with a one-cube schema containing a simple pre-aggregation
  5. 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
  6. 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

emmanuel avatar Jan 05 '22 06:01 emmanuel