Skip to content
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

test_all_types - Timestamp values are out of range of valid JS Date objects #1814

Open
kaciakmaciak opened this issue Aug 17, 2024 · 0 comments

Comments

@kaciakmaciak
Copy link

kaciakmaciak commented Aug 17, 2024

What happens?

Not sure if this is a bug or it's intentional, so I apologise if this is not a bug.

When using test_all_types() together with castTimestampToDate: true the timestamps are cast into invalid dates. This is due to maximum timestamp in JavaScript being slightly smaller than Number.MAX_SAFE_INTEGER. See MDN.

To Reproduce

const db = new duckdb.AsyncDuckDB(logger, worker);
await db.instantiate(bundle.mainModule, bundle.pthreadWorker);
await db.open({
  query: {
    castTimestampToDate: true,
  }
});
const conn = await db.connect();
const result = await conn.query(`
  SELECT
    "timestamp",
    "timestamp_s",
    "timestamp_ms",
    "timestamp_ns",
    "timestamp_tz",
    "timestamp_array",
    "timestamptz_array",
    epoch_ms(-8640000000000000) AS min_date,
    epoch_ms(8640000000000000) AS max_date
  FROM test_all_types()
`);
// timestamp, timestamp_ms, timestamp_s, timestamp_tz are all invalid dates
// min_date and max_date are valid
console.log(result.toArray().map((item) => item.toJSON()));

Please see an example in Codesandbox.

Browser/Environment:

Any

Device:

Any

DuckDB-Wasm Version:

1.28.1-dev248.0

DuckDB-Wasm Deployment:

N/A

Full Name:

Katarina Anton

Affiliation:

Individual

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant