<p dir="auto">In 0.9.x queryGranularity when represented as string was defaulting to use DurationGranularity. Now after the changes in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="200848367" data-permission-text="Title is private" data-url="https://github.com/apache/druid/issues/3850" data-hovercard-type="pull_request" data-hovercard-url="/apache/druid/pull/3850/hovercard" href="https://github.com/apache/druid/pull/3850">#3850</a>, it is now defaulted to use PeriodGranularity instead. This change is incompatible w.r.t timezone as both implementations behave differently based on the user timezone.</p>
<p dir="auto">Sample code -</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    DateTimeZone.setDefault(DateTimeZone.forOffsetHours(5));
    PeriodGranularity periodGranularity = new PeriodGranularity(new Period(&quot;P2D&quot;), null, null);
    DurationGranularity durationGranularity = new DurationGranularity(86400000, 0);
    System.out.println(jsonMapper.writeValueAsString(periodGranularity));
    System.out.println(jsonMapper.writeValueAsString(durationGranularity));"><pre class="notranslate"><code class="notranslate">    DateTimeZone.setDefault(DateTimeZone.forOffsetHours(5));
    PeriodGranularity periodGranularity = new PeriodGranularity(new Period("P2D"), null, null);
    DurationGranularity durationGranularity = new DurationGranularity(86400000, 0);
    System.out.println(jsonMapper.writeValueAsString(periodGranularity));
    System.out.println(jsonMapper.writeValueAsString(durationGranularity));
</code></pre></div>
<p dir="auto">output -</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{&quot;type&quot;:&quot;period&quot;,&quot;period&quot;:&quot;P2D&quot;,&quot;timeZone&quot;:&quot;UTC&quot;,&quot;origin&quot;:null}
{&quot;type&quot;:&quot;duration&quot;,&quot;duration&quot;:86400000,&quot;origin&quot;:&quot;1970-01-01T05:00:00.000+05:00&quot;}"><pre class="notranslate"><code class="notranslate">{"type":"period","period":"P2D","timeZone":"UTC","origin":null}
{"type":"duration","duration":86400000,"origin":"1970-01-01T05:00:00.000+05:00"}
</code></pre></div>
<p dir="auto">Notice the origin in both the versions, PeriodGranularity defaults to UTC timezone if no timezone is specified explicitly while DurationGranularity defaults to the user timezone.</p>
<p dir="auto">In doc Period Granularities are described as:</p>
<ol dir="auto">
<li>They support specifying a time zone which determines where period boundaries start</li>
<li>as well as the timezone of the returned timestamps</li>
</ol>
<p dir="auto">I run druid in UTC time. In my timeseries query,<br>
This is intervals <code class="notranslate">"intervals":["2017-05-14T00:00:00.000+08:00/2017-05-16T00:00:00.000+08:00"]</code>, this is granularity <code class="notranslate">"granularity":{"period":"P1D","timeZone":"Asia/Shanghai","type":"period"}</code>,<br>
And this is what I got</p>
<blockquote>
<p dir="auto">[<br>
{<br>
"timestamp": "2017-05-13T16:00:00.000Z",<br>
"result": {<br>
"error_count": 6154866,<br>
"sum_count": 353336733<br>
}<br>
},<br>
{<br>
"timestamp": "2017-05-14T16:00:00.000Z",<br>
"result": {<br>
"error_count": 6115738,<br>
"sum_count": 357000114<br>
}<br>
}<br>
]</p>
</blockquote>
<p dir="auto">The result is correct according to the first description as it start the time bucket from UTC 16:00:00, but according to second description, the timestamp in result are supposed to <code class="notranslate">2017-05-14T00:00:00.000+08:00</code> and <code class="notranslate">2017-05-15T00:00:00.000+08:00</code> and they are in 0.9.2.</p>
<p dir="auto">So, is it a bug to fix?</p>