We have to migrate Greenplum to Hive, please help me below statement.
1. ('41405'||lpad(hex_to_int(lac),5,'0')||lpad(hex_to_int(ci),5,'0'))
2. lpad(hex_to_int(lac),5,'0')
To convert hex to int, use conv(str, 16, 10) function.
In older versions of Hive use concat() for concatenation.
lpad function exists in Hive
Related
As below substring is developed by Greenplum platform, we have to migrate similar operation to Hive supported. kindly help us.
select substring(a.dealer_msisdn from char_length(a.dealer_msisdn)-9) as dealer_msisdn
example of msisdn value with above query for greenplum
select substring('9970050916' from char_length('9970050916')-9) as dealer_msisdn
Please help me similar operation needs to migrate hive.
In hive substring function syntax is different:
substr(string|binary A, int start, int len), len is optional parameter.
Try this:
select substr('9970050916', char_length('9970050916')-9)
Read Hive UDFs manual
I want to select the largest n values in hive
use mydb;
select greatest_n(10, mycol1, mycol2) from mytab;
i am using hive 2.X. in hive 0.13, i was able to run the above and it worked. but now i get
FAILED: SemanticException [Error 10011]: Invalid function greatest_n
is there a way to do this in hive 2.X ?
Hive has greatest function since Hive-1.1.
Example:
hive> select greatest(1,2,3,4);
4
If you don't have greatest() function then try with the approach mentioned in this link.
I am using string function PATINDEX in SQL to find the index of particular pattern match in string. I have a column in table named as volume which contains values such as 0.75L, 1.0L, 0.375L.
When I execute the below SQL query i.e.
select PATINDEX('%L%',VOLUME) from volume_details
o/p of query -> 5,4,6
But in hive query how to achieve the same since PATINDEX is not supported currently?
I have a hive table which has String column having value as 12,345. Is there any way hive function which can remove comma during insertion in this hive table ?
You can use regexp_replace(string INITIAL_STRING, string PATTERN, string REPLACEMENT) which is a function in Hive.
So if you are moving the data from a table that contains the comma to a new table you will use :
insert into table NEW select regexp_replace(commaColumn,',','') from OLD;
Hive does have split function. which can be used here. split and concat to achieve the desired result
You may refer this question.
Does Hive have a String split function?
I am trying to write a query in SQL and I want to check the length of data in a column. Is there any inbuilt function for that?
you can use LEN() or LENGTH() inbuilt function as a example
SELECT LENGTH(column_name) FROM table_name
Try this one & tell if it's working or not?