blob: 96a41ccd0fa976bb2eec63bbef3a7d84d05fc031 [file] [log] [blame]
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>Compressed Big Decimal · Apache Druid</title><meta name="viewport" content="width=device-width, initial-scale=1.0"/><link rel="canonical" href="https://druid.apache.org/docs/latest/development/extensions-contrib/compressed-big-decimal.html"/><meta name="generator" content="Docusaurus"/><meta name="description" content="&lt;!--"/><meta name="docsearch:language" content="en"/><meta name="docsearch:version" content="26.0.0" /><meta property="og:title" content="Compressed Big Decimal · Apache Druid"/><meta property="og:type" content="website"/><meta property="og:url" content="https://druid.apache.org/index.html"/><meta property="og:description" content="&lt;!--"/><meta property="og:image" content="https://druid.apache.org/img/druid_nav.png"/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://druid.apache.org/img/druid_nav.png"/><link rel="shortcut icon" href="/img/favicon.png"/><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"/><script async="" src="https://www.googletagmanager.com/gtag/js?id=UA-131010415-1"></script><script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'UA-131010415-1');
</script><link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css"/><link rel="stylesheet" href="/css/code-block-buttons.css"/><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js"></script><script type="text/javascript" src="/js/code-block-buttons.js"></script><script src="/js/scrollSpy.js"></script><link rel="stylesheet" href="/css/main.css"/><script src="/js/codetabs.js"></script></head><body class="sideNavVisible separateOnPageNav"><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/"><img class="logo" src="/img/druid_nav.png" alt="Apache Druid"/></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class=""><a href="/technology" target="_self">Technology</a></li><li class=""><a href="/use-cases" target="_self">Use Cases</a></li><li class=""><a href="/druid-powered" target="_self">Powered By</a></li><li class=""><a href="/docs/latest/design/index.html" target="_self">Docs</a></li><li class=""><a href="/community/" target="_self">Community</a></li><li class=""><a href="https://www.apache.org" target="_self">Apache</a></li><li class=""><a href="/downloads.html" target="_self">Download</a></li><li class="navSearchWrapper reactNavSearchWrapper"><input type="text" id="search_input_react" placeholder="Search" title="Search"/></li></ul></nav></div></header></div></div><div class="navPusher"><div class="docMainWrapper wrapper"><div class="container mainContainer docsContainer"><div class="wrapper"><div class="post"><header class="postHeader"><a class="edit-page-link button" href="https://github.com/apache/druid/edit/master/docs/development/extensions-contrib/compressed-big-decimal.md" target="_blank" rel="noreferrer noopener">Edit</a><h1 id="__docusaurus" class="postHeaderTitle">Compressed Big Decimal</h1></header><article><div><span><!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<h2><a class="anchor" aria-hidden="true" id="overview"></a><a href="#overview" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Overview</h2>
<p><strong>Compressed Big Decimal</strong> is an extension which provides support for Mutable big decimal value that can be used to accumulate values without losing precision or reallocating memory. This type helps in absolute precision arithmetic on large numbers in applications, where greater level of accuracy is required, such as financial applications, currency based transactions. This helps avoid rounding issues where in potentially large amount of money can be lost.</p>
<p>Accumulation requires that the two numbers have the same scale, but does not require that they are of the same size. If the value being accumulated has a larger underlying array than this value (the result), then the higher order bits are dropped, similar to what happens when adding a long to an int and storing the result in an int. A compressed big decimal that holds its data with an embedded array.</p>
<p>Compressed big decimal is an absolute number based complex type based on big decimal in Java. This supports all the functionalities supported by Java Big Decimal. Java Big Decimal is not mutable in order to avoid big garbage collection issues. Compressed big decimal is needed to mutate the value in the accumulator.</p>
<h4><a class="anchor" aria-hidden="true" id="main-enhancements-provided-by-this-extension"></a><a href="#main-enhancements-provided-by-this-extension" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Main enhancements provided by this extension:</h4>
<ol>
<li>Functionality: Mutating Big decimal type with greater precision</li>
<li>Accuracy: Provides greater level of accuracy in decimal arithmetic</li>
</ol>
<h2><a class="anchor" aria-hidden="true" id="operations"></a><a href="#operations" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Operations</h2>
<p>To use this extension, make sure to <a href="/docs/latest/development/extensions.html#loading-extensions">load</a> <code>compressed-big-decimal</code> to your config file.</p>
<h2><a class="anchor" aria-hidden="true" id="configuration"></a><a href="#configuration" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Configuration</h2>
<p>There are currently no configuration properties specific to Compressed Big Decimal</p>
<h2><a class="anchor" aria-hidden="true" id="limitations"></a><a href="#limitations" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Limitations</h2>
<ul>
<li>Compressed Big Decimal does not provide correct result when the value being accumulated has a larger underlying array than this value (the result), then the higher order bits are dropped, similar to what happens when adding a long to an int and storing the result in an int.</li>
</ul>
<h3><a class="anchor" aria-hidden="true" id="ingestion-spec"></a><a href="#ingestion-spec" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Ingestion Spec:</h3>
<ul>
<li>Most properties in the Ingest spec derived from <a href="/docs/latest/ingestion/index.html">Ingestion Spec</a> / <a href="/docs/latest/ingestion/data-formats.html">Data Formats</a></li>
</ul>
<table>
<thead>
<tr><th>property</th><th>description</th><th>required?</th></tr>
</thead>
<tbody>
<tr><td>metricsSpec</td><td>Metrics Specification, In metrics specification while specifying metrics details such as name, type should be specified as compressedBigDecimal</td><td>Yes</td></tr>
</tbody>
</table>
<h3><a class="anchor" aria-hidden="true" id="query-spec"></a><a href="#query-spec" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Query spec:</h3>
<ul>
<li>Most properties in the query spec derived from <a href="/docs/latest/querying/groupbyquery.html">groupBy query</a> / <a href="/docs/latest/querying/timeseriesquery.html">timeseries</a>, see documentation for these query types.</li>
</ul>
<table>
<thead>
<tr><th>property</th><th>description</th><th>required?</th></tr>
</thead>
<tbody>
<tr><td>queryType</td><td>This String should always be either &quot;groupBy&quot; OR &quot;timeseries&quot;; this is the first thing Druid looks at to figure out how to interpret the query.</td><td>yes</td></tr>
<tr><td>dataSource</td><td>A String or Object defining the data source to query, very similar to a table in a relational database. See <a href="/docs/latest/querying/datasource.html">DataSource</a> for more information.</td><td>yes</td></tr>
<tr><td>dimensions</td><td>A JSON list of <a href="/docs/latest/querying/dimensionspecs.html">DimensionSpec</a> (Notice that property is optional)</td><td>no</td></tr>
<tr><td>limitSpec</td><td>See <a href="/docs/latest/querying/limitspec.html">LimitSpec</a></td><td>no</td></tr>
<tr><td>having</td><td>See <a href="/docs/latest/querying/having.html">Having</a></td><td>no</td></tr>
<tr><td>granularity</td><td>A period granularity; See <a href="../../querying/granularities.html#period-granularities">Period Granularities</a></td><td>yes</td></tr>
<tr><td>filter</td><td>See <a href="/docs/latest/querying/filters.html">Filters</a></td><td>no</td></tr>
<tr><td>aggregations</td><td>Aggregations forms the input to Averagers; See <a href="/docs/latest/querying/aggregations.html">Aggregations</a>. The Aggregations must specify type, scale and size as follows for compressedBigDecimal Type <code>&quot;aggregations&quot;: [{&quot;type&quot;: &quot;compressedBigDecimal&quot;,&quot;name&quot;: &quot;..&quot;,&quot;fieldName&quot;: &quot;..&quot;,&quot;scale&quot;: [Numeric],&quot;size&quot;: [Numeric]}</code>. Please refer query example in Examples section.</td><td>Yes</td></tr>
<tr><td>postAggregations</td><td>Supports only aggregations as input; See <a href="/docs/latest/querying/post-aggregations.html">Post Aggregations</a></td><td>no</td></tr>
<tr><td>intervals</td><td>A JSON Object representing ISO-8601 Intervals. This defines the time ranges to run the query over.</td><td>yes</td></tr>
<tr><td>context</td><td>An additional JSON Object which can be used to specify certain flags.</td><td>no</td></tr>
</tbody>
</table>
<h2><a class="anchor" aria-hidden="true" id="examples"></a><a href="#examples" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Examples</h2>
<p>Consider the data as</p>
<table>
<thead>
<tr><th>Date</th><th>Item</th><th>SaleAmount</th></tr>
</thead>
<tbody>
</tbody>
</table>
<pre><code class="hljs"><span class="hljs-number">20201208</span>,ItemA,<span class="hljs-number">0.0</span>
<span class="hljs-number">20201208</span>,ItemB,<span class="hljs-number">10.000000000</span>
<span class="hljs-number">20201208</span>,ItemA,<span class="hljs-number">-1.000000000</span>
<span class="hljs-number">20201208</span>,ItemC,<span class="hljs-number">9999999999.000000000</span>
<span class="hljs-number">20201208</span>,ItemB,<span class="hljs-number">5000000000.000000005</span>
<span class="hljs-number">20201208</span>,ItemA,<span class="hljs-number">2.0</span>
<span class="hljs-number">20201208</span>,ItemD,<span class="hljs-number">0.0</span>
</code></pre>
<p>IngestionSpec syntax:</p>
<pre><code class="hljs css language-json">{
<span class="hljs-attr">"type"</span>: <span class="hljs-string">"index_parallel"</span>,
<span class="hljs-attr">"spec"</span>: {
<span class="hljs-attr">"dataSchema"</span>: {
<span class="hljs-attr">"dataSource"</span>: <span class="hljs-string">"invoices"</span>,
<span class="hljs-attr">"timestampSpec"</span>: {
<span class="hljs-attr">"column"</span>: <span class="hljs-string">"timestamp"</span>,
<span class="hljs-attr">"format"</span>: <span class="hljs-string">"yyyyMMdd"</span>
},
<span class="hljs-attr">"dimensionsSpec"</span>: {
<span class="hljs-attr">"dimensions"</span>: [{
<span class="hljs-attr">"type"</span>: <span class="hljs-string">"string"</span>,
<span class="hljs-attr">"name"</span>: <span class="hljs-string">"itemName"</span>
}]
},
<span class="hljs-attr">"metricsSpec"</span>: [{
<span class="hljs-attr">"name"</span>: <span class="hljs-string">"saleAmount"</span>,
<span class="hljs-attr">"type"</span>: *<span class="hljs-string">"compressedBigDecimal"</span>*,
<span class="hljs-attr">"fieldName"</span>: <span class="hljs-string">"saleAmount"</span>
}],
<span class="hljs-attr">"transformSpec"</span>: {
<span class="hljs-attr">"filter"</span>: <span class="hljs-literal">null</span>,
<span class="hljs-attr">"transforms"</span>: []
},
<span class="hljs-attr">"granularitySpec"</span>: {
<span class="hljs-attr">"type"</span>: <span class="hljs-string">"uniform"</span>,
<span class="hljs-attr">"rollup"</span>: <span class="hljs-literal">false</span>,
<span class="hljs-attr">"segmentGranularity"</span>: <span class="hljs-string">"DAY"</span>,
<span class="hljs-attr">"queryGranularity"</span>: <span class="hljs-string">"none"</span>,
<span class="hljs-attr">"intervals"</span>: [<span class="hljs-string">"2020-12-08/2020-12-09"</span>]
}
},
<span class="hljs-attr">"ioConfig"</span>: {
<span class="hljs-attr">"type"</span>: <span class="hljs-string">"index_parallel"</span>,
<span class="hljs-attr">"inputSource"</span>: {
<span class="hljs-attr">"type"</span>: <span class="hljs-string">"local"</span>,
<span class="hljs-attr">"baseDir"</span>: <span class="hljs-string">"/home/user/sales/data/staging/invoice-data"</span>,
<span class="hljs-attr">"filter"</span>: <span class="hljs-string">"invoice-001.20201208.txt"</span>
},
<span class="hljs-attr">"inputFormat"</span>: {
<span class="hljs-attr">"type"</span>: <span class="hljs-string">"tsv"</span>,
<span class="hljs-attr">"delimiter"</span>: <span class="hljs-string">","</span>,
<span class="hljs-attr">"skipHeaderRows"</span>: <span class="hljs-number">0</span>,
<span class="hljs-attr">"columns"</span>: [
<span class="hljs-string">"timestamp"</span>,
<span class="hljs-string">"itemName"</span>,
<span class="hljs-string">"saleAmount"</span>
]
}
},
<span class="hljs-attr">"tuningConfig"</span>: {
<span class="hljs-attr">"type"</span>: <span class="hljs-string">"index_parallel"</span>
}
}
}
</code></pre>
<h3><a class="anchor" aria-hidden="true" id="group-by-query--example"></a><a href="#group-by-query--example" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Group By Query example</h3>
<p>Calculating sales groupBy all.</p>
<p>Query syntax:</p>
<pre><code class="hljs css language-json">{
<span class="hljs-attr">"queryType"</span>: <span class="hljs-string">"groupBy"</span>,
<span class="hljs-attr">"dataSource"</span>: <span class="hljs-string">"invoices"</span>,
<span class="hljs-attr">"granularity"</span>: <span class="hljs-string">"ALL"</span>,
<span class="hljs-attr">"dimensions"</span>: [
],
<span class="hljs-attr">"aggregations"</span>: [
{
<span class="hljs-attr">"type"</span>: <span class="hljs-string">"compressedBigDecimal"</span>,
<span class="hljs-attr">"name"</span>: <span class="hljs-string">"saleAmount"</span>,
<span class="hljs-attr">"fieldName"</span>: <span class="hljs-string">"saleAmount"</span>,
<span class="hljs-attr">"scale"</span>: <span class="hljs-number">9</span>,
<span class="hljs-attr">"size"</span>: <span class="hljs-number">3</span>
}
],
<span class="hljs-attr">"intervals"</span>: [
<span class="hljs-string">"2020-01-08T00:00:00.000Z/P1D"</span>
]
}
</code></pre>
<p>Result:</p>
<pre><code class="hljs css language-json">[ {
<span class="hljs-attr">"version"</span> : <span class="hljs-string">"v1"</span>,
<span class="hljs-attr">"timestamp"</span> : <span class="hljs-string">"2020-12-08T00:00:00.000Z"</span>,
<span class="hljs-attr">"event"</span> : {
<span class="hljs-attr">"revenue"</span> : <span class="hljs-number">15000000010.000000005</span>
}
} ]
</code></pre>
<p>Had you used <em>doubleSum</em> instead of compressedBigDecimal the result would be</p>
<pre><code class="hljs css language-json">[ {
<span class="hljs-attr">"timestamp"</span> : <span class="hljs-string">"2020-12-08T00:00:00.000Z"</span>,
<span class="hljs-attr">"result"</span> : {
<span class="hljs-attr">"revenue"</span> : <span class="hljs-number">1.500000001E10</span>
}
} ]
</code></pre>
<p>As shown above the precision is lost and could lead to loss in money.</p>
<h3><a class="anchor" aria-hidden="true" id="timeseries-query-example"></a><a href="#timeseries-query-example" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>TimeSeries Query Example</h3>
<p>Query syntax:</p>
<pre><code class="hljs css language-json">{
<span class="hljs-attr">"queryType"</span>: <span class="hljs-string">"timeseries"</span>,
<span class="hljs-attr">"dataSource"</span>: <span class="hljs-string">"invoices"</span>,
<span class="hljs-attr">"granularity"</span>: <span class="hljs-string">"ALL"</span>,
<span class="hljs-attr">"aggregations"</span>: [
{
<span class="hljs-attr">"type"</span>: <span class="hljs-string">"compressedBigDecimal"</span>,
<span class="hljs-attr">"name"</span>: <span class="hljs-string">"revenue"</span>,
<span class="hljs-attr">"fieldName"</span>: <span class="hljs-string">"revenue"</span>,
<span class="hljs-attr">"scale"</span>: <span class="hljs-number">9</span>,
<span class="hljs-attr">"size"</span>: <span class="hljs-number">3</span>
}
],
<span class="hljs-attr">"filter"</span>: {
<span class="hljs-attr">"type"</span>: <span class="hljs-string">"not"</span>,
<span class="hljs-attr">"field"</span>: {
<span class="hljs-attr">"type"</span>: <span class="hljs-string">"selector"</span>,
<span class="hljs-attr">"dimension"</span>: <span class="hljs-string">"itemName"</span>,
<span class="hljs-attr">"value"</span>: <span class="hljs-string">"ItemD"</span>
}
},
<span class="hljs-attr">"intervals"</span>: [
<span class="hljs-string">"2020-12-08T00:00:00.000Z/P1D"</span>
]
}
</code></pre>
<p>Result:</p>
<pre><code class="hljs css language-json">[ {
<span class="hljs-attr">"timestamp"</span> : <span class="hljs-string">"2020-12-08T00:00:00.000Z"</span>,
<span class="hljs-attr">"result"</span> : {
<span class="hljs-attr">"revenue"</span> : <span class="hljs-number">15000000010.000000005</span>
}
} ]
</code></pre>
</span></div></article></div><div class="docs-prevnext"></div></div></div><nav class="onPageNav"><ul class="toc-headings"><li><a href="#overview">Overview</a></li><li><a href="#operations">Operations</a></li><li><a href="#configuration">Configuration</a></li><li><a href="#limitations">Limitations</a><ul class="toc-headings"><li><a href="#ingestion-spec">Ingestion Spec:</a></li><li><a href="#query-spec">Query spec:</a></li></ul></li><li><a href="#examples">Examples</a><ul class="toc-headings"><li><a href="#group-by-query--example">Group By Query example</a></li><li><a href="#timeseries-query-example">TimeSeries Query Example</a></li></ul></li></ul></nav></div><footer class="nav-footer druid-footer" id="footer"><div class="container"><div class="text-center"><p><a href="/technology">Technology</a> · <a href="/use-cases">Use Cases</a> · <a href="/druid-powered">Powered by Druid</a> · <a href="/docs/latest/">Docs</a> · <a href="/community/">Community</a> · <a href="/downloads.html">Download</a> · <a href="/faq">FAQ</a></p></div><div class="text-center"><a title="Join the user group" href="https://groups.google.com/forum/#!forum/druid-user" target="_blank"><span class="fa fa-comments"></span></a> · <a title="Follow Druid" href="https://twitter.com/druidio" target="_blank"><span class="fab fa-twitter"></span></a> · <a title="Download via Apache" href="https://www.apache.org/dyn/closer.cgi?path=/incubator/druid/{{ site.druid_versions[0].versions[0].version }}/apache-druid-{{ site.druid_versions[0].versions[0].version }}-bin.tar.gz" target="_blank"><span class="fas fa-feather"></span></a> · <a title="GitHub" href="https://github.com/apache/druid" target="_blank"><span class="fab fa-github"></span></a></div><div class="text-center license">Copyright © 2022 <a href="https://www.apache.org/" target="_blank">Apache Software Foundation</a>.<br/>Except where otherwise noted, licensed under <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a>.<br/>Apache Druid, Druid, and the Druid logo are either registered trademarks or trademarks of The Apache Software Foundation in the United States and other countries.</div></div></footer></div><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script><script>
document.addEventListener('keyup', function(e) {
if (e.target !== document.body) {
return;
}
// keyCode for '/' (slash)
if (e.keyCode === 191) {
const search = document.getElementById('search_input_react');
search && search.focus();
}
});
</script><script>
var search = docsearch({
appId: 'CPK9PMSCEY',
apiKey: 'd4ef4ffe3a2f0c7d1e34b062fd98736b',
indexName: 'apache_druid',
inputSelector: '#search_input_react',
algoliaOptions: {"facetFilters":["language:en","version:26.0.0"]}
});
</script></body></html>