I am trying to create a HIVE table. I am not sure when we use VARCHAR and when we use String. If we use VARCHAR then do we have to define length like we define in RDBMS as VARCHAR(10) Please help
Advertisement
Answer
VARCHAR was introduced in Hive 0.12.0 for more SQL-compliant behavior, such as SQL string comparison semantics, max length, etc (See HIVE-4844).
Varchar types are created with a length specifier (between 1 and 65355), which defines the maximum number of characters allowed in the character string. If a string value being converted/assigned to a varchar value exceeds the length specifier, the string is silently truncated.
Also there is a limitation: Non-generic UDFs cannot directly use varchar type as input arguments or return values.
See here:wiki
STRING has no such limitation. The max length of a STRING is 2GB