Thursday, May 30, 2019

Hive - Complex Data Type (Array)


The complex data types contains :

Array

Map

Structs

Arrays :- The array contains elements of same data type and can be accessed using the index. For example :- if we have an array called animal , it can contain animal like [‘dog’,’cat’,’lion’].These animals can be accessed via index like animal[1] =cat

Let us understand this in four simple steps :-

Step 1.) We will create a sample file called ‘array_exm.txt’


We are having three fields namely id, name and goals .Goals is an array datatype.

Step 2.) we will create the table .

Create table player(id int,name varchar(20),goals array<int>) row format delimited fields terminated by ‘\t’ collection items terminated by ‘,’;


Step 3.) We will load the data into the table.

Load data local inpath ‘pathname’ into table player;



Step 4.) Select the data from the table .


We can also select the specified array position value data from the table .





Wednesday, May 29, 2019

Hive - DataTypes


Hive data types are classified into two types :-

Primitive data types

Complex data types

In this blog post , we will look into the basic understanding of the primitive data types in Hive.

The different types of primitive data types that are supported by Hive are following :-

Integers
  • TINYINT1 byte integer
  • SMALLINT2 byte integer
  • INT4 byte integer
  • BIGINT8 byte integer
  • Boolean type
  • BOOLEANTRUE/FALSE
  • Floating point numbvbers
  • FLOATsingle precision
  • DOUBLEDouble precision
  • Fixed point numbers
  • DECIMALa fixed point value of user defined scale and precision
  • String types
  • STRINGsequence of characters in a specified character set (maximum size is 2 GB)
  • VARCHARsequence of characters in a specified character set with a maximum length
  • CHARsequence of characters in a specified character set with a defined length
  • Date and time types
  • TIMESTAMP — A date and time without a timezone ("LocalDateTime" semantics)
  • TIMESTAMP WITH LOCAL TIME ZONE  A point in time measured down to nanoseconds ("Instant" semantics)
  • DATEa date
  • Binary types
  • BINARYa sequence of bytes

Hadoop - What is a Job in Hadoop ?

In the field of computer science , a job just means a piece of program and the same rule applies to the Hadoop ecosystem as wel...