Skip to content

[Bug] The output time format of the lag/lead function is inconsistent with the input field. #50288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
2 of 3 tasks
asdf555111 opened this issue Apr 22, 2025 · 2 comments
Open
2 of 3 tasks

Comments

@asdf555111
Copy link

Search before asking

  • I had searched in the issues and found no similar issues.

Version

2.1.8

What's Wrong?

Image

The data type of created_time is datetime(6)

What You Expected?

Return the same data type and format as the original field.

How to Reproduce?

create table test(
created_time datetime(6)
);

insert into test
VALUES ('2025-04-21 17:57:32.064000'),
('2025-04-21 17:57:33.804000'),
('2025-04-21 17:57:34.156000');

select
created_time,
lag(created_time,1,0) over(order by created_time) as lg_created_time
from test
;

select
created_time,
lead(created_time,1,0) over(order by created_time) as lg_created_time
from test
;

Anything Else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@HappenLee
Copy link
Contributor

@zhangstar333 Check the case

@zhangstar333
Copy link
Contributor

the lead(created_time,1,0)
created_time is datetime(6)
and 0 is bigint, so the planner cast created_time as bigint,
could use lead(created_time,1,NULL) or
lead(created_time,1, "2025-04-23 10:10:10") sometime value

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants