man-group/arctic

Versionstore: Arctic automatically assigns index a name - Perhaps needs some warning

luongjames8 opened this issue · 1 comments

This is a bit minuitae, but a strange nit...

Arctic Version

Arctic version 1.84.4

Arctic Store

VersionStore

Platform and version

Python 3.9.7

Description of problem and/or code sample that reproduces the issue

When using the arctic package's write method, it automatically names the index "index" without informing the user. This can lead to confusion and unexpected results, particularly when reading the data back out of the library. For example:

lib = arctic.get_library(TEST_LIBRARY_NAME)

data = pd.DataFrame({"col1": [1, 2, 3], "col2": [4, 5, 6]}, 
                    index=pd.date_range('2022-01-01', periods=3, freq='D'))
lib.write(symbol="test_symbol", data=data)

return_data = lib.read(symbol="test_symbol").data

print(data.index.name, return_data.index.name)
assert return_data.index.name == data.index.name # should fail

Here, we create a Pandas DataFrame without a named index and write it to an Arctic store. We then read the data back from the store and compare the names of the original and returned indices. We expect this test to pass without any errors, but it fails due to the fact that the index is automatically named 'index' in the returned data.

To avoid confusion and prevent errors, the Arctic write method should perhapd either:

  • Inform the user that the index will be named if it is not already named, or
  • Reject writes without a named index.

Thanks will have a look.