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 pgvector extension in codegen #446

Closed
comfuture opened this issue Jun 23, 2023 · 3 comments · Fixed by #447
Closed

Support pgvector extension in codegen #446

comfuture opened this issue Jun 23, 2023 · 3 comments · Fixed by #447
Assignees

Comments

@comfuture
Copy link

Describe the bug

edgedb python doesn't seems support pgvector yet.
When I try to create codegen for pgvector, it throws an error.

Reproduction

Simple edgeql that uses pgvector:

with
  vec as module ext::pgvector,
  target := <vec1536>$vector,
  threshold := <float64>$threshold

select Document {
  *,
  dist := vec::cosine_distance(target, .embedding)
}
filter .dist < threshold
order by .dist empty last
limit 5

Try to create code by edgedb-py command:

edgedb-py

Error message

$ edgedb-py
Found EdgeDB project: /workspace
Processing /workspace/queries/search_document.edgeql
Generating /workspace/queries/search_document_async_edgeql.py
Traceback (most recent call last):
  File "/home/vscode/.local/bin/edgedb-py", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/edgedb/codegen/cli.py", line 99, in main
    generator.Generator(args).run()
  File "/home/vscode/.local/lib/python3.11/site-packages/edgedb/codegen/generator.py", line 198, in run
    self._generate_files(suffix)
  File "/home/vscode/.local/lib/python3.11/site-packages/edgedb/codegen/generator.py", line 232, in _generate_files
    content = self._generate(name, query, dr)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/edgedb/codegen/generator.py", line 319, in _generate
    out_type = self._generate_code(dr.output_type, name_hint)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/edgedb/codegen/generator.py", line 452, in _generate_code
    el_code = self._generate_code_with_cardinality(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/edgedb/codegen/generator.py", line 524, in _generate_code_with_cardinality
    rv = self._generate_code(type_, name_hint)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/edgedb/codegen/generator.py", line 434, in _generate_code
    value = TYPE_MAPPING[base_type_name]
            ~~~~~~~~~~~~^^^^^^^^^^^^^^^^
KeyError: 'ext::pgvector::vector'

Expected behavior
Should be able to generate python file named search_document_async_edgeql.py

Versions (please complete the following information):

  • OS: Linux 5ca54fafbd62 5.15.0-1040-azure #47-Ubuntu SMP Thu Jun 1 19:38:24 UTC 2023 x86_64 GNU/Linux
  • EdgeDB version: 3.0+304325b
  • EdgeDB CLI version: 3.3.0+071876c
  • edgedb-python version: 1.5.0
  • Python version: Python 3.11.4

Additional context
Add any other context about the problem here.

@comfuture comfuture changed the title Support pgvector extension Support pgvector extension in codegen Jun 23, 2023
@fantix fantix self-assigned this Jun 25, 2023
@comfuture
Copy link
Author

Is this issue still being resolved? If it can't be resolved with codegen, I'll try to find another way.

@elprans
Copy link
Member

elprans commented Sep 8, 2023

@fantix, please merge #447 if it's ready

@fantix
Copy link
Member

fantix commented Sep 8, 2023

Yeah, it's ready now, I'll solve the issue in the failing test before merging (it might be a server bug due to recent changes in state management).

fantix added a commit that referenced this issue Sep 22, 2023
Changes
=======

* Add an fts::language type that is encoded as text (#417)
  (by @msullivan in 9e7d2d2 for #417)

* Drop support of Python 3.7 (#435)
  (by @fantix in 758a391 for #435)

Fixes
=====

* Fix codegen for pgvector (#447)
  (by @fantix in 7aa58bd for #446)

* Use name hint when server is not providing custom scalar type name (#461)
  (by @arunaruljothi in 6c6225e for #457)
fantix added a commit that referenced this issue Sep 22, 2023
Changes
=======

* Add an fts::language type that is encoded as text (#417)
  (by @msullivan in 9e7d2d2 for #417)

* Drop support of Python 3.7 (#435)
  (by @fantix in 758a391 for #435)

Fixes
=====

* Fix codegen for pgvector (#447)
  (by @fantix in 7aa58bd for #446)

* Use name hint when server is not providing custom scalar type name (#461)
  (by @arunaruljothi in 6c6225e for #457)
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

Successfully merging a pull request may close this issue.

3 participants