Repository navigation
fix(teradata): fix off-by-one in split_dataframe that sent empty exec… - #694
Merged
Merged
Conversation
…utemany batches The old formula (num_chunks = len(df) // chunk_size + 1) always appended one extra iteration. When a document had exactly N * batch_size elements the last chunk was empty, causing teradatasql to send a zero-row parameterized batch to the Teradata server which returned Error 3939 (parameter count mismatch). Replace with range(0, len(df), chunk_size) which never produces an empty slice. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
… fix) Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
awalker4
reviewed
Apr 17, 2026
| assert uploader.upload_config.table_name == "my-table" | ||
|
|
||
|
|
||
| # --- Regression tests for Error 3939 (parameter count mismatch) --- |
Contributor
There was a problem hiding this comment.
Is this a hallucinated bug ID? Might be better to just explain the failure mode being tested
Contributor
There was a problem hiding this comment.
Sorry, it's already doing that below haha. Maybe just drop this comment
Contributor
Author
There was a problem hiding this comment.
3939 is the exception number from tera
Contributor
Author
There was a problem hiding this comment.
parameter count mismatch is the error
awalker4
approved these changes
Apr 17, 2026
awalker4
added a commit
that referenced
this pull request
Nov 19, 2026
…n empty batch (#832) ## What `generator_batching_wbytes` (used by the Elasticsearch, OpenSearch and Pinecone uploaders) had two batching bugs: ```python generator_batching_wbytes(items) # before: no batches after: [items] generator_batching_wbytes([big, small], batch_size_limit_bytes=20) # before: [[], [big], [small]] after: [[big], [small]] ``` ## Why The `return iterable` shortcut for "no limits" is inside a generator, so it ends iteration without yielding anything. An Elasticsearch or OpenSearch upload with `batch_size_bytes=0` therefore sent no documents and reported no error. Separately, when the first item alone exceeded the byte limit, the still-empty batch was yielded before it — the same empty-batch problem #694 fixed in `split_dataframe`. The shortcut is removed, so with no limits everything goes in one batch, and a batch is only closed once it has items. Behaviour with limits is otherwise unchanged; an oversized item still gets a batch of its own. ## Validation Two new tests in `test/unit/utils/test_data_prep.py`; both fail on main. `pytest test/unit --ignore test/unit/unstructured`: 1941 → 1943 passed, same 69 skipped. `ruff check .` and `ruff format --check` pass. Adds a CHANGELOG entry and bumps the version to 1.11.27. Co-authored-by: Austin Walker <[email protected]>
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a document had exactly N * batch_size elements the last chunk was empty - this causes teradatasql to send a zero-row parameterized batch to the Teradata server which returned Error 3939 (parameter count mismatch).
Replace with range(0, len(df), chunk_size) which never produces an empty slice.
Note
Low Risk
Small, well-scoped change to a shared batching utility plus targeted unit tests; primary risk is subtle behavior change for callers that (incorrectly) relied on receiving empty chunks.
Overview
Fixes an off-by-one bug in
split_dataframeso it no longer yields an empty trailing DataFrame slice whenlen(df)is an exact multiple ofchunk_size, preventing zero-rowexecutemanybatches that triggered Teradata Error 3939 (and benefiting all connectors that share this helper).Adds Teradata-focused regression tests covering exact-multiple chunking cases, and bumps the package version/changelog entry to
1.4.26b1.Reviewed by Cursor Bugbot for commit a4e839f. Bugbot is set up for automated code reviews on this repo. Configure here.