# Error index out of bounds

**URL:** <https://discuss.hail.is/t/error-index-out-of-bounds/1766>\
**Category:** Hail Query & hailctl\
**Created:** [November 2, 2020, 8:07pm UTC](https://discuss.hail.is/t/error-index-out-of-bounds/1766 "2020-11-02T20:07:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Santiago](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@Santiago](https://discuss.hail.is/u/Santiago)\
**Post date:** [November 2, 2020, 8:07pm UTC](https://discuss.hail.is/t/error-index-out-of-bounds/1766/1 "2020-11-02T20:07:11Z")

</div>

I tried to run this pipeline and get the error of index out of bounds  
data=hl.import\_vcf(myFolder+"/"+myFile,force\_bgz=True,reference\_genome=‘GRCh38’,array\_elements\_required=False)  
data2=hl.split\_multi\_hts(data, permit\_shuffle=True)  
data2=data2.cache()  
mycount=data2.count()[0]

## File “/usr/local/lib/python3.7/site-packages/hail/matrixtable.py”, line 2426, in count return Env.backend().execute(count\_ir) File “/usr/local/lib/python3.7/site-packages/hail/backend/spark\_backend.py”, line 297, in execute result = json.loads(self.\_jhc.backend().executeJSON(jir)) File “/usr/local/lib/python3.7/site-packages/py4j/java\_gateway.py”, line 1257, in **call** answer, self.gateway\_client, self.target\_id, self.name) File “/usr/local/lib/python3.7/site-packages/hail/backend/spark\_backend.py”, line 42, in deco ‘Error summary: %s’ % (deepest, full, hail. **version** , deepest)) from None hail.utils.java.FatalError: HailException: array index out of bounds: index=2, length=2

Python traceback:  
File “indexingES.py”, line 43, in   
main(sys.argv[1:])

File “indexingES.py”, line 19, in main  
data2=hl.split\_multi\_hts(data, permit\_shuffle=True)

File “”, line 2, in split\_multi\_hts

File “/usr/local/lib/python3.7/site-packages/hail/methods/statgen.py”, line 1786, in split\_multi\_hts  
(hl.range(0, 3).map(lambda i:

File “”, line 2, in map

File “/usr/local/lib/python3.7/site-packages/hail/methods/statgen.py”, line 1790, in   
).map(lambda j: split.PL[j]))))))

File “”, line 2, in map

File “/usr/local/lib/python3.7/site-packages/hail/methods/statgen.py”, line 1790, in   
).map(lambda j: split.PL[j]))))))

Java stack trace:  
org.apache.spark.SparkException: Job aborted due to stage failure: Task 50 in stage 4.0 failed 1 times, most recent failure: Lost task 50.0 in stage 4.0 (TID 4142, localhost, executor driver): is.hail.utils.HailException: array index out of bounds: index=2, length=2

---

<div class="post-metadata">

**Author:** ![tpoterba](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/tpoterba/32/61_2.png) [@tpoterba](https://discuss.hail.is/u/tpoterba)\
**Post date:** [November 2, 2020, 8:08pm UTC](https://discuss.hail.is/t/error-index-out-of-bounds/1766/2 "2020-11-02T20:08:52Z")

</div>

You’ve got input that isn’t what Hail expects – in particular, a PL field with only 2 elements.

Do you have haploid calls? I think that would break hl.split\_multi\_hts.

---

<div class="post-metadata">

**Author:** ![Santiago](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@Santiago](https://discuss.hail.is/u/Santiago)\
**Post date:** [November 2, 2020, 8:09pm UTC](https://discuss.hail.is/t/error-index-out-of-bounds/1766/3 "2020-11-02T20:09:49Z")

</div>

In other file I get this error related with PL:  
Java stack trace:  
org.apache.spark.SparkException: Job aborted due to stage failure: Task 65 in stage 4.0 failed 1 times, most recent failure: Lost task 65.0 in stage 4.0 (TID 4405, localhost, executor driver): is.hail.utils.HailException: PL cannot have missing elements.

---

<div class="post-metadata">

**Author:** ![Santiago](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@Santiago](https://discuss.hail.is/u/Santiago)\
**Post date:** [November 2, 2020, 8:25pm UTC](https://discuss.hail.is/t/error-index-out-of-bounds/1766/4 "2020-11-02T20:25:39Z")

</div>

Ok. So, what can I do?. Really I am only interested in the GT field of the entries. If I select the GT, and then drop the others, this are going to work?.

---

<div class="post-metadata">

**Author:** ![tpoterba](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/tpoterba/32/61_2.png) [@tpoterba](https://discuss.hail.is/u/tpoterba)\
**Post date:** [November 2, 2020, 8:27pm UTC](https://discuss.hail.is/t/error-index-out-of-bounds/1766/5 "2020-11-02T20:27:15Z")

</div>

I think that should work, yes.

---

<div class="post-metadata">

**Author:** ![Santiago](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@Santiago](https://discuss.hail.is/u/Santiago)\
**Post date:** [November 2, 2020, 9:30pm UTC](https://discuss.hail.is/t/error-index-out-of-bounds/1766/6 "2020-11-02T21:30:35Z")

</div>

Thank you!!. Yes, selecting only GT works. Maybe would be better if the exception outputs also the entry data of the error.

---

<div class="post-metadata">

**Author:** ![hdjc90](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/hdjc90/32/641_2.png) [@hdjc90](https://discuss.hail.is/u/hdjc90)\
**Post date:** [July 27, 2022, 2:23pm UTC](https://discuss.hail.is/t/error-index-out-of-bounds/1766/7 "2022-07-27T14:23:00Z")

</div>

@tpoterba I am having a similar issue to this. However, I would like to keep all fields if possible? Do you have a possible workaround for this issue? Thank you!

Error as follows:

## HailUserError: Error summary: HailException: array index out of bounds: index=3, length=3

Hail stack trace:  
File “”, line 5, in   
mt = hl.split\_multi\_hts(mt)

File “/apps/genomics/hail/0.2/el7/AVX512/gnu-7.3/hail/methods/statgen.py”, line 2322, in split\_multi\_hts  
(hl.range(0, 3).map(lambda i:

File “/apps/genomics/hail/0.2/el7/AVX512/gnu-7.3/hail/methods/statgen.py”, line 2326, in   
).map(lambda j: split.PL[j]))))))

File “/apps/genomics/hail/0.2/el7/AVX512/gnu-7.3/hail/methods/statgen.py”, line 2326, in   
).map(lambda j: split.PL[j]))))))

File “/apps/genomics/hail/0.2/el7/AVX512/gnu-7.3/hail/expr/expressions/typed\_expressions.py”, line 481, in **getitem**  
return self.\_method(“indexArray”, self.dtype.element\_type, item)

File “/apps/genomics/hail/0.2/el7/AVX512/gnu-7.3/hail/expr/expressions/base\_expression.py”, line 596, in \_method  
x = ir.Apply(name, ret\_type, self.\_ir, \*(a.\_ir for a in args))

File “/apps/genomics/hail/0.2/el7/AVX512/gnu-7.3/hail/ir/ir.py”, line 2138, in **init**  
self.save\_error\_info()
