Skip to content

Commit

Permalink
Add support for BLOB attribute type override in from_pandas (#2143)
Browse files Browse the repository at this point in the history
  • Loading branch information
kounelisagis authored Jan 27, 2025
1 parent f0267e6 commit 92fb0e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions tiledb/dataframe_.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ def from_dtype(cls, dtype, column_name, varlen_types=()):
if isinstance(dtype, str) and dtype == "ascii":
return cls("ascii", var=True)

if isinstance(dtype, str) and dtype == "blob":
return cls(np.bytes_, var=True)

dtype = pd_types.pandas_dtype(dtype)
# Note: be careful if you rearrange the order of the following checks

Expand Down
6 changes: 4 additions & 2 deletions tiledb/tests/test_pandas_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,15 +271,17 @@ def test_apply_dtype_index_ingest(self):
{
"a": np.random.random_sample(20),
"b": [str(uuid.uuid4()) for _ in range(20)],
"c": [np.random.bytes(10) for _ in range(20)],
}
),
sparse=True,
index_dims=["a", "b"],
column_types={"a": np.float32, "b": np.bytes_},
index_dims=["a", "b", "c"],
column_types={"a": np.float32, "b": np.bytes_, "c": "blob"},
)
with tiledb.open(uri) as A:
assert A.schema.domain.dim(0).dtype == np.float32
assert A.schema.domain.dim(1).dtype == np.bytes_
assert A.schema.domain.dim(2).dtype == np.bytes_

def test_apply_dtype_index_schema_only(self):
uri = self.path("index_dtype_casted_dtype")
Expand Down

0 comments on commit 92fb0e2

Please sign in to comment.