tsio/group: add the ability to rename a group
2 files changed, 23 insertions(+), 0 deletions(-)

M test/test_tsio.py
M tshistory/tsio.py
M test/test_tsio.py +16 -0
@@ 2601,6 2601,22 @@ 2021-01-04  5.0  6.0  7.0
 2021-01-05  6.0  7.0  8.0
     """, df)
 
+    tsh.group_rename(
+        engine,
+        'first_group',
+        'new_group_name'
+    )
+
+    assert not tsh.group_exists(engine, 'first_group')
+    assert tsh.group_exists(engine, 'new_group_name')
+    df2 = tsh.group_get(
+        engine,
+        'new_group_name',
+        revision_date=pd.Timestamp('2021-01-02', tz='UTC')
+    )
+
+    assert df2.equals(df)
+
 
 def test_group_history(engine, tsh):
     for idx, idate in enumerate(

          
M tshistory/tsio.py +7 -0
@@ 963,6 963,13 @@ class timeseries:
         ).scalar()
 
     @tx
+    def group_rename(self, cn, oldname, newname):
+        sql = (f'update "{self.namespace}".group_registry '
+               'set name = %(newname)s '
+               'where name = %(oldname)s')
+        cn.execute(sql, oldname=oldname, newname=newname)
+
+    @tx
     def update_group_metadata(self, cn, name, metadata, internal=False):
         assert isinstance(metadata, dict)
         assert internal or not set(metadata.keys()) & self.metakeys