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

implement built-in cli client #2596

Open
waynexia opened this issue Oct 12, 2023 · 4 comments
Open

implement built-in cli client #2596

waynexia opened this issue Oct 12, 2023 · 4 comments
Labels
C-feature Category Features help wanted Extra attention is needed

Comments

@waynexia
Copy link
Member

What problem does the new feature solve?

Implement a simple native cli client like psql or mysql.

What does the feature do?

Extend the greptime cli subcommand. Implement greptime cli client. It can connect to frontend and read/send SQL interactively via gRPC. Or read and execute a *.sql file.

Implementation challenges

No response

@waynexia waynexia added C-feature Category Features help wanted Extra attention is needed labels Oct 12, 2023
@Lilit0x
Copy link
Contributor

Lilit0x commented Oct 12, 2023

Hi @waynexia , I am interested in working on this, but I'll like some clarifications.

  • How is this different from --attach? Because I see it commented out in the code here
  • The repl.rs file does the heavy lifting of parsing the texts and lines and I can also see that there is a USE DATABASE command. Should this also be part of this new client?

Those are the question I have for now, I will add more as I continue to go through the code.
Thanks

@waynexia
Copy link
Member Author

Hi @Lilit0x!

How is this different from --attach? Because I see it commented out in the code here

--attach is primarily for connecting to "datanode" and for debug purposes. While this one is only a gRPC client, and can only connect to one "frontend" (in case you need, this doc explains what datanode and frontend are). This cli client is mainly for two things:

  • Provide a built-in, simple client with the binary greptime, so we don't need another client (like psql or mysql) for some simple operations.
  • Provide an interactive interface for our SQL dialect. It's slightly different from pg and MySQL.

The repl.rs file does the heavy lifting of parsing the texts and lines and I can also see that there is a USE DATABASE command. Should this also be part of this new client?

We don't need to do this, at least for now. At this stage, this client only needs to support some fundamental functionalities. Others like switching database or client-side states are not on the list.

For setting up database, you can take cli export as an example. It accept --database from cli arg, and parses it to catalog and schema.

@Lilit0x
Copy link
Contributor

Lilit0x commented Oct 20, 2023

Thanks for expatiating, it should be pretty easy. Below is a rough outline of how I'll implement it.

  • Basic arguments:

    • host
    • port
    • database
    • user(this will come in the second stage after basic implementation)
    • file(sql file to run. this will also come after basic implementation)
  • Initiate a Client by combining the host and port into an address (since we're using psql as a model is why I separate the host and port as different args) and create a QueryEngine.

  • Pass these to an instance of the Repl struct.

  • Lastly, displaying the results.

@waynexia
Copy link
Member Author

Looks good. If the input file is not provided we should start an interactive prompt interface like before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature Category Features help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants