jazzido / mondrian-rest

A REST interface for Mondrian ROLAP server
MIT License
32 stars 8 forks source link

Formatting bug #33

Closed hwchen closed 6 years ago

hwchen commented 6 years ago
moncli -b http://localhost:9292 q ces -d "Indicator.Indicator" -m "Population" --format csv
[500 Internal Server Error]:
Puma caught this error: undefined method `[]' for nil:NilClass (NoMethodError)
/home/hwchen/.rvm/gems/jruby-9.1.13.0/gems/mondrian-rest-1.0.0-java/lib/mondrian_rest/api_formatters.rb:104:in `block in pluck'

The schema is basically

<Schema name="test_schema">
    <Cube name="test_cube">
        <Table name="test" schema="test" />
        <Dimension name="Year">
            <Hierarchy hasAll="true">
                <Level name="Year" column="year" levelType="TimeYears" type="Numeric" uniqueMembers="true" />
            </Hierarchy>
        </Dimension>
        <Dimension name="Indicator" foreignKey="id">
            <Hierarchy hasAll="true" primaryKey="id">
                <Table name="dim_test" schema="test" />
                <Level name="Indicator" column="id" nameColumn="name"/>
            </Hierarchy>
        </Dimension>

        <Measure aggregator="sum" column="population" name="Population" visible="true" />

    </Cube>
</Schema>

I think that there may be something odd about the data, because I haven't been able to replicate the behavior on other datasets.

However, for this dataset, changing Indicator Dimension to reference the fact table instead of a dim table fixes the issue.

(The other way to fix the issue is to use the default json format)

So it may just be that reporting a nicer error would be all that is necessary, but I'm going to look at this a bit more.

@jspeis

hwchen commented 6 years ago

With a change in schema and cleaning up the data, this error no longer appears.