Expressing arbitrary granularities via SQL

Hi all,

In the JSON query API we can express duration-based granularities like so:

“granularity”: {

“duration”: 300000,

“origin”: “2017-06-14T00:00:00”,

“type”: “duration”

}

Can these be expressed via SQL? The SQL documentation of functions like FLOOR has a token, but there is no grammar for that token. Some of the examples mention using HOUR, DAY, MONTH but that’s it.

Thanks,

There’s a PR out (https://github.com/druid-io/druid/pull/4360) that will add support to Druid SQL for all period granularities (via a TIME_FLOOR function) although not duration granularities. Duration granularities could be added too, although that might not be necessary, since I think you could get the same effect with a period granularity with a period like PT300000S.

Thanks Gian. Period-based granularities are certainly fine from my perspective. What are the chances of success of cherry-picking that somewhat beastly PR into the 0.10 branch? I wouldn’t be surprised if it is dependent on other changes merged post 0.10.

Thanks,

–Ben

It’s going to be tough to merge it into 0.10.0 without taking a lot of other stuff too. As you suspect, the roots run deep. It would merge somewhat more easily onto 0.10.1, which should be entering the release candidate phase soon (and will probably not include this patch).