Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARROW-10640: [C++] An "if_else" kernel to combine two arrays based on a mask #10410

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
b010b2f
adding basic structure
nirandaperera May 20, 2021
c909293
working primitive types
nirandaperera May 21, 2021
d2aa90e
adding bool type
nirandaperera May 21, 2021
672a99f
adding null kernel
nirandaperera May 21, 2021
0300b8e
adding PR comments
nirandaperera May 24, 2021
b1ec65d
adding more impl
nirandaperera May 25, 2021
52679f3
simplifying exec
nirandaperera May 25, 2021
2f21e9e
promote nulls with visitor
nirandaperera May 25, 2021
6aa1f37
extending test cases
nirandaperera May 25, 2021
e41152f
adding array-scalar null promotion
nirandaperera May 26, 2021
172a824
adding scalar-scalar null promotion
nirandaperera May 26, 2021
768d630
refactor
nirandaperera May 26, 2021
2609734
readability improvements
nirandaperera May 27, 2021
ba36d8d
extending tests
nirandaperera May 27, 2021
cc339f2
completing bool type impl
nirandaperera May 27, 2021
625f36e
adding PR review suggestions
nirandaperera May 27, 2021
673acde
adding a method for set memory
nirandaperera May 27, 2021
4ab1798
adding BitmapOrNot op
nirandaperera May 27, 2021
0ddb75b
extending tests
nirandaperera May 27, 2021
7d62139
extending tests for boolean type
nirandaperera May 27, 2021
874b038
making tests extensible
nirandaperera May 27, 2021
68f065b
cosmetic changes
nirandaperera May 27, 2021
0c25c2a
Update cpp/src/arrow/compute/kernels/scalar_if_else.cc
nirandaperera May 27, 2021
f3ddd66
moving test cases to a method
nirandaperera May 28, 2021
54575a9
adding datum level null promotion
nirandaperera May 28, 2021
e32d709
fixing slicing issue
nirandaperera May 31, 2021
e49842a
rewriting the tests
nirandaperera May 31, 2021
c54e88e
Autoformat/render all the things [automated commit]
nirandaperera Jun 1, 2021
4e58697
adding comments
nirandaperera Jun 1, 2021
7e9dff5
Update cpp/src/arrow/compute/kernels/scalar_if_else.cc
nirandaperera Jun 1, 2021
ee573a8
minor bug fix
nirandaperera Jun 1, 2021
c6d0cdb
minor bug fix
nirandaperera Jun 1, 2021
e15b9df
adding discussed changes to the tests
nirandaperera Jun 1, 2021
4fa62c3
removing offset test case
nirandaperera Jun 1, 2021
6891211
Update cpp/src/arrow/compute/kernels/scalar_if_else_test.cc
nirandaperera Jun 2, 2021
b8802bb
adding PR review comments
nirandaperera Jun 2, 2021
cee34c2
Update cpp/src/arrow/compute/api_scalar.h
nirandaperera Jun 2, 2021
4dbe076
adding docs
nirandaperera Jun 2, 2021
52b6a83
fixing gcc 4.8.1 compilation issue
nirandaperera Jun 3, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cpp/src/arrow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ if(ARROW_COMPUTE)
compute/kernels/scalar_string.cc
compute/kernels/scalar_validity.cc
compute/kernels/scalar_fill_null.cc
compute/kernels/scalar_if_else.cc
compute/kernels/util_internal.cc
compute/kernels/vector_hash.cc
compute/kernels/vector_nested.cc
Expand Down
5 changes: 5 additions & 0 deletions cpp/src/arrow/compute/api_scalar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,10 @@ Result<Datum> FillNull(const Datum& values, const Datum& fill_value, ExecContext
return CallFunction("fill_null", {values, fill_value}, ctx);
}

Result<Datum> IfElse(const Datum& cond, const Datum& if_true, const Datum& if_false,
ExecContext* ctx) {
return CallFunction("if_else", {cond, if_true, if_false}, ctx);
}

} // namespace compute
} // namespace arrow
16 changes: 16 additions & 0 deletions cpp/src/arrow/compute/api_scalar.h
Original file line number Diff line number Diff line change
Expand Up @@ -465,5 +465,21 @@ ARROW_EXPORT
Result<Datum> FillNull(const Datum& values, const Datum& fill_value,
ExecContext* ctx = NULLPTR);

/// \brief IfElse returns elements chosen from `left` or `right`
/// depending on `cond`. `null` values in `cond` will be promoted to the result
///
/// \param[in] cond `Boolean` condition Scalar/ Array
/// \param[in] left Scalar/ Array
/// \param[in] right Scalar/ Array
/// \param[in] ctx the function execution context, optional
///
/// \return the resulting datum
///
/// \since 5.0.0
/// \note API not yet finalized
ARROW_EXPORT
Result<Datum> IfElse(const Datum& cond, const Datum& left, const Datum& right,
ExecContext* ctx = NULLPTR);

} // namespace compute
} // namespace arrow
1 change: 1 addition & 0 deletions cpp/src/arrow/compute/kernels/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ add_arrow_compute_test(scalar_test
scalar_string_test.cc
scalar_validity_test.cc
scalar_fill_null_test.cc
scalar_if_else_test.cc
test_util.cc)

add_arrow_benchmark(scalar_arithmetic_benchmark PREFIX "arrow-compute")
Expand Down
Loading