implydata / pivot

An interactive data exploration UI for Druid

Home Page:https://docs.imply.io/latest/pivot-overview/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Don't work as expected After modify timezone.

Hailei opened this issue · comments

Version: 0.8.27
If I modify time zone to "Asia/Shanghai".
data range picker will display as expected, but pick a time range and query, can't return expected result.e.g if selected interval is 14:00~15:00,but return the data of 6:00 ~ 7:00.

I found that the interval that was posted to pivot server from browser use UTC timezone

"actions":[{"action":"in","expression":{"op":"literal","value":{"start":"2016-05-12T06:44:00.000Z","end":"2016-05-12T06:54:00.000Z"},"type":"TIME_RANGE"}}

Plywood will translate this interval use method dateToIntervalPart

function dateToIntervalPart(date) {
        return date.toISOString()
            .replace('Z', '')
            .replace('.000', '')
            .replace(/:00$/, '')
            .replace(/:00$/, '')
            .replace(/T00$/, '');
    }

Just drop the last letter "Z",the date will use local timezone "Asia/shanghai",but the result is wrong.

the query json like this

{"queryType":"timeseries","dataSource":"dsp_analysis","intervals":"2016-05-12T06:44/2016-05-12T06:54","granularity":{"type":"period","period":"PT1M","timeZone":"Asia/Shanghai"},"context":{"timeout":30000,"skipEmptyBuckets":"true"},"filter":{"type":"and","fields":[{"type":"selector","dimension":"cast","value":"15748"},{"type":"or","fields":[{"type":"selector","dimension":"idea","value":"22195"},{"type":"selector","dimension":"idea","value":"22204"}]}]},"aggregations":[{"name":"pv_sum","type":"doubleSum","fieldName":"pv_sum"},{"name":"bid_sum","type":"doubleSum","fieldName":"bid_sum"},{"name":"consume_sum","type":"doubleSum","fieldName":"consume_sum"}]}

related to #161 #41

I have found the cause. Because My druid use local timezone 'Asia/shanghai'.
But I don't why drop the last letter 'Z'

Hi. Plywood assumes that Druid is running in Etc/UTC that is why it drops the 'Z'. It probably should not do it. I have never encountered a Druid cluster not running in UTC which is why we never detected it in the test. Will fix.

Hi, just consulted some Druid committers. I will modify Plywood to explicitly send 'Z' over in the interval and it may fix your issue but you should change the timezone of your Druid server to UTC. There are a lot of things in Druid that assume timezones being evaluated in UTC.

Hi Pivot will send Z in version >= 0.8.28. Please still consider switching your Druid to be in UTC timezone as many other things (Druid internal) might not work right for you.

@vogievetsky Thanks
My Druid using Asia/shanghai timezone has been running for over half year,hadn't found any Time Zone problem so far.
Druid always transform the interval of query to the given time zone by java environment. e.g.
-Duser.timezone="Asia/Shanghai",the interval "2016-05-13T12Z/2016-05-13T14Z" will be transformed to "2016-05-13T20:00:00.000+08:00/2016-05-13T21:00:00.000+08:00".
So I don't need set timezone to UTC ,
The interval with Timezone is a good idea.No matter which time zone druid use,it always work as expected.