Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

860 B
Raw Blame
/* Copyright 2026 Marimo. All rights reserved. */
import { type Table as ArrowTable, tableFromIPC } from "@uwdata/flechette";

// Adapted from https://github.com/vega/vega-loader-arrow/blob/main/src/index.js
// but this avoids bundling flechette which causes code duplication

interface IPCOptions {
  useProxy?: boolean;
}

export function arrow(data: ArrowTable): unknown[] {
  function isArrowTable(data: unknown): data is ArrowTable {
    return (
      !!(data as ArrowTable)?.schema &&
      Array.isArray((data as ArrowTable).schema.fields) &&
      typeof (data as ArrowTable).toArray === "function"
    );
  }
  return (isArrowTable(data) ? data : decodeIPC(data)).toArray();
}
arrow.responseType = "arrayBuffer";

function decodeIPC(data: ArrayBuffer, options?: IPCOptions): ArrowTable {
  return tableFromIPC(data, options ?? { useProxy: true });
}