dbt-labs / dbt-presto

[ARCHIVED] The Presto adapter plugin for dbt Core
http://getdbt.com/
Apache License 2.0
33 stars 30 forks source link

Seed files with dates don't work #54

Closed wrb2 closed 1 year ago

wrb2 commented 3 years ago

Seed files with date values don't work in dbt-presto.

I created following CSV seed file:

ID,DATE
1,2021-05-12

when I run dbt seed I get following error:

Runtime Error in seed test (data/test.csv)
  Cannot escape <class 'datetime.date'>

Pointing dbt to postgres instead of presto works and correctly creates the table:

 select * from test;
 id |    date    
----+------------
  1 | 2021-05-12 

As a workaround, also setting the column to string in project.yml works, but if you want that to be date, you have to cast it when using the seed file. Seed files with just strings and number work corrently.

wrb2 commented 3 years ago

I tried "hey let's look if timestamps are broken as well" and it turns out I'm either blind or this feature of automated data type inference in seeds is not actually documented anywhere in dbt.

findinpath commented 3 years ago
trino> insert into memory.default.orders (orderkey, orderdate) values (99999, '2021-01-01');
Query 20210916_143132_00002_bz9pd failed: Insert query has mismatched column types: Table: [bigint, date], Query: [integer, varchar(10)]

trino> insert into memory.default.orders (orderkey, orderdate) values (99999, date '2021-01-01');
INSERT: 1 row

Query 20210916_143203_00003_bz9pd, FINISHED, 1 node
Splits: 35 total, 35 done (100.00%)
0.23 [0 rows, 0B] [0 rows/s, 0B/s]

I think that seeding dates on presto / trino will not work because the parsing of the dates needs to be made explicitly in presto/trino.

See :

https://trino.io/docs/current/functions/datetime.html

wrb2 commented 1 year ago

Closing this sinde dbt-presto is abandonware.