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

Feature: CURRENT_TIMESTAMP as a default value for TIMESTAMP attributes #5081

Closed
NatanPuzis opened this issue Mar 20, 2025 · 4 comments
Closed
Labels
feature New features or missing components of existing features

Comments

@NatanPuzis
Copy link

NatanPuzis commented Mar 20, 2025

API

Python

Description

Many RDBMs allow to initialize time-stamp columns with a default that is current time rather than some interpretation of 0 (e.g. epoch) or NULL.

Here is an example from MySQL:
create table comment (comment varchar(512), ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP);

It would be very useful feature if added to the Kuzu's Cypher language. Something like:
CREATE NODE TABLE IF NOT EXISTS File ( path STRING PRIMARY KEY, created_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP );

@NatanPuzis NatanPuzis added the feature New features or missing components of existing features label Mar 20, 2025
@ray6080 ray6080 mentioned this issue Mar 21, 2025
45 tasks
@ray6080
Copy link
Contributor

ray6080 commented Mar 21, 2025

hi @NatanPuzis yeah, this is a useful feature. We've put it into our coming release's TODO list. Will let you know once we're done with it. Thanks!

@acquamarin
Copy link
Collaborator

hi @NatanPuzis
we already support making the current_timestamp as the default value. Instead of writing as CURRENT_TIMESTAMP, you have to write it as a function CURRENT_TIMESTAMP()
E.g.

create table comment (id serial, comment varchar(512), ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP(). primary key (id));

@NatanPuzis
Copy link
Author

Good to know! I think it is worth updating the site documentation to let the readers know that DEFAULTs, besides literal values, can be set to call a function.

@prrao87
Copy link
Member

prrao87 commented Mar 24, 2025

Thanks @NatanPuzis, no doubt this needs to be better documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New features or missing components of existing features
Projects
None yet
Development

No branches or pull requests

4 participants