Skip to content

Commit 352b9e5

Browse files
committed
Add nullptr check in Equals method to handle null impl_ pointers
1 parent 56436e8 commit 352b9e5

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

cpp/src/arrow/compute/expression.cc

+1
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ void PrintTo(const Expression& expr, std::ostream* os) {
220220

221221
bool Expression::Equals(const Expression& other) const {
222222
if (Identical(*this, other)) return true;
223+
if (impl_ == nullptr || other.impl_ == nullptr) return false;
223224

224225
if (impl_->index() != other.impl_->index()) {
225226
return false;

cpp/src/arrow/compute/expression_test.cc

+6
Original file line numberDiff line numberDiff line change
@@ -1916,6 +1916,12 @@ TEST(Expression, SerializationRoundTrips) {
19161916
equal(field_ref("beta"), literal(3.25f))}));
19171917
}
19181918

1919+
TEST(Expression, ExpressionEquals) {
1920+
Expression expr1;
1921+
Expression expr2(literal(1));
1922+
1923+
EXPECT_FALSE(expr1.Equals(expr2));
1924+
}
19191925
TEST(Projection, AugmentWithNull) {
19201926
// NB: input contains *no columns* except i32
19211927
auto input = ArrayFromJSON(struct_({kBoringSchema->GetFieldByName("i32")}),

0 commit comments

Comments
 (0)