soma-smart / Fakelake

Generate massive fake datasets for your datalake, fast. By SOMA
https://soma-smart.github.io/Fakelake/
MIT License
17 stars 1 forks source link

[Feature] Add date time provider #27

Closed bhagenbourger closed 6 months ago

bhagenbourger commented 6 months ago

I tried to user Date provider using this pattern "%Y-%m-%dT%H:%M:%S" but I didn't succeed to create a date time. Is it possible to add date time pattern?

vianneybacoup commented 6 months ago

@bhagenbourger I have developed a datetime provider, but without the timezone.

For parquet, the timestamp type is stored in seconds since epoch, so no timezone. We can have an extra column for timezone, or keep it that way for now.

For csv, the timestamp is in the generated string, so we could add the timezone later on.

Tell me if this is enough for now

bhagenbourger commented 6 months ago

@vianneybacoup thank you for your responsiveness, you rocks! Yes it's enough for now, I don't need a time zone.

I tried the "format" config : an optional parameter **format**. Default is "%Y-%m-%d %H:%M:%S"

My config is:

 - name: date_4
    provider: Random.Date.datetime
    format: "%Y-%m-%d %H%M"
    after: 2000-02-15 12:15:00
    before: 2020-07-17 23:11:57

And my output still contains the seconds and : separator is still here:

string_1,boolean_2,integer_3,date_4
N8LptEoVfJ,XFcqR9b7B6,86,1984-12-19 16:30:39
w9GZJMQIHq,JVDxi5yaQX,50,1997-06-25 23:12:00
CF9pzxNBKh,9fygiKKYTN,,1984-05-01 19:10:26
BaHnigbLLM,GuyApzNhgF,,1989-09-18 15:03:18

Did I miss something?

vianneybacoup commented 6 months ago

The after and before options should follow the same pattern as the format. In your case, you should have a warning in terminal saying that the format couldn't been applied, so default is taken.

This is only because the format is used to parse the input, and to display the output

With this is will work:

 - name: date_4
    provider: Random.Date.datetime
    format: "%Y-%m-%d %H%M"
    after: 2000-02-15 1215
    before: 2020-07-17 2311

I'll update the doc for clarity, thanks !

bhagenbourger commented 6 months ago

I modified after and before options and it works well, thanks for your help.