I'm only starting digging into Cubes, so please pardon if I misunderstand something. I really couldn't find any existing explanation to what I'm experiencing, and the code really seems to be somewhat wrong, so I've decided to create this issue.
In my experience, when I'm querying aggregates without explicit ordering, the order_query method in utils.py never applies the natural order, although it has it.
I performed some debugging and found out that:
natural_order comes to order_query from Drilldown.natural_order;
order_query expects natural_order to be the dictionary of names->directions;
Drilldown.natural_order returns a list of tuples instead;
this causes if name in natural_order to be syntactically correct but always return false, so ORDER BY clause is not generated.
Another surprising thing is the next condition in the same if: name not in order_by. What is order_by? I don't even see it declared anywhere. Looks like without those types problems with natural_order it would actually get to the second condition and crash completely.
Sorry again if I'm misunderstanding some logic and/or design intentions. I'm really looking forward to your comments.
And some details about my environment, although I don't really think they matter.
Hi @anton-kaidalov, yeah there was already an issue on natural ordering. That's some great debugging info, thank you very much. Will have a look at this.
Hi guys,
I'm only starting digging into Cubes, so please pardon if I misunderstand something. I really couldn't find any existing explanation to what I'm experiencing, and the code really seems to be somewhat wrong, so I've decided to create this issue.
In my experience, when I'm querying aggregates without explicit ordering, the
order_query
method inutils.py
never applies the natural order, although it has it.I performed some debugging and found out that:
natural_order
comes toorder_query
fromDrilldown.natural_order
;order_query
expectsnatural_order
to be the dictionary of names->directions;Drilldown.natural_order
returns a list of tuples instead;if name in natural_order
to be syntactically correct but always return false, soORDER BY
clause is not generated.Another surprising thing is the next condition in the same
if
:name not in order_by
. What isorder_by
? I don't even see it declared anywhere. Looks like without those types problems withnatural_order
it would actually get to the second condition and crash completely.Sorry again if I'm misunderstanding some logic and/or design intentions. I'm really looking forward to your comments.
And some details about my environment, although I don't really think they matter.
My database is PostgreSQL.
I use Cubes version 1.1, installed with pipenv.
My model: