From the course: Analyzing Big Data with Hive

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Math functions

Math functions - Hive Tutorial

From the course: Analyzing Big Data with Hive

Start my 1-month free trial

Math functions

- [Instructor] Here we're going to take a look at some basic calculations and math in Hive. Hive has some built-in methods and operators for working with numeric data. We're going to do some basic stuff. We'll start with our simple addition-subtraction operations and then we'll actually use a couple math functions to generate some new data in Hive. Here in my Cloudera environment I'm going to open up the script 7-3.sql and I'm just going to copy this over to our Hive editor. And the first thing I want to do is just show how to use some basic math here. So the star or the asterisks is the multiplication symbol and it works exactly how you would expect. In this query here we're pulling back our sales data from the 2009 partition and we have just a couple basic operations where we take the quanity times the rate minus the discount percent. Then we can round that using the Round function so we don't get this 15 decimal answer. We get a rounded answer that's just much easier when we pop it…

Contents