Skip to content

Tag: hiveql

SQL Summing columns based on date key

I have a dataset as given in the link, DataSet I want to segregate the column “order_item_unit_status” as separate column and bring respective transaction amount for the same. Desired output is given below. Objective is to consolidate the txn_amt into respective categories and group them based on …

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. I am able to run this queries individually. However, facing issues while running with union Error Answer Hive versions prior to 1.2.0 only support UNION ALL Workaround: Use UNION ALL instead of UNION, wrap all into subq…

Want to convert timestamp to date format in hive

want to convert this number ‘20210412070422’ to date format ‘2021-04-12’ in hive I am trying but this returns null value from_unixtime(unix_timestamp(eap_as_of_dt, ‘MM/dd/yyyy’)) Answer The best methoid is to do without unix_timestamp/from_unixtime if possible and in your c…

Hive Explode the Array of Struct key: value:

This is the below Hive Table And this is the data in the above table- Is there any way I can get the below output using HiveQL? I tried use explode() but I get result like that: Answer Use laterral view [outer] inline to get struct elements already etracted and use conditional aggregation to get values corres…