HIVE-9097: fix index out of bound