PgVectorIngestOperator

Use the PgVectorIngestOperator to store vector embeddings along with other data column values into a PostgreSQL table supporting vectors.

Using the Operator

The PgVectorIngestOperator accepts a SQL query that can be used to insert data along with vector embeddings column data in a Postgres database table that has the vector extension.

Make sure that the pgvector extension is installed on your Postgres database. See https://github.com/pgvector/pgvector#installation for installation instructions.

An example using the operator to ingest data is shown below:

tests/system/providers/pgvector/example_pgvector.py[source]

    pgvector_ingest = PgVectorIngestOperator(
        task_id="pgvector_ingest",
        conn_id=POSTGRES_CONN_ID,
        sql=f"INSERT INTO {TABLE_NAME} (name, value, vector_column) "
        f"VALUES ('John Doe', 123, '[1.0, 2.0, 3.0]')",
    )

Was this entry helpful?