hiveql

Hive How to select all but one column?

大憨熊 提交于 2020-08-21 06:35:52
问题 Suppose my table looks something like: Col1 Col2 Col3.....Col20 Col21 Now I want to select all but Col21. I want to change it to unix_timestamp() before I insert into some other table. So the trivial approach is to do something like: INSERT INTO newtable partition(Col21) SELECT Col1, Col2, Col3.....Col20, unix_timestamp() AS Col21 FROM oldTable Is there a way I can achieve this in hive? Thanks a lot for your help! 回答1: Try to setup the below property set hive.support.quoted.identifiers=none;

Hive How to select all but one column?

穿精又带淫゛_ 提交于 2020-08-21 06:35:34
问题 Suppose my table looks something like: Col1 Col2 Col3.....Col20 Col21 Now I want to select all but Col21. I want to change it to unix_timestamp() before I insert into some other table. So the trivial approach is to do something like: INSERT INTO newtable partition(Col21) SELECT Col1, Col2, Col3.....Col20, unix_timestamp() AS Col21 FROM oldTable Is there a way I can achieve this in hive? Thanks a lot for your help! 回答1: Try to setup the below property set hive.support.quoted.identifiers=none;

In Hive, which query is better and why?

北战南征 提交于 2020-08-10 04:23:48
问题 Assume there are two queries: select count(distinct a) from x; select count(*) from (select distinct a from x) y; I know they return the same results, but from the perspective of Hive (using MapReduce ). Can anyone please explain which one is the better choice and why? Any help is appreciated. 回答1: In Hive versions prior 1.2.0 the first query executes using one Map and one Reduce stages. Map sends each value to the single reducer, and reducer does all the job. Single reducer processing too

Reducer Selection in Hive

吃可爱长大的小学妹 提交于 2020-08-09 08:54:09
问题 I have following record set to process like 1000, 1001, 1002 to 1999, 2000, 2001, 2002 to 2999, 3000, 3001, 3002 to 3999 And I want to process the following record set using HIVE in such a way so that reducer-1 will process data 1000 to 1999 and reducer-2 will process data 2000 to 2999 and reducer-3 will process data 3000 to 3999.Please help me to solve above problem. 回答1: Use DISTRIBUTE BY , mappers output is being grouped according to the distribute by clause to be transferred to reducers

why is delete function not working in hive shell?

纵饮孤独 提交于 2020-08-05 11:32:27
问题 hive> delete from daily_case where num_casedaily=0; FAILED: SemanticException [Error 10294]: Attempt to do update or delete using transaction manager that does not support these operations. thank you in advance. 回答1: As @Chema explained ACID Transactions of HIVE. You can change the table property to allow transaction. OR You can do the following. With this you don't have to change table properties. INSERT OVERWRITE INTO daily_case SELECT * FROM daily_case WHERE num_casedaily <> 0; 回答2: Hive

SQL query Frequency Distribution matrix for product

一世执手 提交于 2020-08-04 04:27:08
问题 i want to create a frequency distribution matrix 1.Create a matrix.**Is it possible to get this in separate columns** customer1 p1 p2 p3 customer 2 p2 p3 customer 3 p2 p3 p1 customer 4 p2 p1 2. Then I have to count the number of products that come together the most For eg p2 and p3 comes together 3 times p1 p3 comes 2 times p1 p2 comes 2 times I want to recommend products to customers ,frequency of products that comes together select customerId,product,count(*) from sales group by customerId