Skip to content

Datasets.CreateOrUpdate

go
func (datasetClient) CreateOrUpdate(
    ctx context.Context,
    kind datasets.DatasetKind,
    codeName string,
    name string,
    fields []datasets.Field,
    options ...datasets.DatasetOption,
) (*datasets.Dataset, error)

Create a dataset or update an existing dataset if a dataset with the given codeName already exists.

If the dataset already exists, Tilebox applies the same schema update rules as a direct update. New fields can be added to non-empty datasets. Breaking schema changes are only allowed for empty datasets. New queryable fields and changes to an existing field’s queryable annotation are also only allowed for empty datasets.

You can append allowed enum values after ingesting data. To remove, rename, or reorder them, the dataset must be empty. See updating enum values.

Parameters

kind datasets.DatasetKind required

The dataset kind.

codeName string required

The stable code identifier for the dataset.

name string required

The display name of the dataset.

fields []datasets.Field required

The full custom field list in the dataset schema, including fields and annotations to retain on updates.

options []datasets.DatasetOption

Options for dataset metadata.

Options

datasets.WithSummary(summary string)

Set a short dataset summary.

datasets.WithDescription(description string)

Set the dataset’s markdown description.

Dataset kinds

KindTemporal datasets.DatasetKind

A dataset that contains timestamp, ID, and ingestion time fields.

KindSpatiotemporal datasets.DatasetKind

A dataset that contains timestamp, ID, ingestion time, and geometry fields.

Field types

field.String(name string) Field

A string field

field.Enum(name string, values ...string) Field

An enum with 1–100 unique, nonempty strings as its allowed values. Values are case-sensitive and can contain punctuation or Unicode characters. Add Repeated() for multiple values per datapoint; both forms support Queryable(). See the enum schema example.

field.ProtoEnum(name string, enum protoreflect.Enum) Field

Use an existing protobuf enum supported by Tilebox. If you previously used field.Enum(name, protobufValue), switch to this method. To define your own allowed strings, use field.Enum instead.

field.Bytes(name string) Field

A bytes field

field.Bool(name string) Field

A boolean field

field.Int32(name string) Field

A 32-bit signed integer field

field.Int64(name string) Field

A 64-bit signed integer field

field.Uint64(name string) Field

A 64-bit unsigned integer field

field.Float64(name string) Field

A 64-bit floating-point number field

field.Duration(name string) Field

A duration field

field.Timestamp(name string) Field

A timestamp field

field.UUID(name string) Field

A UUID field

field.Geometry(name string) Field

A geometry field

Field options

Repeated()

Indicate that the field is an array

Description(description string)

Set the description of the field to provide more context and details about the data

ExampleValue(exampleValue string)

Set the example value of the field for documentation purposes

SourceJSONPointer(sourceJSONPointer string)

Optional. Set the RFC 6901 path to this field in the source JSON, such as /properties/eo:cloud_cover. This is useful when transforming datapoints to JSON because Tilebox can reconstruct nested source objects from flattened dataset fields.

Queryable()

Make a non-repeated String, Bool, Int32, Int64, Uint64, or Float64 field available for server-side custom field filters. Custom Enum fields can also be queryable, including repeated enums. A dataset can contain at most two queryable string fields; custom enums do not count toward this limit.

JSONSchemaRef(jsonSchemaRef string)

Optional. Set a JSON Schema reference URI or URI fragment for the field. Use this when the field follows a well-known schema, such as a STAC extension. Tilebox emits the reference as $ref when advertising the field in STAC queryables.

Roles(roles ...FieldRole)

Set semantic display roles for the field. The only currently supported role is field.RolePrimaryTitle.

Queryable string values can contain at most 1,024 Unicode code points. See Queryable fields for schema constraints and Filter by custom fields for query syntax.

Returns

The created or updated dataset object.

Type to search…