It would, I agree, be preferable to state the PTD feature in terms that are clear and understandable before we attempt to add the feature back into the 1.1 codebase. The existing implementation worked, but only for a particular database implementation of PTD, and you're correct that it complicated the code in the sql backend.
We perhaps could express the PTD feature, independent of database implementation and at the logical layer of cubes instead of the physical/mapping layer, in terms of an extra, implicit "cut" on the time dimension:
1) A model defines a time dimension, call it 'date', with several "cubes standard" dimension levels with standard meanings. That is, 'date.year' is the four-digit common calendar year, 'date.dow' is the day of week expressed as 1..7, 'date.week' is the YYYY-MM-DD format of the day ending that week, etc.
2) The model defines a second dimension, call it 'date_ptd', which somehow indicates that the first time dimension 'date' is a *template* for 'date_ptd' dimension. Also, 'date_ptd' indicates that it wishes to be a PTD dimension adding an implicit cut for the underlying template dimension, 'date'.
3) In order for the PTD implicit cut to work, the underlying 'date' dimension needs to define extra hierarchies that re-use existing levels in new arrangements, or alternately, cubes allows cut specifications that don't specify every level of a hierarchy, but instead can specify a cut starting at a depth lower than the top level.
Example:
On March 18, 2015, a user wishes to aggregate a cube 'sales' with drilldown 'date_ptd@ymd:month'. The user wants aggregates, segmented by (year, month), but only aggregating facts whose time falls in the period-to-date of its month -- the first 18 days of each month.
Although the user merely requests /cube/sales/aggregate?drilldown=date_ptd@ymd:month, the cubes server sees that date_ptd is a PTD dimension using 'date' dimension as a template. So it first translates date_ptd@ymd:month into date@ymd:month. Then, the server determines the current datetime, sees that the next level below 'month' in the date_ptd@ymd: (and date@ymd) hierarchy is 'day', determines that the current day is day 18. Then it can compute an extra implicit cut filtering out any date after the 18th of the month.
Now, how to define such a cut? If the 'date' dimension helpfully includes a date@dayhour hierarchy, with 'date.day' level at the top of the hierarchy, then cubes server -- still working at the logical layer -- can say, "hey, there's a hierarchy in the dimension where the level we want a range cut for is at the top level. Let's use it!" Then the implicit cut becomes cut=date@dayhour:1-18 and the server can execute the equivalent of
/cube/sales/aggregate?drilldown=date@ymd:month&cut=date@dayhour:1-18
but when returning results provide the metadata as for ?drilldown=date_ptd@ymd:month .
This approach stays entirely at the logical layer, so it imposes no extra complexity on any particular cubes backend. Only the logical layer's cube browser needs to interpret the PTD-ness of the ate_ptd dimension, calculate the implicit cut, and proceed with the backend's aggregation.
However, this approach requires that the source/template dimension, 'date', define a whole lot of hierarchies solely for the purpose of accomplishing implicit PTD cuts. If you want to drilldown by (year, month), then some other hierarchy must exist with 'date.day' at the top. If you want to drilldown by (year), then some hierarchy must exist with 'date.month' at the top. Any level on which a user might want a drilldown requires that another hierarchy exist in the dimension with the next largest level at the top. I would hate to require users to create all these hierarchies manually; perhaps we could include them in our standard time dimension so that modelers could use that standard time dimension as a template and get all these extra hierarchies.
The only other alternative to the "lots of extra hierarchies stamped out from a template" would be to allow cuts that start below the top level of a hierarchy, e.g. ?cut=date@ymd:?,?,1-?,?,18 where "?" is a placeholder for some character sequence meaning "ignore this level". Such an allowance seems to violate the idea of a drilldown hierarchy, and perhaps might cause performance problems for some backends or some models, so we wouldn't want to add this feature to the cut specification that every cube and backend would have to support.
But if we allow ?cut=date@ymd:?,?,1-?,?,18 then there is no need at all for extra hierarchies to accomplish PTD behavior. It's also possible for us to forbid "downlevel cuts" like this by default, and a cube or dimension must explicitly allow this with a setting in its model.
An extra concern: The PTD dimension I have in my current models don't want to do implicit cuts just on the level below the drilldown level, e.g. "cut for day 1-18 for a month drilldown, cut for hour 0-13 for a day drilldown". Instead, I want *all* the implicit cuts for a particular time dimension to be down to the hour regardless of the drilldown: "cut for day 1-18 AND hour 0-13". Well, that works fine given current cubes specification, because multiple cuts for the same dimension are allowed, so the implicit cut would be ?cut=date@ymdh:?,1-?,18;date@ymdh:?,?,?,0-?,?,?,13 and I'm very happy with that for my current PTD needs. At the logical layer, I could perhaps define this with { "ptd": "hour" } somewhere in the model for the PTD dimension, and that would be used to determine the depth of the implicit cuts.
I have separate thoughts about the non/semi-additive feature, which I'll post separately...