Skip to content

Commit d7b25a1

Browse files
[python] Disable round-robin merge condition repartition
1 parent e1c6008 commit d7b25a1

2 files changed

Lines changed: 20 additions & 18 deletions

File tree

‎paimon-python/pypaimon/ray/merge_condition.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ def filter_batch(
8686
return batch
8787
datafusion = _load_datafusion()
8888
rewritten = condition if _pre_rewritten else rewrite_condition(condition)
89-
ctx = datafusion.SessionContext()
89+
config = datafusion.SessionConfig().set(
90+
"datafusion.optimizer.enable_round_robin_repartition", "false"
91+
)
92+
ctx = datafusion.SessionContext(config)
9093
input_batches = batch.to_batches()
9194
# Use one batch per partition and rebuild from partitioned batches so
9295
# DataFusion neither concatenates 32-bit offsets nor reorders the input.

‎paimon-python/pypaimon/tests/ray_data_evolution_merge_into_test.py‎

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4722,28 +4722,27 @@ def test_filter_batch(self):
47224722
result = filter_batch(batch, 's.age > t.age')
47234723
self.assertEqual(result.column('s.id').to_pylist(), [2, 3])
47244724

4725+
@unittest.skipIf(_SKIP_CONDITION, _SKIP_REASON)
47254726
def test_filter_batch_preserves_partition_order(self):
47264727
from pypaimon.ray.merge_condition import filter_batch
47274728

4728-
first = pa.record_batch({'t.id': pa.array([0])})
4729-
second = pa.record_batch({'t.id': pa.array([1])})
4730-
dataframe = Mock()
4731-
dataframe.collect.return_value = [second, first]
4732-
dataframe.collect_partitioned.return_value = [[first], [second]]
4733-
context = Mock()
4734-
context.sql.return_value = dataframe
4735-
fake_datafusion = Mock()
4736-
fake_datafusion.SessionContext.return_value = context
4737-
source = pa.Table.from_batches([first, second])
4729+
batch_size = 20_000
4730+
expected = list(range(4 * batch_size))
4731+
source = pa.table({
4732+
't.id': pa.chunked_array([
4733+
pa.array(
4734+
range(i * batch_size, (i + 1) * batch_size),
4735+
type=pa.int64(),
4736+
)
4737+
for i in range(4)
4738+
]),
4739+
})
47384740

4739-
with patch(
4740-
'pypaimon.ray.merge_condition._load_datafusion',
4741-
return_value=fake_datafusion,
4742-
):
4743-
result = filter_batch(source, 'TRUE', _pre_rewritten=True)
4741+
result = filter_batch(
4742+
source, '"t.id" >= 0', _pre_rewritten=True,
4743+
)
47444744

4745-
self.assertEqual(result.column('t.id').to_pylist(), [0, 1])
4746-
dataframe.collect.assert_not_called()
4745+
self.assertEqual(result.column('t.id').to_pylist(), expected)
47474746

47484747
@unittest.skipIf(_SKIP_CONDITION, _SKIP_REASON)
47494748
def test_filter_batch_preserves_large_offset_chunks(self):

0 commit comments

Comments
 (0)