0

I'm trying to test a simple SQL query which should do something like this:

import duckdb
import pandas as pd
df_test = pd.read_clipboard()
duckdb.query("SELECT * FROM df_test").df()

Which works but I can't get the following query to work.

select count(df_test) as cnt,
year(a) as yr
from df_test
where d = "outcome1"
group by yr 

However, I get this as an exception, presumably from DuckDB.

BinderException: Binder Error: No function matches the given name and argument types 'year(VARCHAR)'. You might need to add explicit type casts.
    Candidate functions:
    year(TIMESTAMP WITH TIME ZONE) -> BIGINT
    year(DATE) -> BIGINT
    year(TIMESTAMP) -> BIGINT
    year(INTERVAL) -> BIGINT

I was only using Pandas as it seemed to be the easiest way to convert a csv file (using pd.read_clipboard) into DuckDB.

Any ideas?

(I'm using a mac by the way).

enter image description here

elksie5000
  • 7,084
  • 12
  • 57
  • 87

0 Answers0