In this series, I encountered a pg_duckdb gotcha with unconstrained numeric column. With duckdb.force_execution = true , I expected DuckDB to run my aggregate. But it ran on the PostgreSQL engine instead, with a warning. Here's how to see it and fix it.
Reproduce
I created a table with four columns of the same number, differing only in declared type:
DROP TABLE IF EXISTS nf ; CREATE TABLE nf ( id bigint , n_bare numeric , n_10_2 numeric ( 10 , 2 ) , d double precision ); INSERT INTO nf SELECT g , g + 0 . 5 , g + 0 . 5 , g + 0 . 5 FROM generate_series ( 1 , 100000 ) g ; ANALYZE nf ;
Enter fullscreen mode
Exit fullscreen mode
Here are their Postgres type modifiers ( -1 means "no declared precision"):
postgres => SELECT attname , atttypmod FROM pg_attribute WHERE attrelid = 'nf' :: regclass AND attnum > 0 AND NOT attisdropped ORDER BY attnum ; attname | atttypmod ---------+----------- id | - 1 n_bare | - 1 n_10_2 | 655366 d | - 1 ( 4 rows )
Enter fullscreen mode
Exit fullscreen mode
n_bare and d showβ¦