vincbeck commented on code in PR #31206:
URL: https://github.com/apache/airflow/pull/31206#discussion_r1191349299
##########
airflow/providers/amazon/aws/transfers/sql_to_s3.py:
##########
@@ -148,9 +148,13 @@ def _fix_dtypes(df: DataFrame, file_format: FILE_FORMAT)
-> None:
for col in df:
if df[col].dtype.name == "object" and file_format == "parquet":
- # if the type wasn't identified or converted, change it to a
string so if can still be
- # processed.
- df[col] = df[col].astype(str)
+ # if the type wasn't identified or converted, try parsing it
to datetime
+ try:
+ df[col] = pd.to_datetime(df[col])
+ df[col].fillna(pd.to_datetime('1970-01-01'),inplace=True)
Review Comment:
Can you give more details on this one? Why doing that? I am pretty sure
there is a valid reason but please add it in comments to help people understand
it :)
##########
airflow/providers/amazon/aws/transfers/sql_to_s3.py:
##########
@@ -148,9 +148,13 @@ def _fix_dtypes(df: DataFrame, file_format: FILE_FORMAT)
-> None:
for col in df:
if df[col].dtype.name == "object" and file_format == "parquet":
- # if the type wasn't identified or converted, change it to a
string so if can still be
- # processed.
- df[col] = df[col].astype(str)
+ # if the type wasn't identified or converted, try parsing it
to datetime
+ try:
+ df[col] = pd.to_datetime(df[col])
Review Comment:
Can some data be parsable to string and datetime? If so, this change is not
backward compatible. If not, you can stop reading this comment :)
`df[col]` is parsed now as string and with this change, it will be parsed as
`datetime`. In order to make it backward compatible, you need to first try to
parse it as string and then datetime.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]