Skip to content

Commit

Permalink
Make empty index default to datetime to preserve behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Vasil Pashov committed Apr 10, 2024
1 parent 2effe0c commit 2d1512f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions python/arcticdb/version_store/_normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def _from_tz_timestamp(ts, tz):
def _normalize_single_index(index, index_names, index_norm, dynamic_strings=None, string_max_len=None):
# index: pd.Index or np.ndarray -> np.ndarray
index_tz = None
if isinstance(index_norm, NormalizationMetadata.PandasIndex) and not index_norm.is_physically_stored:
if isinstance(index, RangeIndex):
if index.name:
if not isinstance(index.name, int) and not isinstance(index.name, str):
raise NormalizationException(
Expand Down Expand Up @@ -529,7 +529,7 @@ def _index_to_records(self, df, pd_norm, dynamic_strings, string_max_len, empty_
if empty_df and empty_types:
index_norm = pd_norm.index
index_norm.is_physically_stored = False
index = Index([])
index = DatetimeIndex([])
elif isinstance(index, MultiIndex):
# This is suboptimal and only a first implementation since it reduplicates the data
index_norm = pd_norm.multi_index
Expand All @@ -553,8 +553,7 @@ def _index_to_records(self, df, pd_norm, dynamic_strings, string_max_len, empty_
else:
index_norm = pd_norm.index
index_norm.is_physically_stored = not isinstance(index, RangeIndex) and not empty_df
if empty_df:
index = DatetimeIndex([])
index = DatetimeIndex([]) if empty_df else index

return _normalize_single_index(index, list(index.names), index_norm, dynamic_strings, string_max_len)

Expand Down

0 comments on commit 2d1512f

Please sign in to comment.