Questions tagged [hive-query]
82 questions
3
votes
1 answer
Hive View Query Performance: Union tables with different schemas
I have a scenario where I have two Hive tables, and the second one is essentially an evolved schema of the first (it has 1 more column in this example).
Table_A
{
business_date String
Name String
Age Number
} partitioned by business_date
Table_B…

NicolasCage
- 105
- 9
3
votes
0 answers
Fetch all Column Statistics using Single Query Hive
I understand that all the column statistics can be computed for a Hive table using the command-
ANALYZE TABLE Table1 COMPUTE STATISTICS;
Then Specific column level stats can be fetched through the command -
DESCRIBE FORMATTED…

Abhi Nandan
- 195
- 3
- 11
2
votes
1 answer
hive query error for rows error parse exception
hive> create table sample(id int,name string, dept string, pvsl float, nval float, end int) row format delimited fields terminated by ',';
FAILED: ParseException line 1:77 mismatched input 'end' expecting Identifier near ',' in column…

jana
- 21
- 1
2
votes
1 answer
Hive queries with dates
I have a little problem, I would like to filter a date with hive query but the output is empty. My column is string type
I tried this :
select * from my_table
where to_date(date) < to_date('01/08/19 00:00:00')
The format of my column date is…

capucine58
- 21
- 2
2
votes
2 answers
Hive: Cant perform union query with limit
I am trying to run a union all query in hive
select * from tabName where col1='val1' and col2 = 'val2' limit 10 union all select * from tabName where col1='val1' and col2 = 'val3' limit 10;
but i get
FAILED: ParseException line 1:105 missing EOF at…

AbtPst
- 7,778
- 17
- 91
- 172
2
votes
1 answer
Issue with Insert overwrite directory
1)
insert overwrite directory `'/user/sample/newfolder'`
row format delimited
fields terminated by ', '
select * from emp;
Is giving me data without a header. Even after using set hive.cli.print.header=true;
I tried doing hive -e 'set…

Keshav Balivada
- 119
- 2
- 12
2
votes
2 answers
Calculate time difference between two columns of string type in hive without changing the data type string
I am trying to calculate the time difference between two columns of a row which are of string data type. If the time difference between them is less than 2 hours then select the first column of that row else if the time difference is greater than 2…

Khushboo
- 43
- 2
- 9
2
votes
1 answer
drop table command is not deleting path of hive table which was created by spark-sql
I am trying to drop a table(Internal) table that was created Spark-Sql, some how table is getting dropped but location of the table is still exists. Can some one let me know how to do this?
I tried both Beeline and Spark-Sql
create table…

sande
- 567
- 1
- 10
- 24
2
votes
1 answer
Convert String to Timestamp in Hive HQL
I'm having a string like "08/03/2018 02:00:00" which i'm trying to convert into a timestamp value.
I'm using the below code:
unix_timestamp("08/03/2018 02:00:00", "yyyy-MM-dd'T'HH:mm:ss.SSSXXX")
when i use the above code it's throwing a NULL…

Sara
- 312
- 6
- 15
2
votes
1 answer
How to select columns in Hive SQL with the same prefix (beginning) or suffix (ending) or key word in the middle (including)
EDIT 1: Note, I know some of us will question why not list different parts of information in different attributes, so that I will have a relational database to query. The real case is not like the example I am listing below, the variable names are…

Counter10000
- 525
- 1
- 8
- 25
2
votes
1 answer
Hive external table with location
Referred this url : Hive - External table creation
Created Hive external table with location keyword and value is pointing to my local disk.
create external table exemp(id int,name string,age int)
row format delimited
fields terminated by…

Learn Hadoop
- 2,760
- 8
- 28
- 60
1
vote
2 answers
Hive: find unique ids that have certain events
I have a hive table with IDs and associated events that look like below. The table can have multiple event_number for the same ID -
ID event_number Date
ABC 1 2022-08-01
ABC 2 2022-08-01
ABC 3 …

SRm
- 49
- 9
1
vote
2 answers
Replace Digits Using SubString and lpad/rpad
is there any way to replace digits using substring in Hive.
scenario:
1. I need to check 0's from right to left and as soon as i find 0 before any digit then i need to replace all the trailing 0's by 9.
2. In output at-least 3 digit should be…

Sonu
- 77
- 11
1
vote
1 answer
How to find current executing line from a hql file
I have a sample.hql file which contains below lines.
desc db.table1;
desc db.table2;
desc db.table3;
I am trying to run it from shell command
I want to find out if a particular column is present in the table or not
For eg-If col_1 is present in…

Hannah
- 163
- 2
- 12
1
vote
1 answer
Hive Union of two queries is giving compile error
I am not sure what is wrong with following hive query. However, it's throwing error.
select h.database_name, h.table_name, h.frequency as hive_frequency, i.frequency as impala_frequency
from hive_access_frequency h
left join…

Gaurang Shah
- 11,764
- 9
- 74
- 137