Skip to content

Fix empty hybrid_search results and refresh index in integration test#222

Merged
hnwyllmm merged 1 commit into
oceanbase:developfrom
hnwyllmm:test_empy_results
May 21, 2026
Merged

Fix empty hybrid_search results and refresh index in integration test#222
hnwyllmm merged 1 commit into
oceanbase:developfrom
hnwyllmm:test_empy_results

Conversation

@hnwyllmm

@hnwyllmm hnwyllmm commented May 21, 2026

Copy link
Copy Markdown
Member

Summary

  • Remove the early return in _transform_sql_result for empty result_rows, so empty hybrid/search results respect the include parameter instead of always returning all columns.
  • Add unit tests covering empty-result shape for include=None, include=[], and include=["embeddings"].
  • Call collection.refresh_index() before hybrid search in the integration test so index state is ready after recent refresh_index-before-query behavior (calling refresh_index before query #217).

Test plan

  • uv run pytest tests/unit_tests/test_hybrid_search_source_inference.py
  • uv run pytest tests/integration_tests/test_collection_hybrid_search_source_inference.py (requires real DB)

Made with Cursor

Summary by CodeRabbit

  • Bug Fixes

    • Fixed handling of empty search results to return consistent column structures based on the requested data types.
  • Tests

    • Added test coverage for empty result scenarios to verify correct column structure across various configuration options.

Review Change Stack

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented May 21, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 627cbd43-fcfb-415d-89d5-ce0bbb937286

📥 Commits

Reviewing files that changed from the base of the PR and between 2083b41 and b3f7e99.

📒 Files selected for processing (3)
  • src/pyseekdb/client/client_base.py
  • tests/integration_tests/test_collection_hybrid_search_source_inference.py
  • tests/unit_tests/test_hybrid_search_source_inference.py
💤 Files with no reviewable changes (1)
  • src/pyseekdb/client/client_base.py

📝 Walkthrough

Walkthrough

This PR fixes _transform_sql_result to respect the include parameter when handling empty result sets. Previously, the method returned a fixed structure regardless of the include configuration. The fix removes the early return and instead constructs responses with appropriate column keys based on include preferences.

Changes

Empty rows result handling

Layer / File(s) Summary
Core fix: respect include parameter on empty rows
src/pyseekdb/client/client_base.py
Removed the early return for empty result_rows. The method now initializes result lists and builds the return object based on the include parameter, ensuring that empty result sets return the correct column keys rather than a fixed structure.
Unit test validation with test helper
tests/unit_tests/test_hybrid_search_source_inference.py
Added _convert_id_from_bytes helper method to _DummyClient for ID conversion support. Added TestTransformSqlResultEmptyRowsUnit.test_empty_rows_returns_expected_columns_by_include to validate that _transform_sql_result returns correct column keys and empty lists for default include=None, include=[], and include=["embeddings"] when result_rows is empty.
Integration test index refresh
tests/integration_tests/test_collection_hybrid_search_source_inference.py
Added collection.refresh_index() call after test data insertion and before query construction to ensure the index is fresh prior to include/_source inference assertions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

A rabbit hops through empty rows,
No results yet, but hope still glows,
The include parameter now holds sway,
Even when datasets choose not to play. 🐰

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: fixing empty hybrid_search results to respect the include parameter and adding a refresh_index() call in the integration test.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@hnwyllmm hnwyllmm merged commit 5e8a22b into oceanbase:develop May 21, 2026
9 checks passed
@hnwyllmm hnwyllmm deleted the test_empy_results branch May 21, 2026 03:27
JingYuChe pushed a commit to JingYuChe/pyseekdb that referenced this pull request Jun 22, 2026
…oceanbase#222)

## Summary

- Remove the early return in `_transform_sql_result` for empty
`result_rows`, so empty hybrid/search results respect the `include`
parameter instead of always returning all columns.
- Add unit tests covering empty-result shape for `include=None`,
`include=[]`, and `include=["embeddings"]`.
- Call `collection.refresh_index()` before hybrid search in the
integration test so index state is ready after recent
`refresh_index`-before-query behavior (oceanbase#217).

## Test plan

- [x] `uv run pytest
tests/unit_tests/test_hybrid_search_source_inference.py`
- [ ] `uv run pytest
tests/integration_tests/test_collection_hybrid_search_source_inference.py`
(requires real DB)


Made with [Cursor](https://cursor.com)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Fixed handling of empty search results to return consistent column
structures based on the requested data types.

* **Tests**
* Added test coverage for empty result scenarios to verify correct
column structure across various configuration options.

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/oceanbase/pyseekdb/pull/222?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

<!-- review_stack_entry_end -->

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant