-1

I'm using the latest Saiku 3.8.3 standalone and I'm having some problems using the database PostgreSQL 9.1 with different schemas then PUBLIC.

I made the datasource and it connected correctly, here is the data source I'm using without personal details:

type=OLAP
name=chegadaturistas
driver=mondrian.olap4j.MondrianOlap4jDriver
location=jdbc:mondrian:Jdbc=jdbc:postgresql://DBNAME:PORT/DB;Catalog=mondrian:///datasources/chegada_turistas.xml;JdbcDrivers=org.postgresql.Driver;
username=postgres
password=PASSWORD
security.enabled=false

I've also created the Mondrian Schema with legancy option cause I've used Schema Workbench. This is the Schema I've created:

<Schema name="DEPES" description="DEPES">
  <Cube name="CHEGADAS" visible="true" cache="true" enabled="true">
    <Table name="chegada" schema="fato" alias="chegada">
    </Table>
    <Dimension type="StandardDimension" visible="true" foreignKey="id_tempo" highCardinality="false" name="Ano">
      <Hierarchy name="ANO" visible="true" hasAll="true" allMemberName="Todos os Anos" primaryKey="id_tempo">
        <Table name="tempo" schema="dimensao" alias="Tempo">
        </Table>
        <Level name="ANO" visible="true" column="nu_ano" nameColumn="nu_ano" ordinalColumn="nu_ano" type="Integer" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
        </Level>
      </Hierarchy>
    </Dimension>
    <Dimension type="StandardDimension" visible="true" foreignKey="id_origem" highCardinality="false" name="Origem">
      <Hierarchy name="Origem" visible="true" hasAll="true" allMemberName="Todas as Origens" primaryKey="id_origem">
        <Table name="origem" schema="dimensao">
        </Table>
        <Level name="Continente" visible="true" column="no_continente" nameColumn="no_continente" ordinalColumn="no_continente" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
        </Level>
        <Level name="Pais" visible="true" column="no_pais" nameColumn="no_pais" ordinalColumn="no_pais" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
        </Level>
      </Hierarchy>
    </Dimension>
    <Dimension type="StandardDimension" visible="true" foreignKey="id_via" highCardinality="false" name="Via">
      <Hierarchy name="Via" visible="true" hasAll="true" allMemberName="Todas as Vias" primaryKey="id_via">
        <Table name="via" schema="dimensao">
        </Table>
        <Level name="Nome" visible="true" column="id_via" nameColumn="no_via" ordinalColumn="no_via" type="Integer" uniqueMembers="true" levelType="Regular" hideMemberIf="Never">
        </Level>
      </Hierarchy>
    </Dimension>
    <Dimension type="StandardDimension" visible="true" foreignKey="id_destino" highCardinality="false" name="Destino">
      <Hierarchy name="Destino" visible="true" hasAll="true" allMemberName="Todos os Destinos" primaryKey="id_destino">
        <Table name="destino" schema="dimensao">
        </Table>
        <Level name="Regiao" visible="true" column="no_regiao" nameColumn="no_regiao" ordinalColumn="no_regiao" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
        </Level>
        <Level name="UF" visible="true" column="no_uf" nameColumn="no_uf" ordinalColumn="no_uf" type="String" uniqueMembers="true" levelType="Regular" hideMemberIf="Never">
        </Level>
      </Hierarchy>
    </Dimension>
    <Dimension type="StandardDimension" visible="true" foreignKey="id_tempo" highCardinality="false" name="Mes">
      <Hierarchy name="Mes" visible="true" hasAll="true" allMemberName="Todos os Meses" primaryKey="id_tempo">
        <Table name="tempo" schema="dimensao">
        </Table>
        <Level name="Nome do Mes" visible="true" column="nu_mes" nameColumn="no_mes" ordinalColumn="nu_mes" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
        </Level>
        <Level name="N&#250;mero do Mes" visible="true" column="nu_mes" nameColumn="nu_mes" ordinalColumn="nu_mes" type="Integer" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
        </Level>
      </Hierarchy>
    </Dimension>
    <Dimension type="StandardDimension" visible="true" foreignKey="id_tempo" highCardinality="false" name="Semestre">
      <Hierarchy name="Semestre" visible="true" hasAll="true" allMemberName="Todos os Semestres" primaryKey="id_tempo">
        <Table name="tempo" schema="dimensao">
        </Table>
        <Level name="N&#250;mero do Semestre" visible="true" column="nu_semestre" nameColumn="nu_semestre" ordinalColumn="nu_semestre" type="Integer" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
        </Level>
        <Level name="Descri&#231;&#227;o do Semestre" visible="true" column="nu_semestre" nameColumn="no_semestre" ordinalColumn="no_semestre" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
        </Level>
      </Hierarchy>
    </Dimension>
    <Measure name="qt_chegada" column="qt_chegada" datatype="Integer" aggregator="sum" caption="Chegadas" description="Quantidade de Turistas" visible="true">
    </Measure>
  </Cube>
<Schema>

The problem is, when I run Saiku I can't see the schema and it has this error in log:

2016-04-08 08:17:31,976 WARN  [mondrian.rolap.RolapSchema] Model is in legacy format
2016-04-08 08:17:36,725 ERROR [org.saiku.web.core.SecurityAwareConnectionManager] Error connecting: chegadaturistas
mondrian.olap.MondrianException: Mondrian Error:Internal error: Reading row count from table [null, null, tempo]; sql=[select count(*) from "tempo"]

So I noticed the select used by mondrian in the COUNT was with just the table and not the schema.table that should be used on PostgreSQL. To get sure I created a VIEW in PostgreSQL public schema and it didn't give me this error in the "tempo" table, but gave me on another. Is there a way to force Mondrian to use the SCHEMA.TABLE on the selects for PosgreSQL?

Fizard
  • 11
  • 4
  • @tomas-greif, do you have any suggestion to this problem? Does Mondrian 4 only works with PostgreSQL in PUBLIC schema? – Fizard Apr 08 '16 at 18:58

1 Answers1

1

Problem resolved! It seems when you put legacy Mondrian 3 XML on Mondrian 4 (Saiku 3.X uses Mondrian 4) it upgrades the XML but it simply "forget" to put the database SCHEMA tag after it updates. Here is the solution I did thanks to Tom Barber (who answered this on Saiku group on Google.

So just find the log4j.xml, uncomment this (don't duplicate, it's already commented in the file):

<appender name="MONDRIAN" class="org.apache.log4j.RollingFileAppender">
     <param name="File" value="${catalina.base}/logs/mondrian.log"/>
     <param name="Append" value="false"/>
     <param name="MaxFileSize" value="500KB"/>
     <param name="MaxBackupIndex" value="1"/>

     <layout class="org.apache.log4j.PatternLayout">
       <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
     </layout>
   </appender>

   <category name="mondrian">
      <priority value="DEBUG"/>
      <appender-ref ref="MONDRIAN"/>
   </category> 

STOP SAIKU and START IT again. Wait a little and open the saiku.log (it's on "saiku_directory"\tomcat\logs\saiku.log, search the line its something like this:

<Schema name="YOUR_SCHEMA_NAME" missingLink="ignore" metamodelVersion="4.300">
    <PhysicalSchema>
........

Copy the entire schema and paste on a new file.xml, insert the tag schema="SCHEMA_NAME" on all TABLE tags like this:

OLD:
<Table name="chegada" alias="chegada">
NEW:
<Table name="chegada" schema="fato"  alias="chegada">

Start SAIKU again, upload this schema, restart saiku.

Problem solved! :D

Fizard
  • 11
  • 4