Skip to content

Update doesn't update the new of index when MultiIndex is used #2214

@G-D-Petrov

Description

@G-D-Petrov

Describe the bug

Update doesn't handle the index properly when a MultiIndex Dataframe/Series is used.
The old index name is used and the values are set to 0.

Steps/Code to Reproduce

def test_update_with_new_index_name(version_store_factory):    
    lib = version_store_factory(dynamic_schema=True)
    dates = [
        datetime(2018, 1, 1),
        datetime(2018, 1, 2),
        datetime(2018, 1, 3),
        datetime(2018, 1, 4),
        datetime(2018, 1, 5),
        datetime(2018, 1, 6),
    ]
    names = ["A", "B", "C", "D", "E", "F"]
    # Given
    tuples = list(zip(dates, names))
    index = pd.MultiIndex.from_tuples(tuples, names=["date", "names"])

    df = pd.Series([1, 2, 3, 4, 5, 6], index=index)
    lib.write("symbol", df)

    # When
    new_names = ["N_A", "N_B", "N_C", "N_D", "N_E", "N_F"]
    tuples = list(zip(dates, new_names))
    new_index = pd.MultiIndex.from_tuples(tuples, names=["date", "new_names"])
    update_df = pd.Series([7, 8, 9, 10, 11, 12], index=new_index)
    lib.update("symbol", update_df)

    # Then
    result = lib.read("symbol").data

    assert_series_equal(result, update_df)

Expected Results

This test should pass

OS, Python Version and ArcticDB Version

Python: 3.11.11 (main, Dec 4 2024, 08:55:08) [GCC 13.2.0]
OS: Linux-5.15.167.4-microsoft-standard-WSL2-x86_64-with-glibc2.39
ArcticDB: dev

Backend storage used

Any backed

Additional Context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions