-
Notifications
You must be signed in to change notification settings - Fork 33
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
detect date fields in Apache Arrow tables #263
base: main
Are you sure you want to change the base?
Conversation
src/table.js
Outdated
@@ -355,6 +355,8 @@ function alignof(base = {}, data, columns) { | |||
} | |||
|
|||
function type(data, column) { | |||
// duck-type Arrow table date fields | |||
if (String(data?.schema?.fields?.find?.(d => d?.name === column)).match(/<MILLISECOND>/)) return "date"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a better fit:
if (String(data?.schema?.fields?.find?.(d => d?.name === column)).match(/<MILLISECOND>/)) return "date"; | |
if (String(data?.schema?.fields?.find?.(d => d?.name === column)).endsWith("<MILLISECOND>") return "date"; |
I also wonder if the string representation is part of arrow's public API. Should we perhaps check against the typeId instead?
Edit: sorry, accidentally dropped a )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know… maybe… I tried to identify something that had a chance to be a bit stable, but it's a moving target.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I recall the positive typeIds are public, and negative IDs are meant for internal use.
Edit: sort of
* **Note**: Only enum values 0-17 (NONE through Map) are written to an Arrow
* IPC payload.
Co-authored-by: Fabian Iwand <mootari@users.noreply.github.com>
uses the same duck type test as observablehq/inputs#263 closes observablehq/framework#1376
addresses the Inputs.table part of observablehq/framework#1376
I thought we could extend it to duck-type other field types (numbers vs strings), but there is no real need beyond dates and it would add complexity.