Skip to contents

Changes a column's type in place with ALTER TABLE ... ALTER COLUMN ... SET TYPE. DuckLake permits widening promotions only (for example INTEGER to BIGINT, or FLOAT to DOUBLE): every existing value must be representable in the new type, so no data can be lost and no data files need rewriting.

Usage

set_column_type(table_name, column_name, type)

Arguments

table_name

The table to change.

column_name

Name of the column.

type

The new (wider) SQL type.

Value

Invisibly returns NULL.

Details

To narrow a type, which DuckLake refuses, take the explicit route: add_table_column() with the smaller type, copy the values over (after checking they fit), drop_table_column() the original, and rename_table_column() the new column into place.

Examples

if (FALSE) { # \dontrun{
set_column_type("sales", "order_id", "BIGINT")
} # }