ColumnConversionKind represents "how hard" a semantic type conversion will be. TODO(bob): Should this be a type hierarchy to support conversion planning?
const ( // ColumnConversionDangerous indicates that we could effect a type // conversion via built-in cast methods, but that the semantics are // not well-defined enough that a user would want to rely on this. // The use of this value should be accompanied by a link to an issue // to follow up. ColumnConversionDangerous ColumnConversionKind = iota - 1 // ColumnConversionImpossible indicates that it is not possible to // effect the desired type conversion. Additional information will // be present in the error returned from ClassifyConversion. ColumnConversionImpossible // ColumnConversionTrivial indicates that a conversion is // byte-for-byte compatible with existing data and there is no // possibility of introducing a constraint validation error. // This would include conversions such as STRING -> BYTES, or // a change in which only the visible type of a column is changing. ColumnConversionTrivial // ColumnConversionValidate indicates that a conversion is // byte-for-byte compatible with existing data, but that we need // to validate the existing data against the new rule. // This would include BYTE -> STRING, where we need to validate // that all of the existing bytes are valid UTF-8 sequences. ColumnConversionValidate // ColumnConversionGeneral indicates that we will end up rewriting // the existing data into a new format. ColumnConversionGeneral )
These columnConversionKinds are ordered from easiest to hardest.
ClassifyConversion takes two ColumnTypes and determines "how hard" the conversion is. Note that this function will return ColumnConversionTrivial if the two types are equal.