Skip to content

Commit 3f5b4c9

Browse files
authored
Fix Query constructor to return error for dense arrays with return_incomplete=True (#1976)
1 parent b55f628 commit 3f5b4c9

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

tiledb/libtiledb.pyx

+4
Original file line numberDiff line numberDiff line change
@@ -1895,6 +1895,10 @@ cdef class Query(object):
18951895
if not use_arrow:
18961896
raise TileDBError("Cannot initialize return_arrow with use_arrow=False")
18971897
self.use_arrow = use_arrow
1898+
1899+
if return_incomplete and not array.schema.sparse:
1900+
raise TileDBError("Incomplete queries are only supported for sparse arrays at this time")
1901+
18981902
self.return_incomplete = return_incomplete
18991903

19001904
self.domain_index = DomainIndexer(array, query=self)

tiledb/tests/test_libtiledb.py

+16
Original file line numberDiff line numberDiff line change
@@ -3598,6 +3598,22 @@ def test_incomplete_sparse_varlen(self, allows_duplicates, non_overlapping_range
35983598
T2.multi_index[101:105][""], np.array([], dtype=np.dtype("<U"))
35993599
)
36003600

3601+
@pytest.mark.parametrize("sparse", [True, False])
3602+
def test_query_return_incomplete_error(self, sparse):
3603+
path = self.path("test_query_return_incomplete_error")
3604+
3605+
dom = tiledb.Domain(tiledb.Dim(domain=(1, 3), tile=1))
3606+
attrs = [tiledb.Attr("ints", dtype=np.uint8)]
3607+
schema = tiledb.ArraySchema(domain=dom, attrs=attrs, sparse=sparse)
3608+
tiledb.Array.create(path, schema)
3609+
3610+
with tiledb.open(path, "r") as A:
3611+
if sparse:
3612+
A.query(return_incomplete=True)[:]
3613+
else:
3614+
with self.assertRaises(tiledb.TileDBError):
3615+
A.query(return_incomplete=True)[:]
3616+
36013617
@pytest.mark.skipif(not has_pandas(), reason="pandas not installed")
36023618
@pytest.mark.parametrize(
36033619
"use_arrow, return_arrow, indexer",

0 commit comments

Comments
 (0)