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

fix validation logic for date datatype in duckdb and postgres #101

Merged
merged 1 commit into from
Dec 11, 2024

Conversation

srikrishnak
Copy link
Contributor

This fix is pre-requisite to using test cases from substrait directly.

substrait testcases have examples which can only contain the date part but the python client returns a datetime object.

Converting these to strings and comparing is not quite right. e.g., '2024-03-01' == '2024-03-01:00:00:00' will fail if we do string compare.

The fix is to not compare the empty fields hrs, mins, secs, etc if we only contain the date part

This fix is pre-requisite to using test cases from substrait directly.

substrait testcases have examples which can only contain the date part
but the python client returns a datetime object.

Converting these to strings and comparing is not quite right.
e.g., '2024-03-01' == '2024-03-01:00:00:00' will fail if we do string compare.

The fix is to not compare the empty fields hrs, mins, secs, etc if we only
contain the date part
if (
isinstance(result, datetime.datetime)
and has_only_date(result)
and str(result.date()) == case_result
Copy link
Member

Choose a reason for hiding this comment

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

In the long run we need to make sure that we're testing types as well as values. This is fine for now as a workaround.

@EpsilonPrime EpsilonPrime merged commit 4683f1e into substrait-io:main Dec 11, 2024
5 of 7 checks passed
@srikrishnak srikrishnak deleted the fix-date-comparison branch December 11, 2024 06:17
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.

2 participants