1

Is there any way to read arguments in HIVEquery which can substitute to an IN Clause. I have the below query with me.

Select count (*) from table where id in ('1','2','3','4','5').

Is there any way to supply the arguments to IN Clause from a text file ?

mazaneicha
  • 8,794
  • 4
  • 33
  • 52
abc_spark
  • 383
  • 3
  • 19

1 Answers1

1

Use in_file: Put all ids into file, one id in a row.

Select count (*) from table where in_file(id, '/tmp/myfilename'); --local file

Also you can pass the list of values as a single parameter to the IN: https://stackoverflow.com/a/56963448/2700344

Also instead if IN you can do left semi join with a table containing these IDs, like in this answer: https://stackoverflow.com/a/41056870/2700344

leftjoin
  • 36,950
  • 8
  • 57
  • 116