Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hive Create table - When to use VARCHAR and STRING as column data type

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

like image 956
v83rahul Avatar asked Sep 20 '25 09:09

v83rahul


1 Answers

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

like image 79
leftjoin Avatar answered Sep 22 '25 22:09

leftjoin