-
Notifications
You must be signed in to change notification settings - Fork 662
Open
Labels
bugIncorrect behavior inside of ibisIncorrect behavior inside of ibis
Description
What happened?
import datetime
import ibis
t = ibis.memtable(
{"ts": [datetime.datetime.fromisoformat("2023-10-01 12:00:00+00")]},
schema=ibis.schema([("ts", "timestamp('UTC', 6)")]),
)
def view(ts):
print(ts.type())
print(ts.to_sql())
print(ts.to_pyarrow())
print("\n\n")
scalar = ibis.timestamp("2023-10-01 12:00:00+00").cast("timestamp('UTC', 6)")
column = t.ts
view(scalar)
view(column)
view(scalar.cast("timestamp('America/Anchorage')"))
view(column.cast("timestamp('America/Anchorage')"))
Results in (note how the needed cast is missing in the final block)
timestamp('UTC', 6)
SELECT
CAST(MAKE_TIMESTAMPTZ(2023, 10, 1, 12, 0, 0.0, 'UTC') AS TIMESTAMPTZ) AS "Cast(datetime.datetime(2023, 10, 1, 12, 0, tzinfo=tzutc()), timestamp('UTC', 6))"
2023-10-01 12:00:00+00:00
timestamp('UTC', 6)
SELECT
*
FROM "ibis_pandas_memtable_5eusqqjk3rcsrnmoeobf7clqy4" AS "t0"
[
[
2023-10-01 12:00:00.000000Z
]
]
timestamp('America/Anchorage')
SELECT
CAST(CAST(MAKE_TIMESTAMPTZ(2023, 10, 1, 12, 0, 0.0, 'UTC') AS TIMESTAMPTZ) AS TIMESTAMPTZ) AS "Cast(Cast(datetime.datetime(2023, 10, 1, 12, 0, tzinfo=tzutc()), timestamp('UTC', 6)), timestamp('America/Anchorage'))"
2023-10-01 04:00:00-08:00
timestamp('America/Anchorage')
SELECT
CAST("t0"."ts" AS TIMESTAMPTZ) AS "Cast(ts, timestamp('America/Anchorage'))"
FROM "ibis_pandas_memtable_5eusqqjk3rcsrnmoeobf7clqy4" AS "t0"
[
[
2023-10-01 12:00:00.000000Z
]
]
What version of ibis are you using?
main
What backend(s) are you using, if any?
duckdb
Relevant log output
Code of Conduct
- I agree to follow this project's Code of Conduct
contang0
Metadata
Metadata
Assignees
Labels
bugIncorrect behavior inside of ibisIncorrect behavior inside of ibis
Type
Projects
Status
backlog