Results of LUA UDF that returns math.random() are not deterministic with same seed

Details

Detail name Value
Changelog Number 10535
Type Bug
Status Resolved
Affected Versions Exasol 6.1.0, Exasol 6.2.0, Exasol 7.0.0
Fix Versions Exasol 7.1.0
Resolution Date 2021-08-03

Description

A LUA UDF that initializes the random number generator with the same seed returns different results when called multiple times (>10000 times):

CREATE LUA SCALAR SCRIPT "RANDOMSEED" ("seed" DOUBLE) RETURNS DOUBLE AS
function run(ctx)
		math.randomseed(ctx.seed)
		return math.random()
	end
/
select distinct randomseed(123) from t_10000_rows;
--> returns multiple rows instead of one row

Workaround

Since this is limited to LUA UDFs, you can use a Python UDF instead of a Lua UDF:

CREATE PYTHON SCALAR SCRIPT "RANDOMSEED" ("seed" DOUBLE) RETURNS DOUBLE AS
import random
def run(ctx):
	random.seed(ctx.seed)
	return random.random()
/

Fix

The Lua UDF will only return one row, as expected.