From the course: Analyzing Big Data with Hive

Unlock the full course today

Join today to access over 24,200 courses taught by industry experts.

Conditional functions

Conditional functions

- [Voiceover] When we want to query our data and analyze it, one of the things that poses a challenge with how SQL works, is it's based on these batch operations. We run a function and calculation on the entire dataset at a time. Now, conditional statements are a way of separating that out and adding some more flexibility with how we actually analyze and calculate things. These are called conditional operators, and they're special keywords in Hive, just as they are in other SQL languages, to perform these operations that evaluate expressions and find out what's going on with them, and return a different result, based on the output of that expression. So, the basic way we do this is, we identify things with IF. We're going to use IF as a way to identify large sales, in our demo here. Then we're going to create a sales size category, so, is it a small, medium, or large sale, using CASE. CASE is similar to IF, just more of a cascading way of doing it. And then we'll do some what-if…

Contents