DataBrewery / cubes

[NOT MAINTAINED] Light-weight Python OLAP framework for multi-dimensional data analysis
http://cubes.databrewery.org
Other
1.49k stars 314 forks source link

Querying dimension members with a multi-valued cut value causes repeated results #362

Closed jjmontesl closed 8 years ago

jjmontesl commented 8 years ago

The following query:

http://localhost:5000/cube/boe_article/members/date_published?hierarchy=daily&depth=1&cut=department%3Aagencia_espanola_de_proteccion_de_datos%3Banulaciones

Produces the following result, where the actual dimension member is repeated (2013) and the cut dimension department_id appears where it should not.

{
    "hierarchy": "daily", 
    "depth": 1, 
    "data": [
        {
            "department.id": "agencia_espanola_de_proteccion_de_datos", 
            "date_published.year": 2013
        }, 
        {
            "department.id": "anulaciones", 
            "date_published.year": 2013
        }
    ], 
    "dimension": "date_published"
}

The produced SQL:

2016-06-14 01:28:49,140 DEBUG using mapper StarSchemaMapper for cube 'boe_article' (locale: None)
2016-06-14 01:28:49,145 DEBUG SQL(members):
SELECT date_published.year AS "date_published.year", department.id AS "department.id" 
FROM boe_article JOIN boe_department AS department ON boe_article.department_id = department.id JOIN date AS date_published ON boe_article.date_published_id = date_published.id 
WHERE department.id = ? OR department.id = ? GROUP BY "date_published.year", "department.id"

127.0.0.1 - - [14/Jun/2016 01:28:49] "GET /cube/boe_article/members/date_published?hierarchy=daily&depth=1&cut=department%3Aagencia_espanola_de_proteccion_de_datos%3Banulaciones HTTP/1.1" 200 -

Seems to me that department.id shall not be part of the SELECT nor part of the GROUP BY.

jjmontesl commented 8 years ago

Confirmed. Works for me.