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

Function test_linked_list_forward

python/pathway/tests/test_examples.py:172–217  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

170
171
172def test_linked_list_forward():
173 nodes = T(
174 """
175 | next
176 1 | 2
177 2 | 3
178 3 | 4
179 4 | 5
180 5 | 6
181 6 | 7
182 7 | 8
183 8 |
184 """,
185 )
186 nodes = nodes.select(next=nodes.pointer_from(this.next, optional=True))
187
188 linked_list = linked_list_transformer(linked_list=nodes).linked_list
189
190 queries = T(
191 """
192 node_id | steps
193 1 | 0
194 2 | 1
195 6 | 2
196 6 | 3
197 8 | 0
198 8 | 2
199 """,
200 ).with_columns(node_id=nodes.pointer_from(this.node_id))
201 ret = queries.select(result=linked_list.ix(queries.node_id).forward(queries.steps))
202 expected = (
203 T(
204 """
205 | result
206 0 | 1
207 1 | 3
208 2 | 8
209 3 |
210 4 | 8
211 5 |
212 """,
213 )
214 .update_types(result=Any)
215 .select(result=nodes.pointer_from(this.result, optional=True))
216 )
217 assert_table_equality(ret, expected)

Callers

nothing calls this directly

Calls 8

TFunction · 0.90
with_columnsMethod · 0.80
forwardMethod · 0.80
update_typesMethod · 0.80
selectMethod · 0.45
pointer_fromMethod · 0.45
ixMethod · 0.45

Tested by

no test coverage detected