Skip to content

Commit b284161

Browse files
committed
Added more timestamp formats
1 parent 68c5964 commit b284161

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

src/databricks/sql/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,8 @@ def datetime_parser(datetime_string):
636636
"%m/%d/%Y %I:%M:%S %p", # US format MSSQL Server
637637
"%d-%b-%Y %H:%M:%S", # Oracle format
638638
"%Y-%m-%dT%H:%M:%S.%f",
639+
"%Y-%m-%dT%H:%M:%S%z",
640+
"%Y-%m-%d %H:%M:%S %z",
639641
]
640642

641643
for fmt in formats:

tests/unit/test_util.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import decimal
22
import datetime
3+
from datetime import timezone, timedelta
34

45
from databricks.sql.utils import convert_to_assigned_datatypes_in_column_table
56

@@ -24,6 +25,8 @@ def get_column_table_and_description(self):
2425
("timestamp_column_3", "timestamp", None, None, None, None, None),
2526
("timestamp_column_4", "timestamp", None, None, None, None, None),
2627
("timestamp_column_5", "timestamp", None, None, None, None, None),
28+
("timestamp_column_6", "timestamp", None, None, None, None, None),
29+
("timestamp_column_7", "timestamp", None, None, None, None, None),
2730
("binary_column", "binary", None, None, None, None, None),
2831
("array_column", "array", None, None, None, None, None),
2932
("map_column", "map", None, None, None, None, None),
@@ -49,6 +52,8 @@ def get_column_table_and_description(self):
4952
("03/08/2024 02:30:15 PM",),
5053
("08-Mar-2024 14:30:15",),
5154
("2024-03-16T14:30:25.123",),
55+
("2025-03-16T12:30:45+0530",),
56+
("2025-03-16 12:30:45 +0530",),
5257
(b"\xde\xad\xbe\xef",),
5358
('["item1","item2"]',),
5459
('{"key1":"value1","key2":"value2"}',),
@@ -83,6 +88,30 @@ def test_convert_to_assigned_datatypes_in_column_table(self):
8388
(datetime.datetime(2024, 3, 8, 14, 30, 15), datetime.datetime),
8489
(datetime.datetime(2024, 3, 8, 14, 30, 15), datetime.datetime),
8590
(datetime.datetime(2024, 3, 16, 14, 30, 25, 123000), datetime.datetime),
91+
(
92+
datetime.datetime(
93+
2025,
94+
3,
95+
16,
96+
12,
97+
30,
98+
45,
99+
tzinfo=timezone(timedelta(hours=5, minutes=30)),
100+
),
101+
datetime.datetime,
102+
),
103+
(
104+
datetime.datetime(
105+
2025,
106+
3,
107+
16,
108+
12,
109+
30,
110+
45,
111+
tzinfo=timezone(timedelta(hours=5, minutes=30)),
112+
),
113+
datetime.datetime,
114+
),
86115
(b"\xde\xad\xbe\xef", bytes),
87116
('["item1","item2"]', str),
88117
('{"key1":"value1","key2":"value2"}', str),

0 commit comments

Comments
 (0)