From 2d1512f00b7f8abcaaf70825618cbc8a53ca1588 Mon Sep 17 00:00:00 2001 From: Vasil Pashov Date: Wed, 10 Apr 2024 18:14:54 +0300 Subject: [PATCH] Make empty index default to datetime to preserve behavior --- python/arcticdb/version_store/_normalization.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/python/arcticdb/version_store/_normalization.py b/python/arcticdb/version_store/_normalization.py index ebab1cfe80..dbfe3618e4 100644 --- a/python/arcticdb/version_store/_normalization.py +++ b/python/arcticdb/version_store/_normalization.py @@ -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( @@ -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 @@ -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)