Skip to content

Regression: multiple temporal CAST (and/or EXTRACT) ops failing in 0.9.x vs 0.8 series #9956

@alexander-beedie

Description

@alexander-beedie

What happens?

Several previously valid casts (or extract ops) now fail, despite looking quite reasonable (eg: casting from datetime to date, or extracting the epoch from a datetime).

(This is currently a blocker for us as we'd love to make the upgrade to take advantage of the recent list-op fixes/updates, but have a significant reliance on basic temporal casts).

To Reproduce

Setup:

from datetime import datetime
import pandas as pd
import duckdb as dd

values = [
  datetime(2011,1,11,1,2,3), 
  datetime(2022,2,22,4,5,6),
]
df = pd.DataFrame({"dt": values})
dconn = dd.connect()
  • Failing datetime → date cast:

    dconn.execute("SELECT dt::date FROM df").fetchall()
    # Conversion Error: 
    #   Unimplemented type for cast (TIMESTAMP_NS -> DATE)

    Previously returned [(date(2011,1,11),), (date(2022,2,22),)]

  • Failing datetime → time cast:

    dconn.execute("SELECT dt::time FROM df").fetchall()
    # Conversion Error:
    #   Unimplemented type for cast (TIMESTAMP_NS -> TIME)

    Previously returned [(time(1,2,3),), (time(4,5,6),)]

  • Failing extraction of epoch from datetimes:

    dconn.execute("SELECT EXTRACT(epoch FROM dt) FROM df").fetchall()
    # Binder Error: 
    #   epoch can only take temporal arguments

    Previously returned [(1294707723,), (1645502706,)]

    This last one can be temporarily worked around by explicitly casting with dt::timestamp, but still represents a regression as this was not previously required and "dt" clearly is a temporal field ;)

OS:

macOS 14.1.2 (Apple Silicon)

DuckDB Version:

0.9.2

DuckDB Client:

Python

Full Name:

Alexander Beedie

Affiliation:

ADIA

Have you tried this on the latest main branch?

I have tested with a release build (and could not test with a main build)

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

  • Yes, I have

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions