• Read an Arrow schema from a Parquet file in memory.

    This returns an Arrow schema in WebAssembly memory. To transfer the Arrow schema to JavaScript memory you have two options:

    • (Easier): Call Schema.intoIPCStream to construct a buffer that can be parsed with Arrow JS's tableFromIPC function. This results in an Arrow JS Table with zero rows but a valid schema.
    • (More performant but bleeding edge): Call Schema.intoFFI to construct a data representation that can be parsed zero-copy from WebAssembly with arrow-js-ffi using parseSchema.

    Example with IPC Stream:

    import { tableFromIPC } from "apache-arrow";
    import initWasm, {readSchema} from "parquet-wasm";

    // Instantiate the WebAssembly context
    await initWasm();

    const resp = await fetch("https://example.com/file.parquet");
    const parquetUint8Array = new Uint8Array(await resp.arrayBuffer());
    const arrowWasmSchema = readSchema(parquetUint8Array);
    const arrowTable = tableFromIPC(arrowWasmSchema.intoIPCStream());
    const arrowSchema = arrowTable.schema;

    Example with arrow-js-ffi:

    import { parseSchema } from "arrow-js-ffi";
    import initWasm, {readSchema, wasmMemory} from "parquet-wasm";

    // Instantiate the WebAssembly context
    await initWasm();
    const WASM_MEMORY = wasmMemory();

    const resp = await fetch("https://example.com/file.parquet");
    const parquetUint8Array = new Uint8Array(await resp.arrayBuffer());
    const arrowWasmSchema = readSchema(parquetUint8Array);
    const ffiSchema = arrowWasmSchema.intoFFI();
    const arrowTable = parseSchema(WASM_MEMORY.buffer, ffiSchema.addr());
    const arrowSchema = arrowTable.schema;

    Parameters

    • parquet_file: Uint8Array

      Uint8Array containing Parquet data

    Returns Schema