Open nachocab opened 6 months ago
Yep, that's an open bug in DuckDB: https://github.com/duckdb/duckdb-wasm/issues/1231
The workaround is to ingest dates as ISO date strings, then change the column type:
{
const data = [
{create_time: new Date()}
];
const client = await DuckDBClient.of({
// Ingest dates as ISO strings
my_data: data.map(d => ({
...d,
create_time: d.create_time.toISOString()
}))
});
// Changes the column type from Utf8 to Date64
await client.sql`ALTER TABLE my_data ALTER COLUMN create_time SET DATA TYPE DATETIME`;
// Should read "Date64<MILLISECOND>"
const columnType = (await client.query("SELECT create_time FROM my_data")).schema[0].databaseType;
return client;
}
I was hoping there was a way to query an array of objects without losing the time. Here's an example notebook.