postgresqlmaterialized-viewsmicrostrategy

Connecting Microstrategy Cube to a Postgres Materialized View


I have created a Materialized View in a Postgres Database. When I am creating my microstrategy cube connection to this Postgres Database, I am unable to see this Materialized View.

Can anyone help me to understand why I am unable to see this?

Thanks


Solution

  • You need to edit the read settings for your Warehouse Catalog. Location: Schema->Warehouse Catalog Options->Catalog->Read Settings

    Query for tables:

    SELECT n.nspname as NAME_SPACE,
      c.relname as TAB_NAME
    FROM pg_catalog.pg_class c
         LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
    WHERE c.relkind in ('v', 'm', 'r', 'p', '')
          AND n.nspname <> 'pg_catalog'
          AND n.nspname <> 'information_schema'
          AND n.nspname !~ '^pg_toast'
    ORDER BY 1,2
    

    Column Query: hanged to LEFT JOIN in on table INFORMATION_SCHEMA.COLUMNS (no issues for me so far)

    SELECT DISTINCT
        nspname                                      AS NAME_SPACE,
        relname                                      AS TAB_NAME,
        attname                                      AS COL_NAME,
        typname                                      AS DATA_TYPE,
        COALESCE(B.CHARACTER_MAXIMUM_LENGTH, attlen) AS DATA_LEN,
        NUMERIC_PRECISION                            AS DATA_PREC,
        NUMERIC_SCALE                                AS DATA_SCALE
    FROM
        pg_attribute A
    JOIN
        pg_class C
    ON
        A.attrelid = C.oid
    JOIN
        pg_namespace N
    ON
        C.relnamespace = N.oid
    JOIN
        pg_type T
    ON
        A.atttypid = T.oid
    LEFT OUTER JOIN
        INFORMATION_SCHEMA.COLUMNS B
    ON
        A.attname = B.COLUMN_NAME
    AND C.relname = B.TABLE_NAME
    AND N.nspname = B.TABLE_SCHEMA
    WHERE
        relname IN (#TABLE_LIST#)
    AND attnum > 0
    ORDER BY
        1,
        2,
        3
    

    Especially the columns query could be improved but until now I haven't looked back at this as it works fine.

    Reason for all of this can be found in the following discussion: Materialized views don't show up in information_schema.