Column.auto_cast
auto_castshrink_types
Group: Conversions
Aliases: auto_value_type
Documentation
Change the value type of the column to a more specific one, based on its contents.
Arguments
shrink_types
: If setTrue
, smaller types will be chosen if possible, according to the rules below. Defaults toFalse
.
Remarks
Auto Type Selection Rules
- If a
Mixed
column can be assigned a single type, likeChar
orInteger
, that will be used. - Text columns are not parsed. To do that, use the
parse
method. - If a
Float
column contains only integers, it will be converted to an Integer column. - If a
Decimal
column contains only integers that could fit in a 64-bit integer storage, it will be converted to an Integer column. - If
shrink_types
isFalse
(default), no other transformations are applied. - However, if
shrink_types
is set toTrue
, then:- Integer columns will be assigned the smallest size that can fit all
values (down to 16-bit integers; converting to the
Byte
type has to be done manually throughcast
). - If all elements in a text column have the same length, the type will become fixed length.
- Otherwise, if a text column is variable length, but all text elements are no longer than 255 characters, the column will get a max length of 255. Otherwise, the column size limit will stay unchanged.
- Integer columns will be assigned the smallest size that can fit all
values (down to 16-bit integers; converting to the