mirror of
https://github.com/apache/impala.git
synced 2026-01-05 21:00:54 -05:00
IMPALA-4266: Java udf returning string can give incorrect results
The memory management of string results was wrong: strings returned from Exprs must live until the next time FreeLocalAllocations() is called. Otherwise the buffer holding the string is freed or reused by the next UDF call. The fix is to copy string values into a buffer with the right lifetime. Testing: Added a regression test based on Bharath's example that reproduced the bug reliably. Change-Id: I705d271814cb1143f67d8a12f4fd87bab7a8e161 Reviewed-on: http://gerrit.cloudera.org:8080/4941 Reviewed-by: Tim Armstrong <tarmstrong@cloudera.com> Tested-by: Internal Jenkins
This commit is contained in:
committed by
Internal Jenkins
parent
10fa472fa6
commit
381e719065
@@ -290,3 +290,26 @@ INT
|
||||
999
|
||||
999
|
||||
====
|
||||
---- QUERY
|
||||
drop table if exists replace_string_input
|
||||
====
|
||||
---- QUERY
|
||||
create table replace_string_input as
|
||||
values('toast'), ('scone'), ('stuff'), ('sssss'), ('yes'), ('scone'), ('stuff');
|
||||
====
|
||||
---- QUERY
|
||||
# Regression test for IMPALA-4266: memory management bugs with output strings from
|
||||
# Java UDFS, exposed by using the UDF as a grouping key in an aggregation.
|
||||
# The UDF replaces "s" with "ss" in the strings.
|
||||
select distinct udf_test.replace_string(_c0) as es
|
||||
from replace_string_input
|
||||
order by 1;
|
||||
---- TYPES
|
||||
string
|
||||
---- RESULTS
|
||||
'sscone'
|
||||
'ssssssssss'
|
||||
'sstuff'
|
||||
'toasst'
|
||||
'yess'
|
||||
====
|
||||
|
||||
Reference in New Issue
Block a user