()
| 4055 | |
| 4056 | |
| 4057 | def test_join_ix(): |
| 4058 | left = T( |
| 4059 | """ |
| 4060 | | a |
| 4061 | 1 | 3 |
| 4062 | 2 | 2 |
| 4063 | 3 | 1 |
| 4064 | """ |
| 4065 | ).with_columns(a=pw.this.pointer_from(pw.this.a)) |
| 4066 | right = T( |
| 4067 | """ |
| 4068 | | b |
| 4069 | 0 | baz |
| 4070 | 1 | foo |
| 4071 | 2 | bar |
| 4072 | """ |
| 4073 | ) |
| 4074 | |
| 4075 | ret = left.join(right, left.a == right.id, id=left.id).select( |
| 4076 | col=right.ix(left.a, context=pw.this).b |
| 4077 | ) |
| 4078 | |
| 4079 | ret3 = ( |
| 4080 | right.ix(left.a, allow_misses=True) |
| 4081 | .select(col=pw.this.b) |
| 4082 | .filter(pw.this.col.is_not_none()) |
| 4083 | ) |
| 4084 | |
| 4085 | # below is the desugared version of above computation |
| 4086 | # it works, and it's magic |
| 4087 | keys_table = left.join(right, left.a == right.id, id=left.id).select( |
| 4088 | join_column=left.a |
| 4089 | ) |
| 4090 | desugared_ix = keys_table.join( |
| 4091 | right, |
| 4092 | keys_table.join_column == right.id, |
| 4093 | id=keys_table.id, |
| 4094 | ).select(right.b) |
| 4095 | tmp = left.join( |
| 4096 | right, left.a == right.id, id=left.id |
| 4097 | ).promise_universe_is_subset_of(desugared_ix) |
| 4098 | ret2 = tmp.select(col=desugared_ix.restrict(tmp).b) |
| 4099 | assert_table_equality( |
| 4100 | ret, |
| 4101 | T( |
| 4102 | """ |
| 4103 | | col |
| 4104 | 3 | foo |
| 4105 | 2 | bar |
| 4106 | """ |
| 4107 | ), |
| 4108 | ) |
| 4109 | assert_table_equality(ret2, ret) |
| 4110 | assert_table_equality(ret3, ret) |
| 4111 | |
| 4112 | |
| 4113 | def test_join_foreign_col(): |
nothing calls this directly
no test coverage detected