Working with Hadoop 2.7.3

Assalamualaykum Wr Br..:)

Today we discuss about stuff in hadoop 2.7.3

  1. To Know the version of hadoop installed in your system then user the below command  $ hadoop versionhadoopversion
  2. Start the Hadoop using command $ start-all.sh
  3. Know the status of Java virtual Machine process status from command $ JPS
  4. Create a text file in home directory with command as gedit aejaaz.txt and write some data in it and save then close it.
  5. Now moving this file in hdfs using command $ hdfs dfs -put /aejaaz.txt /inputjps
  6. The Above image shows result of all commands stated above.
  7. Find the count of all words in files using hadoop predefined wordcount mapreduce program. Note: at first type hadoop then type jar then path of   wordcount
  8. Now lets start exploring it in web browser from url http://localhost:50070namenodeThats it for today..!!!  Jazakallah khair
Advertisements

Ascii Values in Database

Assalamualaykum Wr Br…I was looking into one value in database for a table named Customer which have column as Gender. The value in column should be either M or F or Null, but cannot have any other value.System throws exception when there is a mismatch of the value specified above.
The data of the table is fed from file.Before Customer table, data is first stored in temporary table then certain validations then moved to customer table. My Client stated that Gender value in file was null and it is temporary table which is showing as null but does not go in Customer acutal table.
When I queried in data as
select * from customer_temp where gender is not null
gives me result set, if I use where gender is null then does not provide result.
Inorder to find the exact value in gender column, I used the following query:
select ASCII(gender) from customer_temp where gender is not null
The above query displayed the value as 13 which is value of carriage return(\n).

SQL Joins in a simple way…

Hi All,
Today we explore the simply quite simple and interesting concept of SQL joins.
Join is a clause which is used to combine rows from two or more tables based on a common field between/among them.
The most common join is INNER JOIN, before we start up, lets create two tables as shown below:
To clear the screen in SQL ORACLE type: cl scr(press Enter).
CREATETABLECOMMAD
Now lets insert some data in these tables as shown below:
INSERT_TABLE
Similarly add some data into orders table as shown:
ORDERS
Now I recapitulate again that we have two tables named “ORDERS” and “CUSTOMERS”. I retrieve the data from two tables but use single from clause thats because of joins. I retrieve OrderId from order table aliases as O, CustomerName from Customers table aliases as C and O.Orderdate as shown:
JOIN
The output which we got was based on the constraint customerid is equal in both tables(CUSTOMERS,ORDERS). When the constraint is satisfied the CUSTOMERS Table fields are populated.
What else would happen if I dont specify Inner in select query which does produces the same output as above shown. We conclude that both INNER JOIN AND JOIN ARE SAME.
If we replace * instead of o.orderid,c.customer and o.orderdate then we get the result set as:
It returns all combination of orders tables rows and customers tables rows based on constraint match.
INNER JOIN: Returns all rows when there is at least one match in BOTH tables.It means in first we got 3 rows as output now we get these 3 rows two times as we joined the two tables.

SQL LEFT JOIN Keyword

The LEFT JOIN keyword returns all rows from the left table (table1), with the matching rows in the right table (table2). The result is NULL in the right side when there is no match.Observe the following screen:
left_join
One thing to note is that left join returns all rows from left table and returns only matched rows from right table.In some databases LEFT JOIN is called LEFT OUTER JOIN.
img_leftjoin
The LEFT JOIN keyword returns all the rows from the left table (Customers), even if there are no matches in the right table (Orders).

SQL RIGHT JOIN Keyword

The RIGHT JOIN keyword returns all rows from the right table (table2), with the matching rows in the left table (table1). The result is NULL in the left side when there is no match.
img_rightjoin
In some databases RIGHT JOIN is called RIGHT OUTER JOIN.

SQL FULL OUTER JOIN Keyword

The FULL OUTER JOIN keyword returns all rows from the left table (table1) and from the right table (table2).
The FULL OUTER JOIN keyword combines the result of both LEFT and RIGHT joins.
img_fulljoin