Data Type - Coercion (ie Type Conversion)


Type conversion is called generally “coercion.”

Coercion is the fact to change:


The function name to coerce can be:

  • cast
  • coerce


Implicit vs Explicit

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

Note that the type hierarchy allows the implicit conversion of STRING to DOUBLE.

Powered by ComboStrap