mirror of
https://github.com/lancedb/lancedb.git
synced 2026-10-13 07:12:27 +00:00
fix(python): avoid full-width bitpacking panic
This commit is contained in:
@@ -20,6 +20,9 @@ arrow = { workspace = true, features = ["pyarrow"] }
|
||||
async-trait.workspace = true
|
||||
bytes.workspace = true
|
||||
lancedb.workspace = true
|
||||
# Maturin includes direct path dependencies in source distributions. The
|
||||
# workspace patch also applies to transitive Lance writer dependencies.
|
||||
lance-encoding = { path = "../vendor/lance-encoding", version = "=13.0.0-beta.12" }
|
||||
datafusion-common.workspace = true
|
||||
lance-core.workspace = true
|
||||
lance-namespace.workspace = true
|
||||
|
||||
@@ -6,6 +6,7 @@ import ctypes
|
||||
import gc
|
||||
import json
|
||||
import os
|
||||
import random
|
||||
import sys
|
||||
import threading
|
||||
import warnings
|
||||
@@ -412,6 +413,21 @@ def test_create_table_rejects_single_dictionary(mem_db: DBConnection):
|
||||
)
|
||||
|
||||
|
||||
def test_create_table_with_negative_int64_dictionary_tail(tmp_db: DBConnection):
|
||||
# A dictionary of negative values can have a full 64-bit width and a
|
||||
# partial 1024-value chunk. The writer must not choose out-of-line
|
||||
# bitpacking, which requires at least one bit of savings.
|
||||
rng = random.Random(42)
|
||||
values = list(range(-800, 800))
|
||||
rows = [{"f0": values[rng.randrange(len(values))]} for _ in range(9216)]
|
||||
schema = pa.schema([pa.field("f0", pa.int64(), nullable=True)])
|
||||
|
||||
table = tmp_db.create_table("negative_int64_tail", data=rows, schema=schema)
|
||||
|
||||
assert table.count_rows() == len(rows)
|
||||
assert table.to_arrow().column("f0").to_pylist() == [row["f0"] for row in rows]
|
||||
|
||||
|
||||
def test_empty_table(mem_db: DBConnection):
|
||||
schema = pa.schema(
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user