-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Append data chunk with Dates and null values? #124
Comments
The problem is the JS (The Clearly this could be made more user-friendly; converting JS |
Of course, if what you actually have are dates, not timestamps, you might consider using the DuckDB type DATE and |
Thank you, @jraymakers! It works! It could be more user-friendly, but I understand the challenges of making data flow in and out of DuckDB. I noticed two other things while transitioning from the old library to this one when using
I created a simple function to handle this on my end (see below), but I wanted to let you know in case it's useful. :) export default function convertForJS(rows: {
[key: string]: string | number | boolean | null;
}[], types: {
[key: string]: string;
}) {
const firstObjectKeys = Object.keys(rows[0]);
for (const key of Object.keys(types)) {
if (!firstObjectKeys.includes(key)) {
continue;
}
if (types[key] === "DATE") {
for (const row of rows) {
row[key] = row[key] === null
? null
: new Date(`${row[key]}T00:00:00.000Z`);
}
} else if (types[key] === "TIMESTAMP") {
for (const row of rows) {
row[key] = row[key] === null
? null
: new Date((row[key] as string).replace(" ", "T") + "Z");
}
} else if (types[key] === "BIGINT") {
for (const row of rows) {
row[key] = row[key] === null ? null : Number(row[key]);
}
}
}
} Just out of curiosity—are you part of the DuckDB team? And are you working on this alone? Cheers! |
It's intentional that the I think there's value in additional methods, similar to the |
Regarding your other question: I work at MotherDuck, which is distinct from DuckDB Labs, although we collaborate closely. Node Neo is done mostly as a side project, not as part of my "day job", though of course there's some overlap. What's good for the DuckDB community is also good for MotherDuck! It got started as a collaboration with @hannes, who set the direction and laid the foundation, but since the initial prototype I've been working on it mostly solo. Note that the repo is part of the DuckDB GitHub organization, and I continue to get some advice and assistance from the kind folks at DuckDB Labs from time to time. |
This makes a lot of sense! And yes, having a method or option to return JavaScript built-ins would be great. In my context, we use the library/DuckDB to process and analyze the data, but afterward, we rely on JavaScript built-ins for visualization.
Very interesting! Thank you for taking the time to share this! Selfishly, I hope you'll keep maintaining this library. 😅 |
Filed this issue to track the idea of adding methods for JS built-ins. I do intend to keep improving and maintaining this library for the foreseeable future. I'm glad you're finding it useful! |
Hi!
I have this data.
I would like to append it to a table.
Following the documentation, I wrote this. Note that I am replacing
undefined
andNaN
bynull
.But I get this error:
Note that I am using Deno, and this is adapted from a test for my library simple-data-analysis.
What am I doing wrong?
Here's the whole script in case you want to test it.
Thank you!
The text was updated successfully, but these errors were encountered: