| import{_ as e,O as n,P as s,ah as a,aW as l}from"./framework-62ad666a.js";const t={},i=l(`<h2 id="查询结果集格式" tabindex="-1"><a class="header-anchor" href="#查询结果集格式" aria-hidden="true">#</a> 查询结果集格式</h2><p>在 IoTDB 中,查询结果集默认按照时间对齐,同时支持另外两种结果返回形式:</p><ul><li>设备时间对齐 <code>align by device</code></li><li>时序不对齐 <code>disable align</code></li></ul><p>注意:对齐方式子句只能用于查询语句句尾。</p><h3 id="按设备对齐" tabindex="-1"><a class="header-anchor" href="#按设备对齐" aria-hidden="true">#</a> 按设备对齐</h3><p>在 <code>align by device</code> 对齐方式下,设备名会单独作为一列出现。如果 select 子句中有 <code>n</code> 列,最终结果就会有该 <code>n + 2</code> 列(时间列和设备名字列)。</p><p>SQL 形如:</p><div class="language-sql line-numbers-mode" data-ext="sql"><pre class="language-sql"><code><span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> root<span class="token punctuation">.</span>ln<span class="token punctuation">.</span><span class="token operator">*</span><span class="token operator">*</span> <span class="token keyword">where</span> <span class="token keyword">time</span> <span class="token operator"><=</span> <span class="token number">2017</span><span class="token operator">-</span><span class="token number">11</span><span class="token operator">-</span><span class="token number">01</span>T00:<span class="token number">01</span>:<span class="token number">00</span> align <span class="token keyword">by</span> device |
| </code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>结果如下:</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>+-----------------------------+-----------------+-----------+------+--------+ |
| | Time| Device|temperature|status|hardware| |
| +-----------------------------+-----------------+-----------+------+--------+ |
| |2017-11-01T00:00:00.000+08:00|root.ln.wf01.wt01| 25.96| true| null| |
| |2017-11-01T00:01:00.000+08:00|root.ln.wf01.wt01| 24.36| true| null| |
| |1970-01-01T08:00:00.001+08:00|root.ln.wf02.wt02| null| true| v1| |
| |1970-01-01T08:00:00.002+08:00|root.ln.wf02.wt02| null| false| v2| |
| |2017-11-01T00:00:00.000+08:00|root.ln.wf02.wt02| null| true| v2| |
| |2017-11-01T00:01:00.000+08:00|root.ln.wf02.wt02| null| true| v2| |
| +-----------------------------+-----------------+-----------+------+--------+ |
| Total line number = 6 |
| It costs 0.012s |
| </code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="时序不对齐" tabindex="-1"><a class="header-anchor" href="#时序不对齐" aria-hidden="true">#</a> 时序不对齐</h3><p>在 <code>disable align</code> 对齐方式下,如果 select 子句中有 <code>n</code> 列,最终结果就会有该 <code>n * 2</code> 列(时间序列的时间和值)。</p><p>注:时序不对齐方式不能用于聚合查询、空值填充,但可使用 Limit 和 Offset 语句进行分页。</p><p>SQL 形如:</p><div class="language-sql line-numbers-mode" data-ext="sql"><pre class="language-sql"><code><span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> root<span class="token punctuation">.</span>ln<span class="token punctuation">.</span><span class="token operator">*</span><span class="token operator">*</span> <span class="token keyword">where</span> <span class="token keyword">time</span> <span class="token operator"><=</span> <span class="token number">2017</span><span class="token operator">-</span><span class="token number">11</span><span class="token operator">-</span><span class="token number">01</span>T00:<span class="token number">01</span>:<span class="token number">00</span> <span class="token keyword">disable</span> align |
| </code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>结果如下:</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>+-----------------------------+--------------------------+-----------------------------+------------------------+-----------------------------+-----------------------------+-----------------------------+------------------------+ |
| | Time|root.ln.wf02.wt02.hardware| Time|root.ln.wf02.wt02.status| Time|root.ln.wf01.wt01.temperature| Time|root.ln.wf01.wt01.status| |
| +-----------------------------+--------------------------+-----------------------------+------------------------+-----------------------------+-----------------------------+-----------------------------+------------------------+ |
| |1970-01-01T08:00:00.001+08:00| v1|1970-01-01T08:00:00.001+08:00| true|2017-11-01T00:00:00.000+08:00| 25.96|2017-11-01T00:00:00.000+08:00| true| |
| |1970-01-01T08:00:00.002+08:00| v2|1970-01-01T08:00:00.002+08:00| false|2017-11-01T00:01:00.000+08:00| 24.36|2017-11-01T00:01:00.000+08:00| true| |
| |2017-11-01T00:00:00.000+08:00| v2|2017-11-01T00:00:00.000+08:00| true| null| null| null| null| |
| |2017-11-01T00:01:00.000+08:00| v2|2017-11-01T00:01:00.000+08:00| true| null| null| null| null| |
| +-----------------------------+--------------------------+-----------------------------+------------------------+-----------------------------+-----------------------------+-----------------------------+------------------------+ |
| Total line number = 4 |
| It costs 0.018s |
| </code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div>`,17);function r(o,d){return n(),s("div",null,[a(` |
| |
| 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. |
| |
| `),i])}const p=e(t,[["render",r],["__file","Result-Format.html.vue"]]);export{p as default}; |