pgcli icon indicating copy to clipboard operation
pgcli copied to clipboard

Autocomplete not working for Apache AGE extension function names

Open rafsun42 opened this issue 1 year ago • 1 comments

Description

Hello,

I am interested in trying the PG extension Apache AGE with pgcli. Almost all uses of the extension is via the functions it provides. So, it would be really useful if pgcli could autocomplete AGE's functions. However, it does not. I have tried adding AGE's catalog to the search path, but that didn't work. It seems the autocomplete feature relies on the file pgliterals.json to get the function names.

Can anyone guide me how to enable this functionality in case I am missing something?

In case this functionality is not there, I am interested in helping implement it. The basic idea is to allow PGCompleter to dynamically query pg_proc table for function name lookups. Any thoughts?

-- Rafsun Masud Apache AGE contributor: https://github.com/apache/age

Your environment

OS: Ubuntu 22.04 CLI: compiled the main branch

  • [x] Please provide your OS and version information.
  • [x] Please provide your CLI version.
  • [x] What is the output of pip freeze command.

rafsun42 avatar Feb 29 '24 00:02 rafsun42

Hi @rafsun42,

We're already querying pg_proc to suggest function names:

https://github.com/dbcli/pgcli/blob/9f114c4549c672c64cb5bb5b56f4fce725267fda/pgcli/pgexecute.py#L694

Then pgcompleter has some additional logic on top of that:

https://github.com/dbcli/pgcli/blob/9f114c4549c672c64cb5bb5b56f4fce725267fda/pgcli/pgcompleter.py#L721

It could be and not f.is_extension that trips you up:

https://github.com/dbcli/pgcli/blob/9f114c4549c672c64cb5bb5b56f4fce725267fda/pgcli/pgcompleter.py#L729

Try removing that and see if it helps. I can't tell for sure now, but I think we originally added that clause because some extensions add a huge number of functions, and it becomes cumbersome for the user to scroll through a huge list.

If that resolves your problem, we can probably make it a configuration option.

j-bennet avatar Mar 03 '24 00:03 j-bennet