AlexR2D2 / metabase_duckdb_driver

Metabase DuckDB Driver shipped as 3rd party plugin
Apache License 2.0
75 stars 25 forks source link

Issues with date columns #15

Closed lucmartinon closed 1 year ago

lucmartinon commented 1 year ago

Hello,

I encounter two problems with dates fields: trying to display a null date will make the query fail with error: Cannot invoke "Object.getClass()" because "target" is null

Failing query:

select 
date_ajout_efd
from all_declaration
limit 10

working:

select 
date_ajout_efd
from all_declaration
where date_ajout_efd is not null
limit 10

I have the same problem with a non-sql question, if you select a date column that is sometimes null, the query fails.

Second problem (which could be linked) is when I try to set up a date variable in an SQL query, the query fails with an error Unknown target type 91

This is true when using a date variable:

select 
date
from all_declaration
[[where date={{date_filter}}]]
limit 10

Also failing for a field filter variable on a date field:

select 
date
from all_declaration
[[where {{date}}]]
limit 10

I hope this is enough info to have a look, let me know if any details are needed! Thanks

AlexR2D2 commented 1 year ago

Hi, fixed in the latest release

lucmartinon commented 1 year ago

Hello! thanks for the release, sorry to report that I seem to still have the problem after upgrading! let me know if I can add any details! Thanks

AlexR2D2 commented 1 year ago

Hello! Could your provide the example of db schema? I can't reproduce the issue.

I created the DuckDB database file using duckdb utility. Then, i created table with date field and added null date, like this:

CREATE TABLE t1(i INTEGER, d DATE);
INSERT INTO t1 VALUES (1, '1979/12/12'), (2, NULL);

Next, i attached the duckdb file to Metabase, and run the query:

select * from t1 limit 10;

and it works...

Second problem with date variable in an SQL query and Unknown target type 91 i reproduced

lucmartinon commented 1 year ago

Oh sorry, I realised I thought i had updated, but that was not the case. After the problem, the problem is indeed solved!

thansk a lot!