hadoop - How can I compute week dates in hive? -


background

Good job in postgresql date_trunc () which it creates It's easy to calculate the start date of a week. It's great for aggregation at week level. E.g.

  SELECT date_trunc ('week', create_date), count (*) from ... group by 1;  

HiveQL's function is WEEKOFYEAR () which gives you the number of weeks. If you combine it with YEAR () , you can create the same type of aggregate as a postgraze

  SELECT YEAR (create_date), WEEKOFYEAR (create_date ), Count (*) to ... GROUP BY YEAR (create_date), WEEKOFYEAR (create_date);  

This is great but if I want the actual date of the week?

Question

How can I calculate the date of the week in HiveQL, either by a year and week number or directly from the timestamp?

There are not many functions in the hive properly, therefore it is supported for custom UDF

1.

2.

2.

2.

P>

Hope this helps .. !!!


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -