code: def test_aggregate_by_with_joins(self):
      ht = hl.utils.range_table(4)
      ht2 = hl.utils.range_table(4)
      ht2 = ht2.annotate(idx2=ht2.idx)
  
      ht = ht.annotate_globals(glob=5)
      grouped = ht.group_by(group=ht2[ht.idx].idx2 < 2)
      result = grouped.aggregate(
          sum=hl.agg.sum(ht2[ht.idx].idx2 + ht.glob) + ht.glob - 15,
          max=hl.agg.max(ht2[ht.idx].idx2),
      )
  
      expected = (
          hl.Table.parallelize(
              [
                  {"group": True, "sum": 1, "max": 1},
                  {"group": False, "sum": 5, "max": 3},
              ],
              hl.tstruct(group=hl.tbool, sum=hl.tint64, max=hl.tint32),
          )
          .annotate_globals(glob=5)
          .key_by("group")
      )
  
      self.assertTrue(result._same(expected))
  
imports: import unittest
  import hail
  from ..helpers import qobtest
label_desc: Use image node_id 2 for calling the GroupedTableTests obj's underlying member method code with example usage: obj.test_aggregate_by_with_joins() without return types