Skip to content

Commit

Permalink
add assertion in table catalog builder
Browse files Browse the repository at this point in the history
Signed-off-by: Bugen Zhao <[email protected]>
  • Loading branch information
BugenZhao committed Oct 12, 2024
1 parent 602c622 commit 09fe68d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/frontend/src/optimizer/plan_node/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,21 @@ impl TableCatalogBuilder {
Some(w) => w,
None => FixedBitSet::with_capacity(self.columns.len()),
};

// If `dist_key_in_pk` is set, check if it matches with `distribution_key`.
// Note that we cannot derive in the opposite direction, because there can be a column
// appearing multiple times in the PK.
if let Some(dist_key_in_pk) = &self.dist_key_in_pk {
let derived_dist_key = dist_key_in_pk
.iter()
.map(|idx| self.pk[*idx].column_index)
.collect_vec();
assert_eq!(
derived_dist_key, distribution_key,
"dist_key mismatch with dist_key_in_pk"
);
}

TableCatalog {
id: TableId::placeholder(),
associated_source_id: None,
Expand Down

0 comments on commit 09fe68d

Please sign in to comment.