Skip to content

Incorrect error message or implementation for datetime formatting? #2793

Closed
@t15k

Description

@t15k

Describe the bug

when starting a SQL query with timezone aware date times, you get an error message like:

Supports only timezone aware datatype, got 2024-04-29 13:30:34.573187+00:00

The SDK code involved is

     39 if value.tzinfo is not None:
     40     print(type(value))
---> 41     raise TypeError(f"Supports only timezone aware datatype, got {value}. {type(value)}")
     43 return f"TIMESTAMP '{value.isoformat(sep=' ', timespec='milliseconds')}'"

Where it checks for the existence of timezone info. And enter the if clause, if there is one.

However the error message say it support only timezone aware dates.

How to Reproduce

import awswrangler as wr
from datetime import timezone, datetime

wr.athena.start_query_execution(
  database='ddd',
  sql=f"""DELETE FROM ddd.t
                WHERE event_date >= :start 
         """,
    params={
        "start": datetime.now(timezone.utc),
    })

Expected behavior

To either have an error message like:

Supports only timezone naive datatype, got 2024-04-29 13:30:34.573187+00:00

or:

to correctly format timetamps with timezone info.

Your project

Private

Screenshots

No response

OS

Mac

Python version

3.11

AWS SDK for pandas version

seen on main branch and ('3.4.2')

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions