Why would Hive tables disappeared suddenly? - hadoop

When I enter show tables; all tables were showed on the screen as return, but when I query any of the table, it saidTable not found... Would anyone please advise why would this happen suddenly? Suddenly means I was browsing a table in the last min and it turned out like this afterwards...
hive> show tables;
OK
mahoutpoc
prod
rc_agg2
rc_uum
uum
Time taken: 1.541 seconds
hive> select * from rc_uum limit 10;
FAILED: SemanticException [Error 10001]: Line 1:14 Table not found 'rc_uum'

This is because 'rc_umm' != 'rc_uum'.

Related

Inserting into a populated table

I am working on a oracle project, but I have come across this error and can't figure it out. So i have created a table "Drugs" and I have 4 columns. They are as follows: (D_id, D_name, D_Date_of_Exp, D_price). I had populated the first 3 columns and forgot to populate the 'D_price' column with values.
So, now when I tried to insert data into it again:
insert into drugs(d_id, d_price) values(50, 400)
gave me this error:
ORA-00001: unique constraint (PARTH.SYS_C007100) violated
I know what causes the error above, my question is, how can I get around that error and insert the prices that match with the 'D_id' in my table.
So, I tried this:
insert into drugs(d_price) values(400)
where d_id = 50;
gave me this error: ORA-00933: SQL command not properly ended
Still lost. Any help would be great, thank you.
As your table already populated, and you missed D_PRICE to populate while inserting data into table. Now It's time to update the record, use the SQL like:
update drugs set d_price = 400
where d_id = 50;

In Hive query status return OK but no records are shown.

select *from mca_info;
OK
Time taken: 0.934 seconds
The above statement is shown.
But earlier that query worked.
Oh ......
I Find it.
Actually data loading from HDFS file was not successful.
Actually table was empty.
When manually I inserted data in mca_info by using query "insert into table....", and then "select *from mca_info" works.
Then the data was shown.

hive prints null values while selecting the particular column

I have one hive table. I'm using JSON data for the hive table. When I select the whole table it works for me. If I select a particular column it prints null values.
The data looks like this
{"page_1":"{\"city\":\"Bangalore\",\"locality\":\"Battarahalli\",\"Name_of_Person\":\"xxx\",\"User_email_address\":\"test#gmail.com\",\"user_phone_number\":\"\",\"sub_locality\":\"\",\"street_name\":\"7th Cross Road, Near Reliance Fresh, T.c Palya,\",\"home_plot_no\":\"45\",\"pin_code\":\"560049\",\"project_society_build_name\":\"Sunshine Layout\",\"landmark_reference_1\":\"\",\"landmark_reference_2\":\"\",\"No_of_Schools\":20,\"No_of_Hospitals\":20,\"No_of_Metro\":0,\"No_of_Mall\":11,\"No_of_Park\":10,\"Distance_of_schools\":1.55,\"Distance_of_Hospitals\":2.29,\"Distance_of_Metro\":0,\"Distance_of_Mall\":1.55,\"Distance_of_Park\":2.01,\"lat\":13.0243273,\"lng\":77.7077906,\"ipinfo\":{\"ip\":\"113.193.30.130\",\"hostname\":\"No Hostname\",\"city\":\"\",\"region\":\"\",\"country\":\"IN\",\"loc\":\"20.0000,77.0000\",\"org\":\"AS45528 Tikona Digital Networks Pvt Ltd.\"}}","page_2":"{\"home_type\":\"Flat\",\"area\":\"1350\",\"beds\":\"3 BHK\",\"bath_rooms\":2,\"building_age\":\"1\",\"floors\":2,\"balcony\":2,\"amenities\":\"premium\",\"amenities_options\":{\"gated_security\":\"\",\"physical_security\":\"\",\"cctv_camera\":\"\",\"controll_access\":\"\",\"elevator\":true,\"power_back_up\":\"\",\"parking\":true,\"partial_parking\":\"\",\"onsite_maintenance_store\":\"\",\"open_garden\":\"\",\"party_lawn\":\"\",\"amenities_balcony\":\"\",\"club_house\":\"\",\"fitness_center\":\"\",\"swimming_pool\":\"\",\"party_hall\":\"\",\"tennis_court\":\"\",\"basket_ball_court\":\"\",\"squash_coutry\":\"\",\"amphi_theatre\":\"\",\"business_center\":\"\",\"jogging_track\":\"\",\"convinience_store\":\"\",\"guest_rooms\":\"\"},\"interior\":\"regular\",\"interior_options\":{\"tiles\":true,\"marble\":\"\",\"wooden\":\"\",\"modular_kitchen\":\"\",\"partial_modular_kitchen\":\"\",\"gas_pipe\":\"\",\"intercom_system\":\"\",\"air_conditioning\":\"\",\"partial_air_conditioning\":\"\",\"wardrobe\":\"\",\"sanitation_fixtures\":\"\",\"false_ceiling\":\"\",\"partial_false_ceiling\":\"\",\"recessed_lighting\":\"\"},\"location\":\"regular\",\"location_options\":{\"good_view\":true,\"transporation_hub\":true,\"shopping_center\":\"\",\"hospital\":\"\",\"school\":\"\",\"ample_parking\":\"\",\"park\":\"\",\"temple\":\"\",\"bank\":\"\",\"less_congestion\":\"\",\"less_pollution\":\"\"},\"maintenance\":\"\",\"maintenance_value\":\"\",\"near_by\":{\"school\":\"\",\"hospital\":\"\",\"mall\":\"\",\"park\":\"\",\"metro\":\"\",\"Near_by_school\":\"Little Champ Gurukulam Pre School \\\/ 1.52 km\",\"Near_by_hospital\":\"Suresh Hospital \\\/ 2.16 km\",\"Near_by_mall\":\"LORVEN LEO \\\/ 2.13 km\",\"Near_by_park\":\"SURYA ENCLAIVE \\\/ 2.09 km\"},\"city\":\"Bangalore\",\"locality\":\"Battarahalli\",\"token\":\"344bd4f0fab99b460873cfff6befb12f\"}"}
I created the table like this
CREATE EXTERNAL TABLE orc_test (json string)
LOCATION '/user/ec2-user/test_orc';
IF I use this query it works for me.
select * from orc_test;
If I try to select one column it prints null
select get_json_object(orc_test.json,'$.locality') as loc
from orc_test;
It prints
NULL NULL NULL
any help will be appreciated.
In your case, I think the back slashes in your data are causing the problem and also the quotes surrounding your page data. I have listed below the updated data, you could save it to a file and load it to the table, then your query should work.
{"page_1":{"city":"Bangalore","locality":"Battarahalli","Name_of_Person":"xxx","User_email_address":"test#gmail.com","user_phone_number":"","sub_locality":"","street_name":"7th Cross Road, Near Reliance Fresh, T.c Palya,","home_plot_no":"45","pin_code":"560049","project_society_build_name":"Sunshine Layout","landmark_reference_1":"","landmark_reference_2":"","No_of_Schools":20,"No_of_Hospitals":20,"No_of_Metro":0,"No_of_Mall":11,"No_of_Park":10,"Distance_of_schools":1.55,"Distance_of_Hospitals":2.29,"Distance_of_Metro":0,"Distance_of_Mall":1.55,"Distance_of_Park":2.01,"lat":13.0243273,"lng":77.7077906,"ipinfo":{"ip":"113.193.30.130","hostname":"No Hostname","city":"","region":"","country":"IN","loc":"20.0000,77.0000","org":"AS45528 Tikona Digital Networks Pvt Ltd."}},"page_2":{"home_type":"Flat","area":"1350","beds":"3 BHK","bath_rooms":2,"building_age":"1","floors":2,"balcony":2,"amenities":"premium","amenities_options":{"gated_security":"","physical_security":"","cctv_camera":"","controll_access":"","elevator":true,"power_back_up":"","parking":true,"partial_parking":"","onsite_maintenance_store":"","open_garden":"","party_lawn":"","amenities_balcony":"","club_house":"","fitness_center":"","swimming_pool":"","party_hall":"","tennis_court":"","basket_ball_court":"","squash_coutry":"","amphi_theatre":"","business_center":"","jogging_track":"","convinience_store":"","guest_rooms":""},"interior":"regular","interior_options":{"tiles":true,"marble":"","wooden":"","modular_kitchen":"","partial_modular_kitchen":"","gas_pipe":"","intercom_system":"","air_conditioning":"","partial_air_conditioning":"","wardrobe":"","sanitation_fixtures":"","false_ceiling":"","partial_false_ceiling":"","recessed_lighting":""},"location":"regular","location_options":{"good_view":true,"transporation_hub":true,"shopping_center":"","hospital":"","school":"","ample_parking":"","park":"","temple":"","bank":"","less_congestion":"","less_pollution":""},"maintenance":"","maintenance_value":"","near_by":{"school":"","hospital":"","mall":"","park":"","metro":"","Near_by_school":"Little Champ Gurukulam Pre School / 1.52 km","Near_by_hospital":"Suresh Hospital / 2.16 km","Near_by_mall":"LORVEN LEO / 2.13 km","Near_by_park":"SURYA ENCLAIVE / 2.09 km"},"city":"Bangalore","locality":"Battarahalli","token":"344bd4f0fab99b460873cfff6befb12f"}}
I tried this and it works for me.
hive> select get_json_object(orc_test.json,'$.page_1.locality') as loc from orc_test;
OK
Battarahalli
Time taken: 0.091 seconds, Fetched: 1 row(s)
hive> select get_json_object(orc_test.json,'$.page_1.city') as loc from orc_test;
OK
Bangalore
Time taken: 0.097 seconds, Fetched: 1 row(s)
hive> select get_json_object(orc_test.json,'$.page_2.home_type') as loc from orc_test;
OK
Flat
Time taken: 0.091 seconds, Fetched: 1 row(s)
It seems that you have not created table with many columns. only one column in hive table.
In hive the whole data of json value has been taken single value for a column. hence it shows null values for the columns.
use a JSON serde in order for Hive to map your JSON to the columns in your table.
Beside vmachan answer, which I think is right, the problem I encountered in similar situation was that json records weren't placed in separate lines. Also it didn't worked when it was an array. So, for example, this worked ok with Hive 3.1.0 using lateral view/json_tuple:
{"color":"black","category":"hue","type":"primary","code":{"rgba":[255,255,255,1],"hex":"#000"}}
{"color":"white","category":"value","code":{"rgba":[0,0,0,1],"hex":"#FFF"}}
{"color":"red","category":"hue","type":"primary","code":{"rgba":[255,0,0,1],"hex":"#FF0"}}
{"color":"blue","category":"hue","type":"primary","code":{"rgba":[0,0,255,1],"hex":"#00F"}}
{"color":"yellow","category":"hue","type":"primary","code":{"rgba":[255,255,0,1],"hex":"#FF0"}}
{"color":"green","category":"hue","type":"secondary","code":{"rgba":[0,255,0,1],"hex":"#0F0"}}
and that was NOT working well:
[{"color":"black","category":"hue","type":"primary","code":{"rgba":[255,255,255,1],"hex":"#000"}},
{"color":"white","category":"value","code":{"rgba":[0,0,0,1],"hex":"#FFF"}},
{"color":"red","category":"hue","type":"primary","code":{"rgba":[255,0,0,1],"hex":"#FF0"}},
{"color":"blue","category":"hue","type":"primary","code":{"rgba":[0,0,255,1],"hex":"#00F"}},
{"color":"yellow","category":"hue","type":"primary","code":{"rgba":[255,255,0,1],"hex":"#FF0"}},
{"color":"green","category":"hue","type":"secondary","code":{"rgba":[0,255,0,1],"hex":"#0F0"}}]

java.io.IOException:java.lang.ClassCastException: org.apache.hadoop.hbase.client.Result cannot be cast to org.apache.hadoop.io.Writable

Tried one sample of handling a table in hbase from hive.
The CREATE EXTERNAL TABLE command was successful, but the select statement gives a class cast exception
ENV:
hive 0.12.0, hbase 0.96.1, hadoop 2.2 , Ubuntu 12.04 on Virtual box
hive> SHOW TABLES;
OK
hbatablese_myhive
Time taken: 0.309 seconds, Fetched: 1 row(s)
hive> SELECT * FROM hbatablese_myhive;
OK
**Failed with exception
java.io.IOException:java.lang.ClassCastException: org.apache.hadoop.hbase.client.Result cannot be cast to org.apache.hadoop.io.Writable**
Time taken: 1.179 seconds
hive>
The same table on HBASE console:
hbase(main):002:0> scan 'myhive'
ROW COLUMN+CELL
row1 column=ratings:userid, timestamp=1392886585074, value=user1
row2 column=ratings:userid, timestamp=1392886606457, value=user2
2 row(s) in 0.0520 seconds
There used to be a Writables.copyWritable(Result result, Result value) call in an old version of the next(Immutablebyteswritable key, Result value) method of TableRecordReaderImpl.java.
the copyWritable has been removed now and only works with Writable, Writable arguments.
To do a copy now, you need to use value.copyFrom(result). This will do a deep copy of the data from source to destination
I am guessing you have some library mismatch which is making these calls happen and trying to cast from Result, Result to Writable, Writable

weird exception in Hive : Error in semantic analysis

Maybe when you see the "Error in semantic" in the title, you consider it as syntax error?
Of course not, I will show you what happened.
hive> use android;
OK
Time taken: 0.223 seconds
hive> desc tb_user_basics;
OK
col_datetime string
col_is_day_new string
col_is_hour_new string
col_ch string
...
p_date string
p_hourmin string
Time taken: 0.189 seconds
hive> select count(distinct col_udid) from android.tb_user_basics where p_date>='20121001' and p_date<='20121231';
FAILED: Error in semantic analysis: org.apache.thrift.transport.TTransportException: java.net.SocketTimeoutException: Read timed out
hive>
>
> select count(distinct col_udid) from android.tb_user_basics where p_date>='20121001' and p_date<='20121231';
FAILED: Error in semantic analysis: Unable to fetch table tb_user_basics
I'm very sure the table does exist in the database android. After the first statement failed, it appears that the table is missing.(Even I add the db prefix in the table name)
I'm wonderring whether it's because of the volumn of data is very big, maybe you have noticed that the time range is [20121001, 20121231].
I run the command before many times, always raise this error. But if I change the contition to "p_date='20121001'", the statement can run normally. (since the volumn is smaller? )
I'm expecting your answers, Thanks.
Probably you are in strict mode. One of strict mode feature is that partitions has to be specified, so this is why queries with "p_date='20121001'" in where cause are working.
Please try the non-strict mode:
set hive.mapred.mode=nonstrict;

Resources