This is an automated email from the ASF dual-hosted git repository. morningman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push: new bdbe59a [Bug]Fix be crash caused by decimal to date (#4282) bdbe59a is described below commit bdbe59a41a4ec45fcdee1cae817b3ce016410035 Author: ZhangYu0123 <67053339+zhangyu0...@users.noreply.github.com> AuthorDate: Sun Aug 9 20:47:43 2020 +0800 [Bug]Fix be crash caused by decimal to date (#4282) Fix be crash caused by cast decimal to date. A be crashed bug caused by Unable to find. _ZN5doris18DecimalV2Operators16cast_to_date_val. also see #4281 --- be/src/exprs/decimalv2_operators.cpp | 18 ++++++++++++++++++ be/src/exprs/decimalv2_operators.h | 1 + 2 files changed, 19 insertions(+) diff --git a/be/src/exprs/decimalv2_operators.cpp b/be/src/exprs/decimalv2_operators.cpp index 0a57321..ef83616 100644 --- a/be/src/exprs/decimalv2_operators.cpp +++ b/be/src/exprs/decimalv2_operators.cpp @@ -147,6 +147,24 @@ DateTimeVal DecimalV2Operators::cast_to_datetime_val( return result; } +DateTimeVal DecimalV2Operators::cast_to_date_val( + FunctionContext* context, const DecimalV2Val& val) { + if (val.is_null) { + return DateTimeVal::null(); + } + + // convert from DecimalV2Val to DecimalV2Value for caculation + const DecimalV2Value& dv = DecimalV2Value::from_decimal_val(val); + DateTimeValue dt; + if (!dt.from_date_int64(dv)) { + return DateTimeVal::null(); + } + dt.cast_to_date(); + DateTimeVal result; + dt.to_datetime_val(&result); + return result; +} + DecimalVal DecimalV2Operators::cast_to_decimal_val( FunctionContext* context, const DecimalV2Val& val) { if (val.is_null) return DecimalVal::null(); diff --git a/be/src/exprs/decimalv2_operators.h b/be/src/exprs/decimalv2_operators.h index 8030985..06d8fee 100644 --- a/be/src/exprs/decimalv2_operators.h +++ b/be/src/exprs/decimalv2_operators.h @@ -54,6 +54,7 @@ public: static DoubleVal cast_to_double_val(FunctionContext*, const DecimalV2Val&); static StringVal cast_to_string_val(FunctionContext*, const DecimalV2Val&); static DateTimeVal cast_to_datetime_val(FunctionContext*, const DecimalV2Val&); + static DateTimeVal cast_to_date_val(FunctionContext*, const DecimalV2Val&); static DecimalVal cast_to_decimal_val(FunctionContext*, const DecimalV2Val&); static DecimalV2Val add_decimalv2_val_decimalv2_val( --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org