vesoft-inc / nebula

A distributed, fast open-source graph database featuring horizontal scalability and high availability
https://nebula-graph.io
Apache License 2.0
10.68k stars 1.2k forks source link

Support for adding built-in transformations in the date function timestamp #2747

Open wx-123456 opened 3 years ago

wx-123456 commented 3 years ago

日期转换函数timpstamp插入和保存都是int64,后面是否会支持yyyy-MM-dd HH:mm:ss这种形式,同时支持内部日期函数转换,将int64转换成yyyy-MM-dd HH:mm:ss。对于int64,现在的解决措施只能是应用内转换和新建string字段展示正常的日期格式

wey-gu commented 3 years ago

Dear @wx-123456 ,

For the insert, it can take a string like this:

INSERT VERTEX school(name, found_time) VALUES "DUT":("DUT", timestamp("1988-03-01T08:00:00"));

While for return/yield, maybe a function to convert int64 into a string would be with better experience to save the application from converting/displaying DateTime props.

What do you think @CPWstatic, please?

Thanks a lot for raising this!

CPWstatic commented 3 years ago
后面是否会支持yyyy-MM-dd HH:mm:ss这种形式

For this part, you could try Date or DateTime.

将int64转换成yyyy-MM-dd HH:mm:ss

This would be considered as function.

jackwener commented 3 years ago

Maybe I can try to fix it.

jamieliu1023 commented 3 years ago

@CPWstatic Is this issue still valid?

laura-ding commented 3 years ago

Maybe I can try to fix it.

Thanks very much. Try it.

jamieliu1023 commented 3 years ago

Maybe I can try to fix it.

Already assigned it to you.

jackwener commented 3 years ago

Insert Insert timestamp is supported at present, so we can ignore insert.

store It isn't good idea that timestamp store as String in special format .

return/show Naturally, we will try to return/show timestamp as String in special format through a function. But it is troublesome that because the type is lost. In the FunctionManager.cpp, we can see that there isn't type timestamp. In the end of request, we will just get List<Row<Int>> from Response, we can't distinguish between Int and Int from timestamp() .

jackwener commented 3 years ago

I think it isn't wise that add a new type or modify many code due to this demand.

wey-gu commented 3 years ago

store It isn't good idea that timestamp store as String in special format .

True, it should only be a handy function(rather than introducing any new types) to take non-int format data to save user from constructing datatime in int type themself. Underlying it should be stored as existing datatime type(int).

CPWstatic commented 3 years ago

Consider this

toDate(int)
date(int)