crate-workbench / langchain

⚡ Building applications with LLMs through composability ⚡
https://python.langchain.com
MIT License
0 stars 0 forks source link

CrateDB: Add support for SQLRecordManager [DOES NOT WORK] #18

Open amotl opened 10 months ago

amotl commented 10 months ago

About

It does not work, because this subsystem uses composite unique keys in combination with an ON CONFLICT DO UPDATE operation, on behalf of the model entity definition UpsertionRecord.

Because the composite uniqueness constraint is currently being emulated already, it can't also emulate ON CONFLICT behaviour on top easily.

Code References

__table_args__ = (
    UniqueConstraint("key", "namespace", name="uix_key_namespace"),
    Index("ix_key_namespace", "key", "namespace"),
)

stmt = insert_stmt.on_conflict_do_update(
    [UpsertionRecord.key, UpsertionRecord.namespace],
    ...
)

Error Message

CrateDB fails with SQLParseException[Number of conflict targets (["key", "namespace"]) did not match the number of primary key columns ([uuid])], which is expected.

sqlalchemy.exc.ProgrammingError: (crate.client.exceptions.ProgrammingError) SQLParseException[Number of conflict targets (["key", "namespace"]) did not match the number of primary key columns ([uuid])]
[SQL: INSERT INTO upsertion_record (uuid, key, namespace, group_id, updated_at) VALUES (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?) ON CONFLICT (key, namespace) DO UPDATE SET group_id = excluded.group_id, updated_at = excluded.updated_at]
[parameters: ('c3c64eca-8c66-44ce-b4f4-01519249eeaf', 'key1', 'kittens', None, 1700599350.084, '9aa23596-fd40-4758-91eb-dac2431e09d1', 'key2', 'kittens', None, 1700599350.084, '3a06bab9-494f-4b3c-8bf5-6b66a155d5d6', 'key3', 'kittens', None, 1700599350.084)]
(Background on this error at: https://sqlalche.me/e/20/f405)