github-actions[bot] commented on code in PR #64624:
URL: https://github.com/apache/doris/pull/64624#discussion_r3473012869
##########
be/src/exprs/aggregate/aggregate_function_percentile_reservoir.h:
##########
@@ -87,22 +92,35 @@ class AggregateFunctionPercentileReservoir final
DataTypePtr get_return_type() const override { return
std::make_shared<DataTypeFloat64>(); }
+ const std::vector<size_t>& get_const_argument_indexes() const override {
+ static const std::vector<size_t> indexes {1};
+ return indexes;
+ }
+
+ Status set_const_arguments(const VExprContextSPtrs& input_exprs_ctxs)
override {
+ if (input_exprs_ctxs.empty()) {
+ return Status::OK();
+ }
+ ColumnWithTypeAndName argument;
+ RETURN_IF_ERROR(input_exprs_ctxs[1]->execute_const_expr(argument));
+ _level = assert_cast<const ColumnFloat64&,
TypeCheckOnRelease::DISABLE>(
Review Comment:
This setter also needs to validate the cached reservoir level. The FE check
now accepts constant expressions that are not numeric `Literal`s after rewrite,
and `FoldConstantRule.evaluate()` deliberately leaves those expressions in
place when `debug_skip_fold_constant` is set. A query such as `SET
debug_skip_fold_constant=true; SELECT percentile_reservoir(k8, CAST(2 AS
DOUBLE)) ...` can therefore pass FE as a constant `Cast`; this setter executes
it and stores `_level = 2` without the `[0, 1]` guard.
`ReservoirSampler::quantileInterpolated()` then clamps the index and returns
the max sample instead of raising the same error as literal `2`. Please
validate `_level` here (like the other percentile states do) or make the FE
check evaluate constant casts before returning.
--
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]