0

When using the TDengine (v3.0.2), I found that the query result is some how weird when the fill clause exists in the time window query. And the following SQL statements can produce the result.

create table tu (ts timestamp, k int, z varchar(12));
insert into tu values('2022-6-1 1:1:1', 2,'b');
insert into tu values('2022-6-1 1:1:2', 3,'c');
insert into tu values('2022-6-1 1:1:3', 4,'d');
select _wstart, sum(k) from tu 
where ts>='2022-06-01 1:1:0' and ts<='2022-6-1 1:1:3' interval(500a) 
fill(prev) order by _wstart desc;


        _wstart         |        sum(k)         |
=================================================
2022-06-01 01:01:00.000 |                  NULL |
2022-06-01 01:01:00.500 |                  NULL |
2022-06-01 01:01:01.000 |                     2 |
2022-06-01 01:01:01.500 |                     2 |
2022-06-01 01:01:02.000 |                     3 |
2022-06-01 01:01:02.500 |                     3 |
2022-06-01 01:01:03.000 |                     4 |
select _wstart, sum(k) from tu 
where ts>='2022-06-01 1:1:0' and ts<='2022-6-1 1:1:3' interval(500a) 
fill(prev) order by _wstart asc;


         _wstart         |        sum(k)         |
==================================================
 2022-06-01 01:01:03.000 |                     4 |
 2022-06-01 01:01:02.500 |                     3 |
 2022-06-01 01:01:02.000 |                     3 |
 2022-06-01 01:01:01.500 |                     2 |
 2022-06-01 01:01:01.000 |                     2 |
 2022-06-01 01:01:00.500 |                     2 |
 2022-06-01 01:01:00.000 |                     2 |

I noticed that the order by clause affected the final results, not just the order of results, but also the result in ‘2022-06-01 01:01:00.000’ and ‘2022-06-01 01:01:00.500’. But when the fill clause does not exist, the results are identical.

I’m wondering if is this a bug? or just a standard result of the fill clause.

Roony
  • 41
  • 4
  • It does not have much description, but can you take a look at: https://github.com/taosdata/TDengine/pull/19120 ? If that is the same problem you should wait for an update, or build from sources ... – Luuk Dec 25 '22 at 17:24

0 Answers0