replaceColumn_#
- swordfish.function.replaceColumn_()#
When table is an in-memory table:
replaceColumn_ replaces table column(s) with the specified vector(s). The data type of the new column is the same as the data type of the specified vector. It supports replacing multiple columns at once. Note that the multi-column replacement operation is not atomic, which means in cases of system errors, some specified column replacements may succeed while others fail partway through.
To update column’s value without changing its data type, we can use both replaceColumn_ and SQL statement update. Only replaceColumn_, however, can change a column’s data type.
When table is a DFS table in the OLAP engine, replaceColumn_ only modifies the data type of the specified column(s). Note that:
The SYMBOL type cannot be converted to or from other types.
Except for SYMBOL, data types within the same category can be converted between each other.
INTEGRAL and FLOATING types can be converted between each other.
INTEGRAL, FLOATING, LITERAL, and TEMPORAL types can be converted to the STRING type.
Note
Replacing columns of DECIMAL type is not currently supported.
- Parameters:
table (Constant) – A non-shared in-memory table or a DFS table.
colName (Constant) – A string indicating the name of the column to replace. When table is an in-memory table, colName can also be a vector of strings indicating multiple column names.
newCol (Constant) –
The column values to replace with.
When table is an in-memory table:
If colName is a scalar, newCol is a vector with the same number of elements as the rows of table.
If colName is a vector, newCol is a tuple containing the same number of elements as colName. Each tuple element is a vector with the same number of elements as the rows of table.
When table is a DFS table in the OLAP engine, newCol is only used to specify the target data type.