Skip to content

"lt join" returns incorrect result on data with the same timestamp #1275

@spxie85

Description

@spxie85

Describe the bug
"lt join" returns incorrect result on data with the same timestamp

To Reproduce

create table tank(SequenceNumber int, ts timestamp)
timestamp(ts) ;

insert into tank values('2021-07-26T02:36:02.566000Z',1);
insert into tank values('2021-07-26T02:36:03.094000Z',2);
insert into tank values('2021-07-26T02:36:03.097000Z',3);
insert into tank values('2021-07-26T02:36:03.097000Z',4);
insert into tank values('2021-07-26T02:36:03.097000Z',5);
insert into tank values('2021-07-26T02:36:03.097000Z',6);
insert into tank values('2021-07-26T02:36:03.098000Z',7);
insert into tank values('2021-07-26T02:36:03.098000Z',8);

select w1.ts, w2.SequenceNumber - w1.SequenceNumber
from tank w1
lt join tank w2;

Returned results:

ts	column
2021-07-26T02:36:02.566000Z	null
2021-07-26T02:36:03.094000Z	1
2021-07-26T02:36:03.097000Z	1
2021-07-26T02:36:03.097000Z	1
2021-07-26T02:36:03.097000Z	2
2021-07-26T02:36:03.097000Z	3
2021-07-26T02:36:03.098000Z	1
2021-07-26T02:36:03.098000Z	2

Expected behavior
Return result like this:

ts	SequenceNumber
2021-07-26T02:36:02.566000Z	null
2021-07-26T02:36:03.094000Z	1
2021-07-26T02:36:03.097000Z	1
2021-07-26T02:36:03.097000Z	1
2021-07-26T02:36:03.097000Z	1
2021-07-26T02:36:03.097000Z	1
2021-07-26T02:36:03.098000Z	1
2021-07-26T02:36:03.098000Z	1

Environment (please complete the following information):

  • OS: Ubuntu 20.04.2 LTS
  • Version: 6.0.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIncorrect or unexpected behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions