The below example demonstrates using dask delayed funtions (ref) from within postgres plpython while using "plpy.execute" (ref) to query the database.
It returns an error:
ERROR: spiexceptions.StatementTooComplex: stack depth limit exceeded
Any idea on what I'm doing wrong? I'm guessing it has something to do with delayed function's async nature and plpy.execute not liking that.
Versions:
- postgresql 15
- postgres's embedded python version 3.8
Example:
DO
LANGUAGE plpython3u
$$
# https://docs.dask.org/en/stable/dataframe-sql.html#delayed-functions
from dask import delayed
@delayed
def do_it():
rv = plpy.execute("select 2 as a") # << max stack depth limit
return 0
plpy.info(do_it().compute())
$$;
Traceback:
ERROR: spiexceptions.StatementTooComplex: stack depth limit exceeded
HINT: Increase the configuration parameter "max_stack_depth" (currently 7168kB), after ensuring the platform's stack depth limit is adequate.
CONTEXT: Traceback (most recent call last):
PL/Python anonymous code block, line 10, in <module>
plpy.info(do_it().compute())
PL/Python anonymous code block, line 313, in compute
PL/Python anonymous code block, line 598, in compute
PL/Python anonymous code block, line 88, in get
PL/Python anonymous code block, line 510, in get_async
PL/Python anonymous code block, line 318, in reraise
PL/Python anonymous code block, line 223, in execute_task
PL/Python anonymous code block, line 118, in _execute_task
PL/Python anonymous code block, line 7, in do_it
rv = plpy.execute("select 2 as a") # << max stack depth limit
PL/Python anonymous code block
Updates:
- added traceback
- made more minimal