-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
61 changes: 61 additions & 0 deletions
61
tests/queries_ported/0_stateless/99010_javascript_max_memory_settings.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
CREATE STREAM IF NOT EXISTS 99010_udf_types(`f32` float); | ||
|
||
CREATE AGGREGATE FUNCTION test_sec_large_99010(value float32) RETURNS float32 LANGUAGE JAVASCRIPT AS $$ | ||
{ | ||
initialize: function() { | ||
this.max = -1.0; | ||
this.sec = -1.0 | ||
}, | ||
process: function(values) { | ||
for (let i = 0; i < values.length; i++) { | ||
if (values[i] > this.max) { | ||
this.sec = this.max; | ||
this.max = values[i] | ||
} | ||
if (values[i] < this.max && values[i] > this.sec) | ||
this.sec = values[i]; | ||
} | ||
}, | ||
finalize: function() { | ||
return this.sec | ||
}, | ||
serialize: function() { | ||
let s = { | ||
'max': this.max, | ||
'sec': this.sec | ||
}; | ||
return JSON.stringify(s) | ||
}, | ||
deserialize: function(state_str) { | ||
let s = JSON.parse(state_str); | ||
this.max = s['max']; | ||
this.sec = s['sec'] | ||
}, | ||
merge: function(state_str) { | ||
let s = JSON.parse(state_str); | ||
if (s['sec'] >= this.max) { | ||
this.max = s['max']; | ||
this.sec = s['sec'] | ||
} else if (s['max'] >= this.max) { | ||
this.sec = this.max; | ||
this.max = s['max'] | ||
} else if (s['max'] > this.sec) { | ||
this.sec = s['max'] | ||
} | ||
} | ||
} | ||
$$; | ||
|
||
select sleep(1) FORMAT Null; | ||
insert into 99010_udf_types(f32) values(2.0); | ||
select sleep(1) FORMAT Null; | ||
|
||
|
||
select test_sec_large_99010(f32) from table(99010_udf_types) settings javascript_max_memory_bytes=2; --- { serverError UDF_MEMORY_THRESHOLD_EXCEEDED } | ||
|
||
with acc as (select test_sec_large_99010(f32) as res from table(99010_udf_types) settings javascript_max_memory_bytes=2) select min(res) as re from acc; --- { serverError UDF_MEMORY_THRESHOLD_EXCEEDED } | ||
|
||
|
||
|
||
DROP STREAM 99010_udf_types; | ||
DROP FUNCTION test_sec_large_99010; |