MCPcopy
hub / github.com/pathwaycom/pathway / test_join_ix

Function test_join_ix

python/pathway/tests/test_common.py:4057–4110  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4055
4056
4057def 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
4113def test_join_foreign_col():

Callers

nothing calls this directly

Calls 10

TFunction · 0.90
with_columnsMethod · 0.80
is_not_noneMethod · 0.80
restrictMethod · 0.80
pointer_fromMethod · 0.45
selectMethod · 0.45
joinMethod · 0.45
ixMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected