imay commented on a change in pull request #2482: fix core dump when using 
datetime in window function
URL: https://github.com/apache/incubator-doris/pull/2482#discussion_r358823773
 
 

 ##########
 File path: be/src/exprs/aggregate_functions.cpp
 ##########
 @@ -2362,8 +2363,37 @@ void 
AggregateFunctions::offset_fn_init(FunctionContext* ctx, T* dst) {
     DCHECK(ctx->is_arg_constant(1));
     DCHECK(ctx->is_arg_constant(2));
     DCHECK_EQ(ctx->get_arg_type(0)->type, ctx->get_arg_type(2)->type);
-    *dst = *static_cast<T*>(ctx->get_constant_arg(2));
+    T src = *static_cast<T*>(ctx->get_constant_arg(2));
+    // The literal null is sometimes incorrectly converted to int, so *dst = 
src may cause SEGV
+    if (UNLIKELY(src.is_null)) {
+        dst->is_null = src.is_null;
+    } else {
+        *dst = src;
+    }
+}
+
+template <>
+void AggregateFunctions::offset_fn_init(FunctionContext* ctx, StringVal* dst) {
+    DCHECK_EQ(ctx->get_num_args(), 3);
+    DCHECK(ctx->is_arg_constant(1));
+    DCHECK(ctx->is_arg_constant(2));
+    DCHECK_EQ(ctx->get_arg_type(0)->type, ctx->get_arg_type(2)->type);
+    StringVal src = *static_cast<StringVal*>(ctx->get_constant_arg(2));
+    if (src.is_null) {
+        *dst = StringVal::null();
+    } else {
+        uint8_t* copy = ctx->allocate(src.len);
+        if (UNLIKELY(copy == NULL)) {
+            // Zero-length allocation always returns a hard-coded pointer.
+            DCHECK(src.len != 0 && !ctx->impl()->state()->query_status().ok());
 
 Review comment:
   I agree with @kangkaisen , This DCHECK seems not suitable. And I think you 
can remove this DCHECK.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to