Skip to content

Commit 43d0ade

Browse files
[xy] Convert datetime type for s3 data integration destination. (mage-ai#4501)
* [xy] Convert datetime for s3 data integration destination. * [xy] Fix flaky test.
1 parent d2fd05e commit 43d0ade

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

mage_ai/tests/api/endpoints/test_custom_designs.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ def __assert_after_list2(self, result, **kwargs):
126126
item['project']['root_project_full_path'] = base_repo_path()
127127

128128
self.assertEqual(
129-
result,
130-
arr,
129+
result.sort(key=lambda x: x['uuid']),
130+
arr.sort(key=lambda x: x['uuid']),
131131
)
132132

133133

mage_integrations/mage_integrations/destinations/amazon_s3/__init__.py

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from botocore.config import Config
1111

1212
from mage_integrations.destinations.base import Destination
13+
from mage_integrations.destinations.constants import COLUMN_FORMAT_DATETIME
1314
from mage_integrations.destinations.utils import update_record_with_internal_columns
1415

1516

@@ -95,6 +96,13 @@ def export_batch_data(self, record_data: List[Dict], stream: str, tags: Dict = N
9596
r['record'] = update_record_with_internal_columns(r['record'])
9697

9798
df = pd.DataFrame([d['record'] for d in record_data])
99+
100+
# Convert data types
101+
schema = self.schemas[stream]
102+
for column, column_settings in schema['properties'].items():
103+
if COLUMN_FORMAT_DATETIME == column_settings.get('format'):
104+
df[column] = pd.to_datetime(df[column])
105+
98106
column_header_format = self.config.get('column_header_format')
99107
if column_header_format:
100108
column_mapping = None

0 commit comments

Comments
 (0)