Skip to content
Advertisement

Tag: hive

How to find previous date in HIVE

I want to find previous date in Hive. For example : I have Date as 20180821 (yyyyMMdd) format, I want to find previous date of this in Hive. I tried date_sub() function, seems it works only with yyyy-MM-dd format. How to solve my issue. Please help Answer In addition to already provided solution with unix_timestamp conversion, please consider also this.

Remove nulls from an array in SQL

Want to remove nulls from an array in hive/sql for example : array is [‘1’,null] after converting to string values it should be ‘1’ only. to split the array I am using below: concat_ws( “,”, …

How to prevent sql without limit in Hive?

Many users are used to using ‘select * from tables’ in oracle/mysql But i should not allow them to query like that in hive Is there any way to prevent a full_table scan in hive? Like trigger or somethng else? Thanks a lot! Answer To prevent full table scan use these settings. Hive will generate exception if partition predicate is

How to find duplicate rows in Hive?

I want to find duplicate rows from one of the Hive table for which I was given two approaches. First approach is to use following two queries: second query is as below which will give count of distinct rows With this approach, for one of my table total row count derived using first query is 3500 and second query gives

Deleting Part of a string in HIVE

I am trying to delete a part of a string in HIVE. I want to delete the last eleven characters for all records in a column. The data looks like: 1018492743|0001-01-01 I want it to look like: 1018492743 The code I have tried looks like: Select right(a.ord_id, len(a.ord_id)-ll) It isn’t working because len isnt a function in HIVE Another issue

Advertisement