# Issues with annotating a MT with a HT

**URL:** <https://discuss.hail.is/t/issues-with-annotating-a-mt-with-a-ht/2693>\
**Category:** Hail Query & hailctl\
**Created:** [June 3, 2022, 3:12pm UTC](https://discuss.hail.is/t/issues-with-annotating-a-mt-with-a-ht/2693 "2022-06-03T15:12:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![CuriousGeneticist](https://avatars.discourse-cdn.com/v4/letter/c/6f9a4e/32.png) [@CuriousGeneticist](https://discuss.hail.is/u/CuriousGeneticist)\
**Post date:** [June 3, 2022, 3:12pm UTC](https://discuss.hail.is/t/issues-with-annotating-a-mt-with-a-ht/2693/1 "2022-06-03T15:12:38Z")

</div>

I have a Hail Table and a MatrixTable, both are keyed by “locus” and “alleles”. I am not sure if I am doing this right, but I am doing `ht[mt.row_key]`, but the `StructExpression` contains the fields from the MatrixTable, instead of the Hail table. I had thought that it should have the ht fields instead, can I know how to resolve this?

---

<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:** [June 3, 2022, 3:18pm UTC](https://discuss.hail.is/t/issues-with-annotating-a-mt-with-a-ht/2693/2 "2022-06-03T15:18:03Z")

</div>

That should be correct – annotating each should look like:

```auto
# annotate ht from mt row fields:
ht = ht.annotate(mt_fields = mt.index_rows(ht.key))

# annotate mt from ht row fields:
mt = mt.annotate_rows(ht_fields = ht.index(mt.row_key))

```

You can print the types of each as follows:

```auto
print(ht.index(mt.row_key).dtype)
print(mt.index_rows(ht.row_key).dtype)

```
