Skip to content
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

chore: add current_timestamp function #13751

Merged
merged 8 commits into from Nov 25, 2023

Conversation

lichuang
Copy link
Collaborator

@lichuang lichuang commented Nov 17, 2023

I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/

Summary

chore: add current_timestamp function


This change is Reviewable

@github-actions github-actions bot added the pr-chore this PR only has small changes that no need to record, like coding styles. label Nov 17, 2023
@TCeason
Copy link
Collaborator

TCeason commented Nov 17, 2023

CI failed

https://github.com/datafuselabs/databend/actions/runs/6899767394/job/18772060466?pr=13751

[SQL] create table db2.test6(id Int8, created timestamp DEFAULT CURRENT_TIMESTAMP)
at tests/sqllogictests/suites/base/05_ddl/05_0000_ddl_create_tables.test:144

Error: SelfError("sqllogictest failed")

@andylokandy
Copy link
Collaborator

andylokandy commented Nov 17, 2023

Will literal CURRENT_TIMESTAMP be supported in the future?

And we could add test for

select CURRENT_TIMESTAMP;  -- not supported yet
select CURRENT_TIMESTAMP();

Literal::CurrentTimestamp => Err(ErrorCode::SemanticError(format!(
"Unsupported literal value: {literal}"
)))?,
Literal::CurrentTimestamp => Scalar::Timestamp(Local::now().timestamp_micros()),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Literal::CurrentTimestamp => Scalar::Timestamp(Local::now().timestamp_micros()),
Literal::CurrentTimestamp => self.resolve_function(*span, "CURRENT_TIMESTAMP", vec![], vec![])
.await

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolve_function is an async function.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolve_scalar_function_call could change to be sync function.

@BohuTANG BohuTANG merged commit adf6e1a into datafuselabs:main Nov 25, 2023
84 checks passed
@lichuang lichuang deleted the current_timestamp branch January 29, 2024 02:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-chore this PR only has small changes that no need to record, like coding styles.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: support function: CURRENT_TIMESTAMP
5 participants