diff --git a/tiledb/libtiledb.pyx b/tiledb/libtiledb.pyx index eea55da7f6..2aa88bead7 100644 --- a/tiledb/libtiledb.pyx +++ b/tiledb/libtiledb.pyx @@ -2075,7 +2075,7 @@ cdef class DenseArrayImpl(Array): q = PyQuery(self._ctx_(), self, tuple(attr_names), tuple(), layout, False) self.pyquery = q - if cond is not None: + if cond is not None and cond != "": from .query_condition import QueryCondition if isinstance(cond, str): @@ -2921,7 +2921,7 @@ cdef class SparseArrayImpl(Array): q = PyQuery(self._ctx_(), self, tuple(attr_names), tuple(), layout, False) self.pyquery = q - if cond is not None: + if cond is not None and cond != "": from .query_condition import QueryCondition if isinstance(cond, str): diff --git a/tiledb/tests/test_query_condition.py b/tiledb/tests/test_query_condition.py index 48637a9781..e3d500c317 100644 --- a/tiledb/tests/test_query_condition.py +++ b/tiledb/tests/test_query_condition.py @@ -978,3 +978,33 @@ def test_delete_with_string_dimension(self): with tiledb.open(path, "r") as A: assert_array_equal(A[:]["d"], [b"c"]) assert_array_equal(A[:]["a"], [30]) + + def test_qc_dense_empty(self): + path = self.path("test_qc_dense_empty") + + dom = tiledb.Domain(tiledb.Dim(name="d", domain=(1, 1), tile=1, dtype=np.uint8)) + attrs = [tiledb.Attr(name="a", dtype=np.uint8)] + schema = tiledb.ArraySchema(domain=dom, attrs=attrs, sparse=False) + tiledb.Array.create(path, schema) + + with tiledb.open(path, mode="w") as A: + A[:] = np.arange(1) + + with tiledb.open(path) as A: + assert_array_equal(A.query(cond="")[:]["a"], [0]) + + def test_qc_sparse_empty(self): + path = self.path("test_qc_sparse_empty") + + dom = tiledb.Domain( + tiledb.Dim(name="d", domain=(1, 10), tile=1, dtype=np.uint8) + ) + attrs = [tiledb.Attr(name="a", dtype=np.uint8)] + schema = tiledb.ArraySchema(domain=dom, attrs=attrs, sparse=True) + tiledb.Array.create(path, schema) + + with tiledb.open(path, mode="w") as A: + A[1] = {"a": np.arange(1)} + + with tiledb.open(path) as A: + assert_array_equal(A.query(cond="")[:]["a"], [0])