Skip to content

A big-endian data variable registers, then every query fails: Byte-swapped arrays not supported #288

Open

Description

@alxmrs

A Dataset whose data variable is big-endian, as a NetCDF file written on a big-endian machine, or some FITS or binary files, can be, registers without error, and then every query on it fails.

import numpy as np, xarray as xr, xarray_sql as xql

ds = xr.Dataset({"w": (("a",), np.zeros(3, ">f8"))}, coords={"a": np.arange(3)})
ctx = xql.Context()
ctx.from_dataset("t", ds)
ctx.sql("SELECT * FROM t").to_pandas()

On main:

DataFusion error: FFI error: Execution error: Error reading batch from stream: ArrowNotImplementedError: Byte-swapped arrays not supported

pyarrow can't make an array from a byte-swapped NumPy array. With #275, such a Dataset is read lazily, as on main, so it fails the same way.

Expected: the query works. One fix is to convert the values to the machine's byte order (values.astype(values.dtype.newbyteorder("="))) when making a block's Arrow column. That costs a copy, which an array in the machine's byte order doesn't need.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions