[jira] [Comment Edited] (CASSANDRA-19150) Align values in rows in CQLSH right for numbers, left for text
[ https://issues.apache.org/jira/browse/CASSANDRA-19150?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17833950#comment-17833950 ] Brad Schoening edited comment on CASSANDRA-19150 at 6/3/24 12:06 PM: - [~arkn98] Ok, I see your point. Reviewing the code and you're question #1, I wonder if it would be tidier to consolidate the formatting into a map like DEFAULT_VALUE_COLORS which maps types to color formats. This could be generalized to a multi-value map for types -> ( color, alignment). For example: {code:java} TYPE_FORMATS = { 'default': (YELLOW, 'left'), 'text': (YELLOW, 'left'), 'int': (GREEN, 'right')} color, algn = TYPE_FORMATS['int']{code} Since Python uses strings 'right' and 'left' in formatting, it might be more consistent to use raw strings here instead of an enum. #2 align by the type of the field sounds right. I checked psql and it simply displays nulls as blanks. #3 If default is normally left, user types and collections should probably be left. #4 how many tests are broken by this change? was (Author: bschoeni): [~arkn98] Ok, I see your point. Reviewing the code and you're question #1, I wonder if it would be tidier to consolidate the formatting into a map like DEFAULT_VALUE_COLORS which maps types to color formats. This could be generalized to a multi-value map for types -> ( color, alignment). For example: {code:java} TYPE_FORMATS = { 'default': (YELLOW, 'left'), 'text': (YELLOW, 'left'), 'int': (GREEN, 'right')} color, algn = TYPE_FORMATS['int']{code} Since Python uses 'right' and 'left', it might be more consistent to use raw strings here instead of an enum. #2 align by the type of the field sounds right. I checked psql and it simply displays nulls as blanks. #3 If default is normally left, user types and collections should probably be left. #4 how many tests are broken by this change? > 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-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Comment Edited] (CASSANDRA-19150) Align values in rows in CQLSH right for numbers, left for text
[ https://issues.apache.org/jira/browse/CASSANDRA-19150?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17833950#comment-17833950 ] Brad Schoening edited comment on CASSANDRA-19150 at 4/5/24 3:15 PM: [~arkn98] Ok, I see your point. Reviewing the code and you're question #1, I wonder if it would be tidier to consolidate the formatting into a map like DEFAULT_VALUE_COLORS which maps types to color formats. This could be generalized to a multi-value map for types -> ( color, alignment). For example: {code:java} TYPE_FORMATS = { 'default': (YELLOW, 'left'), 'text': (YELLOW, 'left'), 'int': (GREEN, 'right')} color, algn = TYPE_FORMATS['int']{code} Since Python uses 'right' and 'left', it might be more consistent to use raw strings here instead of an enum. #2 align by the type of the field sounds right. I checked psql and it simply displays nulls as blanks. #3 If default is normally left, user types and collections should probably be left. #4 how many tests are broken by this change? was (Author: bschoeni): [~arkn98] Ok, I see your point. Reviewing the code and you're question #1, I wonder if it would be tidier to consolidate the formatting into a map like DEFAULT_VALUE_COLORS which maps types to color formats. This could be generalized to a multi-value map for types -> ( color, alignment). For example: {code:java} TYPE_FORMATS = { 'default': (YELLOW, 'left'), 'text': (YELLOW, 'left'), 'int': (GREEN, 'right')} color, algn = TYPE_FORMATS['int']{code} Since Python uses 'right' and 'left', it might be more consistent to use raw strings here instead of an enum. #2 align by the type of the field sounds right #3 if default is normally left, user types and collections should probably be left For #2 and #3 it would be useful to see how psql treats these. #4 how many tests are broken by this change? > 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-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Comment Edited] (CASSANDRA-19150) Align values in rows in CQLSH right for numbers, left for text
[ https://issues.apache.org/jira/browse/CASSANDRA-19150?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17833950#comment-17833950 ] Brad Schoening edited comment on CASSANDRA-19150 at 4/5/24 2:51 PM: [~arkn98] Ok, I see your point. Reviewing the code and you're question #1, I wonder if it would be tidier to consolidate the formatting into a map like DEFAULT_VALUE_COLORS which maps types to color formats. This could be generalized to a multi-value map for types -> ( color, alignment). For example: {code:java} TYPE_FORMATS = { 'default': (YELLOW, 'left'), 'text': (YELLOW, 'left'), 'int': (GREEN, 'right')} color, algn = TYPE_FORMATS['int']{code} Since Python uses 'right' and 'left', it might be more consistent to use raw strings here instead of an enum. #2 align by the type of the field sounds right #3 if default is normally left, user types and collections should probably be left For #2 and #3 it would be useful to see how psql treats these. #4 how many tests are broken by this change? was (Author: bschoeni): [~arkn98] Ok, I see your point. Reviewing the code and you're question #1, I wonder if it would be tidier to consolidate the formatting into a map like DEFAULT_VALUE_COLORS which maps types to color formats. This could be generalized to a multi-value map for types -> ( color, alignment). For example: {code:java} TYPE_FORMATS = { 'default': (YELLOW, 'left'), 'text': (YELLOW, 'left'), 'int': (GREEN, 'right')} color, algn = TYPE_FORMATS['int']{code} Since Python uses 'right' and 'left', it might be more consistent to use raw strings here instead of an enum. > 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-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Comment Edited] (CASSANDRA-19150) Align values in rows in CQLSH right for numbers, left for text
[ https://issues.apache.org/jira/browse/CASSANDRA-19150?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17833950#comment-17833950 ] Brad Schoening edited comment on CASSANDRA-19150 at 4/5/24 3:15 AM: [~arkn98] Ok, I see your point. Reviewing the code and you're question #1, I wonder if it would be tidier to consolidate the formatting into a map like DEFAULT_VALUE_COLORS which maps types to color formats. This could be generalized to a multi-value map for types -> ( color, alignment). For example: {code:java} TYPE_FORMATS = { 'default': (YELLOW, 'left'), 'text': (YELLOW, 'left'), 'int': (GREEN, 'right')} color, algn = TYPE_FORMATS['int']{code} Since Python uses 'right' and 'left', it might be more consistent to use raw strings here instead of an enum. was (Author: bschoeni): [~arkn98] Ok, I see your point. Reviewing the code, I wonder if it would be tidier to consolidate the formatting into a map like DEFAULT_VALUE_COLORS which maps types to color formats. This could be generalized to a multi-value map for types -> ( color, alignment). For example: {code:java} TYPE_FORMATS = { 'default': (YELLOW, 'left'), 'text': (YELLOW, 'left'), 'int': (GREEN, 'right')} color, algn = TYPE_FORMATS['int']{code} Since Python uses 'right' and 'left', it might be more consistent to use raw strings here instead of an enum. > 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-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Comment Edited] (CASSANDRA-19150) Align values in rows in CQLSH right for numbers, left for text
[ https://issues.apache.org/jira/browse/CASSANDRA-19150?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17833950#comment-17833950 ] Brad Schoening edited comment on CASSANDRA-19150 at 4/5/24 2:32 AM: [~arkn98] Ok, I see your point. Reviewing the code, I wonder if it would be tidier to consolidate the formatting into a map like DEFAULT_VALUE_COLORS which maps types to color formats. This could be generalized to a multi-value map for types -> ( color, alignment). For example: {code:java} TYPE_FORMATS = { 'default': (YELLOW, 'left'), 'text': (YELLOW, 'left'), 'int': (GREEN, 'right')} color, algn = TYPE_FORMATS['int']{code} Since Python uses 'right' and 'left', it might be more consistent to use raw strings here instead of an enum. was (Author: bschoeni): [~arkn98] Ok, I see your point. Reviewing the code, I wonder if it would be tidier to consolidate the formatting into a map like DEFAULT_VALUE_COLORS which maps types to color formats. This could be generalized to a multi-value map for types -> ( color, alignment). For example: {code:java} TYPE_FORMATS = { 'default': (YELLOW, LEFT), 'text': (YELLOW, LEFT), 'int': (GREEN, RIGHT)} color, algn = TYPE_FORMATS['int']{code} Since Python uses 'right' and 'left', it might be more consistent to use raw strings here instead of an enum. > 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-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Comment Edited] (CASSANDRA-19150) Align values in rows in CQLSH right for numbers, left for text
[ https://issues.apache.org/jira/browse/CASSANDRA-19150?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17833950#comment-17833950 ] Brad Schoening edited comment on CASSANDRA-19150 at 4/4/24 2:41 PM: [~arkn98] Ok, I see your point. Reviewing the code, I wonder if it would be tidier to consolidate the formatting into a map like DEFAULT_VALUE_COLORS which maps types to color formats. This could be generalized to a multi-value map for types -> ( color, alignment). For example: {code:java} TYPE_FORMATS = { 'default': (YELLOW, LEFT), 'text': (YELLOW, LEFT), 'int': (GREEN, RIGHT)} color, algn = TYPE_FORMATS['int']{code} Since Python uses 'right' and 'left', it might be more consistent to use raw strings here instead of an enum. was (Author: bschoeni): [~arkn98] Ok, I see your point. Reviewing the code, I wonder if it would be tidier to consolidate the formatting into a map like DEFAULT_VALUE_COLORS which maps types to color formats. This could be generalized to a multi-value map for types -> ( color, alignment). For example: {code:java} TYPE_FORMATS = { 'default': (YELLOW, LEFT), 'text': (YELLOW, LEFT), 'int': (GREEN, RIGHT)} color, algn = TYPE_FORMATS['int']{code} > 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-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Comment Edited] (CASSANDRA-19150) Align values in rows in CQLSH right for numbers, left for text
[ https://issues.apache.org/jira/browse/CASSANDRA-19150?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17833950#comment-17833950 ] Brad Schoening edited comment on CASSANDRA-19150 at 4/4/24 2:39 PM: [~arkn98] Ok, I see your point. Reviewing the code, I wonder if it would be tidier to consolidate the formatting into a map like DEFAULT_VALUE_COLORS which maps types to color formats. This could be generalized to a multi-value map for types -> ( color, alignment). For example: {code:java} TYPE_FORMATS = { 'default': (YELLOW, LEFT), 'text': (YELLOW, LEFT), 'int': (GREEN, RIGHT)} color, algn = TYPE_FORMATS['int']{code} was (Author: bschoeni): [~arkn98] Ok, I see your point. Reviewing the code, I wonder if it would be tidier to consolidate the formatting into a map like DEFAULT_VALUE_COLORS which maps types to color formats. This could be generalized to a multi-value map for types -> ( color, alignment). For example: {code:java} TYPE_FORMATS = { 'default': (YELLOW, LEFT), 'text': (YELLOW, LEFT), 'int': (GREEN, RIGHT)} color, algn = TYPE_FORMATS['int']{code} > 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-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Comment Edited] (CASSANDRA-19150) Align values in rows in CQLSH right for numbers, left for text
[ https://issues.apache.org/jira/browse/CASSANDRA-19150?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17832655#comment-17832655 ] Arun Ganesh edited comment on CASSANDRA-19150 at 4/3/24 12:19 PM: -- [~bschoeni], By the time we get to calling the {{ljust\(\)}} or {{rjust\(\)}} at https://github.com/apache/cassandra/blob/trunk/pylib/cqlshlib/cqlshmain.py#L1025, all the values are converted to strings (e.g., [here|https://github.com/apache/cassandra/blob/trunk/pylib/cqlshlib/formatting.py#L251], [here|https://github.com/apache/cassandra/blob/trunk/pylib/cqlshlib/formatting.py#L331], [here|https://github.com/apache/cassandra/blob/trunk/pylib/cqlshlib/formatting.py#L349], and so on). was (Author: JIRAUSER303038): [~bschoeni], By the time we get to calling the {{ljust\(\)}} or {{rjust\(\)}} at https://github.com/apache/cassandra/blob/trunk/pylib/cqlshlib/cqlshmain.py#L1025, all the values are converted to strings (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). > 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-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Comment Edited] (CASSANDRA-19150) Align values in rows in CQLSH right for numbers, left for text
[ https://issues.apache.org/jira/browse/CASSANDRA-19150?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17832655#comment-17832655 ] Arun Ganesh edited comment on CASSANDRA-19150 at 4/2/24 1:08 AM: - [~bschoeni], By the time we get to calling the {{ljust\(\)}} or {{rjust\(\)}} at https://github.com/apache/cassandra/blob/trunk/pylib/cqlshlib/cqlshmain.py#L1025, all the values are converted to strings (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). 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 all values in the column to strings in the first place. I believe that's why we don't use {{"\{\}".format\(\)}} in cqlsh. We can do it, but it would make the code complex. 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-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Comment Edited] (CASSANDRA-19150) Align values in rows in CQLSH right for numbers, left for text
[ https://issues.apache.org/jira/browse/CASSANDRA-19150?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17832655#comment-17832655 ] Arun Ganesh edited comment on CASSANDRA-19150 at 3/31/24 9:21 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 all values in the column to strings in the first place. I believe that's why we don't use {{"\{\}".format\(\)}} in cqlsh. We can do it, but it would make the code complex. 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 all values in the column 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-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Comment Edited] (CASSANDRA-19150) Align values in rows in CQLSH right for numbers, left for text
[ https://issues.apache.org/jira/browse/CASSANDRA-19150?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17832655#comment-17832655 ] Arun Ganesh edited comment on CASSANDRA-19150 at 3/31/24 9:18 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 all values in the column 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-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Comment Edited] (CASSANDRA-19150) Align values in rows in CQLSH right for numbers, left for text
[ https://issues.apache.org/jira/browse/CASSANDRA-19150?page=com.atlassian.jira.plugin.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-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Comment Edited] (CASSANDRA-19150) Align values in rows in CQLSH right for numbers, left for text
[ https://issues.apache.org/jira/browse/CASSANDRA-19150?page=com.atlassian.jira.plugin.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-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Comment Edited] (CASSANDRA-19150) Align values in rows in CQLSH right for numbers, left for text
[ https://issues.apache.org/jira/browse/CASSANDRA-19150?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17832601#comment-17832601 ] Brad Schoening edited comment on CASSANDRA-19150 at 3/31/24 5:39 PM: - [~arkn98] in reviewing your questions, I came across [PEP 3101|https://peps.python.org/pep-3101/#standard-format-specifiers] which introduces new alignment specifiers: * '<' - Forces the field to be left-aligned within the available space (This is the default.) * '>' - Forces the field to be right-aligned within the available space. when I ran this test Python seems to default to right align numbers and left align text. Are we overriding this unnecessarily? {code:java} for i in (1,'x',0.0): print("{0:5}".format(i)) 1 x 0.0 {code} was (Author: bschoeni): [~arkn98] in reviewing your questions, I came across [PEP 3101|https://peps.python.org/pep-3101/#standard-format-specifiers] which introduces new alignment specifiers: * '<' - Forces the field to be left-aligned within the available space (This is the default.) * '>' - Forces the field to be right-aligned within the available space. when I ran this test it seems to default to right align numbers and left align text. {code:java} for i in (1,'x',0.0): print("{0:5}".format(i)) 1 x 0.0 {code} > 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-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Comment Edited] (CASSANDRA-19150) Align values in rows in CQLSH right for numbers, left for text
[ https://issues.apache.org/jira/browse/CASSANDRA-19150?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17832516#comment-17832516 ] Arun Ganesh edited comment on CASSANDRA-19150 at 3/31/24 3:37 AM: -- [~bschoeni] [~smiklosovic] Sorry for the delay again. See [^test_output_old.txt] and [^test_output.txt] for the before and after. These are some things I'd like to discuss before I write/fix the tests: 1. Does the [design|https://github.com/apache/cassandra/pull/3182/files] look okay? Or, should I use a map-lookup to get type->alignment values? 2. Should nulls be treated separately (like all null values align left), or should they be treated according to the type of the field (like nulls in vectors align right, nulls in maps align left, etc.)? 3. How should I align user-types and collections: left or right? I chose right because we were aligning everything to the right before. 4. Breaking all tests that depend on cqlsh, including downstream apps, doesn't seem like a great thing to do. Also, C* devs should not be burdened with type-alignment when they write tests---there should be a way to turn type-based alignment on/off. I suggest that we also introduce the `ALIGNMENT` command from the original description of this ticket. It can have `LEFT|RIGHT|DEFAULT` options. `DEFAULT` will align the output based on the types. 5. Should I document the alignment for the different types somewhere? was (Author: JIRAUSER303038): [~bschoeni] [~smiklosovic] Sorry for the delay again. See [^test_output_old.txt] and [^test_output.txt] for the before and after. These are some things I'd like to discuss before I write/fix the tests: 1. Does the design look okay? Or, should I use a map-lookup to get type->alignment values? 2. Should nulls be treated separately (like all null values align left), or should they be treated according to the type of the field (like nulls in vectors align right, nulls in maps align left, etc.)? 3. How should I align user-types and collections: left or right? I chose right because we were aligning everything to the right before. 4. Breaking all tests that depend on cqlsh, including downstream apps, doesn't seem like a great thing to do. Also, C* devs should not be burdened with type-alignment when they write tests---there should be a way to turn type-based alignment on/off. I suggest that we also introduce the `ALIGNMENT` command from the original description of this ticket. It can have `LEFT|RIGHT|DEFAULT` options. `DEFAULT` will align the output based on the types. 5. Should I document the alignment for the different types somewhere? > 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-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Comment Edited] (CASSANDRA-19150) Align values in rows in CQLSH right for numbers, left for text
[ https://issues.apache.org/jira/browse/CASSANDRA-19150?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17827951#comment-17827951 ] Arun Ganesh edited comment on CASSANDRA-19150 at 3/18/24 12:33 PM: --- Additionally, # I noticed some deadcode. There are multiple places with code like this, {code:java} return bval if colormap is NO_COLOR_MAP else ... {code} When the {{--no-color}} flag is passed, or the tty is "dumb", we do this {code:python} if addcolor is False: colormap = empty_colormap {code} where {{{}empty_colormap = defaultdict(lambda: ''){}}}. The {{NO_COLOR_MAP}} is just a plain {{{}dict(){}}}. {{colormap is NO_COLOR_MAP}} will always be {{{}False{}}}. {code:python} $ python3 Python 3.8.18 (default, Dec 16 2023, 04:10:16) >>> from collections import defaultdict >>> a = defaultdict(lambda: '') >>> b = dict() >>> a is b False{code} # I found two formatter functions for the `duration` type. Is there a difference between `Duration` and `duration`? {code:python} formatter_for('duration')(format_integer_type) . . . @formatter_for('Duration') def format_value_duration(val, colormap, **_): return format_python_formatted_type(duration_as_str(val.months, val.days, val.nanoseconds), colormap, 'duration'){code} The second one is picked up always. was (Author: JIRAUSER303038): Additionally, # I noticed some deadcode. There are multiple places with code like this, {code:java} return bval if colormap is NO_COLOR_MAP else ... {code} When the {{--no-color}} flag is passed, or the tty is "dumb", we do this {code:python} if addcolor is False: colormap = empty_colormap {code} where {{{}empty_colormap = defaultdict(lambda: ''){}}}. The {{NO_COLOR_MAP}} is just a plain {{{}dict(){}}}. {{colormap is NO_COLOR_MAP}} will always be {{{}False{}}}. {code:python} $ python3 Python 3.8.18 (default, Dec 16 2023, 04:10:16) >>> from collections import defaultdict >>> a = defaultdict(lambda: '') >>> b = dict() >>> a is b False{code} # I found two formatter functions for the `duration` type. Is there a difference between `Duration` and `duration`? {code:python} formatter_for('duration')(format_integer_type) . . . @formatter_for('Duration') def format_value_duration(val, colormap, **_): return format_python_formatted_type(duration_as_str(val.months, val.days, val.nanoseconds), colormap, 'duration'){code} The second one is picked up always. > 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 > > 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-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Comment Edited] (CASSANDRA-19150) Align values in rows in CQLSH right for numbers, left for text
[ https://issues.apache.org/jira/browse/CASSANDRA-19150?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17827947#comment-17827947 ] Arun Ganesh edited comment on CASSANDRA-19150 at 3/18/24 12:13 PM: --- Sorry, I took a while to get back to this. I have a [draft PR|https://github.com/apache/cassandra/pull/3182] ready. I have two items to discuss: # I'd like some feedback on the design. The formatter for each type will request whatever alignment it wants like this, (I'm yet to do this on the PR) {code:java} return FormattedValue(val, coloredval, displaywidth, alignment=Alignment.LEFT){code} # I'm planning to use the following left/right alignment for the different types (inspired from psql). |*Type*|*Alignment*| |default|right| |blob/bytearray|left| |decimal|right| |uuid/timeuuid|left| |inet|left| |bool|left| |float/double|right| |text/unicode/ascii|left| |set/list/map|right| |user types|right| When the expand mode is enabled, everything is aligned to the left, just like in psql. was (Author: JIRAUSER303038): Sorry, I took a while to get back to this. I have a [draft PR|https://github.com/apache/cassandra/pull/3182] ready. I have two items to discuss: # I'd like some feedback on the design. The formatter for each type will request whatever alignment it wants like this, (I'm yet to do this on the PR) {code:java} return FormattedValue(val, coloredval, displaywidth, alignment=Alignment.LEFT){code} # I'm planning to use the following left/right alignment for the different types (inspired from psql). |*Type*|*Alignment*| |default|right| |blob/bytearray|left| |decimal|right| |uuid/timeuuid|left| |inet|left| |bool|left| |float/double|right| |text/unicode/ascii|left| |set/list/map|right| |user types|right| When the expand mode is enabled, everything is aligned to the left, just like in psql. > 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 > > 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-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Comment Edited] (CASSANDRA-19150) Align values in rows in CQLSH right for numbers, left for text
[ https://issues.apache.org/jira/browse/CASSANDRA-19150?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17827947#comment-17827947 ] Arun Ganesh edited comment on CASSANDRA-19150 at 3/18/24 12:13 PM: --- Sorry, I took a while to get back to this. I have a [draft PR|https://github.com/apache/cassandra/pull/3182] ready. I have two items to discuss: # I'd like some feedback on the design. The formatter for each type will request whatever alignment it wants like this, (I'm yet to do this on the PR) {code:java} return FormattedValue(val, coloredval, displaywidth, alignment=Alignment.LEFT){code} # I'm planning to use the following left/right alignment for the different types (inspired from psql). |*Type*|*Alignment*| |default|right| |blob/bytearray|left| |decimal|right| |uuid/timeuuid|left| |inet|left| |bool|left| |float/double|right| |text/unicode/ascii|left| |set/list/map|right| |user types|right| When the expand mode is enabled, everything is aligned to the left, just like in psql. was (Author: JIRAUSER303038): Sorry, I took a while to get back to this. I have a draft PR ready. I have two items to discuss: # I'd like some feedback on the design. The formatter for each type will request whatever alignment it wants like this, (I'm yet to do this on the PR) {code:java} return FormattedValue(val, coloredval, displaywidth, alignment=Alignment.LEFT){code} # I'm planning to use the following left/right alignment for the different types (inspired from psql). |*Type*|*Alignment*| |default|right| |blob/bytearray|left| |decimal|right| |uuid/timeuuid|left| |inet|left| |bool|left| |float/double|right| |text/unicode/ascii|left| |set/list/map|right| |user types|right| When the expand mode is enabled, everything is aligned to the left, just like in psql. > 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 > > 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-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org