Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hiveql - RIGHT() LEFT() Function

Is there a function in Hiveql that is equivalent to Right() or Left() function from TSQL? For example, RIGHT(col1,10) to get the first 10 characters from col1.

like image 417
jmich738 Avatar asked Jan 03 '17 03:01

jmich738


People also ask

How Use left and right in SQL Server?

In this example we take a string and a number. Using the left function a number will be added to the left of the string. The Right string function takes two arguments. The first argument is a string value and the second argument is an integer value specifying the length.

What is HiveQL?

Hive enables data summarization, querying, and analysis of data. Hive queries are written in HiveQL, which is a query language similar to SQL. Hive allows you to project structure on largely unstructured data. After you define the structure, you can use HiveQL to query the data without knowledge of Java or MapReduce.

How do I merge two tables in Hive?

Apache Hive Join – HiveQL Select Joins Query Basically, for combining specific fields from two tables by using values common to each one we use Hive JOIN clause. In other words, to combine records from two or more tables in the database we use JOIN clause. However, it is more or less similar to SQL JOIN.


1 Answers

There is no right or left function, but you can implement the same functionality with substr, like this:

left(column, nchar) = substr(column, 1* nchar)

right(column, nchar) = substr(column, (-1)* nchar)

Here nchar is number of characters.

like image 156
sandeep rawat Avatar answered Sep 29 '22 15:09

sandeep rawat