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

coerce Arrow BigInt to Number #2164

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added test/data/height_frequency.arrow
Binary file not shown.
58 changes: 58 additions & 0 deletions test/output/bigintNormalize.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions test/plots/bigint.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as Plot from "@observablehq/plot";
import * as d3 from "d3";
import * as Arrow from "apache-arrow";

const integers = d3.range(40).map((int) => ({
big1: BigInt(int),
Expand All @@ -25,3 +26,19 @@ export async function bigintOrdinal() {
export async function bigintStack() {
return Plot.barY(integers, {x: (d, i) => i % 5, y: "big1"}).plot();
}

export async function bigintNormalize() {
const table = await Arrow.tableFromIPC(fetch("data/height_frequency.arrow"));
return Plot.plot({
height: 500,
x: {percent: true, grid: true},
y: {domain: [1.3, 2.21]},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you remove the y.domain here, the chart works in preview but crashes in node tests. I don't understand what the difference might be.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capture d’écran 2024-09-09 à 19 39 39

This is how the chart looks like in preview. But it crashes in node. Is apache-arrow behaving differently in the browser?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK the test is now fixed — I just don't use a file and generate the arrow structure on the fly.

marks: [
Plot.ruleX([0]),
Plot.ruleY(
table,
Plot.normalizeX("sum", {strokeWidth: 2, y: "height", x: "frequency", tip: {format: {y: ".2f"}}})
)
]
});
}