0

Suppose I have a Hive table that looks like this:

 a    b
41   77
8    32
31   76

I would like to have another column say c which applies a function that loops through all integers between columns a and b. For example, c could contain the sum of all integers between a and b. Is there a way to phrase my Hive query?

Edit: I'm using Hive 2.1.1-mapr-1803 version.

  • Specify DBMS, including version. Explain why you want this redundant data to be static - or your function is not deterministic in practice? – Akina Jul 25 '19 at 19:09
  • Edited to add the Hive version. My function is deterministic but it does not have a closed-form expression. In the example of computingthe sum of integers from a to b above, I wouldn't want an answer that suggests I use the formula for sum of numbers in an arithmetic progression. – Abhishek Parab Jul 25 '19 at 22:07
  • The sum of consecutive integers between a and b has a closed form expression though. It is b(b-1) - a(a+1) – ypercubeᵀᴹ Jul 25 '19 at 22:23

0 Answers0