How to test simple expressions in hive? I mean is there any dual table in hive like Oracle for testing expression and functions Or we have to create sample tables with few records everytime to test any expression . I was looking for any dual table in hive. Does hive have it?
How can we test expressions in hive
989 views Asked by Biswa Bandana Nayak At
4
There are 4 answers
0
On
In late Hive, you can directly write query without "from table", such as 1. select 1 2. select UNIX_TIMESTAMP()
If you need to apply your function on some data, you can create a dual table using create table as select value.
You can try the query here http://demo.gethue.com/
1
On
To create a dual like table in hive where there is one column and one row you can do the following:
create table dual (x int);
insert into table dual select count(*)+1 as x from dual;
Describe the table:
describe dual;
col_name data_type
x int
Query contents:
select * from dual;
dual.x
1
Use to test expressions:
select split('3,2,1','\\,') as my_new_array from dual;
Output:
["3","2","1"]
I have used this table to test many expressions in hive successfully.
Unfortunately, there is no dual table in hive. You will have to unit test your custom code on the actual data set or you can always create a subset of your data and run unit tests of custom codes on derived data sets.