Skip to content

Commit

Permalink
workaround chdb KeyError issue
Browse files Browse the repository at this point in the history
This causes occasional test failures currently, specifically when computing graph metrics, as then we subset a pandas frame and so can end up with non-zero-indexed frames
  • Loading branch information
ADBond committed Dec 12, 2024
1 parent 88ec78c commit c46f6e0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions splinkclickhouse/chdb/database_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ def _table_registration(self, input, table_name):
elif isinstance(input, list):
input = pd.DataFrame.from_records(input)

# chdb currently needs pandas indices to start at 0
# see https://github.com/chdb-io/chdb/issues/282
# reset the index if not the case, but otherwise leave alone
# TODO: remove this workaround once chdb issue is resolved
try:
input[0]
except KeyError:
input = input.reset_index()
cursor = self._get_cursor()
sql = (
f"CREATE OR REPLACE TABLE {self._db_schema}.{table_name} "
Expand Down

0 comments on commit c46f6e0

Please sign in to comment.