Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(Goes with raw-labs/multicorn-das#28)
This PR adds DAS function support to multicorn by introducing:
multicorn_function_execute
, which can be invokedfrom SQL with a set of parameters that includes FDW-like options, named
argument strings, and the actual function parameters.
das_function_execute
that:options
andarguments
into Python dictionaries,multicorn_das.DASFunction.execute_static
) for DAS function execution,Datum
.build_dummy_attinmeta(Oid retType)
for creating asingle-column
AttInMetadata
structure, used when converting the returnedPython object to a
Datum
of the indicatedretType
. If the return type is anarray, it sets attndims=1 to handle array‐like results.
A fix:
INTERVAL
was read from adict
representation, that isn't anything standard (it is the Python object generated bymulticorn-das
), to turn it into an ISO string which Postgres can parse and import. Ifmulticorn-das
generates that a Python ISO string instead of that dictionary, then importing an interval is simplified: we can pass the string to Postgres.dict
, a user wouldn't easily translate it into a PostgresINTERVAL
, while if it comes as an ISO string,value::interval
works.multicorn_function_execute
Runs the logic to execute a DAS function statically.
text[]
of options, which permits to identify which DAS and function to execute,text[]
of parameter names, which is used eventually to build the named arguments as a Python dictionary,pg_proc
, in order to callsforeign_function_execute
, that bridges to Python.foreign_function_execute
It bridges the SQL function to Python:
multicorn_das.DASFunction
and callsexecute_static(...)
.pyobjectToDatum(...)
to transform the Python result to a Postgres Datum.build_dummy_attinmeta
Converting the function result to
Datum
reuses the existing Python conversioncode that runs for tables. Because that code takes its conversion information
from column descriptions, we add
build_dummy_attinmeta
, a function thatreturns a single‐attribute
AttInMetadata
with the given type for the requiredtext-based conversion that are already in place for column values.