Skip to content

Commit 429a9d7

Browse files
committed
test: regression test for LadybugDB/ladybug#1067 ORDER BY STRING then numeric
Merging sorted key blocks ignored trailing keys once all STRING keys tied, misordering the second key (deterministic with multiple key blocks, e.g. 20k rows).
1 parent 97acee8 commit 429a9d7

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

‎test/test_issue.py‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,27 @@ def test_issue_866_repeated_parameterized_write_then_vector_read(
214214
# assert result.get_next() == [2]
215215
# assert not result.has_next()
216216
# result.close()
217+
218+
219+
def test_issue_1067_order_by_string_then_numeric(conn_db_readwrite: ConnDB) -> None:
220+
# https://github.com/LadybugDB/ladybug/issues/1067
221+
# KeyBlockMerger::compareTuplePtrWithStringCol ignored trailing keys once all
222+
# STRING keys tied, misordering e.g. ORDER BY <STRING>, <numeric> when merging
223+
# sorted key blocks (deterministic once the sort spills to multiple key blocks).
224+
conn, _ = conn_db_readwrite
225+
conn.execute(
226+
"CREATE NODE TABLE Obs(id INT64, name STRING, value DOUBLE, PRIMARY KEY(id))"
227+
)
228+
conn.execute(
229+
"COPY Obs FROM (UNWIND range(0, 19999) AS o RETURN o, "
230+
"'item' + CAST(o % 3 AS STRING), CAST((o * 7919) % 100003 AS DOUBLE))"
231+
)
232+
result = conn.execute(
233+
"MATCH (o:Obs) RETURN o.name, o.value ORDER BY o.name, o.value"
234+
)
235+
rows = result.get_all()
236+
result.close()
237+
# Fail loudly if ingestion ever changes: the bug only reproduces once the
238+
# sort spills to multiple key blocks.
239+
assert len(rows) == 20000
240+
assert rows == sorted(rows)

0 commit comments

Comments
 (0)