问题
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 ?
回答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
来源:https://stackoverflow.com/questions/65235506/how-to-provide-arguments-to-in-clause-in-hive