[ 
https://issues.apache.org/jira/browse/CASSANDRA-18879?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Arun Ganesh updated CASSANDRA-18879:
------------------------------------
    Test and Documentation Plan: 
Tested it manually.

My timezone is US/Eastern. You can see the tracing output showing the time 
({{{}2024-01-16 16:18:43.599000-05:00{}}}) in my timezone and the table 
containing the time in UTC ({{{}2024-01-16 21:18:43.599000+0000{}}}).

(See attached log file)

  was:
Tested it manually.

My timezone is US/Eastern. You can see the tracing output showing the time 
({{{}2024-01-16 16:18:43.599000-05:00{}}}) in my timezone and the table 
containing the time in UTC ({{{}2024-01-16 21:18:43.599000+0000{}}}).

 
{code:java}
~/code/cassandra $ ./bin/cqlsh
Connected to Test Cluster at 127.0.0.1:9042
[cqlsh 6.2.0 | Cassandra 5.1-SNAPSHOT | CQL spec 3.4.7 | Native protocol v5]
Use HELP for help.
cqlsh> tracing on;
TRACING set to ON
cqlsh> CREATE KEYSPACE IF NOT EXISTS cycling
   ... WITH REPLICATION = {
   ...   'class' : 'SimpleStrategy',
   ...   'replication_factor' : 1
   ... };

Tracing session: d3d293d0-b4b4-11ee-8d07-296dcee8db28 activity                  
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                      | timestamp                        | source    | 
source_elapsed | client
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+-----------+----------------+-----------
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                              Execute CQL3 query | 2024-01-16 
16:18:43.599000-05:00 | 127.0.0.1 |              0 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                Parsing CREATE KEYSPACE IF NOT 
EXISTS cycling\nWITH REPLICATION = {\n  'class' : 'SimpleStrategy',\n  
'replication_factor' : 1\n}; [Native-Transport-Requests-1] | 2024-01-16 
16:18:43.606000-05:00 | 127.0.0.1 |           7582 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                               
Preparing statement [Native-Transport-Requests-1] | 2024-01-16 
16:18:43.607000-05:00 | 127.0.0.1 |           8513 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                      Reading existing values 
for CAS precondition [Native-Transport-Requests-1] | 2024-01-16 
16:18:43.644000-05:00 | 127.0.0.1 |          45793 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                          Preparing 
d3daaa22-b4b4-11ee-f973-04984c4fa9cd with read [Native-Transport-Requests-1] | 
2024-01-16 16:18:43.651000-05:00 | 127.0.0.1 |          52094 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                     Executing 
single-partition query on paxos [MutationStage-2] | 2024-01-16 
16:18:43.660000-05:00 | 127.0.0.1 |          61881 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
  Acquiring sstable references [MutationStage-2] | 2024-01-16 
16:18:43.661000-05:00 | 127.0.0.1 |          62113 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
     Merging memtable contents [MutationStage-2] | 2024-01-16 
16:18:43.661001-05:00 | 127.0.0.1 |          62168 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                        Read 0 
live rows and 0 tombstone cells [MutationStage-2] | 2024-01-16 
16:18:43.661002-05:00 | 127.0.0.1 |          62383 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                              Promising read/write ballot 
d3daaa22-b4b4-11ee-f973-04984c4fa9cd [MutationStage-2] | 2024-01-16 
16:18:43.661003-05:00 | 127.0.0.1 |          63000 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
        Appending to commitlog [MutationStage-2] | 2024-01-16 
16:18:43.662000-05:00 | 127.0.0.1 |          63686 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
      Adding to paxos memtable [MutationStage-2] | 2024-01-16 
16:18:43.662001-05:00 | 127.0.0.1 |          63768 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                  Executing single-partition 
query on distributed_metadata_log [MutationStage-2] | 2024-01-16 
16:18:43.672000-05:00 | 127.0.0.1 |          73714 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
  Acquiring sstable references [MutationStage-2] | 2024-01-16 
16:18:43.672001-05:00 | 127.0.0.1 |          73981 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                     Skipped 0/2 non-slice-intersecting 
sstables, included 0 due to tombstones [MutationStage-2] | 2024-01-16 
16:18:43.673000-05:00 | 127.0.0.1 |          74318 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                        Key 
cache hit for sstable 15, size = 0 [MutationStage-2] | 2024-01-16 
16:18:43.673001-05:00 | 127.0.0.1 |          74517 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                        Key 
cache hit for sstable 16, size = 0 [MutationStage-2] | 2024-01-16 
16:18:43.673002-05:00 | 127.0.0.1 |          74967 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                     Merged 
data from memtables and 2 sstables [MutationStage-2] | 2024-01-16 
16:18:43.674000-05:00 | 127.0.0.1 |          75983 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                        Read 2 
live rows and 0 tombstone cells [MutationStage-2] | 2024-01-16 
16:18:43.675000-05:00 | 127.0.0.1 |          76158 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                      Executing 
single-partition query on paxos_repair_history [MutationStage-2] | 2024-01-16 
16:18:43.676000-05:00 | 127.0.0.1 |          77301 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
  Acquiring sstable references [MutationStage-2] | 2024-01-16 
16:18:43.676001-05:00 | 127.0.0.1 |          77372 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
     Merging memtable contents [MutationStage-2] | 2024-01-16 
16:18:43.676002-05:00 | 127.0.0.1 |          77428 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                        Read 0 
live rows and 0 tombstone cells [MutationStage-2] | 2024-01-16 
16:18:43.676003-05:00 | 127.0.0.1 |          77582 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                              
CAS precondition is met; proposing client-requested updates for 
d3daaa22-b4b4-11ee-f973-04984c4fa9cd [Native-Transport-Requests-1] | 2024-01-16 
16:18:43.682000-05:00 | 127.0.0.1 |          83781 | 127.0.0.1
   Accepting proposal 
Accepted(139247327236500002:d3daaa22-b4b4-11ee-f973-04984c4fa9cd, 
1705439923650000:key=3\n    Row: STATIC | current_epoch=186, sealed=false\n    
Row: epoch=186 | entry_id=72058139836483484, kind=SCHEMA_CHANGE, 
transformation=020100076379636c696e670076435245415445204b45595350414345204946204e4f5420455849535453206379636c696e670a57495448205245504c49434154494f4e203d207b0a202027636c61737327203a202753696d706c655374726174656779272c0a2020277265706c69636174696f6e5f666163746f7227203a20310a7d3b)
 [MutationStage-2] | 2024-01-16 16:18:43.685000-05:00 | 127.0.0.1 |          
86836 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
        Appending to commitlog [MutationStage-2] | 2024-01-16 
16:18:43.686000-05:00 | 127.0.0.1 |          87877 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
      Adding to paxos memtable [MutationStage-2] | 2024-01-16 
16:18:43.686001-05:00 | 127.0.0.1 |          87976 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                     Executing 
single-partition query on local [MutationStage-3] | 2024-01-16 
16:18:43.690000-05:00 | 127.0.0.1 |          91422 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
  Acquiring sstable references [MutationStage-3] | 2024-01-16 
16:18:43.690001-05:00 | 127.0.0.1 |          91513 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                     Skipped 0/1 non-slice-intersecting 
sstables, included 0 due to tombstones [MutationStage-3] | 2024-01-16 
16:18:43.690002-05:00 | 127.0.0.1 |          91602 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                        Key 
cache hit for sstable 87, size = 0 [MutationStage-3] | 2024-01-16 
16:18:43.690003-05:00 | 127.0.0.1 |          91683 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                     Merged 
data from memtables and 1 sstables [MutationStage-3] | 2024-01-16 
16:18:43.691000-05:00 | 127.0.0.1 |          92124 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                        Read 1 
live rows and 0 tombstone cells [MutationStage-3] | 2024-01-16 
16:18:43.691001-05:00 | 127.0.0.1 |          92216 | 127.0.0.1
 Committing proposal 
Committed(139247327236500002:d3daaa22-b4b4-11ee-f973-04984c4fa9cd, 
1705439923650000:key=3\n    Row: STATIC | current_epoch=186, sealed=false\n    
Row: epoch=186 | entry_id=72058139836483484, kind=SCHEMA_CHANGE, 
transformation=020100076379636c696e670076435245415445204b45595350414345204946204e4f5420455849535453206379636c696e670a57495448205245504c49434154494f4e203d207b0a202027636c61737327203a202753696d706c655374726174656779272c0a2020277265706c69636174696f6e5f666163746f7227203a20310a7d3b)
 [MutationStage-3] | 2024-01-16 16:18:43.691002-05:00 | 127.0.0.1 |          
92404 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
        Appending to commitlog [MutationStage-3] | 2024-01-16 
16:18:43.691003-05:00 | 127.0.0.1 |          92466 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                   Adding to 
distributed_metadata_log memtable [MutationStage-3] | 2024-01-16 
16:18:43.691004-05:00 | 127.0.0.1 |          92595 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
        Appending to commitlog [MutationStage-3] | 2024-01-16 
16:18:43.692000-05:00 | 127.0.0.1 |          93530 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
      Adding to paxos memtable [MutationStage-3] | 2024-01-16 
16:18:43.692001-05:00 | 127.0.0.1 |          93626 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                             Enqueuing 
acknowledge to localhost/127.0.0.1:7000 [MutationStage-3] | 2024-01-16 
16:18:43.693000-05:00 | 127.0.0.1 |          94320 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
    CAS successful [Native-Transport-Requests-1] | 2024-01-16 
16:18:43.693001-05:00 | 127.0.0.1 |          94740 | 127.0.0.1
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                Request complete | 2024-01-16 
16:18:43.909387-05:00 | 127.0.0.1 |         310387 | 127.0.0.1
cqlsh> SELECT * FROM system_traces.sessions;

session_id                           | client    | command | coordinator | 
coordinator_port | duration | parameters                                        
                                                                                
                                                                                
                  | request            | started_at
--------------------------------------+-----------+---------+-------------+------------------+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------+---------------------------------
 d3d293d0-b4b4-11ee-8d07-296dcee8db28 | 127.0.0.1 |   QUERY |   127.0.0.1 |     
        7000 |   310387 | {'consistency_level': 'ONE', 'page_size': '100', 
'query': 'CREATE KEYSPACE IF NOT EXISTS cycling\nWITH REPLICATION = {\n  
''class'' : ''SimpleStrategy'',\n  ''replication_factor'' : 1\n};', 
'serial_consistency_level': 'SERIAL'} | Execute CQL3 query | 2024-01-16 
21:18:43.599000+0000(1 rows) {code}


> Modernize CQLSH datetime conversions
> ------------------------------------
>
>                 Key: CASSANDRA-18879
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-18879
>             Project: Cassandra
>          Issue Type: Improvement
>          Components: CQL/Interpreter
>            Reporter: Brad Schoening
>            Assignee: Arun Ganesh
>            Priority: Low
>         Attachments: cassandra-cqlsh-stdout
>
>          Time Spent: 2h
>  Remaining Estimate: 0h
>
> Python 3.x introduced many updates to datetime conversion which allows 
> simplified conversions.
> 1. For example, tracing.py defines a function datetime_from_utc_to_local() 
> but datetime now has a native function astimezone() which will convert UTC to 
> local time.
> Review the following users of datetime which apply conversions:
>  * cqlshmain.py
>  * formatting.py 
>  * tracing.py
> Example: 
> {code:java}
> >>> from dateutil import tz
> >>> import datetime
> >>> a = datetime.datetime.now().astimezone(tz.tzutc())
> >>> a
> datetime.datetime(2023, 9, 25, 11, 22, 36, 251705, tzinfo=tzutc())
> >>> b = a.astimezone()
> >>> b
> datetime.datetime(2023, 9, 25, 14, 22, 36, 251705, 
> tzinfo=datetime.timezone(datetime.timedelta(seconds=10800), 'EST')) {code}
> See [[PEP 495|http://example.com]]]
>  



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

Reply via email to