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

[Datagen] time, date, timestamp range support with strings. #2357

Merged
merged 2 commits into from
Aug 28, 2024
Merged

Conversation

gz
Copy link
Collaborator

@gz gz commented Aug 28, 2024

Fixes #2318.

Is this a user-visible change (yes/no): ___

Fixes #2318.

Signed-off-by: Gerd Zellweger <mail@gerdzellweger.com>
@gz gz requested a review from mihaibudiu August 28, 2024 08:14
@gz gz changed the title time, date, timestamp range support for strings. time, date, timestamp range support with strings. Aug 28, 2024
@mihaibudiu mihaibudiu changed the title time, date, timestamp range support with strings. [Datagen] time, date, timestamp range support with strings. Aug 28, 2024
Ok(Some((a, b)))
}
Some((Value::String(a), Value::String(b))) => {
let unix_date: NaiveDate = NaiveDate::from_ymd_opt(1970, 1, 1).unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

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

If it's malformed will you get a decent message?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

line 74 and 76 will do the error handlign for malformed user strings

Copy link
Collaborator

Choose a reason for hiding this comment

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

what is the user experience?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

they'll get an error from the adapter -- currently they'll have to inspect the manager log but once we land error handling in manager this will be there too

@@ -650,7 +770,8 @@ impl RecordGenerator {
if let Value::String(str) = obj {
str.clear();

let (min, max) = settings.range.unwrap_or((0, MAX_DATE_VALUE));
let range = parse_range_for_date(field.name.as_str(), &settings.range)?;
let (min, max) = range.unwrap_or((0, MAX_DATE_VALUE));
Copy link
Collaborator

Choose a reason for hiding this comment

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

is 0 1970?
What if the range starts earlier?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is the default range if the user doesn't provide one

Copy link
Collaborator

Choose a reason for hiding this comment

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

but will it work with negative values?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will add a test

Signed-off-by: Gerd Zellweger <mail@gerdzellweger.com>
@gz gz merged commit 2ffa0bf into main Aug 28, 2024
5 checks passed
@gz gz deleted the issue-2318 branch August 28, 2024 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Datagen] It should be easier to specify ranges for TIME/DATE/TIMESTAMP types
2 participants