GithubHelp home page GithubHelp logo

Comments (13)

kenshaw avatar kenshaw commented on May 26, 2024

There's already the \crosstab functionality, you'd be able to implement another different *View in the tblfmt package easily to support this. I don't think it'd be quite difficult, and I'd support a well implemented version. Sorting on the client wouldn't be difficult. In terms "pager" functionality, though, I'm not sure if you mean not using the system's less / more, or what though.

from usql.

kenshaw avatar kenshaw commented on May 26, 2024

Also, if you're just looking for certain ways to find data, off-the-cuff, one can easily do this by piping usql output to tools like sed, awk, perl, ...

from usql.

0-issue avatar 0-issue commented on May 26, 2024

@kenshaw Here's a 14 second screencast that shows US Census projections for 2019 preloaded in a table. In the screencast, I do the following steps:

  1. run a simple PostgreSQL command table <table_name>; to view the table. It loads it in pspg which provides limited sort capability.
  2. then I select the state column, and sort it in descending order by pressing d. All data for Wyoming shows up on top, but the count_names are yet unsorted.
  3. finally I select the county column, and try to sort it ascending order by pressing a. But that sorts the counties across states, as pspg doesn't have a feature (for reasons mentioned above) to do multi-column sort.

Not sure how else would a table viewer support multi-column sort with such simple keybindings without also folding the functionality of pager within its state. Like how would usql know which column has been selected by the user with a mouse click or key navigation? Perhaps a specialized pager like pspg can communicate with usql using some IPC mechanism?

multi-column.mp4

from usql.

kenshaw avatar kenshaw commented on May 26, 2024

Yes, I 100% understood what you meant. Is there a reason you don't just do this directly with your SQL query?

from usql.

0-issue avatar 0-issue commented on May 26, 2024

The reason to not do this with SQL query is more of a UI question. If a user is already looking at a table, pressing a key to sort and unsort can show them in-place how the data changes. Also, another obvious reason would be speed: in my original request for such a feature in pspg, I asked if one can sequentially apply such sort operations and undo them too with simple keystrokes a, d, u, arrow keys. Btw, I updated my last comment with a suggestion for a IPC channel between pspg and usql. Perhaps pspg can exchange command information with usql on a socket to run queries on behalf of user, that way usql wouldn't have to reimplement pspg's functionality, and pspg wouldn't have to reimplement usql's functionality. @okbob

from usql.

kenshaw avatar kenshaw commented on May 26, 2024

I understand your ask, there are reasons this isn't done currently in psql, which is: this isn't how psql was designed to be used. You could hypothetically be retrieving millions, or hundreds of millions of records at a time. Keeping that data on the client side, to allow for easy reordering, would be problematic. In my opinion, humble as it is, the way psql and usql are made to be used is to easily and quickly do small queries at a time, or design "big queries" that are part of larger reporting systems. I can only speak for myself, and note: I'm open to enabling usql to help others how they see best, but for what you're describing, I personally would be doing all of that from SQL directly.

from usql.

okbob avatar okbob commented on May 26, 2024

from usql.

0-issue avatar 0-issue commented on May 26, 2024

@kenshaw

You could hypothetically be retrieving millions, or hundreds of millions of records at a time. Keeping that data on the client side, to allow for easy reordering, would be problematic.

I agree, but that's not what I was thinking... Data will remain on server side, and won't be reordered on client side. usql would update the query on request of pspg each time user request a sort. usql already knows what table a user is currently viewing, it does not need to send the data regarding SQL query and data types to pspg (@okbob). pspg would send a note to usql with a list of tuples containing column numbers and sort direction. As a response, usql would send a new (modified) query to the server, and notify pspg to repage its input. pspg just needs to send a list of tuples that have column numbers and direction IMO.

from usql.

okbob avatar okbob commented on May 26, 2024

from usql.

0-issue avatar 0-issue commented on May 26, 2024

We can avoid query parsing if it is a special command like (pick a better name perhaps): table_interactive <table_name> instead of table <table_name>. Then the command sent to the SQL server can be made by just appending order by <column-a> arc, <column-b> desc, ... to basic table <table_name> command. Though idk if there is a better option...

from usql.

okbob avatar okbob commented on May 26, 2024

from usql.

0-issue avatar 0-issue commented on May 26, 2024

Maybe it is, idk. In my understanding and time with IPC mechanisms like sockets to act as command channels between processes, they can enrich existing CLI tools to avoid code and effort duplication. You already have great working pager pspg that currently has 1-way data channel (pipe) IPC mechanism, if it has an option --socket to have a command channel (socket) then a modern sql shell like usql need not reimplement table features of pspg.

from usql.

okbob avatar okbob commented on May 26, 2024

from usql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.