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

[AIRFLOW-3010] added support for date format to postgres_to_gcs_operator #3850

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions airflow/contrib/operators/postgres_to_gcs_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,10 @@ def convert_types(cls, value):
JSON/Google Cloud Storage/BigQuery. Dates are converted to UTC seconds.
Decimals are converted to floats. Times are converted to seconds.
"""
if type(value) in (datetime.datetime, datetime.date):
if type(value) == datetime.datetime:
return time.mktime(value.timetuple())
elif type(value) == datetime.date:
return value.strftime('%Y-%m-%d')
elif type(value) == datetime.time:
formated_time = time.strptime(str(value), "%H:%M:%S")
return datetime.timedelta(
Expand All @@ -229,8 +231,8 @@ def type_map(cls, postgres_type):
d = {
1114: 'TIMESTAMP',
1184: 'TIMESTAMP',
1082: 'TIMESTAMP',
1083: 'TIMESTAMP',
1082: 'DATE',
1005: 'INTEGER',
1007: 'INTEGER',
1016: 'INTEGER',
Expand Down