impala-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Ho (Code Review)" <>
Subject [Impala-ASF-CR] IMPALA-4729: Implement REPLACE()
Date Tue, 07 Feb 2017 01:51:18 GMT
Michael Ho has posted comments on this change.

Change subject: IMPALA-4729: Implement REPLACE()

Patch Set 14:


Looking good. Just some more minor comments.
File be/src/exprs/

PS13, Line 238: (context->GetFunctionState(FunctionContext::FRAGMENT_LOCAL));
nit: line continuation uses indent 4.
File be/src/exprs/

PS14, Line 238: (context->GetFunctionState(FunctionContext::FRAGMENT_LOCAL));
nit: indent 4.

PS14, Line 278: was
nit: is

PS14, Line 289: ==
Should this be <= ?

It won't overflow if it's StringVal::MAX_LENGTH - 1 + StringVal::MAX_LENGTH <= std::numeric_limits<decltype(buffer_space)>::max(),
right ?

PS14, Line 352: UNLIKELY(resized == false)
nit: !resized.

May be easier to just do:

if (!result.Resize(...)) return StringVal::null();
File be/src/udf/udf.h:

Line 583:   /// Reallocate a StringVal so that it as at least as large as len.  May shrink
May help to clarify that the string being resized needs to be allocated from StringVal(FunctionContext*
context, int len);

Memory allocated from that interface is considered memory managed by Impala instead of the
UDF/UDA (aka local allocations). In other words, one shouldn't call this function on a  string
allocated via FunctionContext::Allocate() at the init() of a UDA. This may result in double
free. Sorry, our UDF memory management story is rather messy.

Line 587:   /// If the resize fails, the original StringVal remains in place.
and returns false. Returns true otherwise.
File testdata/workloads/functional-query/queries/QueryTest/exprs.test:

PS14, Line 1942: select sum(length(replace(y, x, 'bbbbbbbbbb'))) from (select cast(round(
               : float_col) AS STRING) as x, string_col as y from functional.alltypes) v;
This seems rather similar to the previous query ? How about we test the case in which the
replace string is a the string_col instead ?

select sum(length(replace(y, '0', x))) from (select cast(round(
float_col) AS STRING) as x, string_col as y from functional.alltypes) v;

To view, visit
To unsubscribe, visit

Gerrit-MessageType: comment
Gerrit-Change-Id: I1780a7d8fee6d0db9dad148217fb6eb10f773329
Gerrit-PatchSet: 14
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-Owner: Zach Amsden <>
Gerrit-Reviewer: Alex Behm <>
Gerrit-Reviewer: Dan Hecht <>
Gerrit-Reviewer: Michael Ho <>
Gerrit-Reviewer: Tim Armstrong <>
Gerrit-Reviewer: Zach Amsden <>
Gerrit-HasComments: Yes

View raw message