GreptimeTeam / greptimedb

An open-source, cloud-native, distributed time-series database with PromQL/SQL/Python supported. Available on GreptimeCloud.
https://greptime.com/
Apache License 2.0
3.96k stars 282 forks source link

Supports input interval type in the format of ISO 8601 #4215

Open killme2008 opened 1 week ago

killme2008 commented 1 week ago

What type of enhancement is this?

API improvement, User experience

What does the enhancement do?

Unfortunately, GreptimeDB doesn't support writing the interval in the format of ISO 8601 time intervals such as P3Y3M700DT133H17M36.789S etc. But it's output supports it.

But I think we can support it by the transform rules too just like #4182

This lib looks helpful: https://docs.rs/iso8601/latest/iso8601/

Using the Duration::from_str(s) to parse the interval.

https://docs.rs/iso8601/latest/iso8601/enum.Duration.html

Implementation challenges

No response

leaf-potato commented 1 week ago

I am interested in this issue and would like to try to implement it.

etolbakov commented 1 week ago

Frankly speaking I already did a draft, but happy to step away @leaf-potato! Fill free to ping me in case of questions as very likely you are going to extend the expand_interval.rs.

@killme2008 a quick question do you expect an output something like

SELECT INTERVAL 'P3Y3M700DT133H17M36.789S';

+-------------------------------------------------------------+
| IntervalMonthDayNano("163343856789000000")                  |
+-------------------------------------------------------------+
| 0 years 0 mons 0 days 45373 hours 17 mins 36.789000000 secs |
+-------------------------------------------------------------+

or it should be the exact match of years/months/days etc?

killme2008 commented 1 week ago

@killme2008 a quick question do you expect an output something like

Yes, it's exactly what we need.

etolbakov commented 22 hours ago

Hey @leaf-potato Just curious if you had time to take a look at this ticket?