langchain-ai / langchain-postgres

LangChain abstractions backed by Postgres Backend

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`CREATE EXTENSION` fails with Azure Cosmos DB for PostgreSQL

joshuasundance-swca opened this issue · comments

The SQL for enabling the vector extension is hardcoded at

"CREATE EXTENSION IF NOT EXISTS vector;"

But when using Azure Cosmos DB for PostgreSQL, it's necessary to use SELECT create_extension('vector');

From relevant docs:

If CREATE EXTENSION fails with a permission denied error, try the create_extension() function instead. For instance:

SELECT create_extension('postgis');

To remove an extension installed this way, use drop_extension().

The same applies to pgvector in the same context.

I might propose a parameter that allows the user to define the create extension statement, or choose from a list of predefined options if that approach seems better. Currently, of course, the user can create the extension first and then use create_extension=False.

Feel free to open a PR to try to parameterize