Thursday, June 27, 2019

Sqoop - Eval


Eval is normally used to run simple sql queries against the database server.It will also preview the result on the console level.Eval can be used to evaluate any type of query like DDL/DML.

EVAL is only to check the database connection and also to preview the small set of data.It will provide the user to test the simple queries.

Sqoop Syntax :-

sqoop --eval {generic-args} {eval args}

Generic args :-

Argument Description
connect <jdbc-uri>
Specify JDBC connect string
connection-manager <class-name>
Specify connection manager class to use
driver <class-name>
Manually specify JDBC driver class to use
hadoop-mapred-home <dir>
Override $HADOOP_MAPRED_HOME
help
Print usage instructions
password-file
Set path for a file containing the authentication password
-P
Read password from console
password <password>
Set authentication password
username <username>
Set authentication username
verbose
Print more information while working
connection-param-file <filename>
Optional properties file that provides connection parameters
relaxed-isolation
Set connection transaction isolation to read uncommitted for the mappers.


Eval Args :-

e ,query Execute statement in SQL.

query examples :-

sqoop eval \
–connect jdbc:mysql://localhost/test \
–username root \
–query “SELECT * FROM sqoop_test ”





Monday, June 17, 2019

Hive - Reading JSON using Serde

Reading JSON in Hive is quite trickier but JSON serde has made our life easier.The JSON serde can be downloaded from any third party website.The JSON serde for JSON file is available in Hive 0.12 and later version.

We can download JSON serde from any of the sites like :-

https://code.google.com/archive/p/hive-json-serde/downloads

We have downloaded a sample JSON file  from https://support.oneskyapp.com/hc/en-us/articles/208047697-JSON-sample-files


Step 1.) Download the Serde from the above link and store it in any of the required folder .



Step 2.) Once the JSON serde has been downloaded , kindly add it to the Hive using below command.


ADD path/to/jar Jarfile.


Step 3.) Create the required table format using the below syntax .

create external table serde_fruit(fruit string,size string,color string) ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.JsonSerde' location ‘/serde_ex’;



Step 4. ) validate the data by using the select query.




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...