Skip to content

Commit

Permalink
Merge pull request #49 from ADBond/maintenance/workaround-keyerror-test
Browse files Browse the repository at this point in the history
Workaround chdb KeyError issue
  • Loading branch information
ADBond authored Dec 12, 2024
2 parents da63f42 + 7cce89f commit 6b332ef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Table registration in `chdb` now works for pandas tables whose indexes do not have a `0` entry [#49](https://github.com/ADBond/splinkclickhouse/pull/49).

## [0.3.3] - 2024-12-05

### Added
Expand Down
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 6b332ef

Please sign in to comment.