mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-25 01:10:37 +00:00
fix(datatypes): correct ConstantVector rhs comparison in vector equality (#7866)
* fix(datatypes): compare ConstantVector rhs inner in vector equality When either operand is a ConstantVector, the recursive equal() call must compare lhs.inner() against rhs.inner(). The second argument incorrectly used lhs twice, breaking equality when only the rhs was constant. Signed-off-by: Weixie Cui <cuiweixie@gmail.com> * fix: review Signed-off-by: Weixie Cui <cuiweixie@gmail.com> --------- Signed-off-by: Weixie Cui <cuiweixie@gmail.com>
This commit is contained in:
@@ -67,7 +67,7 @@ fn equal(lhs: &dyn Vector, rhs: &dyn Vector) -> bool {
|
||||
.downcast_ref::<ConstantVector>()
|
||||
.unwrap()
|
||||
.inner(),
|
||||
&**lhs
|
||||
&**rhs
|
||||
.as_any()
|
||||
.downcast_ref::<ConstantVector>()
|
||||
.unwrap()
|
||||
@@ -259,6 +259,22 @@ mod tests {
|
||||
])));
|
||||
}
|
||||
|
||||
// Regression: second arm must downcast `rhs` (was `lhs`), or same-length ConstantVectors
|
||||
// with different inners compare equal.
|
||||
#[test]
|
||||
fn test_constant_vector_eq_compares_both_inners() {
|
||||
assert_vector_ref_ne(
|
||||
Arc::new(ConstantVector::new(
|
||||
Arc::new(BooleanVector::from(vec![true])),
|
||||
5,
|
||||
)),
|
||||
Arc::new(ConstantVector::new(
|
||||
Arc::new(BooleanVector::from(vec![false])),
|
||||
5,
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_vector_ne() {
|
||||
assert_vector_ref_ne(
|
||||
|
||||
Reference in New Issue
Block a user