Monday, 5 September 2022

Hive: conv: Convert number from one base to other base

Signature

conv( bigint n, int from_base, int to_base )

hive> SELECT * FROM emp;
OK
emp.id	emp.name	emp.hobbies	emp.technology_experience	emp.gender_age	emp.rating
1	Hari	["Football","Cricket"]	{"Java":"3.4Yrs","C":"4.5Yrs"}	{"gender":"Male","age":30}	-1.5
2	Chamu	["Trekking","Watching movies"]	{"Selenium":"5.6Yrs"}	{"gender":"Feale","age":38}	3.0
3	Sailu	["Chess","Listening to music"]	{"EmbeddedC":"9Yrs"}	{"gender":"Femle","age":32}	2.5
4	Gopi	["Cricket"]	{"Datastage":"11Yrs"}	{"gender":"Male","age":32}	-0.7
Time taken: 0.056 seconds, Fetched: 4 row(s)
hive> ;
hive> ;
hive> SELECT name,gender_age.age,conv(gender_age.age,10,2) FROM emp;
OK
name	age	_c2
Hari	30	11110
Chamu	38	100110
Sailu	32	100000
Gopi	32	100000
Time taken: 0.056 seconds, Fetched: 4 row(s)

 

 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment