zhiqiang-hhhh commented on code in PR #32746:
URL: https://github.com/apache/doris/pull/32746#discussion_r1544006065
##########
be/src/vec/functions/round.h:
##########
@@ -446,6 +479,191 @@ struct Dispatcher {
return nullptr;
}
}
+
+ // NOTE: This function is only tested for truncate
+ // DO NOT USE THIS METHOD FOR OTHER ROUNDING BASED FUNCTION UNTIL YOU KNOW
EXACTLY WHAT YOU ARE DOING !!!
+ static ColumnPtr apply_vec_vec(const IColumn* col_general, const IColumn*
col_scale) {
+ if constexpr (rounding_mode != RoundingMode::Trunc) {
+ throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
+ "Using column as scale is only supported
for function truncate");
+ }
+
+ const ColumnInt32& col_scale_i32 = assert_cast<const
ColumnInt32&>(*col_scale);
+
+ if constexpr (IsNumber<T>) {
+ const auto* col = assert_cast<const ColumnVector<T>*>(col_general);
+ const size_t input_row_count = col->size();
+ auto col_res = ColumnVector<T>::create();
+
+ typename ColumnVector<T>::Container& vec_res = col_res->get_data();
+ vec_res.resize(input_row_count);
+
+ for (size_t i = 0; i < input_row_count; ++i) {
+ const Int32 scale_arg = col_scale_i32.get_data()[i];
+ if (scale_arg > std::numeric_limits<Int16>::max() ||
+ scale_arg < std::numeric_limits<Int16>::min()) {
+ throw doris::Exception(ErrorCode::OUT_OF_BOUND,
+ "Scale argument for function is out
of bound: {}",
+ scale_arg);
+ }
+
+ if (scale_arg == 0) {
+ size_t scale = 1;
+
FunctionRoundingImpl<ScaleMode::Zero>::apply(col->get_data()[i], scale,
+ vec_res[i]);
+ } else if (scale_arg > 0) {
+ size_t scale = int_exp10(col_scale_i32.get_data()[i]);
Review Comment:
Yes, we can.
--
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]