Copilot commented on code in PR #12793:
URL: https://github.com/apache/gluten/pull/12793#discussion_r3796825851
##########
cpp/velox/operators/functions/SparkExprToSubfieldFilterParser.cc:
##########
@@ -93,6 +166,42 @@ SparkExprToSubfieldFilterParser::leafCallToSubfieldFilter(
}
return std::make_pair(std::move(subfield),
facebook::velox::exec::isNotNull());
}
+ } else if (scanBloomFilterPushdownEnabled_ && call.name() == "might_contain"
&& !negated) {
+ // Matches: might_contain(bloomFilter, xxhash64_with_seed(seed, field)).
+ GLUTEN_CHECK(
+ call.inputs().size() == 2,
+ "might_contain expects 2 arguments: bloomFilter and
xxhash64_with_seed(seed, field)");
+ const auto* hashCall = dynamic_cast<const
core::CallTypedExpr*>(call.inputs()[1].get());
+ if (hashCall && hashCall->name() == "xxhash64_with_seed") {
+ GLUTEN_CHECK(hashCall->inputs().size() == 2, "xxhash64_with_seed expects
2 arguments");
+ const auto inputTypeKind = hashCall->inputs()[1]->type()->kind();
+ if (inputTypeKind != TypeKind::INTEGER && inputTypeKind !=
TypeKind::BIGINT) {
+ return std::nullopt;
+ }
+ auto seedValue = toConstant(hashCall->inputs()[0], evaluator);
+ if (!seedValue || seedValue->isNullAt(0)) {
+ LOG(WARNING) << "might_contain: seed value is null or not constant, "
+ << "cannot push down to subfield filter";
+ return std::nullopt;
+ }
+ auto seed = seedValue->as<SimpleVector<int64_t>>()->valueAt(0);
Review Comment:
`seedValue` is unconditionally read as `SimpleVector<int64_t>`, but Spark
literals for the seed are commonly `INTEGER` (int32). If `toConstant` produces
an `INTEGER` vector, this cast can be invalid and lead to incorrect reads or a
crash. Fix by checking `seedValue->typeKind()` and reading `int32_t` vs
`int64_t` accordingly (or use a Velox utility to cast/coerce the constant to
BIGINT before reading).
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]