You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Maciej Sokol (Jira)" <ji...@apache.org> on 2023/01/11 06:57:00 UTC

[jira] [Comment Edited] (CASSANDRA-18141) Cqlsh incorrectly formats duration

    [ https://issues.apache.org/jira/browse/CASSANDRA-18141?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17657098#comment-17657098 ] 

Maciej Sokol edited comment on CASSANDRA-18141 at 1/11/23 6:56 AM:
-------------------------------------------------------------------

I think this is related to python version, i.e python2 vs python3.

It seems that division or str() in python3 was changed.

python test:

a = 55

b = 10

print(str(a/b))

 

Running the above example with python 2.7.18:

*5*

Running the above example with python 3.6.9:

*5.5*

The division is used by cqlsh to convert duration to string,

here: https://github.com/apache/cassandra/blob/trunk/pylib/cqlshlib/formatting.py#L409

and here: https://github.com/apache/cassandra/blob/trunk/pylib/cqlshlib/formatting.py#L429


was (Author: JIRAUSER285315):
I think this is related to python version, i.e python2 vs python3.

It seems that division or str() in python3 was changed.

python test:

a = 55

b = 10

print(str(a/b))

 

Running the above example with python 2.7.18:

*5*

Running the above example with python 3.6.9:

*5.5*

> Cqlsh incorrectly formats duration
> ----------------------------------
>
>                 Key: CASSANDRA-18141
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-18141
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Tool/cqlsh
>            Reporter: Maciej Sokol
>            Priority: Normal
>             Fix For: 4.0.x, 4.1.x, 4.x
>
>
> It looks like something broke between C* 3.11 and C* 4.X when it comes to duration types.
> Example:
> CREATE KEYSPACE users WITH replication = \{'class': 'NetworkTopologyStrategy', 'datacenter1': '1'} AND durable_writes = true;
> CREATE TABLE users.user_credentials_by_email (email text,la_duration duration,PRIMARY KEY(email));
> INSERT INTO users.user_credentials_by_email (email, la_duration ) VALUES ( 'test0@test.com', 12h);
> INSERT INTO users.user_credentials_by_email (email, la_duration ) VALUES ( 'test1@test.com', 12h30m);
> INSERT INTO users.user_credentials_by_email (email, la_duration ) VALUES ( 'test2@test.com', 12h30m30s);
> INSERT INTO users.user_credentials_by_email (email, la_duration ) VALUES ( 'test3@test.com', 12h30m30s250ms);
> INSERT INTO users.user_credentials_by_email (email, la_duration ) VALUES ( 'test4@test.com', PT12H30M);
> 3.11:
> cassandra@cqlsh> SHOW VERSION ;
> [cqlsh 5.0.1 | Cassandra 3.11.15-SNAPSHOT | CQL spec 3.4.4 | Native protocol v4]
> cassandra@cqlsh> SELECT * FROM users.user_credentials_by_email ;
>  email          | la_duration
> ----------------+----------------
>  test0@test.com |            12h
>  test3@test.com | 12h30m30s250ms
>  test4@test.com |         12h30m
>  test1@test.com |         12h30m
>  test2@test.com |      12h30m30s
> (5 rows)
> 4.X:
> cassandra@cqlsh> SHOW VERSION ;
> [cqlsh 6.0.0 | Cassandra 4.0.8-SNAPSHOT | CQL spec 3.4.5 | Native protocol v5]
> cassandra@cqlsh> SELECT * FROM users.user_credentials_by_email ;
>  email          | la_duration
> ----------------+-----------------------------------------------------
>  test0@test.com |                                               12.0h
>  test3@test.com | 12.508402777777778h30.504166666666666m30.25s250.0ms
>  test4@test.com |                                          12.5h30.0m
>  test1@test.com |                                          12.5h30.0m
>  test2@test.com |                       12.508333333333333h30.5m30.0s
> (5 rows)



--
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