jazzido / mondrian-rest

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

catch pluck errors to warn about potential dimension ID/name conflicts #36

Open jspeis opened 6 years ago

jspeis commented 6 years ago

Per #35 , the goal would be to warn MR users of potential issues that can arise when two different IDs share the same name.

hwchen commented 6 years ago

More background, which I had written in another issue:

Puma caught this error: undefined method `[]' for nil:NilClass (NoMethodError)
/home/deploy/.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'
org/jruby/RubyArray.java:2486:in `map'
/home/deploy/.rvm/gems/jruby-9.1.13.0/gems/mondrian-rest-1.0.0-java/lib/mondrian_rest/api_formatters.rb:104:in `pluck'
/home/deploy/.rvm/gems/jruby-9.1.13.0/gems/mondrian-rest-1.0.0-java/lib/mondrian_rest/api_formatters.rb:63:in `block in tidy'

This is an error that happens when there's duplicate labels in a dimension and formatting into csv, jsonrecords (anything not default).

Root issue is duplicates in labels (not the ids!). So far we've just fixed the data and the error went away. This leads to a more permanent solution of enforcing unique membership in every single col of every dimension.

However, there's another issue. Why didn't the default json throw an error when confronted with duplicate labels!

My hazy recollection (perhaps documented elsewhere) is that mondrian would choose the last of the duplicate labels, while silently erasing the previous duplicates.

We should figure out how this can be dealt with within Mondrian and Mondrian-rest: