Remove duplicated code around hive operation