Data Type - Coercion (ie Type Conversion)
Table of Contents
1 - About
Type conversion is called generally “coercion.”
Coercion is the fact to change:
- the type of a primitive (Example from string to number)
2 - Articles Related
3 - Function
The function name to coerce can be:
- cast
- coerce
4 - Form
Implicit vs Explicit
4.1 - Implicit (silent)
Silent coercions can make debugging a broken program particularly frustrating, since they cover up errors and make them harder to diagnose.
The hierarchy of type defines how the types are implicitly converted. Implicit conversion is allowed for types from child to an ancestor. Example of Hierarchy for Hive:
Primitive Type > Number > DOUBLE > FLOAT > BIGINT > INT > SMALLINT > TINYINT
> STRING
>BOOLEAN