It is possible by using the source command.
For example -
Hive> source /path/to/file/file_with_query.hql