Skip to content

Use of Type Annotations to aid FUNCTION synthesis. #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jwp opened this issue Jul 28, 2022 · 0 comments
Open

Use of Type Annotations to aid FUNCTION synthesis. #37

jwp opened this issue Jul 28, 2022 · 0 comments

Comments

@jwp
Copy link
Contributor

jwp commented Jul 28, 2022

There is no intention to implement this in pg-python.

The presence of type annotations provides an opportunity to synthesize function creation. Rather than relying on CREATE FUNCTION SQL scripts, a user/admin may submit an entire Python Module whose (marked) functions will be used to manufacture the necessary catalog changes.

This procedural language implementation encapsulates each SQL FUNCTION in a unique module in order to provide an execution environment consistent with Python modules. In cases where functions have shared dependencies, similar environments, or shallow implementations(one liners), having sets of functions grouped in modules allows an author to eliminate the redundancies. While this is already possible, it is a manual operation that requires the interface (SQL parameters) to be declared far from their implementation. Synthesizing the SQL FUNCTIONs from annotated Python functions and, likely, additional decorators would eliminate that distance.

Having module based storage of functions also encourages offline (no-database) testing of functions. Functions annotated to take Python types (@pytypes no longer required) would not even require mocking of the Postgres module to support analysis. Of course, functions depending on prepared statements (SQL) would need runtime substitutions (mocking) in offline testing.

SELECT py_support.install({schema}::text, {module_name}::text, {module}::text); would have the effect of synthesizing and executing CREATE FUNCTION statements along with the insertion of the module text into a support table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant