Files
lancedb/docs/src/js/interfaces/ColumnAlteration.md
Will Jones 7747c9bcbf feat(node): parse arrow types in alterColumns() (#2208)
Previously, users could only specify new data types in `alterColumns` as
strings:

```ts
await tbl.alterColumns([
  path: "price",
  dataType: "float"
]);
```

But this has some problems:

1. It wasn't clear what were valid types
2. It was impossible to specify nested types, like lists and vector
columns.

This PR changes it to take an Arrow data type, similar to how the Python
API works. This allows casting vector types:

```ts
await tbl.alterColumns([
  {
    path: "vector",
    dataType: new arrow.FixedSizeList(
      2,
      new arrow.Field("item", new arrow.Float16(), false),
    ),
  },
]);
```

Closes #2185
2025-03-12 09:57:36 -07:00

1.5 KiB

@lancedb/lancedbDocs


@lancedb/lancedb / ColumnAlteration

Interface: ColumnAlteration

A definition of a column alteration. The alteration changes the column at path to have the new name name, to be nullable if nullable is true, and to have the data type data_type. At least one of rename or nullable must be provided.

Properties

dataType?

optional dataType: string | DataType<Type, any>;

A new data type for the column. If not provided then the data type will not be changed. Changing data types is limited to casting to the same general type. For example, these changes are valid:

  • int32 -> int64 (integers)
  • double -> float (floats)
  • string -> large_string (strings) But these changes are not:
  • int32 -> double (mix integers and floats)
  • string -> int32 (mix strings and integers)

nullable?

optional nullable: boolean;

Set the new nullability. Note that a nullable column cannot be made non-nullable.


path

path: string;

The path to the column to alter. This is a dot-separated path to the column. If it is a top-level column then it is just the name of the column. If it is a nested column then it is the path to the column, e.g. "a.b.c" for a column c nested inside a column b nested inside a column a.


rename?

optional rename: string;

The new name of the column. If not provided then the name will not be changed. This must be distinct from the names of all other columns in the table.