[
https://issues.apache.org/jira/browse/IGNITE-20907?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Roman Puchkovskiy updated IGNITE-20907:
---------------------------------------
Description:
Currently, only a small number of <from, to> pairs are allowed when changing a
column type with ALTER TABLE ... ALTER COLUMN... SET DATA TYPE, see
[IEP-108|https://cwiki.apache.org/confluence/display/IGNITE/IEP-108+Change+column+type#IEP108Changecolumntype-Proposal.].
When it comes to columns that are not indexed, we can increase the set of
allowable type changes: we can allow any change for which we can guarantee that
any value that is a member of the original type is represented losslessly in
the new type (in other words, any value converted from the original type to the
new type and then converted back will produce the same value as before the
double conversion). Each tuple is accompanied with table version in the MV
storage, so we can always determine the corresponding schema version V and
convert the value in memory when it's read using any table version V' (where
V'>=V). We already have a mechanism of upgrading adapters on read, the
mecnanism can be leveraged for type conversion.
As for indexed columns, the simpliest solution for now is to leave the current
(strict) rules for changing their types as indices seem to require that the
binary representation of all values in the original type remains the same to
avoid index rebuild. This can be addressed later.
was:
CREATE TABLE t (id INT PRIMARY KEY, val INT NOT NULL);
ALTER TABLE t ALTER COLUMN val SET DATA TYPE VARCHAR;
Second query fails with 'Changing the type from INT32 to STRING is not
allowed'. Also, it's not possible to change type to DECIMAL.
Currently, we only support data type changes that do not require existing table
data conversion; instead, we upgrade the column values (when needed) on read.
But current implementation is even more strict: it only allows conversions
directly supported by BinaryTuple class (like int->long).
A mechanism for additional conversions should be added. It will allow
conversions to VARCHAR.
> Support column type changes that do not require existing data conversion
> ------------------------------------------------------------------------
>
> Key: IGNITE-20907
> URL: https://issues.apache.org/jira/browse/IGNITE-20907
> Project: Ignite
> Issue Type: Improvement
> Components: sql
> Reporter: Roman Puchkovskiy
> Priority: Major
> Labels: ignite-3
>
> Currently, only a small number of <from, to> pairs are allowed when changing
> a column type with ALTER TABLE ... ALTER COLUMN... SET DATA TYPE, see
> [IEP-108|https://cwiki.apache.org/confluence/display/IGNITE/IEP-108+Change+column+type#IEP108Changecolumntype-Proposal.].
> When it comes to columns that are not indexed, we can increase the set of
> allowable type changes: we can allow any change for which we can guarantee
> that any value that is a member of the original type is represented
> losslessly in the new type (in other words, any value converted from the
> original type to the new type and then converted back will produce the same
> value as before the double conversion). Each tuple is accompanied with table
> version in the MV storage, so we can always determine the corresponding
> schema version V and convert the value in memory when it's read using any
> table version V' (where V'>=V). We already have a mechanism of upgrading
> adapters on read, the mecnanism can be leveraged for type conversion.
> As for indexed columns, the simpliest solution for now is to leave the
> current (strict) rules for changing their types as indices seem to require
> that the binary representation of all values in the original type remains the
> same to avoid index rebuild. This can be addressed later.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)