tarantool / tarantool/tarantool

Reformat queries, choose output format

Open
#6,387 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature sql
Dominant language
Lua
Stars
3.7k
Forks
419
Avg merge
1d 23h
Merged PRs (30d)
88

Description

Is your feature request related to a problem? Please describe.

Tarantool client using weird format that not easily readable (unlike clickhouse/mysql/postgre) that the tables are formatted properly:

SELECT
    name,
    type,
    position
FROM system.columns
WHERE table = 'matchLogs'

Query id: c91d976e-f22f-48d8-b39b-d2c2e4cf9159

┌─name──────┬─type─────┬─position─┐
│ createdAt │ DateTime │        1 │
│ playerId  │ UInt64   │        2 │
│ matchId   │ UInt64   │        3 │
│ resultAt  │ DateTime │        4 │
│ expGain   │ UInt64   │        5 │
│ bpGain    │ UInt64   │        6 │
│ winCount  │ Int8     │        7 │
│ loseCount │ Int8     │        8 │
└───────────┴──────────┴──────────┘

8 rows in set. Elapsed: 0.003 sec. 

while in tarantool:

box.space.skins:select()
---
- - [87437979299086337, 'test', 1629817441, 1, 1629817441, 1, 0, 0, false, 0, 0, 0,
    0, 0, 0, 0, 0, 0, '1234', '', '', '', '', '', '', '', '', false]
  - [87441140395016193, 'test', 1629818177, 1, 1629818177, 1, 0, 0, false, 0, 0, 0,
    0, 0, 0, 0, 0, 0, '', '', '', '', '', '', '', '', '', false]
  - [87585683224395777, '0W8O1r~-----0~0 updated', 1629851831, 1, 1629851831, 1, 0,
    0, false, 0, 0, 0, 0, 0, 0, 101, 121, 0, '1234567890', '', '', '', '', '', '',
    '', '', false]

box.execute [[ SELECT "id", "name" FROM "skins" ]]
---
- metadata:
  - name: id
    type: unsigned
  - name: name
    type: string
  rows:
  - [87437979299086337, 'test']
  - [87441140395016193, 'test']
  - [87585683224395777, '0W8O1r~-----0~0 updated']

Describe the solution you'd like

Solution I like is to be like ClickHouse, where the queries are reformatted, and results are reformatted properly for easy readability, either for user, or for easy copy pasting for box.space.bla:insert

Describe alternatives you've considered

for example in MySQL we can:
SELECT * FROM bla\G --> this will format instead of tables, it would show key value list

SELECT * FROM help_keyword LIMIT 3\G
*************************** 1. row ***************************
help_keyword_id: 0
           name: JOIN
*************************** 2. row ***************************
help_keyword_id: 1
           name: REPEAT
*************************** 3. row ***************************
help_keyword_id: 2
           name: SERIALIZABLE
3 rows in set (0.00 sec)

or in PostgreSQL: https://stackoverflow.com/questions/9604723/alternate-output-format-for-psql

Additional context

console = require('console');
console.set_default_output('lua');
console.set_default_output('yaml');

both are not helpful

Definition of Done

  1. queries reformatted for easier readability
  2. can customize output format (tabular, key-value, lua-insert-format)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the box.space.skins:select() and box.execute examples in the Tarantool console, including the existing console.set_default_output options. Trace how query input and result output are currently presented, then define the supported tabular, key-value, and Lua-insert formats; done means readable query formatting and selectable output formats matching the Definition of Done.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua, sql
Domain
cli, databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.