Skip to content

Commit

Permalink
Update "create materialized view" clause & add comment about hash dif…
Browse files Browse the repository at this point in the history
…ferentiation in "distinct_on.slt"
  • Loading branch information
shanicky committed Nov 14, 2023
1 parent 35849ca commit aeb2ace
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions e2e_test/streaming/distinct_on.slt
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ statement ok
create table t1 (k int, v int) append only;

statement ok
create materialized view mv1 as select distinct on (k) k + v as sum from t1;
create materialized view mv1 as select distinct on (k) k + v as sum from t1 order by k, v;

statement ok
insert into t1 values (1,11), (2,22), (3,33), (1,111);
@@ -21,7 +21,7 @@ statement ok
create table t2 (k int, v int);

statement ok
create materialized view mv2 as select distinct on (k) k + v as sum from t2;
create materialized view mv2 as select distinct on (k) k + v as sum from t2 order by k, v;

statement ok
insert into t2 values (1,11), (2,22), (3,33), (1,111);
6 changes: 5 additions & 1 deletion src/common/src/hash/consistent_hash/vnode.rs
Original file line number Diff line number Diff line change
@@ -123,8 +123,12 @@ impl VirtualNode {
if let Some(serial) = serial {
extract_vnode_id_from_row_id(serial.as_row_id())
} else {
// NOTE: here it will hash the entire row when the `_row_id` is missing,
// which could result in rows from the same chunk being allocated to different chunks.
// This process doesn’t guarantee the order of rows, producing indeterminate results in some cases,
// such as when `distinct on` is used without an `order by`.
let (row, _) = data_chunk.row_at(idx);
Self::compute_row(row, keys)
row.hash(Crc32FastBuilder).into()
}
} ).collect();
}

0 comments on commit aeb2ace

Please sign in to comment.