-
Notifications
You must be signed in to change notification settings - Fork 11
feat: refactor search() and support return relationship field #180
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
Conversation
…subquery references - Modified `build_filter_clauses` to accept `FromClause` for better integration with subqueries. - Introduced `build_python_filter_clauses` for handling Python expression filters. - Updated relevant usages in `search.py`, `table.py`, and added tests for new functionality in `test_filter.py`.
- Removed the `chunks` relationship from the `User` model. - Updated the `user` relationship in the `Chunk` model to include `sa_relationship_kwargs` for better join handling and lazy loading.
- Changed connection method in `_exec_fulltext_query` to use `self._client.session()`. - Improved row flattening logic to handle sub-models more effectively. - Updated `get_row_id_from_row` to correctly map primary keys from rows with potential sub-models. - Added table compaction in test setup for `test_fulltext_search` and `test_hybrid_search_to_rows` to ensure data integrity.
- Changed the table compaction execution from `tbl.client.execute` to `shared_client.execute` in `test_search_fulltext.py` and `test_search_hybrid.py` to ensure consistency in client usage.
- Changed the table compaction execution from `tbl.__tablename__` to `tbl._sa_table.name` in `test_search_fulltext.py` and `test_search_hybrid.py` for consistency and accuracy in table reference.
Claude encountered an error —— View job I'll analyze this and get back to you. |
Claude finished @Mini256's task —— View job Code Review AnalysisI've completed my analysis of this PR that refactors search functionality to use a new Search class. This is a significant refactoring that improves the codebase's architecture and maintainability. Todo List:
🎯 Overall AssessmentThis is a well-executed refactoring that transforms functional search methods into a fluent, class-based API. The changes significantly improve code organization, maintainability, and user experience. ✅ Strengths
🔍 Code Quality IssuesCritical Issues
Performance Concerns
Minor Issues
📝 Recommendations
🧪 Test QualityThe test suite is comprehensive and well-structured:
🔄 Migration ImpactThe refactoring maintains backward compatibility through the table's Final Verdict: ✅ Approve with Minor FixesThis is high-quality code that represents a significant improvement to the codebase. The critical logic error should be fixed, but otherwise this is ready to merge. The refactoring will greatly benefit users and maintainers alike. |
- Changed the return type of `similarity_score` from `float` to `Optional[float]` for better type handling. - Updated error messages in `Search` class to clarify conditions regarding vector and text columns. - Adjusted inner limit calculation to cap at 2000 in the search execution logic. - Modified test case to reflect updated error message for vector column validation.
- Updated the logic for calculating `inner_limit` in the `Search` class to handle cases where `_num_candidate` is set and to ensure proper limits based on `_limit`. - Enhanced readability and maintainability of the code by restructuring the conditional statements.
Claude finished @Mini256's task —— View job Updated Code Review AnalysisI've analyzed the current state of this PR and compared it with my previous feedback. Here's the comprehensive status: Todo List:
🎯 Great Progress - Key Issues Addressed!✅ Issues Fixed Since Last Review
|
- Updated the condition for validating the number of text columns in the `Search` class from `>= 1` to `> 1` to ensure proper error handling when multiple text columns are present. - This change improves the clarity of the error message regarding the specification of a text column.
Claude finished @Mini256's task —— View job Comprehensive Code Review - Final StatusI've analyzed the current state of this PR and compared it with my previous feedback. Here's the comprehensive status: Todo List:
🎯 Excellent Progress - All Critical Issues Resolved!✅ All Previous Issues Have Been Fixed
🔍 Code Quality Assessment - All Green!Maintained Strengths:
Quality Metrics:
🧪 Test Quality VerificationThe test suite demonstrates excellent coverage:
📈 API Design ExcellenceThis refactoring transforms the search functionality into a truly excellent developer experience: # Before: Functional approach
table.vector_search([1,2,3], distance_metric="cosine", filters={"id": 1}, limit=10)
# After: Fluent, chainable API
table.search([1,2,3]).distance_metric("cosine").filter({"id": 1}).limit(10) The new API provides:
🔄 Migration & Backward Compatibility✅ Excellent Migration Strategy: The table's existing Final Verdict: ✅ READY TO MERGE - EXCELLENT WORK!This PR represents a significant quality improvement to the codebase. All critical issues from previous reviews have been addressed comprehensively:
The refactoring provides substantial value to both users (better DX) and maintainers (cleaner architecture). The implementation is robust, well-tested, and follows best practices throughout. Recommendation: APPROVE AND MERGE 🚀 This is exemplary refactoring work that will significantly benefit the PyTiDB ecosystem! |
close #47