Skip to content

Wrong Date type check for Arrow tables #1231

@mootari

Description

@mootari

What happens?

Dates with millisecond resolution in Arrow tables are misdetected asdate instead of date64[ms].

When an Arrow table is created via

arrow.tableFromJSON([{date: new Date()}])

the infered type is Date (typeId 8) with a unit of 1 (source). However, arrowToSQLType() checks against DateMillisecond(typeId -14) (source).

(It is unclear whether this is a bug in the Arrow implementation or DuckDB integration.)

To Reproduce

observablehq.com example, via DuckDBClient:

{
  const arrow = await import("https://cdn.observableusercontent.com/npm/[email protected]/+esm");
  const table = arrow.tableFromJSON([{date: new Date("2023-02-01T12:34:56Z")}]);
  const type = table.schema.fields[0].type;
  const db = await DuckDBClient.of({t: table});
  const result = (await db.queryRow("select date d from t")).d.toISOString();
  return {result, type, typeId: type.typeId};
}

Browser/Environment:

Chrome 111

Device:

macOS 13.12.1

DuckDB-Wasm Version:

1.24

DuckDB-Wasm Deployment:

observablehq.com

Full Name:

Fabian Iwand

Affiliation:

Observable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions