Evolving the Array Schema

Modifying Array Schema After Creation

Schema evolution allows you to change the schema of an array after it has been created.

#include <tiledb/tiledb.h>

// Allocate context with default config.
tiledb_ctx_t *ctx;
tiledb_ctx_alloc(NULL, &ctx);

// Pass context to allocate ArraySchemaEvolution.
tiledb_array_schema_evolution_t *se;
tiledb_array_schema_evolution_alloc(ctx, &se);

// Create a new attribute.
tiledb_attribute_t *attr;
tiledb_attribute_alloc(ctx, "a2", TILEDB_FLOAT64, &attr);
double fill_val = -1.0f;
tiledb_attribute_set_fill_value(ctx, attr, &fill_val, sizeof(double));

// Add a new attribute to the existing array schema.
tiledb_array_schema_evolution_add_attribute(ctx, se, attr);

// Drop an attribute from the existing array schema.
tiledb_array_schema_evolution_drop_attribute(ctx, se, "a1");

// Apply the evolution to the schema using array URI.
tiledb_array_evolve(ctx, array_uri, se);

// Free allocated objects.
tiledb_ctx_free(&ctx);
tiledb_array_schema_evolution_free(&se);
tiledb_attribute_free(&attr);

Last updated