Skip to content

fix: improved error messages that occur during dataframe autoflushing #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/questdb/dataframe.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -2424,14 +2424,16 @@ cdef void_int _dataframe(
_ensure_has_gil(&gs)
raise c_err_to_py(err)

was_auto_flush = True
_dataframe_handle_auto_flush(&af, ls_buf, &gs)
was_auto_flush = False
except Exception as e:
# It would be an internal bug for this to raise.
if not line_sender_buffer_rewind_to_marker(ls_buf, &err):
raise c_err_to_py(err)

if (isinstance(e, IngressError) and
(e.code == IngressErrorCode.InvalidApiCall)):
(e.code == IngressErrorCode.InvalidApiCall) and not was_auto_flush):
# TODO: This should be allowed by the database.
# It currently isn't so we have to raise an error.
raise IngressError(
Expand Down
12 changes: 12 additions & 0 deletions test/test_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1523,6 +1523,18 @@ def test_serializing_in_chunks(self):
for i in range(index * 10, (index + 1) * 10))
self.assertEqual(buf, exp.encode("utf-8"))

def test_auto_flush_error_msg(self):
header = ["x", "y"]
x = list(range(10000))
y = list(range(10000))

df = pd.DataFrame(zip(x, y), columns=header)

with self.assertRaisesRegex(qi.IngressError, 'Could not flush buffer: Buffer size of 21780 exceeds maximum configured allowed size of 1024 bytes'):
with qi.Sender.from_conf("http::addr=localhost:9000;auto_flush_rows=1000;max_buf_size=1024;protocol_version=2;") as sender:
sender.dataframe(df, table_name='test_df', at=qi.ServerTimestamp)
sender.flush()

def test_arrow_chunked_array(self):
# We build a table with chunked arrow arrays as columns.
chunks_a = [
Expand Down