[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cassandra-commits
Subject:    [jira] [Comment Edited] (CASSANDRA-19150) Align values in rows in CQLSH right for numbers, left for 
From:       "Arun Ganesh (Jira)" <jira () apache ! org>
Date:       2024-03-31 20:50:00
Message-ID: JIRA.13560458.1701689381000.101507.1711918200106 () Atlassian ! JIRA
[Download RAW message or body]


    [ https://issues.apache.org/jira/browse/CASSANDRA-19150?page=com.atlassian.jira.pl \
ugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17832655#comment-17832655 \
] 

Arun Ganesh edited comment on CASSANDRA-19150 at 3/31/24 8:49 PM:
------------------------------------------------------------------

[~bschoeni],

It's a catch-22. To use {{print("\{0:x\}".format(i))}} to align values in the column, \
we should know {{x}}, which should be the length of the longest value in the column \
(either the longest value or the column header). And, you cannot know {{x}} without \
converting them to strings in the first place.

I believe that's why we don't use {{"\{\}".format()}} in cqlsh. Instead, we convert \
all values to strings first (e.g., \
[here|https://github.com/apache/cassandra/blob/trunk/pylib/cqlshlib/formatting.py:251], \
[here|https://github.com/apache/cassandra/blob/trunk/pylib/cqlshlib/formatting.py:331], \
[here|https://github.com/apache/cassandra/blob/trunk/pylib/cqlshlib/formatting.py:349], \
and so on), and later pad it manually to the max-width of each column.


was (Author: JIRAUSER303038):
[~bschoeni],

It's a catch-22. To use {{print("{0:x}".format(i))}} to align values in the column, \
we should know {{x}}, which should be the length of the longest value in the column \
(either the longest value or the column header). And, you cannot know {{x}} without \
converting them to strings in the first place.

I believe that's why we don't use {{"{}".format()}} in cqlsh. Instead, we convert all \
values to strings first (e.g., \
[here|https://github.com/apache/cassandra/blob/trunk/pylib/cqlshlib/formatting.py:251], \
[here|https://github.com/apache/cassandra/blob/trunk/pylib/cqlshlib/formatting.py:331], \
[here|https://github.com/apache/cassandra/blob/trunk/pylib/cqlshlib/formatting.py:349], \
and so on), and later pad it manually to the max-width of each column.

> Align values in rows in CQLSH right for numbers, left for text
> --------------------------------------------------------------
> 
> Key: CASSANDRA-19150
> URL: https://issues.apache.org/jira/browse/CASSANDRA-19150
> Project: Cassandra
> Issue Type: Improvement
> Components: CQL/Interpreter
> Reporter: Stefan Miklosovic
> Assignee: Arun Ganesh
> Priority: Low
> Fix For: 5.x
> 
> Attachments: Screenshot 2023-12-04 at 00.38.16.png, Screenshot 2023-12-09 at \
> 16.58.25.png, signature.asc, test_output.txt, test_output_old.txt 
> Time Spent: 20m
> Remaining Estimate: 0h
> 
> *Updated* Jan 17 2024 after dev discussion
> Change CQLSH to left-align text while continue to right-align numbers.   This will \
>                 match how Postgres shell and Excel treat alignment of text and \
>                 number.
> -------------
> *Original*
> We need to make this
> [https://github.com/apache/cassandra/blob/trunk/pylib/cqlshlib/cqlshmain.py#L1101]
> configurable so values in columns are either all on left or on right side of the \
> column (basically change col.rjust to col.ljust). By default, it would be like it \
> is now but there would be configuration property in cqlsh for that as well as a \
> corresponding CQLSH command (optional), something like {code:java}
> ALIGNMENT LEFT|RIGHT
> {code}
> cc [~bschoeni]



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic