komainu8 opened a new issue, #50752:
URL: https://github.com/apache/arrow/issues/50752
### Describe the bug, including details regarding any error messages,
version, and platform.
### Problem
The following build error can occur when building the Arrow C++ main branch.
```
/arrow/cpp/src/arrow/compute/kernels/scalar_string_ascii.cc:1753:16: error:
unused variable ‘is_utf8’ [-Werror=unused-variable]
1753 | const bool is_utf8 =
is_string_or_string_view(batch[0].type()->id());
| ^~~~~~~
```
### Reproduce
This error occurs under the following conditions:
- Use Debug build(Use -Werror)
- Specify ARROW_COMPUTE=ON
- Specify ARROW_WITH_RE2=OFF
Steps to reproduce:
```
mkdir arrow-cpp-build
git clone https://github.com/apache/arrow.git
cd arrow-cpp-build
cmake ../arrow/cpp --preset ninja-debug-minimal -DARROW_COMPUTE=ON
-DARROW_WITH_RE2=OFF
cmake --build .
```
### Cause
The is_utf8 variable introduced by commit
https://github.com/apache/arrow/commit/374db36347664a38d074d26d28d81ddf1fbd7593
is unused when ARROW_WITH_RE2=OFF is specified.
```diff
static Status Exec(KernelContext* ctx, const ExecSpan& batch, ExecResult*
out) {
const MatchSubstringOptions& options = MatchSubstringState::Get(ctx);
+ const bool is_utf8 = is_string_or_string_view(batch[0].type()->id());
if (options.ignore_case) {
#ifdef ARROW_WITH_RE2
ARROW_ASSIGN_OR_RAISE(auto matcher,
- FindSubstringRegex::Make(options,
InputType::is_utf8, true));
- applicator::ScalarUnaryNotNullStateful<OffsetType, InputType,
FindSubstringRegex>
+ FindSubstringRegex::Make(options, is_utf8,
true));
+ applicator::ScalarUnaryNotNullStateful<OffsetType, InputPhysicalType,
+ FindSubstringRegex>
kernel{std::move(matcher)};
return kernel.Exec(ctx, batch, out);
#else
return Status::NotImplemented("ignore_case requires RE2");
#endif
}
- applicator::ScalarUnaryNotNullStateful<OffsetType, InputType,
FindSubstring> kernel{
- FindSubstring(PlainSubstringMatcher(options))};
+ applicator::ScalarUnaryNotNullStateful<OffsetType, InputPhysicalType,
FindSubstring>
+ kernel{FindSubstring(PlainSubstringMatcher(options))};
return kernel.Exec(ctx, batch, out);
}
};
```
### Suggested fix
We can prevent this error by moving the declaration of `is_utf8` inside the
`#ifdef ARROW_WITH_RE2` block as follows:
```diff
diff --git a/cpp/src/arrow/compute/kernels/scalar_string_ascii.cc
b/cpp/src/arrow/compute/kernels/scalar_string_ascii.cc
index 06ec8c999c..8e7b626837 100644
--- a/cpp/src/arrow/compute/kernels/scalar_string_ascii.cc
+++ b/cpp/src/arrow/compute/kernels/scalar_string_ascii.cc
@@ -1750,9 +1750,9 @@ struct FindSubstringExec {
static Status Exec(KernelContext* ctx, const ExecSpan& batch, ExecResult*
out) {
const MatchSubstringOptions& options = MatchSubstringState::Get(ctx);
- const bool is_utf8 = is_string_or_string_view(batch[0].type()->id());
if (options.ignore_case) {
#ifdef ARROW_WITH_RE2
+ const bool is_utf8 = is_string_or_string_view(batch[0].type()->id());
ARROW_ASSIGN_OR_RAISE(auto matcher,
FindSubstringRegex::Make(options, is_utf8,
true));
applicator::ScalarUnaryNotNullStateful<OffsetType, InputPhysicalType,
```
If this approach looks good to you, I'd be happy to open a PR.
### Component(s)
C++
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]