Refactor the code for list hive partitions, to make it more extensible.
[Github] Pull Request #19444 (jiangxb1987)