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

Improve date/time hint handling for Postgres based on better testing #146

Merged
merged 4 commits into from
Dec 9, 2020

Conversation

vinceatbluelabs
Copy link
Contributor

@vinceatbluelabs vinceatbluelabs commented Dec 9, 2020

Based on the new testing approach in #144, this PR adds component tests for date/time types while loading/exporting CSV files in the PostgreSQL database.

Along the way some places for improvement were found!

389: tests/integration/*****
381: records_mover/db/postgres/copy_options/date_input_style.py
373: setup.py

Reduce total number of bigfiles violations to 1094 or below!

Tasks: TOP => quality
(See full trace by running task with --trace)
Existing violations: 1094
Found 1143 bigfiles violations
# Supported!
quiet_remove(unhandled_hints, 'timeonlyformat')
else:
cant_handle_hint(fail_if_cant_handle_hint, 'datetimeformat', hints)
cant_handle_hint(fail_if_cant_handle_hint, 'timeonlyformat', hints)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops! This resulted in printing the wrong diagnostic error message.

# (1 row)
#
# postgres=#
upgrade_date_order_style('DMY', 'dateformat')
elif dateformat is None:
# null implies that that date format is unknown, and that the
# implementation SHOULD generate using their default value and
Copy link
Contributor Author

@vinceatbluelabs vinceatbluelabs Dec 9, 2020

Choose a reason for hiding this comment

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

In general you can see this file is very case-based. I think it'd both be less exhausting as a piece of code and more helpful for folks if it were turned into a more dynamic function that didn't need to check every single supported case, but instead did something more dynamic (e.g., "is DD before MM in the string in front of me?). That'd also be one less piece to improve before we can advertise general support for date/time format strings in our hints and loosen the Records Spec accordingly.

@@ -1 +1 @@
1094
1143
Copy link
Contributor Author

Choose a reason for hiding this comment

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

See note below about the growth in date_input_style.py and what we can do in the future now that we have better tests...

389: tests/integration/*****
381: records_mover/db/postgres/copy_options/date_input_style.py
373: setup.py

Reduce total number of bigfiles violations to 1094 or below!

Tasks: TOP => quality
(See full trace by running task with --trace)
Existing violations: 1094
Found 1143 bigfiles violations

datetimeformattz in ['YYYY-MM-DD HH:MI:SSOF',
'YYYY-MM-DD HH24:MI:SSOF'] and
datetimeformat == 'YYYY-MM-DD HH24:MI:SS'):
datetimeformat in ['YYYY-MM-DD HH24:MI:SS',
'YYYY-MM-DD HH:MI:SS']):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

HH is equivalent to HH24 in our spec.

self.assertFalse(unhandled_date_cases)
self.assertFalse(unhandled_datetimeformattz_cases)
self.assertFalse(unhandled_datetimeformat_cases)
self.assertFalse(unhandled_timeonly_cases)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As the output of this is a function of the interaction of three different hints, I needed to ensure we covered each of the desired cases once, so this will blow up as new test cases are added and we can add hand-validated expectations.

'dateformat': "MM-DD-YYYY",
},
'MDY'
),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add more cases, enough so that this test covers each off the cases defined in datetime_cases.py

@vinceatbluelabs vinceatbluelabs marked this pull request as ready for review December 9, 2020 21:15
Copy link
Contributor

@cwegrzyn cwegrzyn left a comment

Choose a reason for hiding this comment

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

:shipit:

@vinceatbluelabs vinceatbluelabs merged commit 024641b into master Dec 9, 2020
@ryantimjohn ryantimjohn deleted the loosen_date_requirements_2 branch December 17, 2022 11:14
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