zanmato1984 commented on code in PR #46566: URL: https://github.com/apache/arrow/pull/46566#discussion_r2115262361
########## python/pyarrow/tests/test_acero.py: ########## @@ -300,6 +300,86 @@ def test_order_by(): _ = OrderByNodeOptions([("b", "ascending")], null_placement="start") +def test_hash_join_with_residual_filter(): + left = pa.table({'key': [1, 2, 3], 'a': [4, 5, 6]}) + left_source = Declaration("table_source", options=TableSourceNodeOptions(left)) + right = pa.table({'key': [2, 3, 4], 'b': [4, 5, 6]}) + right_source = Declaration("table_source", options=TableSourceNodeOptions(right)) + + join_opts = HashJoinNodeOptions( + "inner", left_keys="key", right_keys="key", + filter=pc.equal(pc.field('a'), 5)) + joined = Declaration( + "hashjoin", options=join_opts, inputs=[left_source, right_source]) + result = joined.to_table() + expected = pa.table( + [[2], [5], [2], [4]], + names=["key", "a", "key", "b"]) + assert result.equals(expected) + + # test filter expression referencing columns from both side + join_opts = HashJoinNodeOptions( + "left outer", left_keys="key", right_keys="key", + filter=pc.equal(pc.field("a"), 5) | pc.equal(pc.field("b"), 10) + ) + joined = Declaration( + "hashjoin", options=join_opts, inputs=[left_source, right_source]) + result = joined.to_table() + expected = pa.table( + [[2, 1, 3], [5, 4, 6], [2, None, None], [4, None, None]], + names=["key", "a", "key", "b"]) + assert result.equals(expected) + + left = pa.table({'l1': [1], 'l_str': ["alpha"]}) + left_source = Declaration("table_source", options=TableSourceNodeOptions(left)) + right = pa.table({'r1': [1], 'r_str': ["alpha"]}) + right_source = Declaration("table_source", options=TableSourceNodeOptions(right)) + + # test with always true Review Comment: This is not "always true", it's still depending on the actual data. I meant something constant like `_true` or `1 + 1 = 2`. And the "always false" too. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org