Type introspection?

The collection/group API has some very basic introspection via tiledb.object_type() (in Python). Is there a means to perform further introspection, in particular:

  • determine if an array is sparse or dense
  • access schema properties (eg, attribute names and types)
    etc?

Or does the current API require that the application code remember the schema of any given object?

You can introspect an array by reading its array schema. In TileDB-Py:
https://docs.tiledb.io/projects/tiledb-py/en/latest/python-api.html#tiledb.libtiledb.Array.schema
https://docs.tiledb.io/projects/tiledb-py/en/latest/python-api.html#array-schema

New docs are coming up soon, so hopefully it will be easier to find this information :slight_smile:.

A quick example usage of opening the array and accessing the schema and printing the domain:

with tiledb.SparseArray("s3://mybucket/myarray") as A:
  schema = A.schema
  domain = schema.domain
  print(domain)

Thank you!

If there is no a priori knowledge of sparse/dense format, does the Array class support schema access, ie, is this legal? (it seems to work, but the docs suggest it might not work)

with tiledb.Array('path') as A:
    my_array_is_sparse = A.schema.sparse

Yeah, that should work.