Skip to content
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

Support for calling PG-only scalar functions #615

Open
JelteF opened this issue Feb 19, 2025 · 0 comments
Open

Support for calling PG-only scalar functions #615

JelteF opened this issue Feb 19, 2025 · 0 comments
Milestone

Comments

@JelteF
Copy link
Collaborator

JelteF commented Feb 19, 2025

Description

We currently only support calling scalar functions that exist in DuckDB from DuckDB. There are (at least) three situations worth considering here:

  1. Converting a PG-only type (e.g. from an extension), to a type that duckdb understands. e.g. taking a PG spatial type, and converting it to a text representation.
  2. Converting a type that DuckDB understands to a PG-only type. Converting a text representation of a spatial type, back to the actual spatial type.
  3. Converting a type that DuckDB understands to another type that duckdb understands. E.g. a simple plgpgsql UDF that does some date truncation, if the date is before the year 2000.

None of these situations are trivial to implement afaict. But number 3 is probably the first usecase we should tackle. Afaict what we need to do to achieve 3 is:

  1. Our GetCatalogEntry should return catalog entries for functions.
  2. The functions that those return need to call the underlying postgres functions, by first converting the DuckDB arguments to postgres representation, and then the result back to duckdb representation.

Then once we have this, situation 1 and 2 could be built on top of that support, by adding a new type to DuckDB that represents a Postgres type that's fully opaque to DuckDB, i.e. it would simply store the Postgres bytes. The only operations possible on such a vector would be:

  • "cast to string" (because all postgres types support that)
  • call a Postgres-only function on it
  • return it to postgres

Related to #483 (which is about adding support for PG-only set-returning functions)

@JelteF JelteF added this to the Long term milestone Feb 19, 2025
@JelteF JelteF mentioned this issue Feb 25, 2025
2 tasks
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